@blueprint-chart/editor 0.1.16 → 0.1.18
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LandingPage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LandingPage-DVL-4rGR.js","assets/LandingPage-BWDtyjsV.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var n9=Object.defineProperty;var o9=(t,e,n)=>e in t?n9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var vn=(t,e,n)=>o9(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();/**
|
|
3
3
|
* @vue/shared v3.5.29
|
|
4
4
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -77,17 +77,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
77
77
|
display: none;
|
|
78
78
|
}
|
|
79
79
|
`,document.head.appendChild(t)}function qte(t){const e=t?Ea(t):null,n=o=>e?e(o):String(o);return o=>o.series?`${o.series} – ${o.label}: ${n(o.value)}`:`${o.label}: ${n(o.value)}`}function Um(t,e){const{width:n,height:o,points:r,tooltip:i=!0,crosshair:s=!1,crosshairDirection:a=So.Both,crosshairStyle:l=li.Dashed,crosshairColor:c="#999",format:u=qte(e.numberFormat),container:d}=e;if(r.length===0){const P=()=>{};return d&&kc.set(d,P),P}const f=l===li.Solid?"none":l===li.Dotted?"2,2":"4,3",h=[...new Set(r.map(P=>P.cx))].sort((P,$)=>P-$),g=$e(t);let b=null;i&&(Gte(),b=document.createElement("div"),b.className=u$,document.body.appendChild(b));const m=".bc-annotations",v=!g.select(m).empty(),y=P=>v?g.insert(P,m):g.append(P),x=s&&(a===So.Both||a===So.Vertical),_=s&&(a===So.Both||a===So.Horizontal);let k=null,E=null;x&&(k=y("line").attr("class","bc-crosshair bc-crosshair-v").attr("y1",0).attr("y2",o).attr("stroke",c).attr("stroke-width",1).style("stroke-dasharray",f).attr("pointer-events","none").style("display","none")),_&&(E=y("line").attr("class","bc-crosshair bc-crosshair-h").attr("x1",0).attr("x2",n).attr("stroke",c).attr("stroke-width",1).style("stroke-dasharray",f).attr("pointer-events","none").style("display","none"));const B=y("circle").attr("class","bc-proximity-dot").attr("r",6).attr("fill","none").attr("stroke","#333").attr("stroke-width",1).attr("opacity",.45).attr("pointer-events","none").style("display","none"),S=y("rect").attr("class","bc-proximity-overlay").attr("width",n).attr("height",o).attr("fill","none").attr("pointer-events","all");function L(P,$){if(h.length===0)return null;const F=nz(h,P),V=h[F],U=r.filter(he=>he.cx===V);if(U.length===0)return null;let K=U[0],se=Math.abs(U[0].cy-$);for(let he=1;he<U.length;he++){const ce=Math.abs(U[he].cy-$);ce<se&&(K=U[he],se=ce)}return K}const D=P=>{const[$,F]=Ej(P,t),V=L($,F);V&&(B.attr("cx",V.cx).attr("cy",V.cy).attr("stroke",V.color).style("display",null),b&&(b.textContent=u(V),b.style.display="block",m5(B.node(),b,{placement:"top",middleware:[f5(8),p5(),h5()]}).then(({x:U,y:K})=>{b&&(b.style.left=`${U}px`,b.style.top=`${K}px`)})),k&&k.attr("x1",V.cx).attr("x2",V.cx).style("display",null),E&&E.attr("y1",V.cy).attr("y2",V.cy).style("display",null))},I=()=>{B.style("display","none"),b&&(b.style.display="none"),k&&k.style("display","none"),E&&E.style("display","none")},C=S.node();C.addEventListener("mousemove",D),C.addEventListener("mouseleave",I);const T=()=>{C.removeEventListener("mousemove",D),C.removeEventListener("mouseleave",I),S.remove(),B.remove(),b&&(b.remove(),b=null),k&&k.remove(),E&&E.remove(),d&&kc.get(d)===T&&kc.delete(d)};return d&&kc.set(d,T),T}const Yte=ZK??RC,jte={circle:Qy,square:GK,diamond:UK,triangle:RC,triangleDown:Yte,cross:HK,star:XK};function Xte(t,e,n){switch(n){case vr.First:return t===0;case vr.Last:return t===e-1;case vr.FirstLast:return t===0||t===e-1;case vr.All:default:return!0}}function w2(t,e,n,o,r=!1){const i=o.symbol??mr.Circle,s=o.showOn??vr.FirstLast,a=o.style??No.Filled,l=o.size??3.5,c=o.opacity??1,u="var(--bs-body-bg, #fff)",d=e.filter(h=>Xte(h.index,n,s)),f=r?wt():0;if(i===mr.Circle){t.selectAll("path.bc-symbol").remove();const h=t.selectAll("circle.bc-symbol").data(d).join(b=>b.append("circle").attr("class","bc-symbol").attr("cx",m=>m.cx).attr("cy",m=>m.cy).attr("r",l).attr("fill",m=>a===No.Filled?m.color:u).attr("stroke",m=>m.color).attr("stroke-width",a===No.Hollow?1.5:0).attr("opacity",c),b=>b,b=>b.remove());(r?h.transition().duration(f):h).attr("cx",b=>b.cx).attr("cy",b=>b.cy).attr("r",l).attr("fill",b=>a===No.Filled?b.color:u).attr("stroke",b=>b.color).attr("stroke-width",a===No.Hollow?1.5:0).attr("opacity",c)}else{const h=jte[i]??Qy,g=Math.PI*l*l,b=QK().type(h).size(g);t.selectAll("circle.bc-symbol").remove();const m=t.selectAll("path.bc-symbol").data(d).join(y=>y.append("path").attr("class","bc-symbol").attr("transform",x=>`translate(${x.cx},${x.cy})`).attr("d",b).attr("fill",x=>a===No.Filled?x.color:u).attr("stroke",x=>x.color).attr("stroke-width",a===No.Hollow?1.5:0).attr("opacity",c),y=>y,y=>y.remove());(r?m.transition().duration(f):m).attr("transform",y=>`translate(${y.cx},${y.cy})`).attr("d",b).attr("fill",y=>a===No.Filled?y.color:u).attr("stroke",y=>y.color).attr("stroke-width",a===No.Hollow?1.5:0).attr("opacity",c)}}const d$="#4e79a7";class Kte extends ao{initialize(){this.configDefine("xPos",{defaultValue:(r,i)=>0}),this.configDefine("y",{defaultValue:On()}),this.configDefine("color",{defaultValue:d$}),this.configDefine("curve",{defaultValue:yu}),this.configDefine("areaFill",{defaultValue:!1}),this.configDefine("areaFillOpacity",{defaultValue:.2}),this.configDefine("height",{defaultValue:0});const e=this.base.append("g"),n=this.base.append("g"),o=this.base.append("g");this.layer("area",e,{dataBind:(r,i)=>r.selectAll(".bc-area").data(this.config("areaFill")?[i]:[]),insert:r=>r.append("path").attr("class","bc-area"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity"),d=Ys().curve(l).x((f,h)=>i(f,h)).y0(c).y1(f=>s(f.value));r.attr("fill",a).attr("opacity",u).attr("d",d)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity"),d=Ys().curve(l).x((f,h)=>i(f,h)).y0(c).y1(f=>s(f.value));r.duration(wt()).attr("fill",a).attr("opacity",u).attr("d",d)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("line",n,{dataBind:(r,i)=>r.selectAll(".bc-line").data([i]),insert:r=>r.append("path").attr("class","bc-line"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=ki().curve(l).x((u,d)=>i(u,d)).y(u=>s(u.value));r.attr("fill","none").attr("stroke",a).attr("d",c)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=ki().curve(l).x((u,d)=>i(u,d)).y(u=>s(u.value));r.duration(wt()).attr("fill","none").attr("stroke",a).attr("d",c)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("dots",o,{dataBind:(r,i)=>r.selectAll(".bc-dot").data(i,s=>s.label),insert:r=>r.append("circle").attr("class","bc-dot"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color");r.attr("cx",(l,c)=>i(l,c)).attr("cy",l=>s(l.value)).attr("r",3).attr("fill",a)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color");r.duration(wt()).attr("cx",(l,c)=>i(l,c)).attr("cy",l=>s(l.value)).attr("r",3).attr("fill",a)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}})}}function Zte(t,e,n={},o=!1){var we,ee,ge,Q,re,ve,N,G,Y,ue,ae,q,ne;jr(o),Wm(t);let r=[],i=[],s=[],a=null,l=null,c,u;const d=Br.for(t);if(o){const j=Xr(t);u=j==null?void 0:j.margin,d.detach(),(j==null?void 0:j.chartType)==="line"?(r=Array.from(t.querySelectorAll(".bc-frame .bc-area")),i=Array.from(t.querySelectorAll(".bc-frame .bc-line")),s=Array.from(t.querySelectorAll(".bc-frame .bc-dot")),a=t.querySelector(".bc-frame .bc-symbols")):j&&(l=Mr(t)),c=new Map;for(const X of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Z,fe]of ar(X))c.set(Z,fe);t.replaceChildren()}const{body:f}=qr(t,n.frame),h=sr(f).width,g=Ql(e.values,(we=n.verticalAxis)==null?void 0:we.range,(ee=n.verticalAxis)==null?void 0:ee.numberFormat,(ge=n.verticalAxis)==null?void 0:ge.scaleType),b=Oi(h,(Q=n.verticalAxis)==null?void 0:Q.labelPosition,(re=n.horizontalAxis)==null?void 0:re.labelPosition,(ve=n.verticalAxis)==null?void 0:ve.direction,g),{chartArea:m,width:v,height:y,margin:x}=Yr(f,b),_=Mi(u,x),k=Pm(e.labels,(N=n.horizontalAxis)==null?void 0:N.range),E=k.map(j=>e.labels[j]),B=k.map(j=>e.values[j]),S=E.map((j,X)=>({label:j,value:B[X]})),L=$m().domain(E).range([0,v]).padding(n.edgePadding?.6:0),D=L,I=j=>L(j.label)??0,C=((G=n.verticalAxis)==null?void 0:G.scaleType)==="log",[T,P]=wu(B,(Y=n.verticalAxis)==null?void 0:Y.range,(ue=n.verticalAxis)==null?void 0:ue.scaleType),$=C?Ya().domain([T,P]).nice().range([y,0]):On().domain([T,P]).nice().range([y,0]),F=$.domain(),V=F[0]<0&&F[1]>0?$(0):void 0;d.attach(m,_),d.update({vertical:{scale:$,height:y,options:{...n.verticalAxis,gridWidth:v,topPadding:x.top}},horizontal:{scale:D,height:y,options:{...n.horizontalAxis,width:v,zeroY:V}}});const U=m.ownerSVGElement,K=Bi(U,t,"plot",{x:-1,y:-1,width:v+2,height:y+2}),se=$e(m).append("g").attr("clip-path",`url(#${K})`),he=se.node(),ce=((ae=n.colors)==null?void 0:ae[0])??d$,be=Fl(n.interpolation),oe=n.lineSymbols,de=new Kte($e(he));if(de.config({xPos:I,y:$,color:ce,curve:be,areaFill:n.areaFill??!1,areaFillOpacity:n.areaFillOpacity??.2,height:y}),i.length>0||r.length>0||s.length>0){const j=(_==null?void 0:_.dx)??0,X=(_==null?void 0:_.dy)??0,Z=he.querySelectorAll(":scope > g");Z[0]&&zo(Z[0],r,j,X),Z[1]&&zo(Z[1],i,j,X),Z[2]&&zo(Z[2],s,j,X)}if(n.valueLabels&&de.use(c$({position:n.valueLabelPosition,orientation:jn.Vertical})),de.draw(S),(q=n.annotations)!=null&&q.length&&Vm(m,n.annotations,{scaleX:D,scaleY:$,data:S,width:v,height:y,backgroundColor:$r(t),transition:o,priorAnnotations:c}),$e(he).selectAll(".bc-dot").attr("fill-opacity",0).attr("stroke-opacity",0).attr("pointer-events","none"),n.tooltips||n.crosshair){const j=S.map(X=>({cx:I(X),cy:$(X.value),label:X.label,value:X.value,color:ce}));Um(m,{width:v,height:y,points:j,tooltip:n.tooltips,crosshair:n.crosshair,crosshairDirection:n.crosshairDirection,crosshairStyle:n.crosshairStyle,crosshairColor:n.crosshairColor,numberFormat:(ne=n.verticalAxis)==null?void 0:ne.numberFormat,container:t})}if(oe){const j=S.map((Z,fe)=>({cx:I(Z),cy:$(Z.value),color:ce,index:fe}));let X;a?(m.appendChild(a),X=$e(a)):X=$e(m).append("g").attr("class","bc-symbols"),w2(X,j,S.length,oe,o)}Kr(t,{chartType:"line",margin:x}),l&&(Tr(se.node()),Or(t,l))}const _2=28,f$=18,h$=20;function k2(t,e,n,o=_2){if(t.length===0)return[];if(t.length===1)return[Math.max(e,Math.min(n,t[0]))];const r=t.length,i=n-e,a=(r-1)*o>i?Math.max(0,i/(r-1)):o,l=[...t];for(let c=0;c<10;c++){for(let u=1;u<l.length;u++)l[u]-l[u-1]<a&&(l[u]=l[u-1]+a);l[l.length-1]>n&&(l[l.length-1]=n);for(let u=l.length-2;u>=0;u--)l[u+1]-l[u]<a&&(l[u]=l[u+1]-a);l[0]<e&&(l[0]=e)}return l}function p$(t,e,n){const{outerRadius:o,fontSize:r=12,bgColor:i="#fff"}=n,s=o+2,a=s+f$,l=_2/a,c=[],u=[];for(const f of e){const h=(f.startAngle+f.endAngle)/2;h<Math.PI?u.push({...f,midAngle:h}):c.push({...f,midAngle:h})}function d(f,h){if(f.length===0)return;f.sort((_,k)=>_.midAngle-k.midAngle);const g=h?.05:Math.PI+.05,b=h?Math.PI-.05:2*Math.PI-.05,m=f.map(_=>_.midAngle),v=k2(m,g,b,l),y=h?1:-1,x=t.append("g").attr("class","bc-arc-labels");f.forEach((_,k)=>{const E=_.showLabel!==!1,B=_.showValue!==!1;if(!E&&!B)return;const L=v[k]-Math.PI/2,D=Math.cos(L)*s,I=Math.sin(L)*s,C=Math.cos(L)*a,T=Math.sin(L)*a,P=C+y*h$;x.append("polyline").attr("class","bc-arc-label-line").attr("points",`${D},${I} ${C},${T} ${P},${T}`).attr("fill","none").attr("stroke","var(--bc-text-color, #999)").attr("stroke-width",1).attr("opacity",.5);const $=P+y*4,F=x.append("text").attr("class","bc-arc-direct-label").attr("x",$).attr("y",T).attr("text-anchor",h?"start":"end").attr("font-size",`${r}px`);if(E&&F.append("tspan").attr("x",$).attr("dy",B?"-0.1em":"0.35em").attr("font-weight","bold").attr("fill",t$(_.color,i)).text(_.label),B){const V=_.displayAsPercentage&&_.percentage!=null?`${Math.round(_.percentage)}%`:String(_.value);F.append("tspan").attr("x",$).attr("dy",E?"1.2em":"0.35em").attr("fill","var(--bc-text-color, #666)").text(V)}})}d(u,!0),d(c,!1)}const m$=.3;function g$(t,e,n){const{outerRadius:o,innerRadius:r=0,fontSize:i=12}=n,s=(r+o)/2,a=t.append("g").attr("class","bc-arc-labels-inside");for(const l of e){if(l.endAngle-l.startAngle<m$)continue;const u=l.showLabel!==!1,d=l.showValue!==!1;if(!u&&!d)continue;const f=(l.startAngle+l.endAngle)/2-Math.PI/2,h=Math.cos(f)*s,g=Math.sin(f)*s,b=a.append("text").attr("class","bc-arc-inside-label").attr("x",h).attr("y",g).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",`${i}px`),m=Cr(l.color);if(u&&b.append("tspan").attr("x",h).attr("dy",d?"-0.5em":"0em").attr("font-weight","bold").attr("fill",m).text(l.label),d){const v=l.displayAsPercentage&&l.percentage!=null?`${Math.round(l.percentage)}%`:String(l.value);b.append("tspan").attr("x",h).attr("dy",u?"1.2em":"0em").attr("fill",m).attr("opacity",.85).text(v)}}}function Qte(t,e,n){const{outerRadius:o,innerRadius:r=0,fontSize:i=12,bgColor:s}=n,a=(r+o)/2,l=[],c=[];for(const u of e){const d=u.endAngle-u.startAngle,f=d*a,h=u.label.length*7;f>h*1.2&&d>=m$?l.push(u):c.push(u)}l.length>0&&g$(t,l,{outerRadius:o,innerRadius:r,fontSize:i}),c.length>0&&p$(t,c,{outerRadius:o,fontSize:i,bgColor:s})}function Jte(t,e){if(t.length===0)return{left:0,right:0,top:0,bottom:0};const n=Math.max(...t.map(a=>a.length)),o=f$+h$+6+4+n*7+6,i=t.length*_2/2,s=Math.max(10,i-e+20);return{left:o,right:o,top:s,bottom:s}}const v$=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"];class ene extends ao{initialize(){this.configDefine("xPos",{defaultValue:r=>0}),this.configDefine("y",{defaultValue:On()}),this.configDefine("colors",{defaultValue:v$}),this.configDefine("labels",{defaultValue:[]}),this.configDefine("curve",{defaultValue:yu}),this.configDefine("areaFill",{defaultValue:!1}),this.configDefine("areaFillOpacity",{defaultValue:.2}),this.configDefine("height",{defaultValue:0}),this.configDefine("dots",{defaultValue:[]}),this.configDefine("highlightTargets",{defaultValue:new Set});const e=this.base.append("g"),n=this.base.append("g"),o=this.base.append("g");this.layer("areas",e,{dataBind:(r,i)=>r.selectAll(".bc-area").data(this.config("areaFill")?i:[],s=>s.name),insert:r=>r.append("path").attr("class","bc-area"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity");r.attr("data-series",d=>d.colorIndex).attr("fill",d=>a[d.colorIndex%a.length]).attr("opacity",u).attr("d",d=>Ys().curve(l).x((h,g)=>i(g)).y0(c).y1(h=>s(h))(d.values))},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity");r.duration(wt()).attr("data-series",d=>d.colorIndex).attr("fill",d=>a[d.colorIndex%a.length]).attr("opacity",u).attr("d",d=>Ys().curve(l).x((h,g)=>i(g)).y0(c).y1(h=>s(h))(d.values))},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("lines",n,{dataBind:(r,i)=>r.selectAll(".bc-line").data(i,s=>s.name),insert:r=>r.append("path").attr("class","bc-line"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("highlightTargets"),c=l.size>0;r.attr("data-series",u=>u.colorIndex).attr("fill","none").attr("stroke",u=>a[u.colorIndex%a.length]).attr("stroke-width",2).attr("opacity",u=>c?l.has(u.name)?1:.3:null).attr("d",u=>{const d=this.config("curve");return ki().curve(d).x((h,g)=>i(g)).y(h=>s(h))(u.values)})},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("highlightTargets"),c=l.size>0;r.duration(wt()).attr("data-series",u=>u.colorIndex).attr("fill","none").attr("stroke",u=>a[u.colorIndex%a.length]).attr("stroke-width",2).attr("opacity",u=>c?l.has(u.name)?1:.3:null).attr("d",u=>{const d=this.config("curve");return ki().curve(d).x((h,g)=>i(g)).y(h=>s(h))(u.values)})},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("dots",o,{dataBind:r=>r.selectAll(".bc-dot").data(this.config("dots"),i=>i.label+"\0"+i.series),insert:r=>r.append("circle").attr("class","bc-dot"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("labels");r.attr("data-series",c=>c.colorIndex).attr("cx",c=>i(l.indexOf(c.label))).attr("cy",c=>s(c.value)).attr("r",3).attr("fill",c=>a[c.colorIndex%a.length])},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("colors"),l=this.config("labels");r.duration(wt()).attr("data-series",c=>c.colorIndex).attr("cx",c=>i(l.indexOf(c.label))).attr("cy",c=>s(c.value)).attr("r",3).attr("fill",c=>a[c.colorIndex%a.length])},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}})}}function tne(t,e,n={},o=!1){var Ae,je,Xe,Ue,vt,gn,dr,Jn,kn,fr,hs,sa,Pu;jr(o),Wm(t);let r=e,i=[],s=[],a=[],l=[],c=null,u,d;const f=Br.for(t);if(o){const qe=Xr(t);d=qe==null?void 0:qe.margin,f.detach(),(qe==null?void 0:qe.chartType)==="line-multi"?(i=Array.from(t.querySelectorAll(".bc-frame .bc-area")),s=Array.from(t.querySelectorAll(".bc-frame .bc-line")),a=Array.from(t.querySelectorAll(".bc-frame .bc-dot")),l=Array.from(t.querySelectorAll(".bc-frame .bc-symbols"))):qe&&(c=Mr(t)),u=new Map;for(const st of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Tt,Ft]of ar(st))u.set(Tt,Ft);t.replaceChildren()}const{body:h}=qr(t,n.frame),g=r.series??[];let b=g.filter(qe=>!Ja(qe.name,n.seriesOverrides));(n.sortMode==="total"||n.sortMode==="within-groups")&&(b=[...b].sort((qe,st)=>{const Tt=qe.values.reduce((qn,Yn)=>qn+Yn,0);return st.values.reduce((qn,Yn)=>qn+Yn,0)-Tt}));const m=n.colors??v$,v=b.map(qe=>qe.name),y=n.seriesOverrides,x=n.directLabelling===!0||n.directLabelling==="auto"&&n.legend!==!0||!!n.directLabelling&&n.directLabelling!=="auto",_=x?"direct":n.legend!==!1?"legend":"none",k=v.filter(qe=>Ca(qe,_,y)==="direct"),E=n.legend!==!1&&!x,B=sr(h).width,S=350,L=n.legendPosition??"top",D=B>0&&B<S&&(L==="left"||L==="right")?"top":L,I=n.legendAnchor??"start",C=Pm(r.labels,(Ae=n.horizontalAxis)==null?void 0:Ae.range),T=C.map(qe=>r.labels[qe]);b=b.map(qe=>({...qe,values:C.map(st=>qe.values[st])})),r={...r,labels:T,series:b};const P=b.flatMap(qe=>qe.values),$=Ql(P,(je=n.verticalAxis)==null?void 0:je.range,(Xe=n.verticalAxis)==null?void 0:Xe.numberFormat,(Ue=n.verticalAxis)==null?void 0:Ue.scaleType),F=Oi(B,(vt=n.verticalAxis)==null?void 0:vt.labelPosition,(gn=n.horizontalAxis)==null?void 0:gn.labelPosition,(dr=n.verticalAxis)==null?void 0:dr.direction,$),V=k.length>0?l$(k):0,U=F.top!=null,K=Math.max(0,B-(F.left??50)-(F.right??20)-V),se=E?Qa(v,D,K):{width:0,height:0},he=E?se.height+15:0,ce={...F};if(E&&D==="top"){const qe=U?15:0;ce.top=he+qe}E&&D==="bottom"&&(ce.bottom=(ce.bottom??24)+he),E&&D==="left"&&(ce.left=(ce.left??50)+se.width+10),E&&D==="right"&&(ce.right=(ce.right??20)+se.width+10),V>0&&(ce.right=(ce.right??20)+V);const{chartArea:be,width:oe,height:de,margin:we}=Yr(h,ce),ee=Mi(d,we),[ge,Q]=wu(P,(Jn=n.verticalAxis)==null?void 0:Jn.range,(kn=n.verticalAxis)==null?void 0:kn.scaleType),re=$m().domain(r.labels).range([0,oe]).padding(n.edgePadding?.6:0),ve=re,N=qe=>re(r.labels[qe])??0,Y=((fr=n.verticalAxis)==null?void 0:fr.scaleType)==="log"?Ya().domain([ge,Q]).nice().range([de,0]):On().domain([ge,Q]).nice().range([de,0]),ue=Y.domain(),ae=ue[0]<0&&ue[1]>0?Y(0):void 0;f.attach(be,ee),f.update({vertical:{scale:Y,height:de,options:{...n.verticalAxis,gridWidth:oe,topPadding:we.top}},horizontal:{scale:ve,height:de,options:{...n.horizontalAxis,width:oe,zeroY:ae}}});const q=be.ownerSVGElement,ne=Bi(q,t,"plot",{x:0,y:0,width:oe,height:de}),j=$e(be).append("g").attr("clip-path",`url(#${ne})`),X=j.node(),Z=b.map(qe=>({name:qe.name,values:qe.values,colorIndex:g.findIndex(st=>st.name===qe.name)})),fe=Fl(n.interpolation);(hs=n.areaFills)!=null&&hs.length&&nne(X,n.areaFills,b,N,r.labels.length,Y,fe);const pe=[];b.forEach((qe,st)=>{r.labels.forEach((Tt,Ft)=>{pe.push({label:Tt,value:qe.values[Ft],series:qe.name,colorIndex:st})})});const me=n.lineSymbols,Se={solid:"",dotted:"2,4",dashed:"8,4","dash-dot":"8,4,2,4"},ke=n.valueLabels??!1,Te=new Set((n.highlights??[]).map(qe=>qe.target)),Fe=Te.size>0,rt=new ene($e(X));rt.config({xPos:N,y:Y,colors:m,labels:r.labels,curve:fe,areaFill:n.areaFill??!1,areaFillOpacity:n.areaFillOpacity??.2,height:de,dots:pe,highlightTargets:Te});const ut=new Set(Z.map(qe=>qe.name)),$t=i.filter(qe=>{var st;return ut.has(((st=qe.__data__)==null?void 0:st.name)??"")}),Bt=s.filter(qe=>{var st;return ut.has(((st=qe.__data__)==null?void 0:st.name)??"")}),Jt=a.filter(qe=>{var st;return ut.has(((st=qe.__data__)==null?void 0:st.series)??"")});if(Bt.length>0||$t.length>0||Jt.length>0){const qe=(ee==null?void 0:ee.dx)??0,st=(ee==null?void 0:ee.dy)??0,Tt=X.querySelectorAll(":scope > g");Tt[0]&&zo(Tt[0],$t,qe,st),Tt[1]&&zo(Tt[1],Bt,qe,st),Tt[2]&&zo(Tt[2],Jt,qe,st)}if(rt.draw(Z),(sa=n.annotations)!=null&&sa.length){const qe=r.labels.map((st,Tt)=>{var Ft;return{label:st,value:((Ft=b[0])==null?void 0:Ft.values[Tt])??0}});Vm(be,n.annotations,{scaleX:ve,scaleY:Y,data:qe,width:oe,height:de,backgroundColor:$r(t),transition:o,priorAnnotations:u})}const fn=$e(X).append("g").attr("class","bc-value-labels");if(pe.forEach(qe=>{if(!Mu(qe.series,ke,y))return;const st=N(r.labels.indexOf(qe.label)),Tt=Y(qe.value);fn.append("text").attr("class","bc-value-label").attr("data-series",qe.colorIndex).attr("x",st).attr("y",Tt-8).attr("text-anchor","middle").attr("font-size","11px").attr("fill","currentColor").text(String(qe.value))}),$e(X).selectAll(".bc-line").each(function(qe){const st=qe,Tt=an(st.name,st.colorIndex,m,y),Ft=Fte(st.name,y),qn=Rte(st.name,y),Yn=x2(st.name,n.interpolation??"linear",y),Qr=o?$e(this).transition().duration(wt()):$e(this);if(Qr.attr("stroke",Tt).attr("stroke-width",Ft),Fe&&Qr.attr("opacity",Te.has(st.name)?1:.3),qn!=="solid"&&$e(this).attr("stroke-dasharray",Se[qn]??""),Yn!==(n.interpolation??"linear")){const aa=Fl(Yn),ic=ki().curve(aa).x((Jr,Ag)=>N(Ag)).y(Jr=>Y(Jr));Qr.attr("d",ic(st.values))}}),$e(X).selectAll(".bc-area").each(function(qe){const st=qe,Tt=an(st.name,st.colorIndex,m,y),Ft=o?$e(this).transition().duration(wt()):$e(this);Ft.attr("fill",Tt),Fe&&Ft.attr("opacity",Te.has(st.name)?n.areaFillOpacity??.2:.1)}),$e(X).selectAll(".bc-dot").attr("fill-opacity",0).attr("stroke-opacity",0).attr("pointer-events","none"),n.tooltips||n.crosshair){const qe=pe.map(st=>({cx:N(r.labels.indexOf(st.label)),cy:Y(st.value),label:st.label,value:st.value,series:st.series,color:an(st.series,st.colorIndex,m,y)}));Um(be,{width:oe,height:de,points:qe,tooltip:n.tooltips,crosshair:n.crosshair,crosshairDirection:n.crosshairDirection,crosshairStyle:n.crosshairStyle,crosshairColor:n.crosshairColor,numberFormat:(Pu=n.verticalAxis)==null?void 0:Pu.numberFormat,container:t})}const Lt=me?{symbolShape:me.symbol,symbolShowOn:me.showOn,symbolStyle:me.style,symbolSize:me.size,symbolOpacity:me.opacity}:void 0,Mt=r.labels.length;b.forEach((qe,st)=>{const Tt=Vte(qe.name,Lt,y);if(!Tt)return;const Ft={symbol:Tt.symbolShape??(me==null?void 0:me.symbol)??mr.Circle,showOn:Tt.symbolShowOn??(me==null?void 0:me.showOn)??vr.FirstLast,style:Tt.symbolStyle??(me==null?void 0:me.style)??No.Filled,size:Tt.symbolSize??(me==null?void 0:me.size)??3.5,opacity:Tt.symbolOpacity??(me==null?void 0:me.opacity)??1},qn=r.labels.map((ic,Jr)=>({cx:N(Jr),cy:Y(qe.values[Jr]),color:an(qe.name,st,m,y),index:Jr})),Yn=l.find(ic=>ic.getAttribute("data-series-name")===qe.name);let Qr,aa=!1;Yn?(be.appendChild(Yn),Qr=$e(Yn),aa=!0):Qr=$e(be).append("g").attr("class","bc-symbols").attr("data-series",st).attr("data-series-name",qe.name),w2(Qr,qn,Mt,Ft,o&&aa)});const Rn=r.labels.length-1,Un=N(Rn)+6,Gn=[];if(b.forEach((qe,st)=>{var Yn;if(Ca(qe.name,_,y)!=="direct")return;const Ft=qe.values[Rn],qn=((Yn=y==null?void 0:y.find(Qr=>Qr.name===qe.name))==null?void 0:Yn.labelText)||qe.name;Gn.push({name:qe.name,index:st,naturalY:Y(Ft),text:qn})}),Gn.length>0){Gn.sort((Ft,qn)=>Ft.naturalY-qn.naturalY);const qe=Gn.map(Ft=>Ft.naturalY),Tt=k2(qe,0,de,14);Gn.forEach((Ft,qn)=>{$e(be).append("text").attr("class","bc-direct-label").attr("data-series",Ft.index).attr("x",Un).attr("y",Tt[qn]).attr("dy","0.35em").attr("font-size","11px").attr("fill",an(Ft.name,Ft.index,m,y)).text(Ft.text)})}const ur=v.filter(qe=>Ca(qe,_,y)==="legend");if(E&&ur.length>0){const qe=ur.map(Ft=>{const qn=g.findIndex(Yn=>Yn.name===Ft);return an(Ft,qn,m,y)});let st=0,Tt=0;if(D==="top"){const Ft=U?15:0;Tt=-(se.height+10+Ft)}else D==="bottom"?Tt=de+25:D==="left"?st=-(se.width+10):D==="right"&&(st=oe+10);ja(be,ur,qe,Tt,D,I,oe,de,st,[],{left:we.left,right:we.right})}Kr(t,{chartType:"line-multi",margin:we}),c&&(Tr(j.node()),Or(t,c))}function nne(t,e,n,o,r,i,s){const a=$e(t).append("g").attr("class","bc-area-fills");for(const l of e){const c=n.find(b=>b.name===l.from),u=n.find(b=>b.name===l.to);if(!c||!u)continue;const d=l.interpolation?Fl(l.interpolation):s,f=(l.opacity??30)/100,h=l.color??"#ccc",g=l.negativeColor;if(g)rne(a,c.values,u.values,o,i,d,h,g,f);else{const b=Ys().curve(d).x((m,v)=>o(v)).y0((m,v)=>i(u.values[v])).y1(m=>i(m));a.append("path").attr("class","bc-area-fill").attr("d",b(c.values)??"").attr("fill",h).attr("opacity",f)}}}function one(t,e,n,o){const r=t-n,i=e-o;if(r===0&&i===0||r>0&&i>0||r<0&&i<0)return null;const s=i-r;if(s===0)return null;const a=-r/s;return a<0||a>1?null:a}function rne(t,e,n,o,r,i,s,a,l){const c=e.length;if(c===0)return;const u=[];for(let g=0;g<c;g++){const b=o(g),m=r(e[g]),v=r(n[g]);if(u.push({x:b,fromY:m,toY:v}),g<c-1){const y=r(e[g+1]),x=r(n[g+1]),_=one(m,y,v,x);if(_!==null&&_>0&&_<1){const k=b+_*(o(g+1)-b),E=m+_*(y-m),B=v+_*(x-v);u.push({x:k,fromY:E,toY:B})}}}const d=[];let f=[],h=null;for(const g of u){const b=g.fromY-g.toY,m=b<0;h===null?(h=b===0?null:m,f.push(g)):b===0?(f.push(g),f.length>=2&&d.push({points:f,positive:h}),f=[g],h=null):h===m?f.push(g):(f.push(g),f.length>=2&&d.push({points:f,positive:h}),f=[g],h=m)}f.length>=2&&h!==null&&d.push({points:f,positive:h});for(const g of d){const b=g.points;let m=`M${b[0].x},${b[0].fromY}`;for(let v=1;v<b.length;v++)m+=`L${b[v].x},${b[v].fromY}`;for(let v=b.length-1;v>=0;v--)m+=`L${b[v].x},${b[v].toY}`;m+="Z",t.append("path").attr("class",`bc-area-fill ${g.positive?"bc-area-fill-pos":"bc-area-fill-neg"}`).attr("d",m).attr("fill",g.positive?s:a).attr("opacity",l)}}const ine=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"];class sne extends ao{initialize(){}}function ane(t,e,n={},o=!1){b$(t,e,n,.6,o)}function b$(t,e,n,o,r=!1){var ge;jr(r);let i=null,s;if(r){const Q=Xr(t),re=o>0?"donut":"pie";Q&&Q.chartType!==re&&(i=Mr(t)),s=new Map;for(const ve of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[N,G]of ar(ve))s.set(N,G);t.replaceChildren()}const{body:a}=qr(t,n.frame);let l=[...e.labels],c=[...e.values];if(n.sort===Zt.Ascending||n.sort===Zt.Descending){const Q=l.map((re,ve)=>({label:re,value:c[ve]}));Q.sort((re,ve)=>n.sort===Zt.Ascending?re.value-ve.value:ve.value-re.value),l=Q.map(re=>re.label),c=Q.map(re=>re.value)}if(n.sliceMax&&n.sliceMax>0&&l.length>n.sliceMax){const Q=n.sliceMax-1,re=l.slice(0,Q),ve=c.slice(0,Q),N=c.slice(Q).reduce((G,Y)=>G+Y,0);re.push(n.sliceGroupLabel??"Others"),ve.push(N),l=re,c=ve}const u=c.reduce((Q,re)=>Q+re,0),d=c.map(Q=>u>0?Q/u*100:0),f=n.colors??ine,h=f.length<l.length&&f.length>=2?tt.scale(f).mode("lch").colors(l.length):f,g=typeof n.directLabelling=="string"?n.directLabelling:n.directLabelling?Ao.Auto:Ao.Off,b=!!g&&!(g===Ao.Auto&&n.legend===!0),v=(n.showValues??!0)&&!b?c.map((Q,re)=>`(${n.displayAsPercentage?`${Math.round(d[re])}%`:String(Q)})`):[],y=n.legend!==!1&&!b,x=sr(a).width,_=350,k=n.legendPosition??"top",E=x>0&&x<_&&(k==="left"||k==="right")?"top":k,B=n.legendAnchor??"start",S=v.length>0?l.map((Q,re)=>`${Q} ${v[re]}`):l,L=Math.max(0,x-50-20),D=y?Qa(S,E,L):{width:0,height:0},I=y?D.height+15:0,C={};if(y&&E==="top"&&(C.top=I),y&&E==="bottom"&&(C.bottom=24+I),y&&E==="left"&&(C.left=50+D.width+10),y&&E==="right"&&(C.right=20+D.width+10),b){const Q=sr(a),re=20,ve=Q.width-2*re,N=(Q.height>0?Q.height:400)-2*re,G=Math.min(ve,N)/2,Y=Jte(l,G);C.left=(C.left??re)+Y.left,C.right=(C.right??re)+Y.right,C.top=(C.top??re)+Y.top,C.bottom=(C.bottom??re)+Y.bottom}const{chartArea:T,width:P,height:$,margin:F}=Yr(a,C),V=Math.min(P,$)/2,U=V*o,K=Zy().domain(l).range(h),se=zK().sort(null),he=RK().innerRadius(U).outerRadius(V),ce=$e(T).append("g").attr("transform",`translate(${P/2},${$/2})`),be=se(c),oe=be.map((Q,re)=>({label:l[re],arc:Q,color:K(l[re])})),de=nc(t),we=ce.append("g").node();Tu(de,{role:"mark-per-category",parent:we,selector:".bc-arc",data:oe,key:Q=>Q.label,insert:Q=>Q.append("path").attr("class","bc-arc"),attrs:Q=>({d:he(Q.arc)??"",fill:Q.color})});const ee=new sne(ce);if(n.tooltips&&ee.use(Xa()),ee.draw(oe),(ge=n.annotations)!=null&&ge.length){const Q=n.annotations.filter(re=>re.kind==="free");Q.length&&ku(Q,{scaleX:Zn().domain([]).range([0,P]),scaleY:On().domain([0,1]).range([$,0]),data:[],width:P,height:$,backgroundColor:$r(t),transition:r,priorAnnotations:s}).postDraw({base:$e(T)},void 0)}if(b){const Q=be.map((G,Y)=>({label:l[Y],value:G.data,startAngle:G.startAngle,endAngle:G.endAngle,color:K(l[Y]),percentage:d[Y],displayAsPercentage:n.displayAsPercentage,showLabel:n.showLabels??!0,showValue:n.showValues??!0})),re=ce,ve=$r(t),N={outerRadius:V,innerRadius:U,bgColor:ve};g===Ao.Inside?g$(re,Q,N):g===Ao.Auto?Qte(re,Q,N):p$(re,Q,N)}if(n.showTotal&&o>0&&!n.displayAsPercentage){const Q=String(u);ce.append("text").attr("class","bc-arc-total-label").attr("text-anchor","middle").attr("dy","-0.3em").attr("font-size","11px").attr("fill","var(--bc-text-color, #555)").attr("opacity",.7).text("Total"),ce.append("text").attr("class","bc-arc-total-value").attr("text-anchor","middle").attr("dy","1em").attr("font-size","18px").attr("font-weight","bold").attr("fill","var(--bc-text-color, #555)").text(Q)}if(y){let Q=0,re=0;E==="top"?re=-(D.height+10):E==="bottom"?re=$+25:E==="left"?Q=-(D.width+10):E==="right"&&(Q=P+10),ja(T,l,h,re,E,B,P,$,Q,v,{left:F.left,right:F.right})}Kr(t,{chartType:o>0?"donut":"pie"}),i&&(Tr(ce.node()),Or(t,i))}function lne(t,e,n={},o=!1){b$(t,e,n,0,o)}const y$="#4e79a7";class cne extends ao{initialize(){this.configDefine("xPos",{defaultValue:(r,i)=>0}),this.configDefine("y",{defaultValue:On()}),this.configDefine("color",{defaultValue:y$}),this.configDefine("curve",{defaultValue:e2}),this.configDefine("areaFillOpacity",{defaultValue:.25}),this.configDefine("height",{defaultValue:0});const e=this.base.append("g"),n=this.base.append("g"),o=this.base.append("g");this.layer("area",e,{dataBind:(r,i)=>r.selectAll(".bc-area").data([i]),insert:r=>r.append("path").attr("class","bc-area"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity"),d=Ys().curve(l).x((f,h)=>i(f,h)).y0(c).y1(f=>s(f.value));r.attr("fill",a).attr("opacity",u).attr("d",d)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=this.config("height"),u=this.config("areaFillOpacity"),d=Ys().curve(l).x((f,h)=>i(f,h)).y0(c).y1(f=>s(f.value));r.duration(wt()).attr("fill",a).attr("opacity",u).attr("d",d)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("line",n,{dataBind:(r,i)=>r.selectAll(".bc-line").data([i]),insert:r=>r.append("path").attr("class","bc-line"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=ki().curve(l).x((u,d)=>i(u,d)).y(u=>s(u.value));r.attr("fill","none").attr("stroke",a).attr("stroke-width",2).attr("d",c)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color"),l=this.config("curve"),c=ki().curve(l).x((u,d)=>i(u,d)).y(u=>s(u.value));r.duration(wt()).attr("fill","none").attr("stroke",a).attr("stroke-width",2).attr("d",c)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}}),this.layer("dots",o,{dataBind:(r,i)=>r.selectAll(".bc-dot").data(i,s=>s.label),insert:r=>r.append("circle").attr("class","bc-dot"),events:{enter:r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color");r.attr("cx",(l,c)=>i(l,c)).attr("cy",l=>s(l.value)).attr("r",3).attr("fill",a)},"merge:transition":r=>{const i=this.config("xPos"),s=this.config("y"),a=this.config("color");r.duration(wt()).attr("cx",(l,c)=>i(l,c)).attr("cy",l=>s(l.value)).attr("r",3).attr("fill",a)},"exit:transition":r=>{r.duration(wt()).attr("opacity",0).remove()}}})}}function une(t,e,n={},o=!1){var we,ee,ge,Q,re,ve,N,G,Y,ue,ae,q,ne;jr(o),Wm(t);let r=[],i=[],s=[],a=null,l=null,c,u;const d=Br.for(t);if(o){const j=Xr(t);u=j==null?void 0:j.margin,d.detach(),(j==null?void 0:j.chartType)==="area"?(r=Array.from(t.querySelectorAll(".bc-frame .bc-area")),i=Array.from(t.querySelectorAll(".bc-frame .bc-line")),s=Array.from(t.querySelectorAll(".bc-frame .bc-dot")),a=t.querySelector(".bc-frame .bc-symbols")):j&&(l=Mr(t)),c=new Map;for(const X of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Z,fe]of ar(X))c.set(Z,fe);t.replaceChildren()}const{body:f}=qr(t,n.frame),h=sr(f).width,g=Ql(e.values,(we=n.verticalAxis)==null?void 0:we.range,(ee=n.verticalAxis)==null?void 0:ee.numberFormat,(ge=n.verticalAxis)==null?void 0:ge.scaleType),b=Oi(h,(Q=n.verticalAxis)==null?void 0:Q.labelPosition,(re=n.horizontalAxis)==null?void 0:re.labelPosition,(ve=n.verticalAxis)==null?void 0:ve.direction,g),{chartArea:m,width:v,height:y,margin:x}=Yr(f,b),_=Mi(u,x),k=Pm(e.labels,(N=n.horizontalAxis)==null?void 0:N.range),E=k.map(j=>e.labels[j]),B=k.map(j=>e.values[j]),S=E.map((j,X)=>({label:j,value:B[X]})),L=$m().domain(E).range([0,v]).padding(n.edgePadding?.6:0),D=L,I=j=>L(j.label)??0,C=((G=n.verticalAxis)==null?void 0:G.scaleType)==="log",[T,P]=wu(B,(Y=n.verticalAxis)==null?void 0:Y.range,(ue=n.verticalAxis)==null?void 0:ue.scaleType),$=C?Ya().domain([T,P]).nice().range([y,0]):On().domain([T,P]).nice().range([y,0]),F=$.domain(),V=F[0]<0&&F[1]>0?$(0):void 0;d.attach(m,_),d.update({vertical:{scale:$,height:y,options:{...n.verticalAxis,gridWidth:v,topPadding:x.top}},horizontal:{scale:D,height:y,options:{...n.horizontalAxis,width:v,zeroY:V}}});const U=m.ownerSVGElement,K=Bi(U,t,"plot",{x:0,y:0,width:v,height:y}),se=$e(m).append("g").attr("clip-path",`url(#${K})`),he=se.node(),ce=((ae=n.colors)==null?void 0:ae[0])??y$,be=Fl(n.interpolation??"monotoneX"),oe=n.lineSymbols,de=new cne($e(he));if(de.config({xPos:I,y:$,color:ce,curve:be,areaFillOpacity:n.areaFillOpacity??.25,height:y}),i.length>0||r.length>0||s.length>0){const j=(_==null?void 0:_.dx)??0,X=(_==null?void 0:_.dy)??0,Z=he.querySelectorAll(":scope > g");Z[0]&&zo(Z[0],r,j,X),Z[1]&&zo(Z[1],i,j,X),Z[2]&&zo(Z[2],s,j,X)}if(n.valueLabels&&de.use(c$({position:n.valueLabelPosition,orientation:jn.Vertical})),de.draw(S),(q=n.annotations)!=null&&q.length&&Vm(m,n.annotations,{scaleX:D,scaleY:$,data:S,width:v,height:y,backgroundColor:$r(t),transition:o,priorAnnotations:c}),$e(he).selectAll(".bc-dot").attr("fill-opacity",0).attr("stroke-opacity",0).attr("pointer-events","none"),n.tooltips||n.crosshair){const j=S.map(X=>({cx:I(X),cy:$(X.value),label:X.label,value:X.value,color:ce}));Um(m,{width:v,height:y,points:j,tooltip:n.tooltips,crosshair:n.crosshair,crosshairDirection:n.crosshairDirection,crosshairStyle:n.crosshairStyle,crosshairColor:n.crosshairColor,numberFormat:(ne=n.verticalAxis)==null?void 0:ne.numberFormat,container:t})}if(oe){const j=S.map((Z,fe)=>({cx:I(Z),cy:$(Z.value),color:ce,index:fe}));let X;a?(m.appendChild(a),X=$e(a)):X=$e(m).append("g").attr("class","bc-symbols"),w2(X,j,S.length,oe,o)}Kr(t,{chartType:"area",margin:x}),l&&(Tr(se.node()),Or(t,l))}function S2(t){const e=t.series??[];if(e.length===0)return[];const n=e.map(s=>s.name);let o=!1;const r=t.labels.map((s,a)=>{const l={_index:a};return e.forEach(c=>{const u=c.values[a]??0;u<0&&(o=!0),l[c.name]=u}),l});return zC().keys(n).order(Qp).offset(o?cZ:Zp)(r)}function A2(t){const e=t.series??[];if(e.length===0)return[];const n=e.map(s=>s.name),o=t.labels.map((s,a)=>{const l={_index:a};return e.forEach(c=>{l[c.name]=c.values[a]??0}),l}),i=zC().keys(n).order(Qp).offset(lZ)(o);for(const s of i)for(const a of s)a[0]*=100,a[1]*=100;return i}const x$=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"];class dne extends ao{initialize(){this.configDefine("xPos",{defaultValue:o=>0}),this.configDefine("colors",{defaultValue:x$}),this.configDefine("curve",{defaultValue:e2}),this.configDefine("areaFillOpacity",{defaultValue:.85}),this.configDefine("highlightTargets",{defaultValue:new Set});const e=this.base.append("g"),n=this.base.append("g");this.layer("stacked-areas",e,{dataBind:(o,r)=>o.selectAll(".bc-area").data(r,i=>i.name),insert:o=>o.append("path").attr("class","bc-area"),events:{enter:o=>{const r=this.config("xPos"),i=this.config("colors"),s=this.config("curve"),a=this.config("areaFillOpacity"),l=this.config("highlightTargets"),c=l.size>0;o.attr("data-series",u=>u.colorIndex).attr("fill",u=>i[u.colorIndex%i.length]).attr("opacity",u=>c?l.has(u.name)?a:.3:a).attr("d",u=>Ys().curve(s).x((f,h)=>r(h)).y0(f=>f[0]).y1(f=>f[1])(u.points))},"merge:transition":o=>{const r=this.config("xPos"),i=this.config("colors"),s=this.config("curve"),a=this.config("areaFillOpacity"),l=this.config("highlightTargets"),c=l.size>0;o.duration(wt()).attr("data-series",u=>u.colorIndex).attr("fill",u=>i[u.colorIndex%i.length]).attr("opacity",u=>c?l.has(u.name)?a:.3:a).attr("d",u=>Ys().curve(s).x((f,h)=>r(h)).y0(f=>f[0]).y1(f=>f[1])(u.points))},"exit:transition":o=>{o.duration(wt()).attr("opacity",0).remove()}}}),this.layer("line-edges",n,{dataBind:(o,r)=>o.selectAll(".bc-line").data(r,i=>i.name),insert:o=>o.append("path").attr("class","bc-line"),events:{enter:o=>{const r=this.config("xPos"),i=this.config("colors"),s=this.config("curve"),a=this.config("highlightTargets"),l=a.size>0;o.attr("data-series",c=>c.colorIndex).attr("fill","none").attr("stroke",c=>i[c.colorIndex%i.length]).attr("stroke-width",1).attr("opacity",c=>l?a.has(c.name)?1:.3:null).attr("d",c=>ki().curve(s).x((d,f)=>r(f)).y(d=>d[1])(c.points))},"merge:transition":o=>{const r=this.config("xPos"),i=this.config("colors"),s=this.config("curve"),a=this.config("highlightTargets"),l=a.size>0;o.duration(wt()).attr("data-series",c=>c.colorIndex).attr("fill","none").attr("stroke",c=>i[c.colorIndex%i.length]).attr("stroke-width",1).attr("opacity",c=>l?a.has(c.name)?1:.3:null).attr("d",c=>ki().curve(s).x((d,f)=>r(f)).y(d=>d[1])(c.points))},"exit:transition":o=>{o.duration(wt()).attr("opacity",0).remove()}}})}}function fne(t,e,n={},o=!1){var Bt,Jt,fn,Lt,Mt,Rn,Un,Gn,ur;jr(o),Wm(t);let r=e,i=[],s=[],a=null,l,c;const u=Br.for(t);if(o){const Ae=Xr(t);c=Ae==null?void 0:Ae.margin,u.detach(),(Ae==null?void 0:Ae.chartType)==="area-stacked"?(i=Array.from(t.querySelectorAll(".bc-frame .bc-area")),s=Array.from(t.querySelectorAll(".bc-frame .bc-line"))):Ae&&(a=Mr(t)),l=new Map;for(const je of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Xe,Ue]of ar(je))l.set(Xe,Ue);t.replaceChildren()}const{body:d}=qr(t,n.frame),f=Pm(r.labels,(Bt=n.horizontalAxis)==null?void 0:Bt.range);if(f.length<r.labels.length){const Ae=f.map(Xe=>r.labels[Xe]),je=(r.series??[]).map(Xe=>({...Xe,values:f.map(Ue=>Xe.values[Ue])}));r={labels:Ae,values:f.map(Xe=>r.values[Xe]),series:je}}const h=r.series??[],g=h.filter(Ae=>!Ja(Ae.name,n.seriesOverrides)),b=n.colors??x$,m=g.map(Ae=>Ae.name),v=n.seriesOverrides,y=n.directLabelling===!0||n.directLabelling==="auto"&&n.legend!==!0||!!n.directLabelling&&n.directLabelling!=="auto",x=y?"direct":n.legend!==!1?"legend":"none",_=m.filter(Ae=>Ca(Ae,x,v)==="direct"),k=n.legend!==!1&&!y,E=sr(d).width,B=350,S=n.legendPosition??"top",L=E>0&&E<B&&(S==="left"||S==="right")?"top":S,D=n.legendAnchor??"start",I=n.stacked!==!1,C=n.stackPercent===!0||n.stackMode===Al.Percent,T=n.areaSortMode??Zt.None,P=n.areaLines!==!1,$=[...g];if(T!==Zt.None){const Ae=new Map($.map(je=>[je.name,je.values.reduce((Xe,Ue)=>Xe+Ue,0)]));$.sort((je,Xe)=>{const Ue=(Ae.get(je.name)??0)-(Ae.get(Xe.name)??0);return T===Zt.Ascending?Ue:-Ue})}const F={labels:r.labels,values:r.values,series:$},V=C?A2(F):S2(F);let U=0;if(I)for(const Ae of V)for(const je of Ae)je[1]>U&&(U=je[1]);else for(const Ae of $)for(const je of Ae.values)je>U&&(U=je);C&&(U=100);const K=[0,U],se=((Jt=n.verticalAxis)==null?void 0:Jt.numberFormat)??(C?"|d|%":void 0),he=Ql(K,(fn=n.verticalAxis)==null?void 0:fn.range,se,(Lt=n.verticalAxis)==null?void 0:Lt.scaleType),ce=Oi(E,(Mt=n.verticalAxis)==null?void 0:Mt.labelPosition,(Rn=n.horizontalAxis)==null?void 0:Rn.labelPosition,(Un=n.verticalAxis)==null?void 0:Un.direction,he),be=_.length>0?l$(_):0,oe=ce.top!=null,de=Math.max(0,E-(ce.left??50)-(ce.right??20)-be),we=k?Qa(m,L,de):{width:0,height:0},ee=k?we.height+15:0,ge={...ce};if(k&&L==="top"){const Ae=oe?15:0;ge.top=ee+Ae}k&&L==="bottom"&&(ge.bottom=(ge.bottom??24)+ee),k&&L==="left"&&(ge.left=(ge.left??50)+we.width+10),k&&L==="right"&&(ge.right=(ge.right??20)+we.width+10),be>0&&(ge.right=(ge.right??20)+be);const{chartArea:Q,width:re,height:ve,margin:N}=Yr(d,ge),G=Mi(c,N),Y=$m().domain(r.labels).range([0,re]).padding(n.edgePadding?.6:0),ue=Y,ae=Ae=>Y(r.labels[Ae])??0,q=On().domain([0,U]).nice().range([ve,0]);u.attach(Q,G),u.update({vertical:{scale:q,height:ve,options:{...n.verticalAxis,numberFormat:se,gridWidth:re,topPadding:N.top}},horizontal:{scale:ue,height:ve,options:{...n.horizontalAxis,width:re}}});const ne=Q.ownerSVGElement,j=Bi(ne,t,"plot",{x:0,y:0,width:re,height:ve}),X=$e(Q).append("g").attr("clip-path",`url(#${j})`),Z=X.node(),fe=Fl(n.interpolation??"monotoneX"),pe=V.map(Ae=>{const je=h.findIndex(Ue=>Ue.name===Ae.key);let Xe;if(I)Xe=Array.from(Ae).map(Ue=>[q(Ue[0]),q(Ue[1])]);else{const Ue=$.find(vt=>vt.name===Ae.key);Xe=((Ue==null?void 0:Ue.values)??[]).map(vt=>[q(0),q(vt)])}return{name:Ae.key,points:Xe,colorIndex:je>=0?je:0}}),me=new Set((n.highlights??[]).map(Ae=>Ae.target)),Se=me.size>0,ke=n.areaFillOpacity!=null?n.areaFillOpacity:.85,Te=new dne($e(Z));if(Te.config({xPos:ae,colors:b,curve:fe,areaFillOpacity:ke,highlightTargets:me}),i.length>0||s.length>0){const Ae=(G==null?void 0:G.dx)??0,je=(G==null?void 0:G.dy)??0,Xe=Z.querySelectorAll(":scope > g");Xe[0]&&zo(Xe[0],i,Ae,je),Xe[1]&&zo(Xe[1],s,Ae,je)}if(Te.draw(pe),$e(Z).selectAll(".bc-area").each(function(Ae){const je=Ae,Xe=an(je.name,je.colorIndex,b,v),Ue=o?$e(this).transition().duration(wt()):$e(this);Ue.attr("fill",Xe),Se&&Ue.attr("opacity",me.has(je.name)?ke:.3)}),P||$e(Z).selectAll(".bc-line").attr("display","none"),$e(Z).selectAll(".bc-line").each(function(Ae){const je=Ae,Xe=an(je.name,je.colorIndex,b,v),Ue=x2(je.name,n.interpolation??"monotoneX",v),vt=o?$e(this).transition().duration(wt()):$e(this);if(vt.attr("stroke",Xe),Se&&vt.attr("opacity",me.has(je.name)?1:.3),Ue!==(n.interpolation??"monotoneX")){const gn=Fl(Ue),dr=ki().curve(gn).x((Jn,kn)=>ae(kn)).y(Jn=>Jn[1]);vt.attr("d",dr(je.points))}}),(Gn=n.annotations)!=null&&Gn.length){const Ae=r.labels.map((je,Xe)=>{var Ue;return{label:je,value:((Ue=g[0])==null?void 0:Ue.values[Xe])??0}});Vm(Q,n.annotations,{scaleX:ue,scaleY:q,data:Ae,width:re,height:ve,backgroundColor:$r(t),transition:o,priorAnnotations:l})}if(n.tooltips||n.crosshair){const Ae=[];V.forEach(je=>{const Xe=h.findIndex(Ue=>Ue.name===je.key);Array.from(je).forEach((Ue,vt)=>{const gn=Ue[1]-Ue[0];Ae.push({cx:ae(vt),cy:q(Ue[1]),label:r.labels[vt],value:Math.round(gn*100)/100,series:je.key,color:an(je.key,Xe,b,v)})})}),Um(Q,{width:re,height:ve,points:Ae,tooltip:n.tooltips,crosshair:n.crosshair,crosshairDirection:n.crosshairDirection,crosshairStyle:n.crosshairStyle,crosshairColor:n.crosshairColor,numberFormat:(ur=n.verticalAxis)==null?void 0:ur.numberFormat,container:t})}const Fe=r.labels.length-1,rt=ae(Fe)+6,ut=[];if(g.forEach((Ae,je)=>{var Jn;if(Ca(Ae.name,x,v)!=="direct")return;const Ue=V.find(kn=>kn.key===Ae.name);if(!Ue)return;const vt=Ue[Fe],gn=q((vt[0]+vt[1])/2),dr=((Jn=v==null?void 0:v.find(kn=>kn.name===Ae.name))==null?void 0:Jn.labelText)||Ae.name;ut.push({name:Ae.name,index:je,naturalY:gn,text:dr})}),ut.length>0){ut.sort((Ue,vt)=>Ue.naturalY-vt.naturalY);const Ae=ut.map(Ue=>Ue.naturalY),Xe=k2(Ae,0,ve,14);ut.forEach((Ue,vt)=>{$e(Q).append("text").attr("class","bc-direct-label").attr("data-series",Ue.index).attr("x",rt).attr("y",Xe[vt]).attr("dy","0.35em").attr("font-size","11px").attr("fill",an(Ue.name,Ue.index,b,v)).text(Ue.text)})}const $t=m.filter(Ae=>Ca(Ae,x,v)==="legend");if(k&&$t.length>0){const Ae=$t.map(Ue=>{const vt=h.findIndex(gn=>gn.name===Ue);return an(Ue,vt,b,v)});let je=0,Xe=0;if(L==="top"){const Ue=oe?15:0;Xe=-(we.height+10+Ue)}else L==="bottom"?Xe=ve+25:L==="left"?je=-(we.width+10):L==="right"&&(je=re+10);ja(Q,$t,Ae,Xe,L,D,re,ve,je,[],{left:N.left,right:N.right})}Kr(t,{chartType:"area-stacked",margin:N}),a&&(Tr(X.node()),Or(t,a))}const w$=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"];class hne extends ao{initialize(){this.configDefine("x",{defaultValue:Zn()}),this.configDefine("y",{defaultValue:On()}),this.configDefine("colors",{defaultValue:w$});const e=this.base.append("g");this.layer("bars",e,{dataBind:(n,o)=>n.selectAll(".bc-bar-stacked").data(o,r=>r.label+"\0"+r.seriesName),insert:n=>n.append("rect").attr("class","bc-bar bc-bar-stacked"),events:{enter:n=>{const o=this.config("x"),r=this.config("y"),i=this.config("colors");n.attr("data-series",s=>s.seriesName).attr("x",s=>o(s.label)??0).attr("y",s=>r(s.y1)).attr("width",o.bandwidth()).attr("height",s=>r(s.y0)-r(s.y1)).attr("fill",s=>i[s.seriesIndex%i.length])},"merge:transition":n=>{const o=this.config("x"),r=this.config("y"),i=this.config("colors");n.duration(wt()).attr("data-series",s=>s.seriesName).attr("x",s=>o(s.label)??0).attr("y",s=>r(s.y1)).attr("width",o.bandwidth()).attr("height",s=>r(s.y0)-r(s.y1)).attr("fill",s=>i[s.seriesIndex%i.length])},"exit:transition":n=>{n.duration(wt()).attr("opacity",0).remove()}}})}}function pne(t,e,n){const o=[];for(const r of t){const i=r.key,s=n.findIndex(a=>a.name===i);for(let a=0;a<r.length;a++){const l=r[a];o.push({label:e[a],seriesName:i,seriesIndex:s,y0:l[0],y1:l[1],value:l[1]-l[0]})}}return o}function mne(t,e,n={},o=!1){var ue,ae,q,ne,j,X,Z,fe;jr(o);let r=[],i=null,s,a;const l=Br.for(t);if(o){const pe=Xr(t);a=pe==null?void 0:pe.margin,l.detach(),(pe==null?void 0:pe.chartType)==="column-stacked"?r=Array.from(t.querySelectorAll(".bc-frame .bc-bar-stacked")):pe&&(i=Mr(t)),s=new Map;for(const me of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Se,ke]of ar(me))s.set(Se,ke);t.replaceChildren()}const{body:c}=qr(t,n.frame),u=e.series??[],d=u.filter(pe=>!Ja(pe.name,n.seriesOverrides)),f=d.map(pe=>pe.name),h=n.colors??w$,g=n.seriesOverrides,b=n.legend!==!1,m=sr(c).width,v=350,y=n.legendPosition??"top",x=m>0&&m<v&&(y==="left"||y==="right")?"top":y,_=n.legendAnchor??"start",k={labels:e.labels,values:e.values,series:d},E=n.stackMode===Al.Percent,B=E?A2(k):S2(k),S=pne(B,e.labels,u),L=E?100:jd(S,pe=>pe.y1)??0,I=Ql([0,L],(ue=n.verticalAxis)==null?void 0:ue.range,(ae=n.verticalAxis)==null?void 0:ae.numberFormat,(q=n.verticalAxis)==null?void 0:q.scaleType),C=Oi(m,(ne=n.verticalAxis)==null?void 0:ne.labelPosition,(j=n.horizontalAxis)==null?void 0:j.labelPosition,(X=n.verticalAxis)==null?void 0:X.direction,I),T=Math.max(0,m-(C.left??50)-(C.right??20)),P=n2(e.labels,T,n.horizontalAxis);P!==void 0&&(C.bottom=P);const $=C.top!=null,F=Math.max(0,m-(C.left??50)-(C.right??20)),V=b?Qa(f,x,F):{width:0,height:0},U=b?V.height+15:0,K={...C};if(b&&x==="top"){const pe=$?15:0;K.top=U+pe}b&&x==="bottom"&&(K.bottom=(K.bottom??24)+U),b&&x==="left"&&(K.left=(K.left??50)+V.width+10),b&&x==="right"&&(K.right=(K.right??20)+V.width+10);const{chartArea:se,width:he,height:ce,margin:be}=Yr(c,K),oe=Mi(a,be);let de=e.labels;if(n.sortMode==="total"){const pe=e.labels.map((me,Se)=>({label:me,index:Se,total:d.reduce((ke,Te)=>ke+(Te.values[Se]??0),0)}));pe.sort((me,Se)=>Se.total-me.total),de=pe.map(me=>me.label)}const we=Zn().domain(de).range([0,he]).padding(ec(n.barGap)),ee=On().domain([0,L]).nice().range([ce,0]);l.attach(se,oe),l.update({vertical:{scale:ee,height:ce,options:{...n.verticalAxis,gridWidth:he,topPadding:be.top}},horizontal:{scale:we,height:ce,options:{...n.horizontalAxis,width:he}}});const ge=se.ownerSVGElement,Q=Bi(ge,t,"bars",{x:0,y:0,width:he,height:ce}),re=$e(se).append("g").attr("clip-path",`url(#${Q})`),ve=de===e.labels?S:de.flatMap(pe=>S.filter(me=>me.label===pe)),N=new hne(re);if(N.config({x:we,y:ee,colors:h}),r.length>0){const pe=re.node().querySelector("g");zo(pe,r,(oe==null?void 0:oe.dx)??0,(oe==null?void 0:oe.dy)??0)}if(n.tooltips&&N.use(Xa({numberFormat:(Z=n.verticalAxis)==null?void 0:Z.numberFormat})),n.crosshair&&N.use(tc({width:he,height:ce,direction:n.crosshairDirection,style:n.crosshairStyle,color:n.crosshairColor})),(fe=n.annotations)!=null&&fe.length){const pe=e.labels.map((me,Se)=>({label:me,value:d.reduce((ke,Te)=>ke+(Te.values[Se]??0),0)}));N.use(ku(n.annotations,{scaleX:we,scaleY:ee,data:pe,width:he,height:ce,backgroundColor:$r(t),transition:o,priorAnnotations:s}))}N.draw(ve),Kr(t,{chartType:"column-stacked",margin:be}),i&&(Tr(re.node()),Or(t,i)),$e(se).selectAll(".bc-bar-stacked").each(function(pe){const me=pe,Se=an(me.seriesName,me.seriesIndex,h,g),ke=Of(me.seriesName,g),Te=o?$e(this).transition().duration(wt()):$e(this);Te.attr("fill",Se),ke<1&&Te.attr("fill-opacity",ke)});const G=n.valueLabels??!1,Y=$e(se).append("g").attr("class","bc-value-labels");if(ve.forEach(pe=>{if(!Mu(pe.seriesName,G,g))return;const me=(we(pe.label)??0)+we.bandwidth()/2,Se=ee(pe.y0)-(ee(pe.y0)-ee(pe.y1))/2;Y.append("text").attr("class","bc-value-label").attr("data-series",pe.seriesName).attr("x",me).attr("y",Se).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","11px").attr("fill","currentColor").text(E?`${Math.round(pe.value)}%`:String(Math.round(pe.value*100)/100))}),b&&f.length>0){const pe=f.map(ke=>{const Te=u.findIndex(Fe=>Fe.name===ke);return an(ke,Te,h,g)});let me=0,Se=0;if(x==="top"){const ke=$?15:0;Se=-(V.height+10+ke)}else x==="bottom"?Se=ce+25:x==="left"?me=-(V.width+10):x==="right"&&(me=he+10);ja(se,f,pe,Se,x,_,he,ce,me,[],{left:be.left,right:be.right})}}const _$=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],b6=13;class gne extends ao{initialize(){this.configDefine("x",{defaultValue:On()}),this.configDefine("y",{defaultValue:Zn()}),this.configDefine("colors",{defaultValue:_$}),this.configDefine("categoryLabelOffset",{defaultValue:0});const e=this.base.append("g");this.layer("bars",e,{dataBind:(n,o)=>n.selectAll(".bc-bar-stacked").data(o,r=>r.label+"\0"+r.seriesName),insert:n=>n.append("rect").attr("class","bc-bar bc-bar-stacked"),events:{enter:n=>{const o=this.config("x"),r=this.config("y"),i=this.config("colors"),s=this.config("categoryLabelOffset");n.attr("data-series",a=>a.seriesName).attr("x",a=>o(a.y0)).attr("y",a=>(r(a.label)??0)+s).attr("width",a=>o(a.y1)-o(a.y0)).attr("height",Math.max(0,r.bandwidth()-s)).attr("fill",a=>i[a.seriesIndex%i.length])},"merge:transition":n=>{const o=this.config("x"),r=this.config("y"),i=this.config("colors"),s=this.config("categoryLabelOffset");n.duration(wt()).attr("data-series",a=>a.seriesName).attr("x",a=>o(a.y0)).attr("y",a=>(r(a.label)??0)+s).attr("width",a=>o(a.y1)-o(a.y0)).attr("height",Math.max(0,r.bandwidth()-s)).attr("fill",a=>i[a.seriesIndex%i.length])},"exit:transition":n=>{n.duration(wt()).attr("opacity",0).remove()}}})}}function vne(t,e,n){const o=[];for(const r of t){const i=r.key,s=n.findIndex(a=>a.name===i);for(let a=0;a<r.length;a++){const l=r[a];o.push({label:e[a],seriesName:i,seriesIndex:s,y0:l[0],y1:l[1],value:l[1]-l[0]})}}return o}function bne(t,e,n={},o=!1){var j,X,Z,fe,pe,me,Se;jr(o);let r=[],i=null,s,a;const l=Br.for(t);if(o){const ke=Xr(t);a=ke==null?void 0:ke.margin,l.detach(),(ke==null?void 0:ke.chartType)==="bar-stacked"?r=Array.from(t.querySelectorAll(".bc-frame .bc-bar-stacked")):ke&&(i=Mr(t)),s=new Map;for(const Te of t.querySelectorAll(".bc-frame .bc-annotations, .bc-frame .bc-annotations-range"))for(const[Fe,rt]of ar(Te))s.set(Fe,rt);t.replaceChildren()}const{body:c}=qr(t,n.frame),u=e.series??[],d=u.filter(ke=>!Ja(ke.name,n.seriesOverrides)),f=d.map(ke=>ke.name),h=n.colors??_$,g=n.seriesOverrides,b=n.legend!==!1,m=sr(c).width,v=350,y=n.legendPosition??"top",x=m>0&&m<v&&(y==="left"||y==="right")?"top":y,_=n.legendAnchor??"start",k={labels:e.labels,values:e.values,series:d},E=n.stackMode===Al.Percent,B=E?A2(k):S2(k),S=vne(B,e.labels,u),L=E?100:jd(S,ke=>ke.y1)??0,D=n.categoryLabelLine===!0,I=Bm(e.labels),C=D?on.Off:(j=n.verticalAxis)==null?void 0:j.labelPosition,T=Oi(m,C,(X=n.horizontalAxis)==null?void 0:X.labelPosition,(Z=n.verticalAxis)==null?void 0:Z.direction,I,(fe=n.horizontalAxis)==null?void 0:fe.showAxis),P=T.top!=null,$=Math.max(0,m-(T.left??50)-(T.right??20)),F=b?Qa(f,x,$):{width:0,height:0},V=b?F.height+15:0,U={...T};if(b&&x==="top"){const ke=P?15:0;U.top=V+ke}b&&x==="bottom"&&(U.bottom=(U.bottom??24)+V),b&&x==="left"&&(U.left=(U.left??50)+F.width+10),b&&x==="right"&&(U.right=(U.right??20)+F.width+10);const{chartArea:K,width:se,height:he,margin:ce}=Yr(c,U),be=Mi(a,ce);let oe=e.labels;if(n.sortMode==="total"){const ke=e.labels.map((Te,Fe)=>({label:Te,index:Fe,total:d.reduce((rt,ut)=>rt+(ut.values[Fe]??0),0)}));ke.sort((Te,Fe)=>Fe.total-Te.total),oe=ke.map(Te=>Te.label)}const de=On().domain([0,L]).nice().range([0,se]),we=Zn().domain(oe).range([0,he]).padding(ec(n.barGap));l.attach(K,be),l.update({horizontal:{scale:de,height:he,options:{...n.horizontalAxis,width:se}},vertical:{scale:we,height:he,options:{...n.verticalAxis,labelPosition:D?on.Off:(pe=n.verticalAxis)==null?void 0:pe.labelPosition,topPadding:ce.top}},order:"horizontal-first"});const ee=K.ownerSVGElement,ge=Bi(ee,t,"bars",{x:0,y:0,width:se,height:he}),Q=$e(K).append("g").attr("clip-path",`url(#${ge})`),re=oe===e.labels?S:oe.flatMap(ke=>S.filter(Te=>Te.label===ke)),ve=D?b6:0,N=new gne(Q);if(N.config({x:de,y:we,colors:h,categoryLabelOffset:ve}),r.length>0){const ke=Q.node().querySelector("g");zo(ke,r,(be==null?void 0:be.dx)??0,(be==null?void 0:be.dy)??0)}if(n.tooltips&&N.use(Xa({numberFormat:(me=n.verticalAxis)==null?void 0:me.numberFormat})),n.crosshair&&N.use(tc({width:se,height:he,direction:n.crosshairDirection,style:n.crosshairStyle,color:n.crosshairColor,orientation:jn.Horizontal})),(Se=n.annotations)!=null&&Se.length){const ke=e.labels.map((Te,Fe)=>({label:Te,value:d.reduce((rt,ut)=>rt+(ut.values[Fe]??0),0)}));N.use(ku(n.annotations,{scaleX:we,scaleY:de,data:ke,width:se,height:he,backgroundColor:$r(t),orientation:jn.Horizontal,transition:o,priorAnnotations:s}))}if(N.draw(re),Kr(t,{chartType:"bar-stacked",margin:ce}),i&&(Tr(Q.node()),Or(t,i)),$e(K).selectAll(".bc-bar-stacked").each(function(ke){const Te=ke,Fe=an(Te.seriesName,Te.seriesIndex,h,g),rt=Of(Te.seriesName,g),ut=o?$e(this).transition().duration(wt()):$e(this);ut.attr("fill",Fe),rt<1&&ut.attr("fill-opacity",rt)}),D){const ke=$e(K).append("g").attr("class","bc-category-labels");for(const Te of oe){const Fe=we(Te)??0;ke.append("text").attr("class","bc-category-label").attr("x",2).attr("y",Fe+b6/2).attr("text-anchor","start").attr("dominant-baseline","central").attr("font-size","10px").attr("font-weight","600").attr("fill","currentColor").text(Te)}}const G=n.valueLabels??!1,Y=n.valueLabelPosition??bt.Auto,ue=new Set,ae=new Map;for(const ke of oe){const Te=re.filter(Fe=>Fe.label===ke).sort((Fe,rt)=>Fe.y1-rt.y1);if(Te.length>0){const Fe=Te[Te.length-1];ue.add(Fe.label+"\0"+Fe.seriesName);for(let rt=0;rt<Te.length-1;rt++){const ut=Te[rt].label+"\0"+Te[rt].seriesName;ae.set(ut,de(Te[rt+1].y1)-de(Te[rt].y1))}}}const q=new Map,ne=$e(K).append("g").attr("class","bc-value-labels");if(re.forEach(ke=>{if(!Mu(ke.seriesName,G,g))return;const Te=E?`${Math.round(ke.value)}%`:String(Math.round(ke.value*100)/100),Fe=de(ke.y1)-de(ke.y0),rt=Te.length*6.5+8,ut=Fe>=rt,$t=(we(ke.label)??0)+ve+(we.bandwidth()-ve)/2,Bt=an(ke.seriesName,ke.seriesIndex,h,g),Jt=ue.has(ke.label+"\0"+ke.seriesName),fn=Y===bt.Outside||Y===bt.Auto&&!ut&&Jt,Lt=()=>{const Mt=de(ke.y0)+Fe/2;ne.append("text").attr("class","bc-value-label").attr("data-series",ke.seriesName).attr("opacity",0).attr("x",Mt).attr("y",$t).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","11px").attr("fill",Cr(Bt)).text(Te)};if(fn)if(Y===bt.Inside)Lt();else{const Mt=de(ke.y1)+4,Rn=q.get(ke.label)??0,Un=ae.get(ke.label+"\0"+ke.seriesName),Gn=Mt<Rn,ur=Un!==void 0&&rt+4>Un,Ae=se+ce.right-2,je=Mt+rt>Ae;Gn||ur||je?Lt():(q.set(ke.label,Mt+rt),ne.append("text").attr("class","bc-value-label").attr("data-series",ke.seriesName).attr("x",Mt).attr("y",$t).attr("text-anchor","start").attr("dominant-baseline","central").attr("font-size","11px").attr("fill","currentColor").text(Te))}else if(!ut)Lt();else{const Mt=de(ke.y0)+Fe/2;ne.append("text").attr("class","bc-value-label").attr("data-series",ke.seriesName).attr("x",Mt).attr("y",$t).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","11px").attr("fill",Cr(Bt)).text(Te)}}),b&&f.length>0){const ke=f.map(rt=>{const ut=u.findIndex($t=>$t.name===rt);return an(rt,ut,h,g)});let Te=0,Fe=0;if(x==="top"){const rt=P?15:0;Fe=-(F.height+10+rt)}else x==="bottom"?Fe=he+25:x==="left"?Te=-(F.width+10):x==="right"&&(Te=se+10);ja(K,f,ke,Fe,x,_,se,he,Te,[],{left:ce.left,right:ce.right})}}const k$=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],y6=16,yh=20,x6=13;class yne extends ao{initialize(){this.configDefine("y",{defaultValue:Zn()}),this.configDefine("colors",{defaultValue:k$}),this.configDefine("categoryLabelOffset",{defaultValue:0});const e=this.base.append("g");this.layer("bars",e,{dataBind:(n,o)=>n.selectAll(".bc-bar-split").data(o,r=>r.label+"\0"+r.seriesName),insert:n=>n.append("rect").attr("class","bc-bar bc-bar-split"),events:{enter:n=>{const o=this.config("y"),r=this.config("colors"),i=this.config("categoryLabelOffset");n.attr("data-series",s=>s.seriesName).attr("x",s=>s.xPos).attr("y",s=>(o(s.label)??0)+i).attr("width",s=>s.barWidth).attr("height",Math.max(0,o.bandwidth()-i)).attr("fill",s=>r[s.seriesIndex%r.length])},"merge:transition":n=>{const o=this.config("y"),r=this.config("colors"),i=this.config("categoryLabelOffset");n.duration(wt()).attr("data-series",s=>s.seriesName).attr("x",s=>s.xPos).attr("y",s=>(o(s.label)??0)+i).attr("width",s=>s.barWidth).attr("height",Math.max(0,o.bandwidth()-i)).attr("fill",s=>r[s.seriesIndex%r.length])},"exit:transition":n=>{n.duration(wt()).attr("opacity",0).remove()}}})}}function xne(t,e,n,o){const r=t.length;if(r===0)return[];const i=Math.max(0,(n-(r-1)*y6)/r),s=o?jd(t.flatMap(a=>a.values))??0:0;return t.map((a,l)=>{const c=o?s:jd(a.values)??0,u=On().domain([0,c]).nice().range([0,i]);return{seriesName:a.name,seriesIndex:e.findIndex(d=>d.name===a.name),xOffset:l*(i+y6),panelWidth:i,xScale:u}})}function wne(t,e,n,o){const r=[];for(const i of t){const s=o.find(a=>a.name===i.seriesName);if(s)for(const a of e){const l=n.indexOf(a),c=l>=0?s.values[l]??0:0,u=Math.max(0,i.xScale(c)-i.xScale(0));r.push({label:a,seriesName:i.seriesName,seriesIndex:i.seriesIndex,value:c,xPos:i.xOffset,barWidth:u})}}return r}function _ne(t,e,n={},o=!1){var ve,N,G,Y,ue,ae;jr(o);let r=[],i=null,s;const a=Br.for(t);if(o){const q=Xr(t);s=q==null?void 0:q.margin,a.detach(),(q==null?void 0:q.chartType)==="bar-split"?r=Array.from(t.querySelectorAll(".bc-frame .bc-bar-split")):q&&(i=Mr(t)),t.replaceChildren()}const{body:l}=qr(t,n.frame),c=e.series??[],u=c.filter(q=>!Ja(q.name,n.seriesOverrides)),d=u.map(q=>q.name),f=n.colors??k$,h=n.seriesOverrides,g=n.legend!==!1,b=sr(l).width,m=350,v=n.legendPosition??"top",y=b>0&&b<m&&(v==="left"||v==="right")?"top":v,x=n.legendAnchor??"start",_=n.categoryLabelLine===!0,k=Bm(e.labels),E=_?on.Off:(ve=n.verticalAxis)==null?void 0:ve.labelPosition,B=Oi(b,E,(N=n.horizontalAxis)==null?void 0:N.labelPosition,(G=n.verticalAxis)==null?void 0:G.direction,k,(Y=n.horizontalAxis)==null?void 0:Y.showAxis);B.top=(B.top??12)+yh;const S=Math.max(0,b-(B.left??50)-(B.right??20)),L=g?Qa(d,y,S):{width:0,height:0},D=g?L.height+15:0,I={...B};g&&y==="top"&&(I.top=D+yh),g&&y==="bottom"&&(I.bottom=(I.bottom??24)+D),g&&y==="left"&&(I.left=(I.left??50)+L.width+10),g&&y==="right"&&(I.right=(I.right??20)+L.width+10);const{chartArea:C,width:T,height:P,margin:$}=Yr(l,I),F=Mi(s,$);let V=e.labels;if(n.sortMode==="total"){const q=e.labels.map((ne,j)=>({label:ne,total:u.reduce((X,Z)=>X+(Z.values[j]??0),0)}));q.sort((ne,j)=>j.total-ne.total),V=q.map(ne=>ne.label)}const U=Zn().domain(V).range([0,P]).padding(ec(n.barGap)),K=_?x6:0;a.attach(C,F),a.update({vertical:{scale:U,height:P,options:{...n.verticalAxis,labelPosition:_?on.Off:(ue=n.verticalAxis)==null?void 0:ue.labelPosition,topPadding:$.top}},order:"horizontal-first"});const se=n.sharedScale===!0,he=xne(u,c,T,se),ce=C.ownerSVGElement,be=Bi(ce,t,"bars",{x:0,y:0,width:T,height:P}),oe=$e(C).append("g").attr("clip-path",`url(#${be})`),de=$e(C).append("g").attr("class","bc-split-headers");for(const q of he)de.append("text").attr("class","bc-split-header").attr("x",q.xOffset+q.panelWidth/2).attr("y",-yh/2).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","11px").attr("font-weight","600").attr("fill","currentColor").text(q.seriesName);const we=wne(he,V,e.labels,c),ee=new yne(oe);if(ee.config({y:U,colors:f,categoryLabelOffset:K}),r.length>0){const q=oe.node().querySelector("g");zo(q,r,(F==null?void 0:F.dx)??0,(F==null?void 0:F.dy)??0)}if(n.tooltips&&ee.use(Xa({numberFormat:(ae=n.verticalAxis)==null?void 0:ae.numberFormat})),n.crosshair&&ee.use(tc({width:T,height:P,direction:n.crosshairDirection,style:n.crosshairStyle,color:n.crosshairColor,orientation:jn.Horizontal})),ee.draw(we),Kr(t,{chartType:"bar-split",margin:$}),i&&(Tr(oe.node()),Or(t,i)),$e(C).selectAll(".bc-bar-split").each(function(q){const ne=q,j=an(ne.seriesName,ne.seriesIndex,f,h),X=Of(ne.seriesName,h),Z=o?$e(this).transition().duration(wt()):$e(this);Z.attr("fill",j),X<1&&Z.attr("fill-opacity",X)}),_){const q=$e(C).append("g").attr("class","bc-category-labels");for(const ne of V){const j=U(ne)??0;q.append("text").attr("class","bc-category-label").attr("x",2).attr("y",j+x6/2).attr("text-anchor","start").attr("dominant-baseline","central").attr("font-size","10px").attr("font-weight","600").attr("fill","currentColor").text(ne)}}const ge=n.valueLabels??!0,Q=n.valueLabelPosition??bt.Auto,re=$e(C).append("g").attr("class","bc-value-labels");if(we.forEach(q=>{if(!Mu(q.seriesName,ge,h))return;const ne=he.find(Te=>Te.seriesName===q.seriesName);if(!ne)return;const j=an(q.seriesName,q.seriesIndex,f,h),X=q.xPos+q.barWidth,Z=Math.max(0,U.bandwidth()-K),fe=(U(q.label)??0)+K+Z/2,pe=Q===bt.Inside||Q===bt.Auto&&q.barWidth>30;let me,Se,ke;if(pe)me=X-4,Se="end",ke=Cr(j);else{const Te=X+4,Fe=ne.xOffset+ne.panelWidth;Te+20>Fe?(me=q.xPos-4,Se="end"):(me=Te,Se="start"),ke="currentColor"}re.append("text").attr("class","bc-value-label").attr("data-series",q.seriesName).attr("x",me).attr("y",fe).attr("text-anchor",Se).attr("dominant-baseline","central").attr("font-size","11px").attr("fill",ke).text(String(q.value))}),g&&d.length>0){const q=d.map(X=>{const Z=c.findIndex(fe=>fe.name===X);return an(X,Z,f,h)});let ne=0,j=0;y==="top"?j=-(L.height+10+yh):y==="bottom"?j=P+25:y==="left"?ne=-(L.width+10):y==="right"&&(ne=T+10),ja(C,d,q,j,y,x,T,P,ne,[],{left:$.left,right:$.right})}}const K1=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],w6=13;class kne extends ao{initialize(){this.configDefine("x",{defaultValue:On()}),this.configDefine("y0",{defaultValue:Zn()}),this.configDefine("y1",{defaultValue:Zn()}),this.configDefine("colors",{defaultValue:K1}),this.configDefine("categoryLabelOffset",{defaultValue:0});const e=this.base.append("g");this.layer("bars",e,{dataBind:(n,o)=>n.selectAll(".bc-bar-grouped").data(o,r=>r.label+"\0"+r.seriesName),insert:n=>n.append("rect").attr("class","bc-bar bc-bar-grouped"),events:{enter:n=>{const o=this.config("x"),r=this.config("y0"),i=this.config("y1"),s=this.config("colors"),a=this.config("categoryLabelOffset");n.attr("data-series",l=>l.seriesName).attr("x",o(0)).attr("y",l=>(r(l.label)??0)+a+(i(l.seriesName)??0)).attr("width",l=>Math.max(0,o(l.value)-o(0))).attr("height",i.bandwidth()).attr("fill",l=>s[l.seriesIndex%s.length])},"merge:transition":n=>{const o=this.config("x"),r=this.config("y0"),i=this.config("y1"),s=this.config("colors"),a=this.config("categoryLabelOffset");n.duration(wt()).attr("data-series",l=>l.seriesName).attr("x",o(0)).attr("y",l=>(r(l.label)??0)+a+(i(l.seriesName)??0)).attr("width",l=>Math.max(0,o(l.value)-o(0))).attr("height",i.bandwidth()).attr("fill",l=>s[l.seriesIndex%s.length])},"exit:transition":n=>{n.duration(wt()).attr("opacity",0).remove()}}})}}function Sne(t,e,n={},o=!1){var N,G,Y,ue,ae,q;jr(o);let r=[],i=null,s;const a=Br.for(t);if(o){const ne=Xr(t);s=ne==null?void 0:ne.margin,a.detach(),(ne==null?void 0:ne.chartType)==="bar-grouped"?r=Array.from(t.querySelectorAll(".bc-frame .bc-bar-grouped")):ne&&(i=Mr(t)),t.replaceChildren()}const{body:l}=qr(t,n.frame),c=e.series??[],u=c.filter(ne=>!Ja(ne.name,n.seriesOverrides)),d=u.map(ne=>ne.name),f=n.colors??K1,h=n.seriesOverrides,g=n.legend!==!1,b=sr(l).width,m=350,v=n.legendPosition??"top",y=b>0&&b<m&&(v==="left"||v==="right")?"top":v,x=n.legendAnchor??"start",_=n.categoryLabelLine===!0,k=Bm(e.labels),E=_?on.Off:(N=n.verticalAxis)==null?void 0:N.labelPosition,B=Oi(b,E,(G=n.horizontalAxis)==null?void 0:G.labelPosition,(Y=n.verticalAxis)==null?void 0:Y.direction,k,(ue=n.horizontalAxis)==null?void 0:ue.showAxis),S=Math.max(0,b-(B.left??50)-(B.right??20)),L=g?Qa(d,y,S):{width:0,height:0},D=g?L.height+15:0,I={...B};g&&y==="top"&&(I.top=D),g&&y==="bottom"&&(I.bottom=(I.bottom??24)+D),g&&y==="left"&&(I.left=(I.left??50)+L.width+10),g&&y==="right"&&(I.right=(I.right??20)+L.width+10);const{chartArea:C,width:T,height:P,margin:$}=Yr(l,I),F=Mi(s,$);let V=e.labels;if(n.sortMode==="total"){const ne=e.labels.map((j,X)=>({label:j,total:u.reduce((Z,fe)=>Z+(fe.values[X]??0),0)}));ne.sort((j,X)=>X.total-j.total),V=ne.map(j=>j.label)}const U=Zn().domain(V).range([0,P]).paddingInner(ec(n.barGap)).paddingOuter(.05),K=_?w6:0,se=Math.max(0,U.bandwidth()-K),he=Zn().domain(d).range([0,se]).padding(.05),ce=jd(u.flatMap(ne=>ne.values))??0,be=On().domain([0,ce]).nice().range([0,T]);a.attach(C,F),a.update({vertical:{scale:U,height:P,options:{...n.verticalAxis,labelPosition:_?on.Off:(ae=n.verticalAxis)==null?void 0:ae.labelPosition,topPadding:$.top}},horizontal:{scale:be,height:P,options:{...n.horizontalAxis,width:T}},order:"horizontal-first"});const oe=C.ownerSVGElement,de=Bi(oe,t,"bars",{x:0,y:0,width:T,height:P}),we=$e(C).append("g").attr("clip-path",`url(#${de})`);if(n.barBackground){const ne=(n.colors??K1)[0];we.selectAll(".bc-bar-bg").data(V,j=>j).enter().append("rect").attr("class","bc-bar-bg").attr("x",0).attr("y",j=>(U(j)??0)+K).attr("width",T).attr("height",U.bandwidth()-K).attr("fill",ne).attr("opacity",.18)}if(n.barSeparators&&V.length>1){const ne=U.step();for(let j=1;j<V.length;j++){const X=(U(V[j-1])??0)+U.bandwidth()+(ne-U.bandwidth())/2;we.append("line").attr("class","bc-bar-separator").attr("x1",0).attr("x2",T).attr("y1",X).attr("y2",X).attr("stroke","currentColor").attr("opacity",.15)}}const ee=[];for(const ne of V){const j=e.labels.indexOf(ne);for(const X of u){const Z=c.findIndex(fe=>fe.name===X.name);ee.push({label:ne,seriesName:X.name,seriesIndex:Z,value:j>=0?X.values[j]??0:0})}}const ge=new kne(we);if(ge.config({x:be,y0:U,y1:he,colors:f,categoryLabelOffset:K}),r.length>0){const ne=we.node().querySelector("g");zo(ne,r,(F==null?void 0:F.dx)??0,(F==null?void 0:F.dy)??0)}if(n.tooltips&&ge.use(Xa({numberFormat:(q=n.verticalAxis)==null?void 0:q.numberFormat})),n.crosshair&&ge.use(tc({width:T,height:P,direction:n.crosshairDirection,style:n.crosshairStyle,color:n.crosshairColor,orientation:jn.Horizontal})),ge.draw(ee),Kr(t,{chartType:"bar-grouped",margin:$}),i&&(Tr(we.node()),Or(t,i)),$e(C).selectAll(".bc-bar-grouped").each(function(ne){const j=ne,X=an(j.seriesName,j.seriesIndex,f,h),Z=Of(j.seriesName,h),fe=o?$e(this).transition().duration(wt()):$e(this);fe.attr("fill",X),Z<1&&fe.attr("fill-opacity",Z)}),_){const ne=$e(C).append("g").attr("class","bc-category-labels");for(const j of V){const X=U(j)??0;ne.append("text").attr("class","bc-category-label").attr("x",2).attr("y",X+w6/2).attr("text-anchor","start").attr("dominant-baseline","central").attr("font-size","10px").attr("font-weight","600").attr("fill","currentColor").text(j)}}const Q=n.valueLabels??!0,re=n.valueLabelPosition??bt.Auto,ve=$e(C).append("g").attr("class","bc-value-labels");if(ee.forEach(ne=>{if(!Mu(ne.seriesName,Q,h))return;const j=an(ne.seriesName,ne.seriesIndex,f,h),X=Math.max(0,be(ne.value)-be(0)),Z=be(0)+X,fe=(U(ne.label)??0)+K+(he(ne.seriesName)??0)+he.bandwidth()/2,pe=re===bt.Inside||re===bt.Auto&&X>30;let me,Se,ke;pe?(me=Z-4,Se="end",ke=Cr(j)):(me=Z+4,Se="start",ke="currentColor"),ve.append("text").attr("class","bc-value-label").attr("data-series",ne.seriesName).attr("x",me).attr("y",fe).attr("text-anchor",Se).attr("dominant-baseline","central").attr("font-size","11px").attr("fill",ke).text(String(ne.value))}),g&&d.length>0){const ne=d.map(Z=>{const fe=c.findIndex(pe=>pe.name===Z);return an(Z,fe,f,h)});let j=0,X=0;y==="top"?X=-(L.height+10):y==="bottom"?X=P+25:y==="left"?j=-(L.width+10):y==="right"&&(j=T+10),ja(C,d,ne,X,y,x,T,P,j,[],{left:$.left,right:$.right})}}const C2=new Map;function Wo(t,e,n){C2.set(t,{renderer:e,options:n})}function Ane(t){var e;return(e=C2.get(t))==null?void 0:e.renderer}function au(t){var e;return((e=C2.get(t))==null?void 0:e.options)??[]}const _6=[{value:Hn.Solid,text:"Solid"},{value:Hn.Dashed,text:"Dashed"},{value:Hn.Dotted,text:"Dotted"},{value:Hn.None,text:"None"}],Uo={key:"colors",type:Qe.Colors,label:"Colors"},Go={key:"colorPalette",type:Qe.Select,label:"Color palette",default:"Blueprint",choices:[{value:"",text:"Custom"},...JC().map(t=>({value:t.name,text:t.label}))]},qo={key:"autoContrast",type:Qe.Boolean,label:"Auto-adjust contrast",default:!1},Yo={key:"allowDarkMode",type:Qe.Boolean,label:"Allow dark mode",default:!0},Ou={key:"legend",type:Qe.Boolean,label:"Show legend",default:!0},oa={key:"legendPosition",type:Qe.Select,label:"Legend position",default:wc.Top,choices:[{value:wc.Top,text:"Top"},{value:wc.Bottom,text:"Bottom"},{value:wc.Left,text:"Left"},{value:wc.Right,text:"Right"}]},ra={key:"legendAnchor",type:Qe.Select,label:"Legend anchor",default:Ps.Start,choices:[{value:Ps.Start,text:"Start"},{value:Ps.Middle,text:"Middle"},{value:Ps.End,text:"End"}]},Gm={key:"directLabelling",type:Qe.Select,label:"Direct labelling",default:Ao.Off,choices:[{value:Ao.Off,text:"Off"},{value:Ao.Auto,text:"Auto"},{value:Ao.Outside,text:"Outside"},{value:Ao.Inside,text:"Inside"}]},$2={key:"directLabelAnchor",type:Qe.Select,label:"Label anchor",default:Ps.Middle,choices:[{value:Ps.Start,text:"Start"},{value:Ps.Middle,text:"Middle"},{value:Ps.End,text:"End"}]},qm={key:"valueLabels",type:Qe.Boolean,label:"Value labels",default:!1},Ym={key:"valueLabelPosition",type:Qe.Select,label:"Label position",default:bt.Auto,choices:[{value:bt.Auto,text:"Auto"},{value:bt.Outside,text:"Outside"},{value:bt.Inside,text:"Inside"}]},ia={key:"tooltips",type:Qe.Boolean,label:"Tooltips",default:!1},S$={key:"crosshair",type:Qe.Boolean,label:"Crosshair",default:!1},A$={key:"crosshairDirection",type:Qe.Select,label:"Crosshair direction",default:So.Both,choices:[{value:So.Both,text:"Both"},{value:So.Vertical,text:"Vertical"},{value:So.Horizontal,text:"Horizontal"}]},C$={key:"crosshairStyle",type:Qe.Select,label:"Crosshair style",default:li.Dashed,choices:[{value:li.Solid,text:"Solid"},{value:li.Dashed,text:"Dashed"},{value:li.Dotted,text:"Dotted"}]},$$={key:"crosshairColor",type:Qe.Text,label:"Crosshair color",default:"#999",placeholder:"#999"},T$={key:"lineSymbols",type:Qe.Boolean,label:"Show line symbols",default:!1},M$={key:"lineSymbolShape",type:Qe.Select,label:"Symbol",default:mr.Circle,choices:[{value:mr.Circle,text:"Circle"},{value:mr.Square,text:"Square"},{value:mr.Diamond,text:"Diamond"},{value:mr.Triangle,text:"Triangle Up"},{value:mr.TriangleDown,text:"Triangle Down"},{value:mr.Cross,text:"Cross"},{value:mr.Star,text:"Star"}]},O$={key:"lineSymbolShowOn",type:Qe.Select,label:"Show on",default:vr.FirstLast,choices:[{value:vr.FirstLast,text:"First & Last"},{value:vr.First,text:"First"},{value:vr.Last,text:"Last"},{value:vr.All,text:"All"}]},B$={key:"lineSymbolStyle",type:Qe.Select,label:"Style",default:No.Filled,choices:[{value:No.Filled,text:"Filled"},{value:No.Hollow,text:"Hollow"}]},L$={key:"lineSymbolSize",type:Qe.Text,label:"Size",default:"3.5",placeholder:"3.5"},P$={key:"lineSymbolOpacity",type:Qe.Text,label:"Opacity",default:"1",placeholder:"1"},Bf={key:"sortMode",type:Qe.Select,label:"Sort mode",default:ai.None,choices:[{value:ai.None,text:"None"},{value:ai.Total,text:"By total"},{value:ai.WithinGroups,text:"Within groups"}]},jm={key:"edgePadding",type:Qe.Boolean,label:"Edge padding",default:!1},Xm={key:"waterfall",type:Qe.Boolean,label:"Waterfall",default:!1},Km={key:"waterfallTotal",type:Qe.Boolean,label:"Waterfall total",default:!1},Lf={key:"barBackground",type:Qe.Boolean,label:"Bar background",default:!1},Zm={key:"barGap",type:Qe.Text,label:"Bar gap",default:String(ef),placeholder:String(ef)},Pf={key:"barSeparators",type:Qe.Boolean,label:"Bar separators",default:!1},Qm={key:"connectedColumns",type:Qe.Boolean,label:"Connected columns",default:!1},Jm={key:"connectionsOpacity",type:Qe.Text,label:"Opacity",default:"0.15",placeholder:"0.15"},eg={key:"swapLabelValue",type:Qe.Boolean,label:"Swap labels and values",default:!1},D$={key:"stackMode",type:Qe.Select,label:"Stack mode",default:Al.Normal,choices:[{value:Al.Normal,text:"Normal"},{value:Al.Percent,text:"Percentage (100%)"}]},Cne={key:"sharedScale",type:Qe.Boolean,label:"Shared scale",default:!1},oc={key:"categoryLabelLine",type:Qe.Boolean,label:"Labels on separate line",default:!1},E$={key:"displayAsPercentage",type:Qe.Boolean,label:"Display as percentage",default:!1},N$={key:"showTotal",type:Qe.Boolean,label:"Show total",default:!1},I$={key:"showLabels",type:Qe.Boolean,label:"Show labels",default:!0},R$={key:"showValues",type:Qe.Boolean,label:"Show values",default:!0},F$={key:"sliceMax",type:Qe.Text,label:"Max slices",default:"6"},V$={key:"sliceGroupLabel",type:Qe.Text,label:"Group label",default:"Others",placeholder:"Others"},$ne={key:"areaFillOpacity",type:Qe.Text,label:"Opacity",default:"0.85",placeholder:"0.85"},Tne={key:"stacked",type:Qe.Boolean,label:"Stack areas",default:!0},Mne={key:"stackPercent",type:Qe.Boolean,label:"Stack to 100%",default:!1},One={key:"areaLines",type:Qe.Boolean,label:"Separate areas with lines",default:!0},Bne={key:"areaSortMode",type:Qe.Select,label:"Sort areas",default:Zt.None,choices:[{value:Zt.None,text:"Keep order"},{value:Zt.Ascending,text:"Smallest first"},{value:Zt.Descending,text:"Largest first"}]},Lne={key:"interpolation",type:Qe.Select,label:"Line interpolation",default:ni.Linear,choices:[{value:ni.Linear,text:"Linear"},{value:ni.MonotoneX,text:"Monotone"},{value:ni.Step,text:"Step"},{value:ni.StepBefore,text:"Step (before)"},{value:ni.StepAfter,text:"Step (after)"},{value:ni.Basis,text:"Basis"},{value:ni.Cardinal,text:"Cardinal"},{value:ni.CatmullRom,text:"Catmull-Rom"}]},k6=[{value:tu.Linear,text:"Linear"},{value:tu.Log,text:"Logarithmic"}],S6=[{value:on.Auto,text:"Auto"},{value:on.Inside,text:"Inside"},{value:on.Outside,text:"Outside"},{value:on.Off,text:"Off"}],Pne=[{value:Cd.Auto,text:"Auto"},{value:Cd.Horizontal,text:"Horizontal"},{value:Cd.Vertical,text:"Vertical"}];function Df(t){return[{key:"showVerticalAxis",type:Qe.Boolean,label:"Show vertical axis",default:t.showVerticalAxis??!0},{key:"verticalAxisDirection",type:Qe.Select,label:"Vertical axis side",default:oi.Left,choices:[{value:oi.Left,text:"Left"},{value:oi.Right,text:"Right"}]},{key:"showVerticalTicks",type:Qe.Boolean,label:"Show vertical ticks",default:t.showVerticalTicks},{key:"verticalLabelPosition",type:Qe.Select,label:"Vertical labels",default:on.Auto,choices:S6},{key:"verticalGridStyle",type:Qe.Select,label:"Vertical grid style",default:t.verticalGrid,choices:_6},{key:"verticalNumberFormat",type:Qe.NumberFormat,label:"Vertical number format"},...t.valueAxis==="vertical"?[{key:"verticalScaleType",type:Qe.Select,label:"Vertical scale",default:tu.Linear,choices:k6},t.valueAxisZeroBaseline?{key:"verticalRangeMin",type:Qe.Text,label:"Vertical min",default:"0",placeholder:"auto"}:{key:"verticalRangeMin",type:Qe.Text,label:"Vertical min",placeholder:"auto"},{key:"verticalRangeMax",type:Qe.Text,label:"Vertical max",placeholder:"auto"}]:[],{key:"showHorizontalAxis",type:Qe.Boolean,label:"Show horizontal axis",default:!0},{key:"showHorizontalTicks",type:Qe.Boolean,label:"Show horizontal ticks",default:t.showHorizontalTicks},{key:"horizontalLabelPosition",type:Qe.Select,label:"Horizontal labels",default:on.Auto,choices:S6},{key:"horizontalLabelRotation",type:Qe.Select,label:"Horizontal label rotation",default:Cd.Horizontal,choices:Pne},{key:"horizontalGridStyle",type:Qe.Select,label:"Horizontal grid style",default:t.horizontalGrid,choices:_6},{key:"horizontalNumberFormat",type:Qe.NumberFormat,label:"Horizontal number format"},...t.valueAxis==="horizontal"?[{key:"horizontalScaleType",type:Qe.Select,label:"Horizontal scale",default:tu.Linear,choices:k6},t.valueAxisZeroBaseline?{key:"horizontalRangeMin",type:Qe.Text,label:"Horizontal min",default:"0",placeholder:"auto"}:{key:"horizontalRangeMin",type:Qe.Text,label:"Horizontal min",placeholder:"auto"},{key:"horizontalRangeMax",type:Qe.Text,label:"Horizontal max",placeholder:"auto"}]:[],...t.horizontalRange?[{key:"horizontalRangeMin",type:Qe.Text,label:"Horizontal min",placeholder:"auto"},{key:"horizontalRangeMax",type:Qe.Text,label:"Horizontal max",placeholder:"auto"}]:[]]}const tg=Df({verticalGrid:Hn.Dashed,horizontalGrid:Hn.None,showVerticalTicks:!1,showHorizontalTicks:!1,showVerticalAxis:!1,valueAxis:"vertical",valueAxisZeroBaseline:!0}),Ef=Df({verticalGrid:Hn.None,horizontalGrid:Hn.Dashed,showVerticalTicks:!1,showHorizontalTicks:!1,valueAxis:"horizontal",valueAxisZeroBaseline:!0}),z$=Df({verticalGrid:Hn.Dashed,horizontalGrid:Hn.None,showVerticalTicks:!1,showHorizontalTicks:!1,showVerticalAxis:!1,valueAxis:"vertical",horizontalRange:!0}),Dne=Df({verticalGrid:Hn.Dashed,horizontalGrid:Hn.None,showVerticalTicks:!1,showHorizontalTicks:!1,showVerticalAxis:!1,valueAxis:"vertical",horizontalRange:!0,valueAxisZeroBaseline:!0}),ng={...Lne,default:ni.MonotoneX},Ene={...A$,default:So.Vertical},Nne={...S$,default:!0},Ine={...T$,default:!0},H$={...Bf,default:ai.Total},T2={...qm,default:!0},Rne={...E$,default:!0},Fne={...F$,default:"5"},Vne={...N$,default:!0},og={...Gm,default:Ao.Auto},rg={...Ou,default:!1},ig=[S$,A$,C$,$$],M2=[Nne,Ene,C$,$$],sg=[qm,Ym,ia,...ig],O2=[T2,Ym,ia,...ig],zne=[T$,M$,O$,B$,L$,P$],Hne=[Ine,M$,O$,B$,L$,P$],W$=[qm,ia,...M2,...zne],Wne=[qm,ia,...M2,...Hne],Une=[Rne,N$,I$,R$,Fne,V$],Gne=[E$,Vne,I$,R$,F$,V$];Wo(Le.BarVertical,s$,[Uo,Go,qo,Yo,eg,Lf,Pf,Zm,Qm,Jm,Xm,Km,oc,...tg,...sg]);Wo(Le.BarHorizontal,a$,[Uo,Go,qo,Yo,eg,Lf,Pf,Zm,Qm,Jm,Xm,Km,oc,...Ef,...O2]);Wo(Le.BarMulti,Wte,[Uo,Go,qo,Yo,H$,rg,ra,oa,og,$2,...tg,...sg]);Wo(Le.Line,Zte,[Uo,Go,qo,Yo,ng,jm,...z$,...W$]);Wo(Le.LineMulti,tne,[Uo,Go,qo,Yo,ng,jm,Bf,rg,ra,oa,og,...z$,...Wne]);Wo(Le.Donut,ane,[Uo,Go,qo,Yo,rg,ra,oa,og,ia,...Gne]);Wo(Le.Pie,lne,[Uo,Go,qo,Yo,rg,ra,oa,og,ia,...Une]);Wo(Le.Area,une,[Uo,Go,qo,Yo,ng,jm,...Dne,...W$]);const qne=Df({verticalGrid:Hn.Dashed,horizontalGrid:Hn.None,showVerticalTicks:!1,showHorizontalTicks:!1,showVerticalAxis:!1,valueAxis:"vertical",horizontalRange:!0,valueAxisZeroBaseline:!0});Wo(Le.AreaStacked,fne,[Uo,Go,qo,Yo,$ne,ng,jm,Bne,Tne,Mne,One,Ou,ra,oa,Gm,...qne,ia,...M2]);Wo(Le.ColumnStacked,mne,[Uo,Go,qo,Yo,D$,Bf,Ou,ra,oa,Gm,$2,...tg,...sg]);Wo(Le.BarStacked,bne,[Uo,Go,qo,Yo,D$,Bf,Ou,ra,oa,Gm,$2,oc,...Ef,...O2]);Wo(Le.BarSplit,_ne,[Uo,Go,qo,Yo,Cne,Bf,Ou,ra,oa,oc,...Ef,T2,Ym,ia,...ig]);Wo(Le.BarGrouped,Sne,[Uo,Go,qo,Yo,H$,Ou,ra,oa,Lf,Pf,oc,...Ef,T2,Ym,ia,...ig]);Wo(Le.VerticalBar,s$,[Uo,Go,qo,Yo,eg,Lf,Pf,Zm,Qm,Jm,Xm,Km,oc,...tg,...sg]);Wo(Le.HorizontalBar,a$,[Uo,Go,qo,Yo,eg,Lf,Pf,Zm,Qm,Jm,Xm,Km,oc,...Ef,...O2]);function A6(t){const e=t==null?void 0:t.trim();if(!e)return;const n=Number.parseFloat(e);return Number.isFinite(n)?n:void 0}function fs(t){var i;const e=t.split(`
|
|
80
|
-
`).map(s=>s.trim()).filter(Boolean),n=[],o=[],r=(i=e[0])==null?void 0:i.match(/^_series\s*=\s*(.+)$/);if(r){const s=r[1].trim(),a=s.includes('","')?s.split(",").map(u=>u.trim().replace(/^"|"$/g,"")):s.replace(/^"|"$/g,"").split(",").map(u=>u.trim()),l=a.map(()=>[]);for(let u=1;u<e.length;u++){const d=e[u].match(/^"([^"]+)"\s*=\s*([^"]+)$/),h=e[u].match(/^"([^"]+)"\s*=\s*"([^"]*)"$/)??d;if(h){n.push(h[1]);const g=h[2].split(",");for(let b=0;b<a.length;b++)l[b].push(A6(g[b]))}}const c=a.map((u,d)=>({name:u,values:l[d]}));return{labels:n,values:l[0]??[],series:c}}for(const s of e){const a=s.match(/^"([^"]+)"\s*=\s*(.+)$/);a&&(n.push(a[1]),o.push(A6(a[2])))}return{labels:n,values:o}}function Yne(t,e){const n={},o=QC(t.colorPalette);return o?n.colors=o:t.colors&&t.colors.length>0&&(n.colors=t.colors),t.autoContrast&&e&&n.colors&&(n.colors=o$(n.colors,e)),t.allowDarkMode!==void 0&&(n.allowDarkMode=t.allowDarkMode),n}function jne(t){const e={};return t.legend!==void 0&&(e.legend=t.legend),t.legendPosition!==void 0&&(e.legendPosition=t.legendPosition),t.legendAnchor!==void 0&&(e.legendAnchor=t.legendAnchor),t.directLabelling!==void 0&&(e.directLabelling=t.directLabelling),t.directLabelAnchor!==void 0&&(e.directLabelAnchor=t.directLabelAnchor),e}function Xne(t){if(!(t.showVerticalTicks!==void 0||t.verticalGridStyle!==void 0||t.verticalNumberFormat!==void 0||t.showVerticalAxis!==void 0||t.verticalAxisDirection!==void 0||t.verticalScaleType!==void 0||t.verticalLabelPosition!==void 0||t.verticalRangeMin||t.verticalRangeMax))return{};const n={};t.showVerticalTicks!==void 0&&(n.showTicks=t.showVerticalTicks),t.verticalAxisDirection!==void 0&&(n.direction=t.verticalAxisDirection),t.verticalGridStyle!==void 0&&(n.gridStyle=t.verticalGridStyle),t.verticalNumberFormat!==void 0&&(n.numberFormat=t.verticalNumberFormat),t.showVerticalAxis!==void 0&&(n.showAxis=t.showVerticalAxis),t.verticalScaleType!==void 0&&(n.scaleType=t.verticalScaleType),t.verticalLabelPosition!==void 0&&(n.labelPosition=t.verticalLabelPosition);const o=Jd(t.verticalRangeMin??""),r=Jd(t.verticalRangeMax??"");return(o!==void 0||r!==void 0)&&(n.range={},o!==void 0&&(n.range.min=o),r!==void 0&&(n.range.max=r)),{verticalAxis:n}}function Kne(t){if(!(t.showHorizontalTicks!==void 0||t.horizontalGridStyle!==void 0||t.horizontalNumberFormat!==void 0||t.showHorizontalAxis!==void 0||t.horizontalScaleType!==void 0||t.horizontalLabelPosition!==void 0||t.horizontalLabelRotation!==void 0||t.horizontalRangeMin||t.horizontalRangeMax))return{};const n={};t.showHorizontalTicks!==void 0&&(n.showTicks=t.showHorizontalTicks),t.horizontalGridStyle!==void 0&&(n.gridStyle=t.horizontalGridStyle),t.horizontalNumberFormat!==void 0&&(n.numberFormat=t.horizontalNumberFormat),t.showHorizontalAxis!==void 0&&(n.showAxis=t.showHorizontalAxis),t.horizontalScaleType!==void 0&&(n.scaleType=t.horizontalScaleType),t.horizontalLabelPosition!==void 0&&(n.labelPosition=t.horizontalLabelPosition),t.horizontalLabelRotation!==void 0&&(n.labelRotation=t.horizontalLabelRotation);const o=Jd(t.horizontalRangeMin??""),r=Jd(t.horizontalRangeMax??"");return(o!==void 0||r!==void 0)&&(n.range={},o!==void 0&&(n.range.min=o),r!==void 0&&(n.range.max=r)),{horizontalAxis:n}}function Zne(t){return t.lineSymbols?{lineSymbols:{symbol:t.lineSymbolShape??mr.Circle,showOn:t.lineSymbolShowOn??vr.FirstLast,style:t.lineSymbolStyle??No.Filled,size:parseFloat(t.lineSymbolSize??"3.5")||3.5,opacity:parseFloat(t.lineSymbolOpacity??"1")||1}}:{}}function U$(t,e){const n={...Yne(t,e),...jne(t),...Xne(t),...Kne(t),...Zne(t)};t.interpolation!==void 0&&(n.interpolation=t.interpolation),t.valueLabels!==void 0&&(n.valueLabels=t.valueLabels),t.valueLabelPosition!==void 0&&(n.valueLabelPosition=t.valueLabelPosition),t.tooltips!==void 0&&(n.tooltips=t.tooltips),t.crosshair!==void 0&&(n.crosshair=t.crosshair),t.crosshairDirection&&(n.crosshairDirection=t.crosshairDirection),t.crosshairStyle&&(n.crosshairStyle=t.crosshairStyle),t.crosshairColor&&(n.crosshairColor=t.crosshairColor),t.displayAsPercentage!==void 0&&(n.displayAsPercentage=t.displayAsPercentage),t.showTotal!==void 0&&(n.showTotal=t.showTotal),t.showLabels!==void 0&&(n.showLabels=t.showLabels),t.showValues!==void 0&&(n.showValues=t.showValues),t.swapLabelValue!==void 0&&(n.swapLabelValue=t.swapLabelValue);const o=parseInt(t.sliceMax??"",10);!isNaN(o)&&o>0&&(n.sliceMax=o),t.sliceGroupLabel!==void 0&&(n.sliceGroupLabel=t.sliceGroupLabel),t.barBackground!==void 0&&(n.barBackground=t.barBackground),t.barSeparators!==void 0&&(n.barSeparators=t.barSeparators);const r=parseFloat(t.barGap??"");isNaN(r)||(n.barGap=Math.max(0,Math.min(100,r))),t.connectedColumns!==void 0&&(n.connectedColumns=t.connectedColumns);const i=parseFloat(t.connectionsOpacity??"");isNaN(i)||(n.connectionsOpacity=Math.max(0,Math.min(1,i))),t.stackMode!==void 0&&(n.stackMode=t.stackMode),t.stacked!==void 0&&(n.stacked=t.stacked),t.stackPercent!==void 0&&(n.stackPercent=t.stackPercent),t.areaSortMode!==void 0&&(n.areaSortMode=t.areaSortMode),t.areaLines!==void 0&&(n.areaLines=t.areaLines);const s=parseFloat(t.areaFillOpacity??"");return isNaN(s)||(n.areaFillOpacity=s),t.edgePadding!==void 0&&(n.edgePadding=t.edgePadding),t.waterfall!==void 0&&(n.waterfall=t.waterfall),t.waterfallTotal!==void 0&&(n.waterfallTotal=t.waterfallTotal),t.categoryLabelLine!==void 0&&(n.categoryLabelLine=t.categoryLabelLine),n}const kv=Object.create(null);function G$(t){if(!kv[t]){const e={};for(const n of au(t))n.default!==void 0&&(e[n.key]=n.default);kv[t]=e}return kv[t]}function c0(t,e){var r;const n=G$(t);return((r=e.colors)==null?void 0:r.length)?{...n,colorPalette:void 0,...e}:{...n,...e}}const Qne={protanopia:"Protanopia (no red)",deuteranopia:"Deuteranopia (no green)",tritanopia:"Tritanopia (no blue)"},q$={protanopia:[.152286,1.052583,-.204868,0,0,.114503,.786281,.099216,0,0,-.003882,-.048116,1.051998,0,0,0,0,0,1,0],deuteranopia:[.367322,.860646,-.227968,0,0,.280085,.672501,.047413,0,0,-.01182,.04294,.968881,0,0,0,0,0,1,0],tritanopia:[1.255528,-.076749,-.178779,0,0,-.078411,.930809,.147602,0,0,.004733,.691367,.3039,0,0,0,0,0,1,0]};function Y$(t){return`bc-cvd-${t}`}function Jne(t){const e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"filter");n.setAttribute("id",Y$(t)),n.setAttribute("color-interpolation-filters","linearRGB");const o=document.createElementNS(e,"feColorMatrix");return o.setAttribute("type","matrix"),o.setAttribute("values",q$[t].join(" ")),n.appendChild(o),n}function eoe(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Sv(t){return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function toe(t,e){const[n,o,r]=tt(t).rgb().map(u=>eoe(u/255)),i=q$[e],s=Sv(i[0]*n+i[1]*o+i[2]*r),a=Sv(i[5]*n+i[6]*o+i[7]*r),l=Sv(i[10]*n+i[11]*o+i[12]*r),c=u=>Math.min(255,Math.max(0,Math.round(u*255)));return tt(c(s),c(a),c(l)).hex()}const noe=10;function ooe(t){if(t.length<2)return[];const e=["protanopia","deuteranopia","tritanopia"],n=[];for(const o of e){const r=t.map(s=>toe(s,o)),i=[];for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){const l=tt.deltaE(r[s],r[a]);l<noe&&i.push({a:t[s],b:t[a],deltaE:l})}i.length>0&&n.push({type:o,label:Qne[o],pairs:i})}return n}function roe(t){const e={properties:[],data:null,colorizes:[],highlights:[],areaFills:[],annotations:[],annotationVisibility:[],series:[],scenes:[],transforms:[]};for(const n of t)switch(n.type){case"property":e.properties.push(n);break;case"data":if(e.data!==null)throw new SyntaxError("duplicate data block");e.data=n;break;case"colorize":e.colorizes.push(n);break;case"highlight":e.highlights.push(n);break;case"areafill":e.areaFills.push(n);break;case"annotation":e.annotations.push(n);break;case"annotation-visibility":e.annotationVisibility.push(n);break;case"series":e.series.push(n);break;case"scene":e.scenes.push(n);break;case"transform":e.transforms.push(n);break}return e}function ioe(t){const e={properties:[],data:null,colorizes:[],highlights:[],areaFills:[],annotations:[],annotationVisibility:[],series:[],transforms:[]};for(const n of t)switch(n.type){case"property":e.properties.push(n);break;case"data":if(e.data!==null)throw new SyntaxError("duplicate data block");e.data=n;break;case"colorize":e.colorizes.push(n);break;case"highlight":e.highlights.push(n);break;case"areafill":e.areaFills.push(n);break;case"annotation":e.annotations.push(n);break;case"annotation-visibility":e.annotationVisibility.push(n);break;case"series":e.series.push(n);break;case"transform":e.transforms.push(n);break}return e}function soe(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Tl(t,e,n,o){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,Tl.prototype),r.expected=e,r.found=n,r.location=o,r.name="SyntaxError",r}soe(Tl,Error);function Av(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Tl.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,o;for(o=0;o<t.length;o++)if(t[o].source===this.location.source){n=t[o].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,i=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,s=this.location.source+":"+i.line+":"+i.column;if(n){var a=this.location.end,l=Av("",i.line.toString().length," "),c=n[r.line-1],u=r.line===a.line?a.column:c.length+1,d=u-r.column||1;e+=`
|
|
80
|
+
`).map(s=>s.trim()).filter(Boolean),n=[],o=[],r=(i=e[0])==null?void 0:i.match(/^_series\s*=\s*(.+)$/);if(r){const s=r[1].trim(),a=s.includes('","')?s.split(",").map(u=>u.trim().replace(/^"|"$/g,"")):s.replace(/^"|"$/g,"").split(",").map(u=>u.trim()),l=a.map(()=>[]);for(let u=1;u<e.length;u++){const d=e[u].match(/^"([^"]+)"\s*=\s*([^"]+)$/),h=e[u].match(/^"([^"]+)"\s*=\s*"([^"]*)"$/)??d;if(h){n.push(h[1]);const g=h[2].split(",");for(let b=0;b<a.length;b++)l[b].push(A6(g[b]))}}const c=a.map((u,d)=>({name:u,values:l[d]}));return{labels:n,values:l[0]??[],series:c}}for(const s of e){const a=s.match(/^"([^"]+)"\s*=\s*(.+)$/);a&&(n.push(a[1]),o.push(A6(a[2])))}return{labels:n,values:o}}function Yne(t,e){const n={},o=QC(t.colorPalette);return o?n.colors=o:t.colors&&t.colors.length>0&&(n.colors=t.colors),t.autoContrast&&e&&n.colors&&(n.colors=o$(n.colors,e)),t.allowDarkMode!==void 0&&(n.allowDarkMode=t.allowDarkMode),n}function jne(t){const e={};return t.legend!==void 0&&(e.legend=t.legend),t.legendPosition!==void 0&&(e.legendPosition=t.legendPosition),t.legendAnchor!==void 0&&(e.legendAnchor=t.legendAnchor),t.directLabelling!==void 0&&(e.directLabelling=t.directLabelling),t.directLabelAnchor!==void 0&&(e.directLabelAnchor=t.directLabelAnchor),e}function Xne(t){if(!(t.showVerticalTicks!==void 0||t.verticalGridStyle!==void 0||t.verticalNumberFormat!==void 0||t.showVerticalAxis!==void 0||t.verticalAxisDirection!==void 0||t.verticalScaleType!==void 0||t.verticalLabelPosition!==void 0||t.verticalRangeMin||t.verticalRangeMax))return{};const n={};t.showVerticalTicks!==void 0&&(n.showTicks=t.showVerticalTicks),t.verticalAxisDirection!==void 0&&(n.direction=t.verticalAxisDirection),t.verticalGridStyle!==void 0&&(n.gridStyle=t.verticalGridStyle),t.verticalNumberFormat!==void 0&&(n.numberFormat=t.verticalNumberFormat),t.showVerticalAxis!==void 0&&(n.showAxis=t.showVerticalAxis),t.verticalScaleType!==void 0&&(n.scaleType=t.verticalScaleType),t.verticalLabelPosition!==void 0&&(n.labelPosition=t.verticalLabelPosition);const o=Jd(t.verticalRangeMin??""),r=Jd(t.verticalRangeMax??"");return(o!==void 0||r!==void 0)&&(n.range={},o!==void 0&&(n.range.min=o),r!==void 0&&(n.range.max=r)),{verticalAxis:n}}function Kne(t){if(!(t.showHorizontalTicks!==void 0||t.horizontalGridStyle!==void 0||t.horizontalNumberFormat!==void 0||t.showHorizontalAxis!==void 0||t.horizontalScaleType!==void 0||t.horizontalLabelPosition!==void 0||t.horizontalLabelRotation!==void 0||t.horizontalRangeMin||t.horizontalRangeMax))return{};const n={};t.showHorizontalTicks!==void 0&&(n.showTicks=t.showHorizontalTicks),t.horizontalGridStyle!==void 0&&(n.gridStyle=t.horizontalGridStyle),t.horizontalNumberFormat!==void 0&&(n.numberFormat=t.horizontalNumberFormat),t.showHorizontalAxis!==void 0&&(n.showAxis=t.showHorizontalAxis),t.horizontalScaleType!==void 0&&(n.scaleType=t.horizontalScaleType),t.horizontalLabelPosition!==void 0&&(n.labelPosition=t.horizontalLabelPosition),t.horizontalLabelRotation!==void 0&&(n.labelRotation=t.horizontalLabelRotation);const o=Jd(t.horizontalRangeMin??""),r=Jd(t.horizontalRangeMax??"");return(o!==void 0||r!==void 0)&&(n.range={},o!==void 0&&(n.range.min=o),r!==void 0&&(n.range.max=r)),{horizontalAxis:n}}function Zne(t){return t.lineSymbols?{lineSymbols:{symbol:t.lineSymbolShape??mr.Circle,showOn:t.lineSymbolShowOn??vr.FirstLast,style:t.lineSymbolStyle??No.Filled,size:parseFloat(t.lineSymbolSize??"3.5")||3.5,opacity:parseFloat(t.lineSymbolOpacity??"1")||1}}:{}}function U$(t,e){const n={...Yne(t,e),...jne(t),...Xne(t),...Kne(t),...Zne(t)};t.interpolation!==void 0&&(n.interpolation=t.interpolation),t.valueLabels!==void 0&&(n.valueLabels=t.valueLabels),t.valueLabelPosition!==void 0&&(n.valueLabelPosition=t.valueLabelPosition),t.tooltips!==void 0&&(n.tooltips=t.tooltips),t.crosshair!==void 0&&(n.crosshair=t.crosshair),t.crosshairDirection&&(n.crosshairDirection=t.crosshairDirection),t.crosshairStyle&&(n.crosshairStyle=t.crosshairStyle),t.crosshairColor&&(n.crosshairColor=t.crosshairColor),t.displayAsPercentage!==void 0&&(n.displayAsPercentage=t.displayAsPercentage),t.showTotal!==void 0&&(n.showTotal=t.showTotal),t.showLabels!==void 0&&(n.showLabels=t.showLabels),t.showValues!==void 0&&(n.showValues=t.showValues),t.swapLabelValue!==void 0&&(n.swapLabelValue=t.swapLabelValue);const o=parseInt(t.sliceMax??"",10);!isNaN(o)&&o>0&&(n.sliceMax=o),t.sliceGroupLabel!==void 0&&(n.sliceGroupLabel=t.sliceGroupLabel),t.barBackground!==void 0&&(n.barBackground=t.barBackground),t.barSeparators!==void 0&&(n.barSeparators=t.barSeparators);const r=parseFloat(t.barGap??"");isNaN(r)||(n.barGap=Math.max(0,Math.min(100,r))),t.connectedColumns!==void 0&&(n.connectedColumns=t.connectedColumns);const i=parseFloat(t.connectionsOpacity??"");isNaN(i)||(n.connectionsOpacity=Math.max(0,Math.min(1,i))),t.stackMode!==void 0&&(n.stackMode=t.stackMode),t.stacked!==void 0&&(n.stacked=t.stacked),t.stackPercent!==void 0&&(n.stackPercent=t.stackPercent),t.areaSortMode!==void 0&&(n.areaSortMode=t.areaSortMode),t.areaLines!==void 0&&(n.areaLines=t.areaLines);const s=parseFloat(t.areaFillOpacity??"");return isNaN(s)||(n.areaFillOpacity=s),t.edgePadding!==void 0&&(n.edgePadding=t.edgePadding),t.waterfall!==void 0&&(n.waterfall=t.waterfall),t.waterfallTotal!==void 0&&(n.waterfallTotal=t.waterfallTotal),t.categoryLabelLine!==void 0&&(n.categoryLabelLine=t.categoryLabelLine),n}const Qne={[Le.BarVertical]:"Vertical Bar Chart",[Le.BarHorizontal]:"Horizontal Bar Chart",[Le.BarMulti]:"Grouped Bar Chart",[Le.Line]:"Line Chart",[Le.LineMulti]:"Multi-Line Chart",[Le.Pie]:"Pie Chart",[Le.Donut]:"Donut Chart"};function Jne(t,e){if(t.length===0)return[];const n=t.filter(a=>a==="string").length,o=t.filter(a=>a==="number").length,r=t.filter(a=>a==="date").length,i=[],s=(a,l,c)=>i.push({chartType:a,label:Qne[a]??a,fitness:l,reason:c});return r===1&&o>=1?o===1?(s(Le.Line,"best","1 date + 1 numeric column — ideal for trend"),s(Le.BarVertical,"alternative","Can also show as bars")):(s(Le.LineMulti,"best",`1 date + ${o} numeric columns — compare trends`),s(Le.BarMulti,"alternative","Can also show as grouped bars")):n===1&&o===1?(s(Le.BarVertical,"best","1 categorical + 1 numeric — classic bar chart"),s(Le.BarHorizontal,"good","Horizontal bars work well for long labels"),e<=8&&(s(Le.Donut,"good",`${e} items — suitable for part-of-whole`),s(Le.Pie,"alternative","Pie chart for part-of-whole"))):n===1&&o>1?(s(Le.BarMulti,"best",`1 categorical + ${o} numeric columns — compare groups`),s(Le.LineMulti,"good","Can also show as multi-line chart")):o>=1&&(n>=1||r>=1)&&s(Le.BarVertical,"good","Default bar chart recommendation"),i}const kv=Object.create(null);function G$(t){if(!kv[t]){const e={};for(const n of au(t))n.default!==void 0&&(e[n.key]=n.default);kv[t]=e}return kv[t]}function c0(t,e){var r;const n=G$(t);return((r=e.colors)==null?void 0:r.length)?{...n,colorPalette:void 0,...e}:{...n,...e}}const eoe={protanopia:"Protanopia (no red)",deuteranopia:"Deuteranopia (no green)",tritanopia:"Tritanopia (no blue)"},q$={protanopia:[.152286,1.052583,-.204868,0,0,.114503,.786281,.099216,0,0,-.003882,-.048116,1.051998,0,0,0,0,0,1,0],deuteranopia:[.367322,.860646,-.227968,0,0,.280085,.672501,.047413,0,0,-.01182,.04294,.968881,0,0,0,0,0,1,0],tritanopia:[1.255528,-.076749,-.178779,0,0,-.078411,.930809,.147602,0,0,.004733,.691367,.3039,0,0,0,0,0,1,0]};function Y$(t){return`bc-cvd-${t}`}function toe(t){const e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"filter");n.setAttribute("id",Y$(t)),n.setAttribute("color-interpolation-filters","linearRGB");const o=document.createElementNS(e,"feColorMatrix");return o.setAttribute("type","matrix"),o.setAttribute("values",q$[t].join(" ")),n.appendChild(o),n}function noe(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Sv(t){return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function ooe(t,e){const[n,o,r]=tt(t).rgb().map(u=>noe(u/255)),i=q$[e],s=Sv(i[0]*n+i[1]*o+i[2]*r),a=Sv(i[5]*n+i[6]*o+i[7]*r),l=Sv(i[10]*n+i[11]*o+i[12]*r),c=u=>Math.min(255,Math.max(0,Math.round(u*255)));return tt(c(s),c(a),c(l)).hex()}const roe=10;function ioe(t){if(t.length<2)return[];const e=["protanopia","deuteranopia","tritanopia"],n=[];for(const o of e){const r=t.map(s=>ooe(s,o)),i=[];for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){const l=tt.deltaE(r[s],r[a]);l<roe&&i.push({a:t[s],b:t[a],deltaE:l})}i.length>0&&n.push({type:o,label:eoe[o],pairs:i})}return n}function soe(t){const e={properties:[],data:null,colorizes:[],highlights:[],areaFills:[],annotations:[],annotationVisibility:[],series:[],scenes:[],transforms:[]};for(const n of t)switch(n.type){case"property":e.properties.push(n);break;case"data":if(e.data!==null)throw new SyntaxError("duplicate data block");e.data=n;break;case"colorize":e.colorizes.push(n);break;case"highlight":e.highlights.push(n);break;case"areafill":e.areaFills.push(n);break;case"annotation":e.annotations.push(n);break;case"annotation-visibility":e.annotationVisibility.push(n);break;case"series":e.series.push(n);break;case"scene":e.scenes.push(n);break;case"transform":e.transforms.push(n);break}return e}function aoe(t){const e={properties:[],data:null,colorizes:[],highlights:[],areaFills:[],annotations:[],annotationVisibility:[],series:[],transforms:[]};for(const n of t)switch(n.type){case"property":e.properties.push(n);break;case"data":if(e.data!==null)throw new SyntaxError("duplicate data block");e.data=n;break;case"colorize":e.colorizes.push(n);break;case"highlight":e.highlights.push(n);break;case"areafill":e.areaFills.push(n);break;case"annotation":e.annotations.push(n);break;case"annotation-visibility":e.annotationVisibility.push(n);break;case"series":e.series.push(n);break;case"transform":e.transforms.push(n);break}return e}function loe(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Tl(t,e,n,o){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,Tl.prototype),r.expected=e,r.found=n,r.location=o,r.name="SyntaxError",r}loe(Tl,Error);function Av(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Tl.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,o;for(o=0;o<t.length;o++)if(t[o].source===this.location.source){n=t[o].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,i=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,s=this.location.source+":"+i.line+":"+i.column;if(n){var a=this.location.end,l=Av("",i.line.toString().length," "),c=n[r.line-1],u=r.line===a.line?a.column:c.length+1,d=u-r.column||1;e+=`
|
|
81
81
|
--> `+s+`
|
|
82
82
|
`+l+` |
|
|
83
83
|
`+i.line+" | "+c+`
|
|
84
84
|
`+l+" | "+Av("",r.column-1," ")+Av("",d,"^")}else e+=`
|
|
85
|
-
at `+s}return e};Tl.buildMessage=function(t,e){var n={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(d){return Array.isArray(d)?i(d[0])+"-"+i(d[1]):i(d)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function o(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+o(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+o(u)})}function i(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+o(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+o(u)})}function s(c){return n[c.type](c)}function a(c){var u=c.map(s),d,f;if(u.sort(),u.length>0){for(d=1,f=1;d<u.length;d++)u[d-1]!==u[d]&&(u[f]=u[d],f++);u.length=f}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+a(t)+" but "+l(e)+" found."};function
|
|
85
|
+
at `+s}return e};Tl.buildMessage=function(t,e){var n={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(d){return Array.isArray(d)?i(d[0])+"-"+i(d[1]):i(d)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function o(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+o(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+o(u)})}function i(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+o(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+o(u)})}function s(c){return n[c.type](c)}function a(c){var u=c.map(s),d,f;if(u.sort(),u.length>0){for(d=1,f=1;d<u.length;d++)u[d-1]!==u[d]&&(u[f]=u[d],f++);u.length=f}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+a(t)+" but "+l(e)+" found."};function coe(t,e){e=e!==void 0?e:{};var n={},o=e.grammarSource,r={Chart:xx},i=xx,s="chart",a="{",l="}",c="data",u="=",d=",",f=" ",h="colorize",g="highlight",b="areafill",m="annotation",v="range",y="note",x="series",_="scene",k="step",E="transform",B="hide_annotation",S="hide_range",L="hide_note",D="show_annotation",I="show_range",C="show_note",T="%",P="-",$=".",F='"',V="\\",U="n",K="r",se="t",he="u",ce="//",be="/*",oe="*/",de=/^[^\t\n\r{}=]/,we=/^[a-zA-Z_#]/,ee=/^[a-zA-Z0-9_#\-]/,ge=/^[0-9]/,Q=/^[eE]/,re=/^[+\-]/,ve=/^[^"\\]/,N=/^[0-9a-fA-F]/,G=/^[^\n]/,Y=/^[ \t\n\r]/,ue=It("chart",!1),ae=It("{",!1),q=It("}",!1),ne=It("data",!1),j=It("=",!1),X=It(",",!1),Z=It(" ",!1),fe=Di([" ",`
|
|
86
86
|
`,"\r","{","}","="],!0,!1),pe=It("colorize",!1),me=It("highlight",!1),Se=It("areafill",!1),ke=It("annotation",!1),Te=It("range",!1),Fe=It("note",!1),rt=It("series",!1),ut=It("scene",!1),$t=It("step",!1),Bt=It("transform",!1),Jt=It("hide_annotation",!1),fn=It("hide_range",!1),Lt=It("hide_note",!1),Mt=It("show_annotation",!1),Rn=It("show_range",!1),Un=It("show_note",!1),Gn=It("%",!1),ur=Wf("identifier"),Ae=Di([["a","z"],["A","Z"],"_","#"],!1,!1),je=Di([["a","z"],["A","Z"],["0","9"],"_","#","-"],!1,!1),Xe=It("-",!1),Ue=It(".",!1),vt=Di([["0","9"]],!1,!1),gn=Di(["e","E"],!1,!1),dr=Di(["+","-"],!1,!1),Jn=Wf("string"),kn=It('"',!1),fr=It("\\",!1),hs=Di(['"',"\\"],!0,!1),sa=It("n",!1),Pu=It("r",!1),qe=It("t",!1),st=It("u",!1),Tt=Di([["0","9"],["a","f"],["A","F"]],!1,!1),Ft=YB(),qn=It("//",!1),Yn=Di([`
|
|
87
87
|
`],!0,!1),Qr=It("/*",!1),aa=It("*/",!1),ic=Wf("whitespace"),Jr=Di([" "," ",`
|
|
88
|
-
`,"\r"],!1,!1),Ag=Wf("optional whitespace"),sB=function(O,W){const _e=
|
|
89
|
-
`},HB=function(){return"\r"},WB=function(){return" "},UB=function(O){return String.fromCharCode(parseInt(O,16))},GB=function(O){qB("Unknown escape sequence \\"+O)},z=e.peg$currPos|0,yt=z,sc=[{line:1,column:1}],ei=z,Hf=e.peg$maxFailExpected||[],De=e.peg$silentFails|0,Du;if(e.startRule){if(!(e.startRule in r))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=r[e.startRule]}function qB(O,W){throw W=W!==void 0?W:Cg(yt,z),XB(O,W)}function It(O,W){return{type:"literal",text:O,ignoreCase:W}}function Di(O,W,_e){return{type:"class",parts:O,inverted:W,ignoreCase:_e}}function YB(){return{type:"any"}}function jB(){return{type:"end"}}function Wf(O){return{type:"other",description:O}}function yx(O){var W=sc[O],_e;if(W)return W;if(O>=sc.length)_e=sc.length-1;else for(_e=O;!sc[--_e];);for(W=sc[_e],W={line:W.line,column:W.column};_e<O;)t.charCodeAt(_e)===10?(W.line++,W.column=1):W.column++,_e++;return sc[O]=W,W}function Cg(O,W,_e){var xe=yx(O),Pe=yx(W),Ee={source:o,start:{offset:O,line:xe.line,column:xe.column},end:{offset:W,line:Pe.line,column:Pe.column}};return Ee}function Ne(O){z<ei||(z>ei&&(ei=z,Hf=[]),Hf.push(O))}function XB(O,W){return new Tl(O,null,null,W)}function KB(O,W,_e){return new Tl(Tl.buildMessage(O,W),O,W,_e)}function xx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,ct(),t.substr(z,5)===s?(W=s,z+=5):(W=n,De===0&&Ne(ue)),W!==n)if(_e=uo(),_e!==n)if(xe=Gf(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=wx();We!==n;)Ee.push(We),We=wx();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(ct(),yt=O,O=sB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function wx(){var O,W;return O=z,ct(),W=_x(),W===n&&(W=Ax(),W===n&&(W=Cx(),W===n&&(W=$x(),W===n&&(W=Mx(),W===n&&(W=Ox(),W===n&&(W=Tx(),W===n&&(W=Px(),W===n&&(W=Dx(),W===n&&(W=Ex(),W===n&&(W=Nx(),W===n&&(W=Ix(),W===n&&(W=Rx(),W===n&&(W=Bx(),W===n&&(W=QB(),W===n&&(W=Lx(),W===n&&(W=Uf())))))))))))))))),W!==n?(ct(),yt=O,O=aB(W)):(z=O,O=n),O}function _x(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,4)===c?(W=c,z+=4):(W=n,De===0&&Ne(ne)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=Sx(),Pe===n&&(Pe=kx());Pe!==n;)xe.push(Pe),Pe=Sx(),Pe===n&&(Pe=kx());Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=lB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function kx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,ct(),W=Vx(),W!==n)if(ct(),t.charCodeAt(z)===61?(_e=u,z++):(_e=n,De===0&&Ne(j)),_e!==n)if(ct(),xe=Eu(),xe!==n){if(Pe=[],Ee=z,t.charCodeAt(z)===44?(We=d,z++):(We=n,De===0&&Ne(X)),We!==n?(ct(),nt=Eu(),nt!==n?(yt=Ee,Ee=bx(W,xe,nt)):(z=Ee,Ee=n)):(z=Ee,Ee=n),Ee!==n)for(;Ee!==n;)Pe.push(Ee),Ee=z,t.charCodeAt(z)===44?(We=d,z++):(We=n,De===0&&Ne(X)),We!==n?(ct(),nt=Eu(),nt!==n?(yt=Ee,Ee=bx(W,xe,nt)):(z=Ee,Ee=n)):(z=Ee,Ee=n);else Pe=n;Pe!==n?(Ee=ct(),yt=O,O=cB(W,xe,Pe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;return O===n&&(O=z,ct(),W=Uf(),W!==n?(ct(),yt=O,O=uB(W)):(z=O,O=n)),O}function Sx(){var O,W,_e,xe;return O=z,ct(),W=ZB(),W!==n?(t.charCodeAt(z)===9?(_e=f,z++):(_e=n,De===0&&Ne(Z)),_e!==n?(ct(),xe=Eu(),xe!==n?(ct(),yt=O,O=dB(W,xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function ZB(){var O,W,_e,xe;if(O=z,W=z,_e=[],xe=t.charAt(z),de.test(xe)?z++:(xe=n,De===0&&Ne(fe)),xe!==n)for(;xe!==n;)_e.push(xe),xe=t.charAt(z),de.test(xe)?z++:(xe=n,De===0&&Ne(fe));else _e=n;return _e!==n?W=t.substring(W,z):W=_e,W!==n&&(yt=O,W=fB(W)),O=W,O}function Ax(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,8)===h?(W=h,z+=8):(W=n,De===0&&Ne(pe)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=hB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Cx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,9)===g?(W=g,z+=9):(W=n,De===0&&Ne(me)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=pB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O===n&&(O=z,t.substr(z,9)===g?(W=g,z+=9):(W=n,De===0&&Ne(me)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=mB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n)),O}function $x(){var O,W,_e,xe,Pe,Ee,We,nt,Xo,Sn;if(O=z,t.substr(z,8)===b?(W=b,z+=8):(W=n,De===0&&Ne(Se)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(Pe=uo(),Pe!==n)if(Ee=co(),Ee!==n)if(ct(),t.charCodeAt(z)===123?(We=a,z++):(We=n,De===0&&Ne(ae)),We!==n){for(ct(),nt=[],Xo=lo();Xo!==n;)nt.push(Xo),Xo=lo();Xo=ct(),t.charCodeAt(z)===125?(Sn=l,z++):(Sn=n,De===0&&Ne(q)),Sn!==n?(yt=O,O=gB(xe,Ee,nt)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Tx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,10)===m?(W=m,z+=10):(W=n,De===0&&Ne(ke)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=vB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Mx(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,5)===v?(W=v,z+=5):(W=n,De===0&&Ne(Te)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=lo();Pe!==n;)xe.push(Pe),Pe=lo();Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=bB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function Ox(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,4)===y?(W=y,z+=4):(W=n,De===0&&Ne(Fe)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=lo();Pe!==n;)xe.push(Pe),Pe=lo();Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=yB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function Bx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,6)===x?(W=x,z+=6):(W=n,De===0&&Ne(rt)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=xB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function QB(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,5)===_?(W=_,z+=5):(W=n,De===0&&Ne(ut)),W===n&&(t.substr(z,4)===k?(W=k,z+=4):(W=n,De===0&&Ne($t))),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe===n&&(xe=null),ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=Fx();We!==n;)Ee.push(We),We=Fx();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=wB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Lx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,9)===E?(W=E,z+=9):(W=n,De===0&&Ne(Bt)),W!==n)if(_e=uo(),_e!==n)if(xe=Gf(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=_B(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Px(){var O,W,_e,xe;return O=z,t.substr(z,15)===B?(W=B,z+=15):(W=n,De===0&&Ne(Jt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=kB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Dx(){var O,W,_e,xe;return O=z,t.substr(z,10)===S?(W=S,z+=10):(W=n,De===0&&Ne(fn)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=SB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Ex(){var O,W,_e,xe;return O=z,t.substr(z,9)===L?(W=L,z+=9):(W=n,De===0&&Ne(Lt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=AB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Nx(){var O,W,_e,xe;return O=z,t.substr(z,15)===D?(W=D,z+=15):(W=n,De===0&&Ne(Mt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=CB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Ix(){var O,W,_e,xe;return O=z,t.substr(z,10)===I?(W=I,z+=10):(W=n,De===0&&Ne(Rn)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=$B(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Rx(){var O,W,_e,xe;return O=z,t.substr(z,9)===C?(W=C,z+=9):(W=n,De===0&&Ne(Un)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=TB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Fx(){var O,W;return O=z,ct(),W=_x(),W===n&&(W=Ax(),W===n&&(W=Cx(),W===n&&(W=$x(),W===n&&(W=Mx(),W===n&&(W=Ox(),W===n&&(W=Tx(),W===n&&(W=Px(),W===n&&(W=Dx(),W===n&&(W=Ex(),W===n&&(W=Nx(),W===n&&(W=Ix(),W===n&&(W=Rx(),W===n&&(W=Bx(),W===n&&(W=Lx(),W===n&&(W=Uf()))))))))))))))),W!==n?(ct(),yt=O,O=MB(W)):(z=O,O=n),O}function lo(){var O,W;return O=z,ct(),W=Uf(),W!==n?(ct(),yt=O,O=OB(W)):(z=O,O=n),O}function Uf(){var O,W,_e,xe;return O=z,W=Vx(),W!==n?(ct(),t.charCodeAt(z)===61?(_e=u,z++):(_e=n,De===0&&Ne(j)),_e!==n?(ct(),xe=Eu(),xe!==n?(yt=O,O=BB(W,xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Vx(){var O;return O=co(),O===n&&(O=Gf()),O}function Eu(){var O,W,_e;return O=z,W=zx(),W!==n?(t.charCodeAt(z)===37?(_e=T,z++):(_e=n,De===0&&Ne(Gn)),_e!==n?(yt=O,O=LB(W)):(z=O,O=n)):(z=O,O=n),O===n&&(O=z,W=zx(),W!==n&&(yt=O,W=PB(W)),O=W,O===n&&(O=z,W=co(),W!==n&&(yt=O,W=DB(W)),O=W,O===n&&(O=z,W=Gf(),W!==n&&(yt=O,W=EB(W)),O=W))),O}function Gf(){var O,W,_e,xe,Pe;if(De++,O=z,W=z,_e=t.charAt(z),we.test(_e)?z++:(_e=n,De===0&&Ne(Ae)),_e!==n){for(xe=[],Pe=t.charAt(z),ee.test(Pe)?z++:(Pe=n,De===0&&Ne(je));Pe!==n;)xe.push(Pe),Pe=t.charAt(z),ee.test(Pe)?z++:(Pe=n,De===0&&Ne(je));_e=[_e,xe],W=_e}else z=W,W=n;return W!==n?O=t.substring(O,z):O=W,De--,O===n&&(W=n,De===0&&Ne(ur)),O}function zx(){var O,W,_e,xe,Pe,Ee,We,nt,Xo,Sn;if(O=z,W=z,_e=z,t.charCodeAt(z)===45?(xe=P,z++):(xe=n,De===0&&Ne(Xe)),xe===n&&(xe=null),Pe=z,t.charCodeAt(z)===46?(Ee=$,z++):(Ee=n,De===0&&Ne(Ue)),Ee!==n){if(We=[],nt=t.charAt(z),ge.test(nt)?z++:(nt=n,De===0&&Ne(vt)),nt!==n)for(;nt!==n;)We.push(nt),nt=t.charAt(z),ge.test(nt)?z++:(nt=n,De===0&&Ne(vt));else We=n;We!==n?(Ee=[Ee,We],Pe=Ee):(z=Pe,Pe=n)}else z=Pe,Pe=n;if(Pe===n){if(Pe=z,Ee=[],We=t.charAt(z),ge.test(We)?z++:(We=n,De===0&&Ne(vt)),We!==n)for(;We!==n;)Ee.push(We),We=t.charAt(z),ge.test(We)?z++:(We=n,De===0&&Ne(vt));else Ee=n;if(Ee!==n){if(We=z,t.charCodeAt(z)===46?(nt=$,z++):(nt=n,De===0&&Ne(Ue)),nt!==n){for(Xo=[],Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));Sn!==n;)Xo.push(Sn),Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));nt=[nt,Xo],We=nt}else z=We,We=n;We===n&&(We=null),Ee=[Ee,We],Pe=Ee}else z=Pe,Pe=n}if(Pe!==n){if(Ee=z,We=t.charAt(z),Q.test(We)?z++:(We=n,De===0&&Ne(gn)),We!==n){if(nt=t.charAt(z),re.test(nt)?z++:(nt=n,De===0&&Ne(dr)),nt===n&&(nt=null),Xo=[],Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt)),Sn!==n)for(;Sn!==n;)Xo.push(Sn),Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));else Xo=n;Xo!==n?(We=[We,nt,Xo],Ee=We):(z=Ee,Ee=n)}else z=Ee,Ee=n;Ee===n&&(Ee=null),xe=[xe,Pe,Ee],_e=xe}else z=_e,_e=n;return _e!==n?W=t.substring(W,z):W=_e,W!==n&&(yt=O,W=NB(W)),O=W,O}function co(){var O,W,_e,xe;if(De++,O=z,t.charCodeAt(z)===34?(W=F,z++):(W=n,De===0&&Ne(kn)),W!==n){for(_e=[],xe=Hx();xe!==n;)_e.push(xe),xe=Hx();t.charCodeAt(z)===34?(xe=F,z++):(xe=n,De===0&&Ne(kn)),xe!==n?(yt=O,O=IB(_e)):(z=O,O=n)}else z=O,O=n;return De--,O===n&&(W=n,De===0&&Ne(Jn)),O}function Hx(){var O,W,_e;return O=z,t.charCodeAt(z)===92?(W=V,z++):(W=n,De===0&&Ne(fr)),W!==n?(_e=JB(),_e!==n?(yt=O,O=RB(_e)):(z=O,O=n)):(z=O,O=n),O===n&&(O=t.charAt(z),ve.test(O)?z++:(O=n,De===0&&Ne(hs))),O}function JB(){var O,W,_e,xe,Pe,Ee,We,nt;return O=z,t.charCodeAt(z)===34?(W=F,z++):(W=n,De===0&&Ne(kn)),W!==n&&(yt=O,W=FB()),O=W,O===n&&(O=z,t.charCodeAt(z)===92?(W=V,z++):(W=n,De===0&&Ne(fr)),W!==n&&(yt=O,W=VB()),O=W,O===n&&(O=z,t.charCodeAt(z)===110?(W=U,z++):(W=n,De===0&&Ne(sa)),W!==n&&(yt=O,W=zB()),O=W,O===n&&(O=z,t.charCodeAt(z)===114?(W=K,z++):(W=n,De===0&&Ne(Pu)),W!==n&&(yt=O,W=HB()),O=W,O===n&&(O=z,t.charCodeAt(z)===116?(W=se,z++):(W=n,De===0&&Ne(qe)),W!==n&&(yt=O,W=WB()),O=W,O===n&&(O=z,t.charCodeAt(z)===117?(W=he,z++):(W=n,De===0&&Ne(st)),W!==n?(_e=z,xe=z,Pe=t.charAt(z),N.test(Pe)?z++:(Pe=n,De===0&&Ne(Tt)),Pe!==n?(Ee=t.charAt(z),N.test(Ee)?z++:(Ee=n,De===0&&Ne(Tt)),Ee!==n?(We=t.charAt(z),N.test(We)?z++:(We=n,De===0&&Ne(Tt)),We!==n?(nt=t.charAt(z),N.test(nt)?z++:(nt=n,De===0&&Ne(Tt)),nt!==n?(Pe=[Pe,Ee,We,nt],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n)):(z=xe,xe=n)):(z=xe,xe=n),xe!==n?_e=t.substring(_e,z):_e=xe,_e!==n?(yt=O,O=UB(_e)):(z=O,O=n)):(z=O,O=n),O===n&&(O=z,t.length>z?(W=t.charAt(z),z++):(W=n,De===0&&Ne(Ft)),W!==n&&(yt=O,W=GB(W)),O=W)))))),O}function qf(){var O;return O=e9(),O===n&&(O=t9()),O}function e9(){var O,W,_e,xe;if(O=z,t.substr(z,2)===ce?(W=ce,z+=2):(W=n,De===0&&Ne(qn)),W!==n){for(_e=[],xe=t.charAt(z),G.test(xe)?z++:(xe=n,De===0&&Ne(Yn));xe!==n;)_e.push(xe),xe=t.charAt(z),G.test(xe)?z++:(xe=n,De===0&&Ne(Yn));W=[W,_e],O=W}else z=O,O=n;return O}function t9(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,2)===be?(W=be,z+=2):(W=n,De===0&&Ne(Qr)),W!==n){for(_e=[],xe=z,Pe=z,De++,t.substr(z,2)===oe?(Ee=oe,z+=2):(Ee=n,De===0&&Ne(aa)),De--,Ee===n?Pe=void 0:(z=Pe,Pe=n),Pe!==n?(t.length>z?(Ee=t.charAt(z),z++):(Ee=n,De===0&&Ne(Ft)),Ee!==n?(Pe=[Pe,Ee],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n);xe!==n;)_e.push(xe),xe=z,Pe=z,De++,t.substr(z,2)===oe?(Ee=oe,z+=2):(Ee=n,De===0&&Ne(aa)),De--,Ee===n?Pe=void 0:(z=Pe,Pe=n),Pe!==n?(t.length>z?(Ee=t.charAt(z),z++):(Ee=n,De===0&&Ne(Ft)),Ee!==n?(Pe=[Pe,Ee],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n);t.substr(z,2)===oe?(xe=oe,z+=2):(xe=n,De===0&&Ne(aa)),xe!==n?(W=[W,_e,xe],O=W):(z=O,O=n)}else z=O,O=n;return O}function uo(){var O,W;if(De++,O=[],W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf()),W!==n)for(;W!==n;)O.push(W),W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());else O=n;return De--,O===n&&(W=n,De===0&&Ne(ic)),O}function ct(){var O,W;for(De++,O=[],W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());W!==n;)O.push(W),W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());return De--,W=n,De===0&&Ne(Ag),O}if(Du=i(),e.peg$library)return{peg$result:Du,peg$currPos:z,peg$FAILED:n,peg$maxFailExpected:Hf,peg$maxFailPos:ei};if(Du!==n&&z===t.length)return Du;throw Du!==n&&z<t.length&&Ne(jB()),KB(Hf,ei<t.length?t.charAt(ei):null,ei<t.length?Cg(ei,ei+1):Cg(ei,ei))}function ag(t){try{return aoe(t)}catch(e){if(e instanceof Error&&"location"in e){const n=e.location;throw new SyntaxError(`${e.message} at ${n.start.line}:${n.start.column}`)}throw e}}function Vr(t){return new Map(t.map(e=>[e.key,e.value]))}function lg(t,e){const n=Vr(e),o=au(t),r=new Set(o.map(s=>s.key)),i={};for(const s of o){const a=n.get(s.key);a!==void 0&&r.has(s.key)&&(s.type===Qe.Colors?i[s.key]=String(a).split(",").map(l=>l.trim()).filter(Boolean):s.type===Qe.Boolean?i[s.key]=a==="true"||a===!0:i[s.key]=String(a))}return i}function loe(t){return!(/^-?\d+(\.\d+)?$/.test(t)||/^-?\d+(\.\d+)?%$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t))}function u0(t){return t.entries.map(e=>{if(e.values&&e.values.length>1){if(e.key==="_series")return`_series = ${e.values.map(r=>`"${r}"`).join(",")}`;const o=e.values.join(",");return`"${e.key}" = ${o}`}const n=e.isPercentage?`${e.value}%`:String(e.value);return e.key==="_series"?`_series = "${n}"`:typeof e.value=="string"&&loe(n)?`"${e.key}" = "${n}"`:`"${e.key}" = ${n}`}).join(`
|
|
90
|
-
`)}function
|
|
88
|
+
`,"\r"],!1,!1),Ag=Wf("optional whitespace"),sB=function(O,W){const _e=soe(W);return{type:"chart",chartType:O,properties:_e.properties,data:_e.data,colorizes:_e.colorizes,highlights:_e.highlights,areaFills:_e.areaFills,annotations:_e.annotations,annotationVisibility:_e.annotationVisibility,series:_e.series,scenes:_e.scenes,transforms:_e.transforms}},aB=function(O){return O},lB=function(O){return{type:"data",entries:O}},bx=function(O,W,_e){return _e},cB=function(O,W,_e){const xe=[W,..._e];return{type:"property",key:O,value:xe[0].value,isPercentage:!1,values:xe.map(Pe=>Pe.value)}},uB=function(O){return O},dB=function(O,W){return{type:"property",key:O,value:W.value,isPercentage:W.isPercentage}},fB=function(O){return O.trim()},hB=function(O,W){return{type:"colorize",target:O,properties:W}},pB=function(O,W){return{type:"colorize",target:O,properties:W,fromHighlight:!0}},mB=function(O){return{type:"highlight",target:O,properties:[]}},gB=function(O,W,_e){return{type:"areafill",from:O,to:W,properties:_e}},vB=function(O,W){return{type:"annotation",kind:"point",target:O,properties:W}},bB=function(O){return{type:"annotation",kind:"range",properties:O}},yB=function(O){return{type:"annotation",kind:"free",properties:O}},xB=function(O,W){return{type:"series",name:O,properties:W}},wB=function(O,W){const _e=aoe(W);return{type:"scene",name:O??null,properties:_e.properties,data:_e.data,colorizes:_e.colorizes,highlights:_e.highlights,areaFills:_e.areaFills,annotations:_e.annotations,annotationVisibility:_e.annotationVisibility,series:_e.series,transforms:_e.transforms}},_B=function(O,W){return{type:"transform",transformType:O,properties:W}},kB=function(O){return{type:"annotation-visibility",action:"hide",kind:"point",id:O}},SB=function(O){return{type:"annotation-visibility",action:"hide",kind:"range",id:O}},AB=function(O){return{type:"annotation-visibility",action:"hide",kind:"free",id:O}},CB=function(O){return{type:"annotation-visibility",action:"show",kind:"point",id:O}},$B=function(O){return{type:"annotation-visibility",action:"show",kind:"range",id:O}},TB=function(O){return{type:"annotation-visibility",action:"show",kind:"free",id:O}},MB=function(O){return O},OB=function(O){return O},BB=function(O,W){return{type:"property",key:O,value:W.value,isPercentage:W.isPercentage}},LB=function(O){return{value:O,isPercentage:!0}},PB=function(O){return{value:O,isPercentage:!1}},DB=function(O){return{value:O,isPercentage:!1}},EB=function(O){return{value:O,isPercentage:!1}},NB=function(O){return parseFloat(O)},IB=function(O){return O.join("")},RB=function(O){return O},FB=function(){return'"'},VB=function(){return"\\"},zB=function(){return`
|
|
89
|
+
`},HB=function(){return"\r"},WB=function(){return" "},UB=function(O){return String.fromCharCode(parseInt(O,16))},GB=function(O){qB("Unknown escape sequence \\"+O)},z=e.peg$currPos|0,yt=z,sc=[{line:1,column:1}],ei=z,Hf=e.peg$maxFailExpected||[],De=e.peg$silentFails|0,Du;if(e.startRule){if(!(e.startRule in r))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=r[e.startRule]}function qB(O,W){throw W=W!==void 0?W:Cg(yt,z),XB(O,W)}function It(O,W){return{type:"literal",text:O,ignoreCase:W}}function Di(O,W,_e){return{type:"class",parts:O,inverted:W,ignoreCase:_e}}function YB(){return{type:"any"}}function jB(){return{type:"end"}}function Wf(O){return{type:"other",description:O}}function yx(O){var W=sc[O],_e;if(W)return W;if(O>=sc.length)_e=sc.length-1;else for(_e=O;!sc[--_e];);for(W=sc[_e],W={line:W.line,column:W.column};_e<O;)t.charCodeAt(_e)===10?(W.line++,W.column=1):W.column++,_e++;return sc[O]=W,W}function Cg(O,W,_e){var xe=yx(O),Pe=yx(W),Ee={source:o,start:{offset:O,line:xe.line,column:xe.column},end:{offset:W,line:Pe.line,column:Pe.column}};return Ee}function Ne(O){z<ei||(z>ei&&(ei=z,Hf=[]),Hf.push(O))}function XB(O,W){return new Tl(O,null,null,W)}function KB(O,W,_e){return new Tl(Tl.buildMessage(O,W),O,W,_e)}function xx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,ct(),t.substr(z,5)===s?(W=s,z+=5):(W=n,De===0&&Ne(ue)),W!==n)if(_e=uo(),_e!==n)if(xe=Gf(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=wx();We!==n;)Ee.push(We),We=wx();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(ct(),yt=O,O=sB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function wx(){var O,W;return O=z,ct(),W=_x(),W===n&&(W=Ax(),W===n&&(W=Cx(),W===n&&(W=$x(),W===n&&(W=Mx(),W===n&&(W=Ox(),W===n&&(W=Tx(),W===n&&(W=Px(),W===n&&(W=Dx(),W===n&&(W=Ex(),W===n&&(W=Nx(),W===n&&(W=Ix(),W===n&&(W=Rx(),W===n&&(W=Bx(),W===n&&(W=QB(),W===n&&(W=Lx(),W===n&&(W=Uf())))))))))))))))),W!==n?(ct(),yt=O,O=aB(W)):(z=O,O=n),O}function _x(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,4)===c?(W=c,z+=4):(W=n,De===0&&Ne(ne)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=Sx(),Pe===n&&(Pe=kx());Pe!==n;)xe.push(Pe),Pe=Sx(),Pe===n&&(Pe=kx());Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=lB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function kx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,ct(),W=Vx(),W!==n)if(ct(),t.charCodeAt(z)===61?(_e=u,z++):(_e=n,De===0&&Ne(j)),_e!==n)if(ct(),xe=Eu(),xe!==n){if(Pe=[],Ee=z,t.charCodeAt(z)===44?(We=d,z++):(We=n,De===0&&Ne(X)),We!==n?(ct(),nt=Eu(),nt!==n?(yt=Ee,Ee=bx(W,xe,nt)):(z=Ee,Ee=n)):(z=Ee,Ee=n),Ee!==n)for(;Ee!==n;)Pe.push(Ee),Ee=z,t.charCodeAt(z)===44?(We=d,z++):(We=n,De===0&&Ne(X)),We!==n?(ct(),nt=Eu(),nt!==n?(yt=Ee,Ee=bx(W,xe,nt)):(z=Ee,Ee=n)):(z=Ee,Ee=n);else Pe=n;Pe!==n?(Ee=ct(),yt=O,O=cB(W,xe,Pe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;return O===n&&(O=z,ct(),W=Uf(),W!==n?(ct(),yt=O,O=uB(W)):(z=O,O=n)),O}function Sx(){var O,W,_e,xe;return O=z,ct(),W=ZB(),W!==n?(t.charCodeAt(z)===9?(_e=f,z++):(_e=n,De===0&&Ne(Z)),_e!==n?(ct(),xe=Eu(),xe!==n?(ct(),yt=O,O=dB(W,xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function ZB(){var O,W,_e,xe;if(O=z,W=z,_e=[],xe=t.charAt(z),de.test(xe)?z++:(xe=n,De===0&&Ne(fe)),xe!==n)for(;xe!==n;)_e.push(xe),xe=t.charAt(z),de.test(xe)?z++:(xe=n,De===0&&Ne(fe));else _e=n;return _e!==n?W=t.substring(W,z):W=_e,W!==n&&(yt=O,W=fB(W)),O=W,O}function Ax(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,8)===h?(W=h,z+=8):(W=n,De===0&&Ne(pe)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=hB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Cx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,9)===g?(W=g,z+=9):(W=n,De===0&&Ne(me)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=pB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O===n&&(O=z,t.substr(z,9)===g?(W=g,z+=9):(W=n,De===0&&Ne(me)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=mB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n)),O}function $x(){var O,W,_e,xe,Pe,Ee,We,nt,Xo,Sn;if(O=z,t.substr(z,8)===b?(W=b,z+=8):(W=n,De===0&&Ne(Se)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(Pe=uo(),Pe!==n)if(Ee=co(),Ee!==n)if(ct(),t.charCodeAt(z)===123?(We=a,z++):(We=n,De===0&&Ne(ae)),We!==n){for(ct(),nt=[],Xo=lo();Xo!==n;)nt.push(Xo),Xo=lo();Xo=ct(),t.charCodeAt(z)===125?(Sn=l,z++):(Sn=n,De===0&&Ne(q)),Sn!==n?(yt=O,O=gB(xe,Ee,nt)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Tx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,10)===m?(W=m,z+=10):(W=n,De===0&&Ne(ke)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=vB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Mx(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,5)===v?(W=v,z+=5):(W=n,De===0&&Ne(Te)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=lo();Pe!==n;)xe.push(Pe),Pe=lo();Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=bB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function Ox(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,4)===y?(W=y,z+=4):(W=n,De===0&&Ne(Fe)),W!==n)if(ct(),t.charCodeAt(z)===123?(_e=a,z++):(_e=n,De===0&&Ne(ae)),_e!==n){for(ct(),xe=[],Pe=lo();Pe!==n;)xe.push(Pe),Pe=lo();Pe=ct(),t.charCodeAt(z)===125?(Ee=l,z++):(Ee=n,De===0&&Ne(q)),Ee!==n?(yt=O,O=yB(xe)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;return O}function Bx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,6)===x?(W=x,z+=6):(W=n,De===0&&Ne(rt)),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=xB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function QB(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,5)===_?(W=_,z+=5):(W=n,De===0&&Ne(ut)),W===n&&(t.substr(z,4)===k?(W=k,z+=4):(W=n,De===0&&Ne($t))),W!==n)if(_e=uo(),_e!==n)if(xe=co(),xe===n&&(xe=null),ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=Fx();We!==n;)Ee.push(We),We=Fx();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=wB(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Lx(){var O,W,_e,xe,Pe,Ee,We,nt;if(O=z,t.substr(z,9)===E?(W=E,z+=9):(W=n,De===0&&Ne(Bt)),W!==n)if(_e=uo(),_e!==n)if(xe=Gf(),xe!==n)if(ct(),t.charCodeAt(z)===123?(Pe=a,z++):(Pe=n,De===0&&Ne(ae)),Pe!==n){for(ct(),Ee=[],We=lo();We!==n;)Ee.push(We),We=lo();We=ct(),t.charCodeAt(z)===125?(nt=l,z++):(nt=n,De===0&&Ne(q)),nt!==n?(yt=O,O=_B(xe,Ee)):(z=O,O=n)}else z=O,O=n;else z=O,O=n;else z=O,O=n;else z=O,O=n;return O}function Px(){var O,W,_e,xe;return O=z,t.substr(z,15)===B?(W=B,z+=15):(W=n,De===0&&Ne(Jt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=kB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Dx(){var O,W,_e,xe;return O=z,t.substr(z,10)===S?(W=S,z+=10):(W=n,De===0&&Ne(fn)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=SB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Ex(){var O,W,_e,xe;return O=z,t.substr(z,9)===L?(W=L,z+=9):(W=n,De===0&&Ne(Lt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=AB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Nx(){var O,W,_e,xe;return O=z,t.substr(z,15)===D?(W=D,z+=15):(W=n,De===0&&Ne(Mt)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=CB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Ix(){var O,W,_e,xe;return O=z,t.substr(z,10)===I?(W=I,z+=10):(W=n,De===0&&Ne(Rn)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=$B(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Rx(){var O,W,_e,xe;return O=z,t.substr(z,9)===C?(W=C,z+=9):(W=n,De===0&&Ne(Un)),W!==n?(_e=uo(),_e!==n?(xe=co(),xe!==n?(yt=O,O=TB(xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Fx(){var O,W;return O=z,ct(),W=_x(),W===n&&(W=Ax(),W===n&&(W=Cx(),W===n&&(W=$x(),W===n&&(W=Mx(),W===n&&(W=Ox(),W===n&&(W=Tx(),W===n&&(W=Px(),W===n&&(W=Dx(),W===n&&(W=Ex(),W===n&&(W=Nx(),W===n&&(W=Ix(),W===n&&(W=Rx(),W===n&&(W=Bx(),W===n&&(W=Lx(),W===n&&(W=Uf()))))))))))))))),W!==n?(ct(),yt=O,O=MB(W)):(z=O,O=n),O}function lo(){var O,W;return O=z,ct(),W=Uf(),W!==n?(ct(),yt=O,O=OB(W)):(z=O,O=n),O}function Uf(){var O,W,_e,xe;return O=z,W=Vx(),W!==n?(ct(),t.charCodeAt(z)===61?(_e=u,z++):(_e=n,De===0&&Ne(j)),_e!==n?(ct(),xe=Eu(),xe!==n?(yt=O,O=BB(W,xe)):(z=O,O=n)):(z=O,O=n)):(z=O,O=n),O}function Vx(){var O;return O=co(),O===n&&(O=Gf()),O}function Eu(){var O,W,_e;return O=z,W=zx(),W!==n?(t.charCodeAt(z)===37?(_e=T,z++):(_e=n,De===0&&Ne(Gn)),_e!==n?(yt=O,O=LB(W)):(z=O,O=n)):(z=O,O=n),O===n&&(O=z,W=zx(),W!==n&&(yt=O,W=PB(W)),O=W,O===n&&(O=z,W=co(),W!==n&&(yt=O,W=DB(W)),O=W,O===n&&(O=z,W=Gf(),W!==n&&(yt=O,W=EB(W)),O=W))),O}function Gf(){var O,W,_e,xe,Pe;if(De++,O=z,W=z,_e=t.charAt(z),we.test(_e)?z++:(_e=n,De===0&&Ne(Ae)),_e!==n){for(xe=[],Pe=t.charAt(z),ee.test(Pe)?z++:(Pe=n,De===0&&Ne(je));Pe!==n;)xe.push(Pe),Pe=t.charAt(z),ee.test(Pe)?z++:(Pe=n,De===0&&Ne(je));_e=[_e,xe],W=_e}else z=W,W=n;return W!==n?O=t.substring(O,z):O=W,De--,O===n&&(W=n,De===0&&Ne(ur)),O}function zx(){var O,W,_e,xe,Pe,Ee,We,nt,Xo,Sn;if(O=z,W=z,_e=z,t.charCodeAt(z)===45?(xe=P,z++):(xe=n,De===0&&Ne(Xe)),xe===n&&(xe=null),Pe=z,t.charCodeAt(z)===46?(Ee=$,z++):(Ee=n,De===0&&Ne(Ue)),Ee!==n){if(We=[],nt=t.charAt(z),ge.test(nt)?z++:(nt=n,De===0&&Ne(vt)),nt!==n)for(;nt!==n;)We.push(nt),nt=t.charAt(z),ge.test(nt)?z++:(nt=n,De===0&&Ne(vt));else We=n;We!==n?(Ee=[Ee,We],Pe=Ee):(z=Pe,Pe=n)}else z=Pe,Pe=n;if(Pe===n){if(Pe=z,Ee=[],We=t.charAt(z),ge.test(We)?z++:(We=n,De===0&&Ne(vt)),We!==n)for(;We!==n;)Ee.push(We),We=t.charAt(z),ge.test(We)?z++:(We=n,De===0&&Ne(vt));else Ee=n;if(Ee!==n){if(We=z,t.charCodeAt(z)===46?(nt=$,z++):(nt=n,De===0&&Ne(Ue)),nt!==n){for(Xo=[],Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));Sn!==n;)Xo.push(Sn),Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));nt=[nt,Xo],We=nt}else z=We,We=n;We===n&&(We=null),Ee=[Ee,We],Pe=Ee}else z=Pe,Pe=n}if(Pe!==n){if(Ee=z,We=t.charAt(z),Q.test(We)?z++:(We=n,De===0&&Ne(gn)),We!==n){if(nt=t.charAt(z),re.test(nt)?z++:(nt=n,De===0&&Ne(dr)),nt===n&&(nt=null),Xo=[],Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt)),Sn!==n)for(;Sn!==n;)Xo.push(Sn),Sn=t.charAt(z),ge.test(Sn)?z++:(Sn=n,De===0&&Ne(vt));else Xo=n;Xo!==n?(We=[We,nt,Xo],Ee=We):(z=Ee,Ee=n)}else z=Ee,Ee=n;Ee===n&&(Ee=null),xe=[xe,Pe,Ee],_e=xe}else z=_e,_e=n;return _e!==n?W=t.substring(W,z):W=_e,W!==n&&(yt=O,W=NB(W)),O=W,O}function co(){var O,W,_e,xe;if(De++,O=z,t.charCodeAt(z)===34?(W=F,z++):(W=n,De===0&&Ne(kn)),W!==n){for(_e=[],xe=Hx();xe!==n;)_e.push(xe),xe=Hx();t.charCodeAt(z)===34?(xe=F,z++):(xe=n,De===0&&Ne(kn)),xe!==n?(yt=O,O=IB(_e)):(z=O,O=n)}else z=O,O=n;return De--,O===n&&(W=n,De===0&&Ne(Jn)),O}function Hx(){var O,W,_e;return O=z,t.charCodeAt(z)===92?(W=V,z++):(W=n,De===0&&Ne(fr)),W!==n?(_e=JB(),_e!==n?(yt=O,O=RB(_e)):(z=O,O=n)):(z=O,O=n),O===n&&(O=t.charAt(z),ve.test(O)?z++:(O=n,De===0&&Ne(hs))),O}function JB(){var O,W,_e,xe,Pe,Ee,We,nt;return O=z,t.charCodeAt(z)===34?(W=F,z++):(W=n,De===0&&Ne(kn)),W!==n&&(yt=O,W=FB()),O=W,O===n&&(O=z,t.charCodeAt(z)===92?(W=V,z++):(W=n,De===0&&Ne(fr)),W!==n&&(yt=O,W=VB()),O=W,O===n&&(O=z,t.charCodeAt(z)===110?(W=U,z++):(W=n,De===0&&Ne(sa)),W!==n&&(yt=O,W=zB()),O=W,O===n&&(O=z,t.charCodeAt(z)===114?(W=K,z++):(W=n,De===0&&Ne(Pu)),W!==n&&(yt=O,W=HB()),O=W,O===n&&(O=z,t.charCodeAt(z)===116?(W=se,z++):(W=n,De===0&&Ne(qe)),W!==n&&(yt=O,W=WB()),O=W,O===n&&(O=z,t.charCodeAt(z)===117?(W=he,z++):(W=n,De===0&&Ne(st)),W!==n?(_e=z,xe=z,Pe=t.charAt(z),N.test(Pe)?z++:(Pe=n,De===0&&Ne(Tt)),Pe!==n?(Ee=t.charAt(z),N.test(Ee)?z++:(Ee=n,De===0&&Ne(Tt)),Ee!==n?(We=t.charAt(z),N.test(We)?z++:(We=n,De===0&&Ne(Tt)),We!==n?(nt=t.charAt(z),N.test(nt)?z++:(nt=n,De===0&&Ne(Tt)),nt!==n?(Pe=[Pe,Ee,We,nt],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n)):(z=xe,xe=n)):(z=xe,xe=n),xe!==n?_e=t.substring(_e,z):_e=xe,_e!==n?(yt=O,O=UB(_e)):(z=O,O=n)):(z=O,O=n),O===n&&(O=z,t.length>z?(W=t.charAt(z),z++):(W=n,De===0&&Ne(Ft)),W!==n&&(yt=O,W=GB(W)),O=W)))))),O}function qf(){var O;return O=e9(),O===n&&(O=t9()),O}function e9(){var O,W,_e,xe;if(O=z,t.substr(z,2)===ce?(W=ce,z+=2):(W=n,De===0&&Ne(qn)),W!==n){for(_e=[],xe=t.charAt(z),G.test(xe)?z++:(xe=n,De===0&&Ne(Yn));xe!==n;)_e.push(xe),xe=t.charAt(z),G.test(xe)?z++:(xe=n,De===0&&Ne(Yn));W=[W,_e],O=W}else z=O,O=n;return O}function t9(){var O,W,_e,xe,Pe,Ee;if(O=z,t.substr(z,2)===be?(W=be,z+=2):(W=n,De===0&&Ne(Qr)),W!==n){for(_e=[],xe=z,Pe=z,De++,t.substr(z,2)===oe?(Ee=oe,z+=2):(Ee=n,De===0&&Ne(aa)),De--,Ee===n?Pe=void 0:(z=Pe,Pe=n),Pe!==n?(t.length>z?(Ee=t.charAt(z),z++):(Ee=n,De===0&&Ne(Ft)),Ee!==n?(Pe=[Pe,Ee],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n);xe!==n;)_e.push(xe),xe=z,Pe=z,De++,t.substr(z,2)===oe?(Ee=oe,z+=2):(Ee=n,De===0&&Ne(aa)),De--,Ee===n?Pe=void 0:(z=Pe,Pe=n),Pe!==n?(t.length>z?(Ee=t.charAt(z),z++):(Ee=n,De===0&&Ne(Ft)),Ee!==n?(Pe=[Pe,Ee],xe=Pe):(z=xe,xe=n)):(z=xe,xe=n);t.substr(z,2)===oe?(xe=oe,z+=2):(xe=n,De===0&&Ne(aa)),xe!==n?(W=[W,_e,xe],O=W):(z=O,O=n)}else z=O,O=n;return O}function uo(){var O,W;if(De++,O=[],W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf()),W!==n)for(;W!==n;)O.push(W),W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());else O=n;return De--,O===n&&(W=n,De===0&&Ne(ic)),O}function ct(){var O,W;for(De++,O=[],W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());W!==n;)O.push(W),W=t.charAt(z),Y.test(W)?z++:(W=n,De===0&&Ne(Jr)),W===n&&(W=qf());return De--,W=n,De===0&&Ne(Ag),O}if(Du=i(),e.peg$library)return{peg$result:Du,peg$currPos:z,peg$FAILED:n,peg$maxFailExpected:Hf,peg$maxFailPos:ei};if(Du!==n&&z===t.length)return Du;throw Du!==n&&z<t.length&&Ne(jB()),KB(Hf,ei<t.length?t.charAt(ei):null,ei<t.length?Cg(ei,ei+1):Cg(ei,ei))}function ag(t){try{return coe(t)}catch(e){if(e instanceof Error&&"location"in e){const n=e.location;throw new SyntaxError(`${e.message} at ${n.start.line}:${n.start.column}`)}throw e}}function Vr(t){return new Map(t.map(e=>[e.key,e.value]))}function lg(t,e){const n=Vr(e),o=au(t),r=new Set(o.map(s=>s.key)),i={};for(const s of o){const a=n.get(s.key);a!==void 0&&r.has(s.key)&&(s.type===Qe.Colors?i[s.key]=String(a).split(",").map(l=>l.trim()).filter(Boolean):s.type===Qe.Boolean?i[s.key]=a==="true"||a===!0:i[s.key]=String(a))}return i}function uoe(t){return!(/^-?\d+(\.\d+)?$/.test(t)||/^-?\d+(\.\d+)?%$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t))}function u0(t){return t.entries.map(e=>{if(e.values&&e.values.length>1){if(e.key==="_series")return`_series = ${e.values.map(r=>`"${r}"`).join(",")}`;const o=e.values.join(",");return`"${e.key}" = ${o}`}const n=e.isPercentage?`${e.value}%`:String(e.value);return e.key==="_series"?`_series = "${n}"`:typeof e.value=="string"&&uoe(n)?`"${e.key}" = "${n}"`:`"${e.key}" = ${n}`}).join(`
|
|
90
|
+
`)}function doe(t,e){const n=Vr(t.properties),o=n.get("type"),r=o??e;return{name:t.name,chartType:o,properties:n,data:t.data,chartTypeOptions:lg(r,t.properties),colorizes:t.colorizes,highlights:t.highlights,areaFills:t.areaFills,annotations:t.annotations,annotationVisibility:t.annotationVisibility??[],series:t.series,transforms:t.transforms}}function C6(t,e){const n=t.find(o=>o.key===e);return n?String(n.value):void 0}function $6(t,e){const n=t.find(o=>o.key===e);if(n)return n.isPercentage,n.value}function T6(t){const e=t.find(n=>n.key==="maxWidth");if(e)return e.isPercentage?`${e.value}%`:e.value}const ba=t=>t==="true"||t===!0;function d0(t){return t.map(e=>({target:e.target,color:C6(e.properties,"color")??"#e15759",label:C6(e.properties,"label")}))}function f0(t){return t.map(e=>({target:e.target}))}function h0(t){return t.map(e=>{const n=Vr(e.properties);return{from:e.from,to:e.to,color:n.has("color")?String(n.get("color")):void 0,negativeColor:n.has("negativeColor")?String(n.get("negativeColor")):void 0,opacity:n.has("opacity")?Number(n.get("opacity")):void 0,interpolation:n.has("interpolation")?String(n.get("interpolation")):void 0}})}function p0(t){return t.map(e=>{const n=Vr(e.properties),o=e.kind??Dt.Point;if(o===Dt.Range){const a={kind:Dt.Range,start:n.has("start")?isNaN(Number(n.get("start")))?String(n.get("start")):Number(n.get("start")):0,end:n.has("end")?isNaN(Number(n.get("end")))?String(n.get("end")):Number(n.get("end")):0};return n.has("id")&&(a.id=String(n.get("id"))),n.has("orientation")&&(a.orientation=String(n.get("orientation"))),n.has("startAnchor")&&(a.startAnchor=String(n.get("startAnchor"))),n.has("endAnchor")&&(a.endAnchor=String(n.get("endAnchor"))),n.has("bgColor")&&(a.bgColor=String(n.get("bgColor"))),n.has("bgOpacity")&&(a.bgOpacity=Number(n.get("bgOpacity"))),n.has("direction")&&(a.direction=String(n.get("direction"))),n.has("text")&&(a.text=String(n.get("text"))),n.has("textColor")&&(a.textColor=String(n.get("textColor"))),a}if(o===Dt.Free){const a={kind:Dt.Free,text:String(n.get("text")??""),x:$6(e.properties,"x")??0,y:$6(e.properties,"y")??0};n.has("id")&&(a.id=String(n.get("id"))),n.has("textColor")&&(a.textColor=String(n.get("textColor")));const l=T6(e.properties);return l!==void 0&&(a.maxWidth=l),n.has("textOutline")&&(a.textOutline=ba(n.get("textOutline"))),a}const r="target"in e?e.target:"",i={kind:Dt.Point,target:r,text:String(n.get("text")??"")};n.has("id")&&(i.id=String(n.get("id"))),n.has("textColor")&&(i.textColor=String(n.get("textColor")));const s=T6(e.properties);return s!==void 0&&(i.maxWidth=s),n.has("textOutline")&&(i.textOutline=ba(n.get("textOutline"))),n.has("showLine")&&(i.showLine=ba(n.get("showLine"))),n.has("anchorDirection")&&(i.anchorDirection=String(n.get("anchorDirection"))),n.has("textOffsetX")&&(i.textOffsetX=Number(n.get("textOffsetX"))),n.has("textOffsetY")&&(i.textOffsetY=Number(n.get("textOffsetY"))),n.has("lineStyle")&&(i.lineStyle=String(n.get("lineStyle"))),n.has("lineWeight")&&(i.lineWeight=Number(n.get("lineWeight"))),n.has("showArrow")&&(i.showArrow=ba(n.get("showArrow"))),n.has("lineTargetDistance")&&(i.lineTargetDistance=Number(n.get("lineTargetDistance"))),n.has("showCircle")&&(i.showCircle=ba(n.get("showCircle"))),n.has("circleSize")&&(i.circleSize=Number(n.get("circleSize"))),n.has("circleStyle")&&(i.circleStyle=String(n.get("circleStyle"))),n.has("circleColor")&&(i.circleColor=String(n.get("circleColor"))),i})}function m0(t){return t.map(e=>{const n=Vr(e.properties),o={name:e.name};return n.has("color")&&(o.color=String(n.get("color"))),n.has("lineWidth")&&(o.lineWidth=Number(n.get("lineWidth"))),n.has("dash")&&(o.dash=String(n.get("dash"))),n.has("interpolation")&&(o.interpolation=String(n.get("interpolation"))),n.has("labelMode")&&(o.labelMode=String(n.get("labelMode"))),n.has("labelText")&&(o.labelText=String(n.get("labelText"))),n.has("valueLabels")&&(o.valueLabels=ba(n.get("valueLabels"))),n.has("lineSymbols")&&(o.lineSymbols=ba(n.get("lineSymbols"))),n.has("hidden")&&(o.hidden=ba(n.get("hidden"))),n.has("symbolShape")&&(o.symbolShape=String(n.get("symbolShape"))),n.has("symbolShowOn")&&(o.symbolShowOn=String(n.get("symbolShowOn"))),n.has("symbolStyle")&&(o.symbolStyle=String(n.get("symbolStyle"))),n.has("symbolSize")&&(o.symbolSize=Number(n.get("symbolSize"))),n.has("symbolOpacity")&&(o.symbolOpacity=Number(n.get("symbolOpacity"))),o})}const foe=`chart bar-vertical {
|
|
91
91
|
title = "E is the most frequent letter in English"
|
|
92
92
|
description = "How often each letter appears in typical English text"
|
|
93
93
|
byline = "Pierre Romera"
|
|
@@ -115,7 +115,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
115
115
|
"D" = 4.25
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
`,
|
|
118
|
+
`,hoe=`chart bar-vertical {
|
|
119
119
|
title = "China emits more CO₂ than the US and India combined"
|
|
120
120
|
description = "Annual emissions in billion tonnes, 2023"
|
|
121
121
|
source = "Global Carbon Project"
|
|
@@ -147,7 +147,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
147
147
|
showCircle = false
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
`,
|
|
150
|
+
`,poe=`chart bar-horizontal {
|
|
151
151
|
title = "Mandarin has nearly twice as many native speakers as Spanish"
|
|
152
152
|
description = "Number of native speakers worldwide, in millions"
|
|
153
153
|
source = "Ethnologue"
|
|
@@ -170,7 +170,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
170
170
|
"Japanese" = 125
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
`,
|
|
173
|
+
`,moe=`chart bar-multi {
|
|
174
174
|
title = "Software overtakes hardware as the top revenue driver"
|
|
175
175
|
description = "USD billions"
|
|
176
176
|
byline = "Pierre Romera"
|
|
@@ -189,7 +189,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
189
189
|
"Q2 2025" = 16.2,15.5,10.8
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
`,
|
|
192
|
+
`,goe=`chart bar-multi {
|
|
193
193
|
title = "USA tops Paris 2024 with 126 medals across all categories"
|
|
194
194
|
description = "2024 Paris Summer Games — top six nations"
|
|
195
195
|
source = "Olympics.com"
|
|
@@ -210,7 +210,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
210
210
|
"France" = 16,20,23
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
`,
|
|
213
|
+
`,voe=`chart line {
|
|
214
214
|
title = "2024 was the hottest year on record"
|
|
215
215
|
description = "Deviation from the 1951–1980 average, in °C"
|
|
216
216
|
source = "NASA GISS"
|
|
@@ -242,7 +242,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
242
242
|
showCircle = true
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
`,
|
|
245
|
+
`,boe=`chart line-multi {
|
|
246
246
|
title = "Detroit's unemployment hit 16% during the Great Recession"
|
|
247
247
|
description = "Percent of labour force, 2000–2014"
|
|
248
248
|
source = "Bureau of Labor Statistics"
|
|
@@ -270,7 +270,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
270
270
|
"2014" = 6.5,8.0,7.1,8.2
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
`,
|
|
273
|
+
`,yoe=`chart pie {
|
|
274
274
|
title = "Asia is home to nearly 60% of the world's population"
|
|
275
275
|
description = "Estimated share, 2024"
|
|
276
276
|
source = "United Nations"
|
|
@@ -287,7 +287,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
287
287
|
"North America" = 4.8
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
`,
|
|
290
|
+
`,xoe=`chart bar-vertical {
|
|
291
291
|
title = "Brazil produces more coffee than the next three countries combined"
|
|
292
292
|
description = "Million 60-kg bags, 2023/24 crop year"
|
|
293
293
|
source = "International Coffee Organization"
|
|
@@ -313,7 +313,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
313
313
|
direction = descending
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
`,
|
|
316
|
+
`,woe=`chart donut {
|
|
317
317
|
title = "Chrome dominates with two-thirds of the desktop browser market"
|
|
318
318
|
description = "Worldwide, January 2025"
|
|
319
319
|
source = "StatCounter"
|
|
@@ -332,7 +332,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
332
332
|
"Others" = 2.9
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
`,
|
|
335
|
+
`,_oe=`chart area {
|
|
336
336
|
title = "Apple stock climbed 36 % through 2024"
|
|
337
337
|
description = "Monthly closing price in USD"
|
|
338
338
|
source = "Yahoo Finance"
|
|
@@ -354,7 +354,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
354
354
|
"Dec" = 249
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
`,
|
|
357
|
+
`,koe=`chart area-stacked {
|
|
358
358
|
title = "Renewables rose from 18 % to 23 % of global energy since 2000"
|
|
359
359
|
description = "Share of primary energy by source, 2000–2023"
|
|
360
360
|
source = "Our World in Data"
|
|
@@ -372,7 +372,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
372
372
|
"2023" = 24,29,24,23
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
`,
|
|
375
|
+
`,Soe=`chart column-stacked {
|
|
376
376
|
title = "Software revenue grew steadily while hardware spiked in Q4"
|
|
377
377
|
description = "Quarterly revenue in millions, 2024"
|
|
378
378
|
source = "Annual report"
|
|
@@ -385,7 +385,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
385
385
|
"Q4" = 155,105,58
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
`,
|
|
388
|
+
`,Aoe=`chart bar-stacked {
|
|
389
389
|
title = "India's working-age population now surpasses China's"
|
|
390
390
|
description = "Millions of people, 2023"
|
|
391
391
|
source = "UN Population Division"
|
|
@@ -402,7 +402,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
402
402
|
"Brazil" = 42,150,22
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
`,
|
|
405
|
+
`,Coe=`chart area-stacked {
|
|
406
406
|
title = "EU subsidies to new members surged after enlargement"
|
|
407
407
|
description = "Agricultural subsidies to post-socialist EU members, million euros"
|
|
408
408
|
source = "Eurostat"
|
|
@@ -601,7 +601,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
601
601
|
highlight "Non-salaried workers"
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
-
|
|
604
|
+
`,$oe=`chart bar-split {
|
|
605
605
|
title = "CDU/CSU led German polls at 29 % ahead of the 2021 election"
|
|
606
606
|
description = "How Germany would vote in the September 2021 federal election, according to polling in the previous June"
|
|
607
607
|
source = "FG Wahlen"
|
|
@@ -618,7 +618,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
618
618
|
"Left" = 7,9,5
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
`,
|
|
621
|
+
`,Toe=`chart bar-grouped {
|
|
622
622
|
title = "Asia Pacific holds more renewable capacity than all other regions combined"
|
|
623
623
|
description = "Installed capacity in gigawatts (GW)"
|
|
624
624
|
source = "IRENA"
|
|
@@ -633,18 +633,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
633
633
|
"Africa" = 15,10,40
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
`;function M6(t,e){const n=t.properties.find(o=>o.key===e);return n?String(n.value):""}function
|
|
636
|
+
`;function M6(t,e){const n=t.properties.find(o=>o.key===e);return n?String(n.value):""}function Moe(t){if(!t.data)return"";const e=t.data.entries,n=e.find(i=>i.key==="_series");if(n){const s=["category",...String(n.value).split(",")].join(" "),a=e.filter(l=>l.key!=="_series").map(l=>{const c=String(l.value).split(",");return[l.key,...c].join(" ")});return[s,...a].join(`
|
|
637
637
|
`)}const o=["label","value"].join(" "),r=e.map(i=>[i.key,String(i.value)].join(" "));return[o,...r].join(`
|
|
638
|
-
`)}function
|
|
638
|
+
`)}function Ooe(t){if(!t.data)return"";const e=t.data.entries,n=e.find(o=>o.key==="_series");if(n){const o=`_series = "${String(n.value)}"`,r=e.filter(i=>i.key!=="_series").map(i=>`"${i.key}" = "${String(i.value)}"`);return[o,...r].join(`
|
|
639
639
|
`)}return e.map(o=>`"${o.key}" = ${String(o.value)}`).join(`
|
|
640
|
-
`)}function eo(t,e){const n=ag(e);return{id:t,title:M6(n,"title"),description:M6(n,"description"),chartType:n.chartType,tsvData:$oe(n),serializedData:Toe(n),dsl:e}}const O6=[eo("letter-frequency",uoe),eo("co2-emissions",doe),eo("coffee-production",boe),eo("spoken-languages",foe),eo("quarterly-revenue",hoe),eo("medal-count",poe),eo("temperature-anomaly",moe),eo("unemployment-rates",goe),eo("browser-market",yoe),eo("world-population",voe),eo("stock-price-area",xoe),eo("energy-mix-stacked-area",woe),eo("quarterly-stacked-columns",_oe),eo("population-stacked-bar",koe),eo("election-polls",Aoe),eo("renewable-capacity",Coe),eo("farm-compass",Soe)],B6=new Set;function Moe(t,e,n){let o=e;for(const r of t)r.transformType==="sort"?o=ai.Total:B6.has(r.transformType)||(B6.add(r.transformType),console.warn(`[blueprint-chart] Unknown transform "${r.transformType}" in ${n}; ignored.`));return o}function Ooe(t){const e=i=>{const s=t.get(i);return s==null?void 0:String(s)||void 0},n=t.get("transparentBackground"),o={title:e("title"),description:e("description"),source:e("source"),sourceUrl:e("sourceUrl"),byline:e("byline"),note:e("note"),padding:e("padding"),transparentBackground:n===!0||n==="true"||void 0};return Object.values(o).some(i=>i!==void 0)?o:void 0}function Boe(t){const e=Vr(t.properties),n=t.data?u0(t.data):"",o=fs(n),r=e.get("sort"),i=r==null?void 0:String(r),s=i===Zt.Ascending||i===Zt.Descending?i:void 0,a=e.get("theme"),l=e.get("sortMode");let c;return(l===ai.Total||l===ai.WithinGroups||l===ai.None)&&(c=l),c=Moe(t.transforms,c,"chart"),{chartType:t.chartType,data:o,properties:t.properties,frame:Ooe(e),colorizes:d0(t.colorizes),highlights:f0(t.highlights),areaFills:h0(t.areaFills),annotations:p0(t.annotations),seriesOverrides:m0(t.series),scenes:t.scenes,sort:s,sortMode:c,theme:a==null?void 0:String(a)||void 0}}const L6=new Set;function Loe(t,e,n){let o=e;for(const r of t)r.transformType==="sort"?o=ai.Total:L6.has(r.transformType)||(L6.add(r.transformType),console.warn(`[blueprint-chart] Unknown transform "${r.transformType}" in ${n}; ignored.`));return o}function Poe(){return{properties:new Map,chartTypeOptions:{},colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],hiddenAnnotationIds:new Set,transforms:[]}}function Doe(t,e,n){const o=Poe();for(let r=0;r<=e;r++){const i=t[r],s=Vr(i.properties),a=s.get("type");a&&(o.chartType=a);const l=o.chartType??n;i.data&&(o.data=i.data);const c=lg(l,i.properties);if(o.chartTypeOptions={...o.chartTypeOptions,...c},i.colorizes.length>0?o.colorizes=i.colorizes:i.data&&(o.colorizes=[]),r===e&&(o.highlights=i.highlights),i.areaFills.length>0&&(o.areaFills=i.areaFills),i.annotations.length>0){const u=[...o.annotations];for(const d of i.annotations){const f=Vr(d.properties).get("id");if(f!=null){const h=u.findIndex(g=>Vr(g.properties).get("id")===f);if(h>=0){u[h]=d;continue}}u.push(d)}o.annotations=u}for(const u of i.annotationVisibility)u.action===eC.Hide?o.hiddenAnnotationIds.add(u.id):o.hiddenAnnotationIds.delete(u.id);i.series.length>0&&(o.seriesOverrides=i.series),i.transforms.length>0&&(o.transforms=[...o.transforms,...i.transforms]);for(const[u,d]of s)o.properties.set(u,d)}return o}function Eoe(t,e){const n=t.options??(t.properties?c0(t.chartType,lg(t.chartType,t.properties)):{}),o={chartType:t.chartType,data:t.data,options:n,frame:t.frame,colorizes:t.colorizes??[],highlights:t.highlights??[],areaFills:t.areaFills??[],annotations:t.annotations??[],seriesOverrides:t.seriesOverrides??[],sort:t.sort,sortMode:t.sortMode,theme:t.theme};if(e==null||!t.scenes||e<0||e>=t.scenes.length)return o;const r=Doe(t.scenes,e,t.chartType),i=r.chartType??t.chartType,s=r.data?fs(u0(r.data)):o.data,a=Object.keys(r.chartTypeOptions).length>0?c0(i,{...n,...r.chartTypeOptions}):n,l=r.colorizes.length>0?d0(r.colorizes):r.data?[]:o.colorizes,c=e!=null?f0(r.highlights):o.highlights,u=r.areaFills.length>0?h0(r.areaFills):o.areaFills,d=r.annotations.length>0?p0(r.annotations):[],f=[...o.annotations,...d],h=r.hiddenAnnotationIds.size>0?f.filter(x=>!x.id||!r.hiddenAnnotationIds.has(x.id)):f,g=r.seriesOverrides.length>0?m0(r.seriesOverrides):o.seriesOverrides,b=Loe(r.transforms,o.sortMode,`scene ${e}`),m=["title","description","source","sourceUrl","byline","note"],v={};for(const x of m){const _=r.properties.get(x);typeof _=="string"&&(v[x]=_)}const y=Object.keys(v).length>0?{...o.frame,...v}:o.frame;return{...o,chartType:i,data:s,options:a,frame:y,colorizes:l,highlights:c,areaFills:u,annotations:h,seriesOverrides:g,sortMode:b}}const Z1=new WeakMap;function Noe(t){const e=Z1.get(t);if(!(!e||e.size===0)){for(const n of e)t.style[n]="";e.clear()}}function vc(t,e){let n=Z1.get(t);n||(n=new Set,Z1.set(t,n)),n.add(e)}function Ioe(t,e,n){if(Noe(t),n.ignoreLayout||!e)return{constrained:!1};const o=Vr(e),r=o.get("heightMode"),i=o.get("aspectRatio"),s=o.get("fixedHeight");let a=!1;if(r==="aspect-ratio"&&i){const l=String(i).split(":").map(Number);l.length===2&&l[0]>0&&l[1]>0&&(t.style.aspectRatio=`${l[0]} / ${l[1]}`,t.style.height="auto",vc(t,"aspectRatio"),vc(t,"height"),a=!0)}else r==="fixed"&&s&&(t.style.height=`${s}px`,vc(t,"height"),a=!0);return a&&(t.style.display="flex",t.style.flexDirection="column",t.style.overflow="hidden",vc(t,"display"),vc(t,"flexDirection"),vc(t,"overflow")),{constrained:a}}const B2=new WeakMap;function j$(t){t.querySelectorAll("[data-bc-fade-overlay]").forEach(e=>{typeof e.getAnimations=="function"&&e.getAnimations().forEach(n=>n.cancel()),e.remove()})}function Roe(t,e,n){if(!n)return null;const o=B2.get(t);return!o||o===e?null:(j$(t),Mr(t))}function Foe(t,e,n){if(B2.set(t,e),n){const o=t.querySelector(".bc-frame .bc-frame-body");o&&Tr(o),Or(t,n)}}function P6(t){B2.delete(t),j$(t)}function Voe(t,e,n){const o=t.querySelector(".bc-frame");if(!o)return;const r=[];o.classList.forEach(i=>{i.startsWith("bc-theme-")&&r.push(i)});for(const i of r)o.classList.remove(i);e.theme&&o.classList.add(`bc-theme-${e.theme}`),n.constrained&&o.classList.add("bc-frame--constrained")}function L2(t,e,n={}){var h;if(n.transition||(t.replaceChildren(),P6(t)),e.data.labels.length===0){n.transition&&(t.replaceChildren(),P6(t));return}let o=e;if(n.stripColors){const g={...e};if(e.properties&&(g.properties=e.properties.filter(b=>b.key!=="colors"&&b.key!=="colorPalette")),e.options){const{colors:b,colorPalette:m,...v}=e.options;g.options=v}o=g}const r=Ioe(t,o.properties,n),i=Eoe(o,n.sceneIndex),s=Ane(i.chartType);if(!s)return;const a=Roe(t,i.chartType,!!n.transition);a&&t.replaceChildren();const l=$r(t),c=U$(i.options,l);let u;if(n.thumbnail)u=null;else{const g=((h=i.frame)==null?void 0:h.padding)??n.padding??"16px";u={...i.frame??{},padding:g}}const d=nc(t);n.transition&&d.beginCommit(),s(t,i.data,{frame:u,sort:i.sort,sortMode:i.sortMode,...c,colorizes:i.colorizes.length>0?i.colorizes:void 0,highlights:i.highlights.length>0?i.highlights:void 0,areaFills:i.areaFills.length>0?i.areaFills:void 0,annotations:i.annotations.length>0?i.annotations:void 0,seriesOverrides:i.seriesOverrides.length>0?i.seriesOverrides:void 0},!!n.transition),n.transition&&d.commit({mode:n.transitionMode});const f=n.theme??i.theme;Voe(t,{theme:f},r),Foe(t,i.chartType,a)}function X$(t,e,n){if(!e){n!=null&&n.transition||t.replaceChildren();return}const o=ag(e),r=Boe(o);L2(t,r,n)}const D6="abcdefghijklmnopqrstuvwxyz0123456789";function zoe(){let t="";for(let e=0;e<8;e++)t+=D6[Math.floor(Math.random()*D6.length)];return t}const Hoe=Oo("scenes",()=>{const t=Ve([]),e=Ie(-1),n=Ie(!1);let o=null;const r=A(()=>e.value<0||e.value>=t.value.length?null:t.value[e.value]);function i(){const v=zoe();return t.value.push({id:v,name:null}),v}function s(v){v<0||v>=t.value.length||(t.value.splice(v,1),e.value>=t.value.length&&(e.value=t.value.length>0?t.value.length-1:-1),t.value.length===0&&(e.value=-1))}function a(v,y){v<0||v>=t.value.length||(t.value[v]={...t.value[v],...y})}function l(v){v!==e.value&&(v===-1||v>=0&&v<t.value.length)&&(e.value=v)}function c(){l(e.value+1)}function u(){l(e.value-1)}function d(v,y){if(v<0||v>=t.value.length||y<0||y>=t.value.length)return;const[x]=t.value.splice(v,1);t.value.splice(y,0,x),e.value===v?e.value=y:v<e.value&&y>=e.value?e.value--:v>e.value&&y<=e.value&&e.value++}function f(){n.value||(n.value=!0,t.value.length!==0&&(e.value=-1,o=setInterval(()=>{e.value<t.value.length-1?e.value++:h()},3e3)))}function h(){n.value=!1,o!==null&&(clearInterval(o),o=null)}function g(){h(),t.value=[],e.value=-1}function b(){return{scenes:t.value.map(v=>({...v})),activeIndex:e.value}}function m(v){h(),t.value=v.scenes.map(y=>({...y})),e.value=v.activeIndex}return{scenes:t,activeIndex:e,playing:n,activeScene:r,add:i,remove:s,update:a,setActive:l,nextScene:c,previousScene:u,reorder:d,startPlayback:f,stopPlayback:h,reset:g,snapshot:b,hydrate:m}});function wn(){const t=Hoe(),{scenes:e,activeIndex:n,playing:o,activeScene:r}=Ct(t);return{scenes:e,activeIndex:n,playing:o,activeScene:r,add:t.add,remove:t.remove,update:t.update,setActive:t.setActive,nextScene:t.nextScene,previousScene:t.previousScene,reorder:t.reorder,startPlayback:t.startPlayback,stopPlayback:t.stopPlayback,reset:t.reset,snapshot:t.snapshot,hydrate:t.hydrate}}function g0(t,e){if(t===e)return!0;if(t==null||e==null)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((n,o)=>g0(n,e[o]));if(typeof t=="object"&&typeof e=="object"){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(r=>g0(t[r],e[r]))}return!1}function K$(t){return!(t===void 0||Array.isArray(t)&&t.length===0)}function E6(t,e,n,o){for(let r=o-1;r>=0;r--){const i=n[r];if(i&&e in i&&K$(i[e]))return i[e]}return t}function N6(t,e,n,o){for(let r=o-1;r>=0;r--){const i=n[r];if(i!=null&&i.properties&&e in i.properties)return String(i.properties[e])}return t}const rf={sizing:"max-width",fixedWidth:600,maxWidth:660,heightMode:"auto",fixedHeight:400,aspectRatio:"16:9",padding:16,transparentBackground:!1,playerType:"buttons",playerPosition:"left"},I6={chartType:Le.BarVertical,title:"",description:"",byline:"",source:"",sourceUrl:"",note:"",sort:Zt.None,sortMode:"none",data:"",selectedColumn:"",colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],layout:{...rf}};function ll(t,e){return A({get(){const{activeScene:n,activeIndex:o,scenes:r}=wn(),i=n.value;return i&&e in i&&K$(i[e])?i[e]:o.value>=0?E6(t.value,e,r.value,o.value):t.value},set(n){const{activeIndex:o,activeScene:r,update:i,scenes:s}=wn();if(o.value>=0&&r.value){const a=E6(t.value,e,s.value,o.value);if(g0(n,a)){const l={...r.value};delete l[e],s.value[o.value]=l}else i(o.value,{[e]:n});return}t.value=n}})}function ua(t,e){return A({get(){const{activeScene:n,activeIndex:o,scenes:r}=wn(),i=n.value;return i!=null&&i.properties&&e in i.properties?String(i.properties[e]):o.value>=0?N6(t.value,e,r.value,o.value):t.value},set(n){const{activeIndex:o,activeScene:r,update:i,scenes:s}=wn();if(o.value>=0&&r.value){const a=N6(t.value,e,s.value,o.value);if(n===a){const l={...r.value.properties};delete l[e];const c=Object.keys(l).length>0?l:void 0,u={...r.value,properties:c};c||delete u.properties,s.value[o.value]=u}else{const l=r.value.properties??{};i(o.value,{properties:{...l,[e]:n}})}return}t.value=n}})}const Woe=Oo("chartConfig",()=>{const t=ir({...I6}),e=K0(t),n=ll(e.chartType,"chartType"),o=ll(e.data,"data"),r=ll(e.colorizes,"colorizes"),i=ll(e.highlights,"highlights"),s=ll(e.areaFills,"areaFills"),a=ll(e.annotations,"annotations"),l=ll(e.seriesOverrides,"seriesOverrides"),c=ua(e.title,"title"),u=ua(e.description,"description"),d=ua(e.byline,"byline"),f=ua(e.source,"source"),h=ua(e.sourceUrl,"sourceUrl"),g=ua(e.note,"note"),b=ua(e.sort,"sort"),m=ua(e.sortMode,"sortMode");function v(){Object.assign(t,{...I6,colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],layout:{...rf}})}function y(x){Object.assign(t,{...x,layout:{...rf,...x.layout}})}return{chartType:n,data:o,colorizes:r,highlights:i,areaFills:s,annotations:a,seriesOverrides:l,title:c,description:u,byline:d,source:f,sourceUrl:h,note:g,sort:b,sortMode:m,layout:e.layout,selectedColumn:e.selectedColumn,_base:Oe(e),reset:v,hydrate:y}});function dn(){const t=Woe(),e=Ct(t);return{chartType:e.chartType,data:e.data,colorizes:e.colorizes,highlights:e.highlights,areaFills:e.areaFills,annotations:e.annotations,seriesOverrides:e.seriesOverrides,title:e.title,description:e.description,byline:e.byline,source:e.source,sourceUrl:e.sourceUrl,note:e.note,sort:e.sort,sortMode:e.sortMode,layout:e.layout,selectedColumn:e.selectedColumn,_base:t._base,reset:t.reset,hydrate:t.hydrate}}function Uoe(t){const e=t.split(`
|
|
641
|
-
`)[0]??"",n=(e.match(/\t/g)??[]).length,o=(e.match(/,/g)??[]).length;return n>=o?" ":","}function xh(t,e){if(e===" ")return t.split(" ").map(i=>i.trim());const n=[];let o="",r=!1;for(let i=0;i<t.length;i++){const s=t[i];s==='"'?r&&t[i+1]==='"'?(o+='"',i++):r=!r:s===e&&!r?(n.push(o.trim()),o=""):o+=s}return n.push(o.trim()),n}const
|
|
640
|
+
`)}function eo(t,e){const n=ag(e);return{id:t,title:M6(n,"title"),description:M6(n,"description"),chartType:n.chartType,tsvData:Moe(n),serializedData:Ooe(n),dsl:e}}const O6=[eo("letter-frequency",foe),eo("co2-emissions",hoe),eo("coffee-production",xoe),eo("spoken-languages",poe),eo("quarterly-revenue",moe),eo("medal-count",goe),eo("temperature-anomaly",voe),eo("unemployment-rates",boe),eo("browser-market",woe),eo("world-population",yoe),eo("stock-price-area",_oe),eo("energy-mix-stacked-area",koe),eo("quarterly-stacked-columns",Soe),eo("population-stacked-bar",Aoe),eo("election-polls",$oe),eo("renewable-capacity",Toe),eo("farm-compass",Coe)],B6=new Set;function Boe(t,e,n){let o=e;for(const r of t)r.transformType==="sort"?o=ai.Total:B6.has(r.transformType)||(B6.add(r.transformType),console.warn(`[blueprint-chart] Unknown transform "${r.transformType}" in ${n}; ignored.`));return o}function Loe(t){const e=i=>{const s=t.get(i);return s==null?void 0:String(s)||void 0},n=t.get("transparentBackground"),o={title:e("title"),description:e("description"),source:e("source"),sourceUrl:e("sourceUrl"),byline:e("byline"),note:e("note"),padding:e("padding"),transparentBackground:n===!0||n==="true"||void 0};return Object.values(o).some(i=>i!==void 0)?o:void 0}function Poe(t){const e=Vr(t.properties),n=t.data?u0(t.data):"",o=fs(n),r=e.get("sort"),i=r==null?void 0:String(r),s=i===Zt.Ascending||i===Zt.Descending?i:void 0,a=e.get("theme"),l=e.get("sortMode");let c;return(l===ai.Total||l===ai.WithinGroups||l===ai.None)&&(c=l),c=Boe(t.transforms,c,"chart"),{chartType:t.chartType,data:o,properties:t.properties,frame:Loe(e),colorizes:d0(t.colorizes),highlights:f0(t.highlights),areaFills:h0(t.areaFills),annotations:p0(t.annotations),seriesOverrides:m0(t.series),scenes:t.scenes,sort:s,sortMode:c,theme:a==null?void 0:String(a)||void 0}}const L6=new Set;function Doe(t,e,n){let o=e;for(const r of t)r.transformType==="sort"?o=ai.Total:L6.has(r.transformType)||(L6.add(r.transformType),console.warn(`[blueprint-chart] Unknown transform "${r.transformType}" in ${n}; ignored.`));return o}function Eoe(){return{properties:new Map,chartTypeOptions:{},colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],hiddenAnnotationIds:new Set,transforms:[]}}function Noe(t,e,n){const o=Eoe();for(let r=0;r<=e;r++){const i=t[r],s=Vr(i.properties),a=s.get("type");a&&(o.chartType=a);const l=o.chartType??n;i.data&&(o.data=i.data);const c=lg(l,i.properties);if(o.chartTypeOptions={...o.chartTypeOptions,...c},i.colorizes.length>0?o.colorizes=i.colorizes:i.data&&(o.colorizes=[]),r===e&&(o.highlights=i.highlights),i.areaFills.length>0&&(o.areaFills=i.areaFills),i.annotations.length>0){const u=[...o.annotations];for(const d of i.annotations){const f=Vr(d.properties).get("id");if(f!=null){const h=u.findIndex(g=>Vr(g.properties).get("id")===f);if(h>=0){u[h]=d;continue}}u.push(d)}o.annotations=u}for(const u of i.annotationVisibility)u.action===eC.Hide?o.hiddenAnnotationIds.add(u.id):o.hiddenAnnotationIds.delete(u.id);i.series.length>0&&(o.seriesOverrides=i.series),i.transforms.length>0&&(o.transforms=[...o.transforms,...i.transforms]);for(const[u,d]of s)o.properties.set(u,d)}return o}function Ioe(t,e){const n=t.options??(t.properties?c0(t.chartType,lg(t.chartType,t.properties)):{}),o={chartType:t.chartType,data:t.data,options:n,frame:t.frame,colorizes:t.colorizes??[],highlights:t.highlights??[],areaFills:t.areaFills??[],annotations:t.annotations??[],seriesOverrides:t.seriesOverrides??[],sort:t.sort,sortMode:t.sortMode,theme:t.theme};if(e==null||!t.scenes||e<0||e>=t.scenes.length)return o;const r=Noe(t.scenes,e,t.chartType),i=r.chartType??t.chartType,s=r.data?fs(u0(r.data)):o.data,a=Object.keys(r.chartTypeOptions).length>0?c0(i,{...n,...r.chartTypeOptions}):n,l=r.colorizes.length>0?d0(r.colorizes):r.data?[]:o.colorizes,c=e!=null?f0(r.highlights):o.highlights,u=r.areaFills.length>0?h0(r.areaFills):o.areaFills,d=r.annotations.length>0?p0(r.annotations):[],f=[...o.annotations,...d],h=r.hiddenAnnotationIds.size>0?f.filter(x=>!x.id||!r.hiddenAnnotationIds.has(x.id)):f,g=r.seriesOverrides.length>0?m0(r.seriesOverrides):o.seriesOverrides,b=Doe(r.transforms,o.sortMode,`scene ${e}`),m=["title","description","source","sourceUrl","byline","note"],v={};for(const x of m){const _=r.properties.get(x);typeof _=="string"&&(v[x]=_)}const y=Object.keys(v).length>0?{...o.frame,...v}:o.frame;return{...o,chartType:i,data:s,options:a,frame:y,colorizes:l,highlights:c,areaFills:u,annotations:h,seriesOverrides:g,sortMode:b}}const Z1=new WeakMap;function Roe(t){const e=Z1.get(t);if(!(!e||e.size===0)){for(const n of e)t.style[n]="";e.clear()}}function vc(t,e){let n=Z1.get(t);n||(n=new Set,Z1.set(t,n)),n.add(e)}function Foe(t,e,n){if(Roe(t),n.ignoreLayout||!e)return{constrained:!1};const o=Vr(e),r=o.get("heightMode"),i=o.get("aspectRatio"),s=o.get("fixedHeight");let a=!1;if(r==="aspect-ratio"&&i){const l=String(i).split(":").map(Number);l.length===2&&l[0]>0&&l[1]>0&&(t.style.aspectRatio=`${l[0]} / ${l[1]}`,t.style.height="auto",vc(t,"aspectRatio"),vc(t,"height"),a=!0)}else r==="fixed"&&s&&(t.style.height=`${s}px`,vc(t,"height"),a=!0);return a&&(t.style.display="flex",t.style.flexDirection="column",t.style.overflow="hidden",vc(t,"display"),vc(t,"flexDirection"),vc(t,"overflow")),{constrained:a}}const B2=new WeakMap;function j$(t){t.querySelectorAll("[data-bc-fade-overlay]").forEach(e=>{typeof e.getAnimations=="function"&&e.getAnimations().forEach(n=>n.cancel()),e.remove()})}function Voe(t,e,n){if(!n)return null;const o=B2.get(t);return!o||o===e?null:(j$(t),Mr(t))}function zoe(t,e,n){if(B2.set(t,e),n){const o=t.querySelector(".bc-frame .bc-frame-body");o&&Tr(o),Or(t,n)}}function P6(t){B2.delete(t),j$(t)}function Hoe(t,e,n){const o=t.querySelector(".bc-frame");if(!o)return;const r=[];o.classList.forEach(i=>{i.startsWith("bc-theme-")&&r.push(i)});for(const i of r)o.classList.remove(i);e.theme&&o.classList.add(`bc-theme-${e.theme}`),n.constrained&&o.classList.add("bc-frame--constrained")}function L2(t,e,n={}){var h;if(n.transition||(t.replaceChildren(),P6(t)),e.data.labels.length===0){n.transition&&(t.replaceChildren(),P6(t));return}let o=e;if(n.stripColors){const g={...e};if(e.properties&&(g.properties=e.properties.filter(b=>b.key!=="colors"&&b.key!=="colorPalette")),e.options){const{colors:b,colorPalette:m,...v}=e.options;g.options=v}o=g}const r=Foe(t,o.properties,n),i=Ioe(o,n.sceneIndex),s=Ane(i.chartType);if(!s)return;const a=Voe(t,i.chartType,!!n.transition);a&&t.replaceChildren();const l=$r(t),c=U$(i.options,l);let u;if(n.thumbnail)u=null;else{const g=((h=i.frame)==null?void 0:h.padding)??n.padding??"16px";u={...i.frame??{},padding:g}}const d=nc(t);n.transition&&d.beginCommit(),s(t,i.data,{frame:u,sort:i.sort,sortMode:i.sortMode,...c,colorizes:i.colorizes.length>0?i.colorizes:void 0,highlights:i.highlights.length>0?i.highlights:void 0,areaFills:i.areaFills.length>0?i.areaFills:void 0,annotations:i.annotations.length>0?i.annotations:void 0,seriesOverrides:i.seriesOverrides.length>0?i.seriesOverrides:void 0},!!n.transition),n.transition&&d.commit({mode:n.transitionMode});const f=n.theme??i.theme;Hoe(t,{theme:f},r),zoe(t,i.chartType,a)}function X$(t,e,n){if(!e){n!=null&&n.transition||t.replaceChildren();return}const o=ag(e),r=Poe(o);L2(t,r,n)}const D6="abcdefghijklmnopqrstuvwxyz0123456789";function Woe(){let t="";for(let e=0;e<8;e++)t+=D6[Math.floor(Math.random()*D6.length)];return t}const Uoe=Oo("scenes",()=>{const t=Ve([]),e=Ie(-1),n=Ie(!1);let o=null;const r=A(()=>e.value<0||e.value>=t.value.length?null:t.value[e.value]);function i(){const v=Woe();return t.value.push({id:v,name:null}),v}function s(v){v<0||v>=t.value.length||(t.value.splice(v,1),e.value>=t.value.length&&(e.value=t.value.length>0?t.value.length-1:-1),t.value.length===0&&(e.value=-1))}function a(v,y){v<0||v>=t.value.length||(t.value[v]={...t.value[v],...y})}function l(v){v!==e.value&&(v===-1||v>=0&&v<t.value.length)&&(e.value=v)}function c(){l(e.value+1)}function u(){l(e.value-1)}function d(v,y){if(v<0||v>=t.value.length||y<0||y>=t.value.length)return;const[x]=t.value.splice(v,1);t.value.splice(y,0,x),e.value===v?e.value=y:v<e.value&&y>=e.value?e.value--:v>e.value&&y<=e.value&&e.value++}function f(){n.value||(n.value=!0,t.value.length!==0&&(e.value=-1,o=setInterval(()=>{e.value<t.value.length-1?e.value++:h()},3e3)))}function h(){n.value=!1,o!==null&&(clearInterval(o),o=null)}function g(){h(),t.value=[],e.value=-1}function b(){return{scenes:t.value.map(v=>({...v})),activeIndex:e.value}}function m(v){h(),t.value=v.scenes.map(y=>({...y})),e.value=v.activeIndex}return{scenes:t,activeIndex:e,playing:n,activeScene:r,add:i,remove:s,update:a,setActive:l,nextScene:c,previousScene:u,reorder:d,startPlayback:f,stopPlayback:h,reset:g,snapshot:b,hydrate:m}});function wn(){const t=Uoe(),{scenes:e,activeIndex:n,playing:o,activeScene:r}=Ct(t);return{scenes:e,activeIndex:n,playing:o,activeScene:r,add:t.add,remove:t.remove,update:t.update,setActive:t.setActive,nextScene:t.nextScene,previousScene:t.previousScene,reorder:t.reorder,startPlayback:t.startPlayback,stopPlayback:t.stopPlayback,reset:t.reset,snapshot:t.snapshot,hydrate:t.hydrate}}function g0(t,e){if(t===e)return!0;if(t==null||e==null)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((n,o)=>g0(n,e[o]));if(typeof t=="object"&&typeof e=="object"){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(r=>g0(t[r],e[r]))}return!1}function K$(t){return!(t===void 0||Array.isArray(t)&&t.length===0)}function E6(t,e,n,o){for(let r=o-1;r>=0;r--){const i=n[r];if(i&&e in i&&K$(i[e]))return i[e]}return t}function N6(t,e,n,o){for(let r=o-1;r>=0;r--){const i=n[r];if(i!=null&&i.properties&&e in i.properties)return String(i.properties[e])}return t}const rf={sizing:"max-width",fixedWidth:600,maxWidth:660,heightMode:"auto",fixedHeight:400,aspectRatio:"16:9",padding:16,transparentBackground:!1,playerType:"buttons",playerPosition:"left"},I6={chartType:Le.BarVertical,title:"",description:"",byline:"",source:"",sourceUrl:"",note:"",sort:Zt.None,sortMode:"none",data:"",selectedColumn:"",colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],layout:{...rf}};function ll(t,e){return A({get(){const{activeScene:n,activeIndex:o,scenes:r}=wn(),i=n.value;return i&&e in i&&K$(i[e])?i[e]:o.value>=0?E6(t.value,e,r.value,o.value):t.value},set(n){const{activeIndex:o,activeScene:r,update:i,scenes:s}=wn();if(o.value>=0&&r.value){const a=E6(t.value,e,s.value,o.value);if(g0(n,a)){const l={...r.value};delete l[e],s.value[o.value]=l}else i(o.value,{[e]:n});return}t.value=n}})}function ua(t,e){return A({get(){const{activeScene:n,activeIndex:o,scenes:r}=wn(),i=n.value;return i!=null&&i.properties&&e in i.properties?String(i.properties[e]):o.value>=0?N6(t.value,e,r.value,o.value):t.value},set(n){const{activeIndex:o,activeScene:r,update:i,scenes:s}=wn();if(o.value>=0&&r.value){const a=N6(t.value,e,s.value,o.value);if(n===a){const l={...r.value.properties};delete l[e];const c=Object.keys(l).length>0?l:void 0,u={...r.value,properties:c};c||delete u.properties,s.value[o.value]=u}else{const l=r.value.properties??{};i(o.value,{properties:{...l,[e]:n}})}return}t.value=n}})}const Goe=Oo("chartConfig",()=>{const t=ir({...I6}),e=K0(t),n=ll(e.chartType,"chartType"),o=ll(e.data,"data"),r=ll(e.colorizes,"colorizes"),i=ll(e.highlights,"highlights"),s=ll(e.areaFills,"areaFills"),a=ll(e.annotations,"annotations"),l=ll(e.seriesOverrides,"seriesOverrides"),c=ua(e.title,"title"),u=ua(e.description,"description"),d=ua(e.byline,"byline"),f=ua(e.source,"source"),h=ua(e.sourceUrl,"sourceUrl"),g=ua(e.note,"note"),b=ua(e.sort,"sort"),m=ua(e.sortMode,"sortMode");function v(){Object.assign(t,{...I6,colorizes:[],highlights:[],areaFills:[],annotations:[],seriesOverrides:[],layout:{...rf}})}function y(x){Object.assign(t,{...x,layout:{...rf,...x.layout}})}return{chartType:n,data:o,colorizes:r,highlights:i,areaFills:s,annotations:a,seriesOverrides:l,title:c,description:u,byline:d,source:f,sourceUrl:h,note:g,sort:b,sortMode:m,layout:e.layout,selectedColumn:e.selectedColumn,_base:Oe(e),reset:v,hydrate:y}});function dn(){const t=Goe(),e=Ct(t);return{chartType:e.chartType,data:e.data,colorizes:e.colorizes,highlights:e.highlights,areaFills:e.areaFills,annotations:e.annotations,seriesOverrides:e.seriesOverrides,title:e.title,description:e.description,byline:e.byline,source:e.source,sourceUrl:e.sourceUrl,note:e.note,sort:e.sort,sortMode:e.sortMode,layout:e.layout,selectedColumn:e.selectedColumn,_base:t._base,reset:t.reset,hydrate:t.hydrate}}function qoe(t){const e=t.split(`
|
|
641
|
+
`)[0]??"",n=(e.match(/\t/g)??[]).length,o=(e.match(/,/g)??[]).length;return n>=o?" ":","}function xh(t,e){if(e===" ")return t.split(" ").map(i=>i.trim());const n=[];let o="",r=!1;for(let i=0;i<t.length;i++){const s=t[i];s==='"'?r&&t[i+1]==='"'?(o+='"',i++):r=!r:s===e&&!r?(n.push(o.trim()),o=""):o+=s}return n.push(o.trim()),n}const Yoe=[/^\d{4}-\d{2}-\d{2}$/,/^\d{4}-\d{2}$/,/^\d{4}$/,/^\d{1,2}\/\d{1,2}\/\d{2,4}$/,/^\d{1,2}-\d{1,2}-\d{2,4}$/,/^(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{1,2},?\s+\d{4}$/i,/^\d{4}\/\d{2}\/\d{2}$/,/^\d{4}\/\d{2}$/,/^Q[1-4]\s+\d{4}$/];function joe(t){if(!t)return!1;for(const e of Yoe)if(e.test(t))return/^\d{4}(-\d{2})?$/.test(t)||/^\d{4}\/\d{2}$/.test(t)||/^Q[1-4]\s+\d{4}$/.test(t)?!0:!Number.isNaN(Date.parse(t));return!1}function Z$(t){const e=t.match(/^[<>≤≥~]\s*(.+)$/);if(e){const n=e[1].replace(/[,%$€£¥₹]/g,"").trim();if(n.length>0&&!Number.isNaN(Number(n)))return e[1].trim()}return t}function Xoe(t){if(!t)return!1;const e=Z$(t).replace(/[,%$€£¥₹]/g,"").trim();return e.length>0&&!Number.isNaN(Number(e))}function Q1(t,e){return t.map((n,o)=>{const r=e.map(i=>i[o]??"").filter(i=>i.length>0);return r.length===0?"string":r.every(joe)?"date":r.every(Xoe)?"number":"string"})}function Q$(t){var s;const e=t.split(`
|
|
642
642
|
`).map(a=>a.trim()).filter(Boolean);if(e.length===0)return{columns:[],rows:[],columnTypes:[]};const n=(s=e[0])==null?void 0:s.match(/^_series\s*=\s*(.+)$/);if(n){const a=n[1].trim(),c=["label",...a.includes('","')?a.split(",").map(f=>f.trim().replace(/^"|"$/g,"")):a.replace(/^"|"$/g,"").split(",").map(f=>f.trim())],u=[];for(let f=1;f<e.length;f++){const h=e[f].match(/^"([^"]+)"\s*=\s*([^"]+)$/),b=e[f].match(/^"([^"]+)"\s*=\s*"([^"]*)"$/)??h;b&&u.push([b[1],...b[2].split(",").map(m=>m.trim())])}const d=Q1(c,u);return{columns:c,rows:u,columnTypes:d}}const o=["label","value"],r=[];for(const a of e){const l=a.match(/^"([^"]+)"\s*=\s*(.+)$/);l&&r.push([l[1],l[2].replace(/%$/,"").trim()])}const i=Q1(o,r);return{columns:o,rows:r,columnTypes:i}}function R6(t,e,n=" "){const o=s=>n===" "?s:s.includes(n)||s.includes('"')||s.includes(`
|
|
643
643
|
`)?`"${s.replace(/"/g,'""')}"`:s,r=t.map(o).join(n),i=e.map(s=>s.map(o).join(n));return[r,...i].join(`
|
|
644
644
|
`)}function J1(t,e){const n=e??{},o=n.trimWhitespace!==!1,r=t.split(`
|
|
645
|
-
`).filter(u=>u.trim().length>0);if(r.length===0)return{columns:[],rows:[],columnTypes:[]};const i=n.delimiter&&n.delimiter!=="auto"?n.delimiter:Uoe(t),s=n.firstRowIsHeader!==!1;let a,l;s?(a=xh(r[0],i),l=r.slice(1).map(u=>xh(u,i))):(a=xh(r[0],i).map((d,f)=>`Column ${f+1}`),l=r.map(d=>xh(d,i))),o&&(a=a.map(u=>u.trim()),l=l.map(u=>u.map(d=>d.trim()))),n.decimalSeparator===","&&(l=l.map(u=>u.map(d=>/^\d+,\d+$/.test(d)?d.replace(",","."):d))),l=l.map(u=>u.map(Z$));const c=Q1(a,l);return{columns:a,rows:l,columnTypes:c}}var Je=(t=>(t.Sort="sort",t.Filter="filter",t.HideColumns="hide-columns",t.Transpose="transpose",t.Parse="parse",t.Rename="rename",t.GroupBy="group-by",t.Computed="computed",t))(Je||{}),go=(t=>(t.Equals="equals",t.NotEquals="not-equals",t.Contains="contains",t.GreaterThan="greater-than",t.LessThan="less-than",t))(go||{}),Rt=(t=>(t.Type="type",t.String="string",t.Numeric="numeric",t.Date="date",t))(Rt||{});const Po=["string","number","date"],op=[{id:"to-number",label:"To Number",description:"Strip non-numeric characters and convert to number",category:Rt.Type,accepts:Po,outputType:"number"},{id:"to-string",label:"To String",description:"Keep value as plain text",category:Rt.Type,accepts:Po,outputType:"string"},{id:"to-date",label:"To Date",description:"Parse text into an ISO date",category:Rt.Type,accepts:Po,outputType:"date"},{id:"to-boolean",label:"To Boolean",description:"Map yes/no, true/false, 1/0 to boolean",category:Rt.Type,accepts:Po,outputType:"string"},{id:"parse-json",label:"Parse JSON",description:"Parse JSON string and optionally extract a key",category:Rt.Type,accepts:["string"],outputType:"string",params:["key"]},{id:"trim",label:"Trim",description:"Remove leading and trailing whitespace",category:Rt.String,accepts:Po,outputType:"string"},{id:"lowercase",label:"Lowercase",description:"Convert all characters to lowercase",category:Rt.String,accepts:Po,outputType:"string"},{id:"uppercase",label:"Uppercase",description:"Convert all characters to uppercase",category:Rt.String,accepts:Po,outputType:"string"},{id:"title-case",label:"Title Case",description:"Capitalize the first letter of each word",category:Rt.String,accepts:Po,outputType:"string"},{id:"slugify",label:"Slugify",description:"Lowercase and replace non-alphanumeric with hyphens",category:Rt.String,accepts:Po,outputType:"string"},{id:"regex-replace",label:"Regex Replace",description:"Find and replace using a regular expression",category:Rt.String,accepts:Po,outputType:"string",params:["pattern","replacement"]},{id:"extract",label:"Extract Substring",description:"Extract a portion of text by character position",category:Rt.String,accepts:Po,outputType:"string",params:["start","end"]},{id:"pad-start",label:"Pad Start",description:"Pad the beginning to a fixed length",category:Rt.String,accepts:Po,outputType:"string",params:["length","char"]},{id:"pad-end",label:"Pad End",description:"Pad the end to a fixed length",category:Rt.String,accepts:Po,outputType:"string",params:["length","char"]},{id:"remove-diacritics",label:"Remove Diacritics",description:"Strip accents and diacritical marks",category:Rt.String,accepts:Po,outputType:"string"},{id:"split",label:"Split into Columns",description:"Split values by a separator into new columns",category:Rt.String,accepts:Po,outputType:"string",params:["separator","limit"]},{id:"round",label:"Round",description:"Round to a number of decimal places",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["decimals"]},{id:"floor",label:"Floor",description:"Round down to the nearest integer",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"ceil",label:"Ceiling",description:"Round up to the nearest integer",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"abs",label:"Absolute Value",description:"Remove the sign (make positive)",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"clamp",label:"Clamp",description:"Constrain values between a min and max",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["min","max"]},{id:"log",label:"Logarithm",description:"Natural log — compress wide-range values for charting",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"exp",label:"Exponential",description:"Raise e to the power of each value",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"normalize",label:"Normalize (0–1)",description:"Scale values to 0–1 range for cross-series comparison",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"standardize",label:"Standardize (z-score)",description:"Center around mean, scale by std deviation",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"bin",label:"Bin/Bucket",description:"Group values into fixed-size buckets",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["size"]},{id:"extract-year",label:"Extract Year",description:"Get the four-digit year as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-month",label:"Extract Month",description:"Get the month (1–12) as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-day",label:"Extract Day",description:"Get the day of the month as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-weekday",label:"Extract Weekday",description:"Get the day name (Monday, Tuesday, …)",category:Rt.Date,accepts:["date"],outputType:"string"},{id:"extract-hour",label:"Extract Hour",description:"Get the hour (0–23) as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"shift-date",label:"Shift Date",description:"Add or subtract days, months, or years",category:Rt.Date,accepts:["date"],outputType:"date",params:["amount","unit"]},{id:"truncate-date",label:"Truncate to Period",description:"Round down to start of week, month, quarter, or year",category:Rt.Date,accepts:["date"],outputType:"date",params:["period"]},{id:"date-diff",label:"Duration Since",description:"Days between each date and a reference date",category:Rt.Date,accepts:["date"],outputType:"number",params:["reference"]}],P2=new Map(op.map(t=>[t.id,t]));function J$(t,e){const n=P2.get(t);return n?n.accepts.includes(e):!1}function joe(t){var e;return((e=P2.get(t))==null?void 0:e.outputType)??"string"}function da(t,e){const n=parseFloat(t);if(Number.isNaN(n))return t;const o=e(n);return Number.isNaN(o)?t:String(o)}function ws(t,e){const n=new Date(t);return Number.isNaN(n.getTime())?t:e(n)}function Xoe(t,e,n){switch(e){case"to-number":{const o=Number(t.replace(/[^0-9.\-+eE]/g,""));return Number.isNaN(o)?"":String(o)}case"to-string":return t;case"to-date":return ws(t,o=>o.toISOString());case"to-boolean":{const o=t.toLowerCase().trim();return["true","1","yes","on","y"].includes(o)?"true":["false","0","no","off","n",""].includes(o)?"false":t}case"parse-json":try{const o=JSON.parse(t);return n.key?String(o[n.key]??""):JSON.stringify(o)}catch{return t}default:return t}}function Koe(t,e,n){switch(e){case"trim":return t.trim();case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();case"title-case":return t.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase());case"slugify":return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");case"regex-replace":{if(!n.pattern)return t;try{return t.replace(new RegExp(n.pattern,"g"),n.replacement??"")}catch{return t}}case"extract":return t.slice(Number(n.start)||0,n.end?Number(n.end):void 0);case"pad-start":return t.padStart(Number(n.length)||0,n.char||" ");case"pad-end":return t.padEnd(Number(n.length)||0,n.char||" ");case"remove-diacritics":return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"");default:return t}}function Zoe(t,e,n){switch(e){case"round":{const r=10**(Number(n.decimals)||0);return da(t,i=>Math.round(i*r)/r)}case"floor":return da(t,Math.floor);case"ceil":return da(t,Math.ceil);case"abs":return da(t,Math.abs);case"clamp":{const o=n.min?Number(n.min):-1/0,r=n.max?Number(n.max):1/0;return da(t,i=>Math.min(Math.max(i,o),r))}case"log":return da(t,o=>o>0?Math.log(o):NaN);case"exp":return da(t,Math.exp);case"bin":{const o=Number(n.size)||1;return da(t,r=>Math.floor(r/o)*o)}default:return t}}function Qoe(t,e,n){switch(e){case"extract-year":return ws(t,o=>String(o.getFullYear()));case"extract-month":return ws(t,o=>String(o.getMonth()+1));case"extract-day":return ws(t,o=>String(o.getDate()));case"extract-weekday":return ws(t,o=>o.toLocaleDateString("en",{weekday:"long"}));case"extract-hour":return ws(t,o=>String(o.getHours()));case"shift-date":return ws(t,o=>{const r=Number(n.amount)||0,i=n.unit||"days";return i==="years"?o.setFullYear(o.getFullYear()+r):i==="months"?o.setMonth(o.getMonth()+r):o.setDate(o.getDate()+r),o.toISOString()});case"truncate-date":return ws(t,o=>{const r=n.period||"month";return r==="year"?new Date(o.getFullYear(),0,1).toISOString():r==="quarter"?new Date(o.getFullYear(),Math.floor(o.getMonth()/3)*3,1).toISOString():r==="month"?new Date(o.getFullYear(),o.getMonth(),1).toISOString():(r==="week"&&(o.setDate(o.getDate()-o.getDay()),o.setHours(0,0,0,0)),o.toISOString())});case"date-diff":{const o=new Date(n.reference||new Date().toISOString());return Number.isNaN(o.getTime())?t:ws(t,r=>String(Math.round((r.getTime()-o.getTime())/(1e3*60*60*24))))}default:return t}}function Joe(t,e,n){return e.startsWith("to-")||e==="parse-json"?Xoe(t,e,n):new Set(["round","floor","ceil","abs","clamp","log","exp","bin"]).has(e)?Zoe(t,e,n):e.startsWith("extract-")||e.startsWith("shift-")||e.startsWith("truncate-")||e==="date-diff"?Qoe(t,e,n):Koe(t,e,n)}const ere="";function tre(t,e){const n=t.rows.map(o=>{const r=[...o];return r[e]=ere,r});return{columns:[...t.columns],rows:n,columnTypes:[...t.columnTypes]}}function nre(t,e,n){const o=n.separator||",",r=n.limit?Number(n.limit):void 0;let i=0;const s=t.rows.map(d=>{const f=d[e].split(o),h=r?f.slice(0,r):f;return i=Math.max(i,h.length),h}),a=[...t.columns],l=[...t.columnTypes],c=[];for(let d=0;d<i;d++)c.push(`${n.column}_${d+1}`);a.splice(e,1,...c),l.splice(e,1,...Array(i).fill("string"));const u=t.rows.map((d,f)=>{const h=s[f],g=[...d],b=[...h,...Array(i-h.length).fill("")];return g.splice(e,1,...b),g});return{columns:a,rows:u,columnTypes:l}}function ore(t,e,n){const o=t.rows.map(s=>parseFloat(s[e])).filter(s=>!Number.isNaN(s));if(o.length===0)return t;const r=t.rows.map(s=>[...s]),i=[...t.columnTypes];if(i[e]="number",n==="normalize"){const s=Math.min(...o),l=Math.max(...o)-s;for(const c of r){const u=parseFloat(c[e]);c[e]=Number.isNaN(u)?c[e]:String(l===0?0:(u-s)/l)}}else{const s=o.reduce((c,u)=>c+u,0)/o.length,a=o.reduce((c,u)=>c+(u-s)**2,0)/o.length,l=Math.sqrt(a);for(const c of r){const u=parseFloat(c[e]);c[e]=Number.isNaN(u)?c[e]:String(l===0?0:(u-s)/l)}}return{columns:[...t.columns],rows:r,columnTypes:i}}function rre(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column||!e.operation)return t;const o=e.operation,r=t.columnTypes[n];if(!J$(o,r))return tre(t,n);if(o==="split")return nre(t,n,e);if(o==="normalize"||o==="standardize")return ore(t,n,o);const i=t.rows.map(a=>[...a]);for(const a of i)a[n]=Joe(a[n],o,e);const s=[...t.columnTypes];return s[n]=joe(o),{columns:[...t.columns],rows:i,columnTypes:s}}function sf(t){return Number(t.replace(/[,%$€£¥₹]/g,"").trim())||0}function ire(t,e,n){if(n==="number")return sf(t)-sf(e);if(n==="date"){const o=Date.parse(t)||0,r=Date.parse(e)||0;return o-r}return t.localeCompare(e)}function D2(t){return t.columns?t.columns.split(",").map(e=>e.trim()).filter(Boolean):t.column?[t.column]:[]}function sre(t,e){const n=D2(e);if(n.length===0)return t;const o=n.map(a=>t.columns.indexOf(a)).filter(a=>a>=0);if(o.length===0)return t;const r=e.direction===Zt.Descending?-1:1,i=e.operation;if(i&&o.length>1){const a=[...t.rows].sort((l,c)=>{const u=o.map(g=>sf(l[g]??"")),d=o.map(g=>sf(c[g]??""));let f,h;return i==="avg"?(f=u.reduce((g,b)=>g+b,0)/u.length,h=d.reduce((g,b)=>g+b,0)/d.length):(f=u.reduce((g,b)=>g+b,0),h=d.reduce((g,b)=>g+b,0)),r*(f-h)});return{...t,rows:a}}const s=[...t.rows].sort((a,l)=>{for(const c of o){const u=t.columnTypes[c]??"string",d=ire(a[c]??"",l[c]??"",u);if(d!==0)return r*d}return 0});return{...t,rows:s}}function are(t,e,n){if(!n&&e!==go.Equals&&e!==go.NotEquals)return!0;switch(e){case go.Equals:return t===n;case go.NotEquals:return t!==n;case go.Contains:return t.toLowerCase().includes(n.toLowerCase());case go.GreaterThan:{const o=Number(t.replace(/[,%$€£¥₹]/g,"").trim()),r=Number(n);return!Number.isNaN(o)&&!Number.isNaN(r)&&o>r}case go.LessThan:{const o=Number(t.replace(/[,%$€£¥₹]/g,"").trim()),r=Number(n);return!Number.isNaN(o)&&!Number.isNaN(r)&&o<r}default:return!0}}function lre(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column)return t;const o=t.rows.filter(r=>are(r[n]??"",e.condition??go.Equals,e.value??""));return{...t,rows:o}}function cre(t,e){const n=D2(e);if(n.length===0)return t;const o=t.columns.map((r,i)=>n.includes(r)?-1:i).filter(r=>r>=0);return o.length===t.columns.length?t:{columns:o.map(r=>t.columns[r]),rows:t.rows.map(r=>o.map(i=>r[i])),columnTypes:o.map(r=>t.columnTypes[r])}}function ure(t){if(t.rows.length===0||t.columns.length===0)return t;const e=["Field",...t.rows.map(r=>r[0]??"")],n=[],o=["string"];for(let r=1;r<t.columns.length;r++){const i=[t.columns[r]];for(let s=0;s<t.rows.length;s++)i.push(t.rows[s][r]??"");n.push(i)}for(let r=0;r<t.rows.length;r++){const i=n.map(s=>s[r+1]??"").filter(s=>s.length>0);i.length>0&&i.every(s=>!Number.isNaN(Number(s.replace(/[,%$€£¥₹]/g,"").trim()))&&s.trim().length>0)?o.push("number"):o.push("string")}return{columns:e,rows:n,columnTypes:o}}function dre(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column||!e.newName)return t;const o=[...t.columns];return o[n]=e.newName,{...t,columns:o}}const eT={sum:t=>t.reduce((e,n)=>e+n,0),avg:t=>t.reduce((e,n)=>e+n,0)/t.length,min:t=>Math.min(...t),max:t=>Math.max(...t)};function fre(t,e){return t.split(",").map(n=>n.trim()).filter(Boolean).map(n=>{const o=n.lastIndexOf(":");if(o<0)return null;const r=n.slice(0,o),i=n.slice(o+1);if(i!=="count"&&!eT[i])return null;const s=i==="count"?-1:e.indexOf(r);return i!=="count"&&s<0?null:{col:r,fn:i,colIndex:s}}).filter(n=>n!==null)}function hre(t,e,n){if(t==="count")return String(e.length);const o=e.map(r=>sf(r[n]??""));return String(eT[t](o))}function pre(t,e){const n=D2({columns:e.groupColumns}).map(i=>t.columns.indexOf(i)).filter(i=>i>=0);if(n.length===0||!e.aggregates)return t;const o=fre(e.aggregates,t.columns);if(o.length===0)return t;const r=new Map;for(const i of t.rows){const s=n.map(c=>i[c]??""),a=s.join("\0"),l=r.get(a);l?l.rows.push(i):r.set(a,{key:s,rows:[i]})}return{columns:[...n.map(i=>t.columns[i]),...o.map(i=>`${i.col}_${i.fn}`)],columnTypes:[...n.map(i=>t.columnTypes[i]),...o.map(()=>"number")],rows:[...r.values()].map(({key:i,rows:s})=>[...i,...o.map(a=>hre(a.fn,s,a.colIndex))])}}const mre=Oo("dataTransforms",()=>{const t=Ve([]);let e=1;function n(h,g={}){const b=String(e++);return t.value.push({id:b,type:h,config:g}),b}function o(h){const g=t.value.findIndex(b=>b.id===h);g>=0&&t.value.splice(g,1)}function r(h,g){const b=t.value.find(m=>m.id===h);b&&(b.config={...g})}function i(h,g){const b=t.value.findIndex(v=>v.id===h);if(b<0||g<0||g>=t.value.length)return;const[m]=t.value.splice(b,1);t.value.splice(g,0,m)}function s(h,g,b,m){let v={columns:[...g],rows:b.map(y=>[...y]),columnTypes:[...m]};for(const y of h)switch(y.type){case Je.Sort:v=sre(v,y.config);break;case Je.Filter:v=lre(v,y.config);break;case Je.HideColumns:v=cre(v,y.config);break;case Je.Transpose:v=ure(v);break;case Je.Parse:v=rre(v,y.config);break;case Je.Rename:v=dre(v,y.config);break;case Je.GroupBy:v=pre(v,y.config);break}return v}function a(h,g,b){return s(t.value,h,g,b)}function l(h,g,b,m){const v=t.value.slice(0,h);return s(v,g,b,m)}function c(h,g,b){const{config:m}=h;if(m.column&&!g.includes(m.column))return`Column "${m.column}" not found`;if(h.type===Je.Parse&&m.column&&m.operation){const v=g.indexOf(m.column);if(v>=0&&!J$(m.operation,b[v])){const y=P2.get(m.operation);return`${(y==null?void 0:y.label)??m.operation} requires ${y==null?void 0:y.accepts.join(" or ")} column, got ${b[v]}`}}return h.type===Je.Rename?m.column?m.newName?null:"New name is required":"No column selected":h.type===Je.Filter&&!m.column||h.type===Je.Sort&&!m.column&&!m.columns?"No column selected":h.type===Je.GroupBy?m.groupColumns?m.aggregates?null:"No aggregates defined":"No group columns selected":null}function u(){t.value=[],e=1}function d(h){t.value=h.map(g=>({...g,config:{...g.config}})),e=h.reduce((g,b)=>Math.max(g,Number(b.id)||0),0)+1}function f(){return t.value.map(h=>({id:h.id,type:h.type,config:{...h.config}}))}return{steps:t,addStep:n,removeStep:o,updateStep:r,moveStep:i,applyStepList:s,applyTransforms:a,getColumnsAtStep:l,validateStep:c,reset:u,hydrate:d,snapshot:f}});function Lr(){const t=mre(),{steps:e}=Ct(t);return{steps:e,addStep:t.addStep,removeStep:t.removeStep,updateStep:t.updateStep,moveStep:t.moveStep,applyStepList:t.applyStepList,applyTransforms:t.applyTransforms,getColumnsAtStep:t.getColumnsAtStep,validateStep:t.validateStep,reset:t.reset,hydrate:t.hydrate,snapshot:t.snapshot}}function Ra(t,e){if(e<0||e>=t.length)return null;const n={id:t[e].id,name:t[e].name},o=new Set;for(let r=0;r<=e;r++){const i=t[r];if(i.chartType!==void 0&&(n.chartType=i.chartType),i.data!==void 0&&(n.data=i.data),i.chartTypeOptions!==void 0&&(n.chartTypeOptions=n.chartTypeOptions?{...n.chartTypeOptions,...i.chartTypeOptions}:{...i.chartTypeOptions}),i.colorizes!==void 0&&i.colorizes.length>0?n.colorizes=i.colorizes:i.data!==void 0&&(n.colorizes=[]),r===e&&(n.highlights=i.highlights),i.areaFills!==void 0&&i.areaFills.length>0&&(n.areaFills=i.areaFills),i.annotations!==void 0&&i.annotations.length>0&&(n.annotations=i.annotations),i.annotationVisibility)for(const s of i.annotationVisibility)s.action==="hide"?o.add(s.id):o.delete(s.id);i.seriesOverrides!==void 0&&i.seriesOverrides.length>0&&(n.seriesOverrides=i.seriesOverrides),i.transforms!==void 0&&(n.transforms=i.transforms),i.properties!==void 0&&(n.properties=n.properties?{...n.properties,...i.properties}:{...i.properties})}return o.size>0&&(n.hiddenAnnotationIds=o),n}function tT(t,e){var n;if(e<0||e>=t.length)return-1;for(let o=e;o>=0;o--)if(((n=t[o])==null?void 0:n.data)!==void 0)return o;return-1}function nT(t){var e,n;if((e=t==null?void 0:t.transforms)!=null&&e.length){for(let o=t.transforms.length-1;o>=0;o--)if(t.transforms[o].type===Je.Sort)return((n=t.transforms[o].config)==null?void 0:n.direction)??Zt.Ascending}}function F6(t){return/^-?\d+(\.\d+)?%?$/.test(t)?t:`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function cg(t,e){if(t.length<=2)return e.map(i=>{const s=i[0]??"",a=i[1]??"";return`"${s}" = ${F6(a)}`}).join(`
|
|
645
|
+
`).filter(u=>u.trim().length>0);if(r.length===0)return{columns:[],rows:[],columnTypes:[]};const i=n.delimiter&&n.delimiter!=="auto"?n.delimiter:qoe(t),s=n.firstRowIsHeader!==!1;let a,l;s?(a=xh(r[0],i),l=r.slice(1).map(u=>xh(u,i))):(a=xh(r[0],i).map((d,f)=>`Column ${f+1}`),l=r.map(d=>xh(d,i))),o&&(a=a.map(u=>u.trim()),l=l.map(u=>u.map(d=>d.trim()))),n.decimalSeparator===","&&(l=l.map(u=>u.map(d=>/^\d+,\d+$/.test(d)?d.replace(",","."):d))),l=l.map(u=>u.map(Z$));const c=Q1(a,l);return{columns:a,rows:l,columnTypes:c}}var Je=(t=>(t.Sort="sort",t.Filter="filter",t.HideColumns="hide-columns",t.Transpose="transpose",t.Parse="parse",t.Rename="rename",t.GroupBy="group-by",t.Computed="computed",t))(Je||{}),go=(t=>(t.Equals="equals",t.NotEquals="not-equals",t.Contains="contains",t.GreaterThan="greater-than",t.LessThan="less-than",t))(go||{}),Rt=(t=>(t.Type="type",t.String="string",t.Numeric="numeric",t.Date="date",t))(Rt||{});const Po=["string","number","date"],op=[{id:"to-number",label:"To Number",description:"Strip non-numeric characters and convert to number",category:Rt.Type,accepts:Po,outputType:"number"},{id:"to-string",label:"To String",description:"Keep value as plain text",category:Rt.Type,accepts:Po,outputType:"string"},{id:"to-date",label:"To Date",description:"Parse text into an ISO date",category:Rt.Type,accepts:Po,outputType:"date"},{id:"to-boolean",label:"To Boolean",description:"Map yes/no, true/false, 1/0 to boolean",category:Rt.Type,accepts:Po,outputType:"string"},{id:"parse-json",label:"Parse JSON",description:"Parse JSON string and optionally extract a key",category:Rt.Type,accepts:["string"],outputType:"string",params:["key"]},{id:"trim",label:"Trim",description:"Remove leading and trailing whitespace",category:Rt.String,accepts:Po,outputType:"string"},{id:"lowercase",label:"Lowercase",description:"Convert all characters to lowercase",category:Rt.String,accepts:Po,outputType:"string"},{id:"uppercase",label:"Uppercase",description:"Convert all characters to uppercase",category:Rt.String,accepts:Po,outputType:"string"},{id:"title-case",label:"Title Case",description:"Capitalize the first letter of each word",category:Rt.String,accepts:Po,outputType:"string"},{id:"slugify",label:"Slugify",description:"Lowercase and replace non-alphanumeric with hyphens",category:Rt.String,accepts:Po,outputType:"string"},{id:"regex-replace",label:"Regex Replace",description:"Find and replace using a regular expression",category:Rt.String,accepts:Po,outputType:"string",params:["pattern","replacement"]},{id:"extract",label:"Extract Substring",description:"Extract a portion of text by character position",category:Rt.String,accepts:Po,outputType:"string",params:["start","end"]},{id:"pad-start",label:"Pad Start",description:"Pad the beginning to a fixed length",category:Rt.String,accepts:Po,outputType:"string",params:["length","char"]},{id:"pad-end",label:"Pad End",description:"Pad the end to a fixed length",category:Rt.String,accepts:Po,outputType:"string",params:["length","char"]},{id:"remove-diacritics",label:"Remove Diacritics",description:"Strip accents and diacritical marks",category:Rt.String,accepts:Po,outputType:"string"},{id:"split",label:"Split into Columns",description:"Split values by a separator into new columns",category:Rt.String,accepts:Po,outputType:"string",params:["separator","limit"]},{id:"round",label:"Round",description:"Round to a number of decimal places",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["decimals"]},{id:"floor",label:"Floor",description:"Round down to the nearest integer",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"ceil",label:"Ceiling",description:"Round up to the nearest integer",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"abs",label:"Absolute Value",description:"Remove the sign (make positive)",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"clamp",label:"Clamp",description:"Constrain values between a min and max",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["min","max"]},{id:"log",label:"Logarithm",description:"Natural log — compress wide-range values for charting",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"exp",label:"Exponential",description:"Raise e to the power of each value",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"normalize",label:"Normalize (0–1)",description:"Scale values to 0–1 range for cross-series comparison",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"standardize",label:"Standardize (z-score)",description:"Center around mean, scale by std deviation",category:Rt.Numeric,accepts:["number"],outputType:"number"},{id:"bin",label:"Bin/Bucket",description:"Group values into fixed-size buckets",category:Rt.Numeric,accepts:["number"],outputType:"number",params:["size"]},{id:"extract-year",label:"Extract Year",description:"Get the four-digit year as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-month",label:"Extract Month",description:"Get the month (1–12) as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-day",label:"Extract Day",description:"Get the day of the month as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"extract-weekday",label:"Extract Weekday",description:"Get the day name (Monday, Tuesday, …)",category:Rt.Date,accepts:["date"],outputType:"string"},{id:"extract-hour",label:"Extract Hour",description:"Get the hour (0–23) as a number",category:Rt.Date,accepts:["date"],outputType:"number"},{id:"shift-date",label:"Shift Date",description:"Add or subtract days, months, or years",category:Rt.Date,accepts:["date"],outputType:"date",params:["amount","unit"]},{id:"truncate-date",label:"Truncate to Period",description:"Round down to start of week, month, quarter, or year",category:Rt.Date,accepts:["date"],outputType:"date",params:["period"]},{id:"date-diff",label:"Duration Since",description:"Days between each date and a reference date",category:Rt.Date,accepts:["date"],outputType:"number",params:["reference"]}],P2=new Map(op.map(t=>[t.id,t]));function J$(t,e){const n=P2.get(t);return n?n.accepts.includes(e):!1}function Koe(t){var e;return((e=P2.get(t))==null?void 0:e.outputType)??"string"}function da(t,e){const n=parseFloat(t);if(Number.isNaN(n))return t;const o=e(n);return Number.isNaN(o)?t:String(o)}function ws(t,e){const n=new Date(t);return Number.isNaN(n.getTime())?t:e(n)}function Zoe(t,e,n){switch(e){case"to-number":{const o=Number(t.replace(/[^0-9.\-+eE]/g,""));return Number.isNaN(o)?"":String(o)}case"to-string":return t;case"to-date":return ws(t,o=>o.toISOString());case"to-boolean":{const o=t.toLowerCase().trim();return["true","1","yes","on","y"].includes(o)?"true":["false","0","no","off","n",""].includes(o)?"false":t}case"parse-json":try{const o=JSON.parse(t);return n.key?String(o[n.key]??""):JSON.stringify(o)}catch{return t}default:return t}}function Qoe(t,e,n){switch(e){case"trim":return t.trim();case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();case"title-case":return t.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase());case"slugify":return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");case"regex-replace":{if(!n.pattern)return t;try{return t.replace(new RegExp(n.pattern,"g"),n.replacement??"")}catch{return t}}case"extract":return t.slice(Number(n.start)||0,n.end?Number(n.end):void 0);case"pad-start":return t.padStart(Number(n.length)||0,n.char||" ");case"pad-end":return t.padEnd(Number(n.length)||0,n.char||" ");case"remove-diacritics":return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"");default:return t}}function Joe(t,e,n){switch(e){case"round":{const r=10**(Number(n.decimals)||0);return da(t,i=>Math.round(i*r)/r)}case"floor":return da(t,Math.floor);case"ceil":return da(t,Math.ceil);case"abs":return da(t,Math.abs);case"clamp":{const o=n.min?Number(n.min):-1/0,r=n.max?Number(n.max):1/0;return da(t,i=>Math.min(Math.max(i,o),r))}case"log":return da(t,o=>o>0?Math.log(o):NaN);case"exp":return da(t,Math.exp);case"bin":{const o=Number(n.size)||1;return da(t,r=>Math.floor(r/o)*o)}default:return t}}function ere(t,e,n){switch(e){case"extract-year":return ws(t,o=>String(o.getFullYear()));case"extract-month":return ws(t,o=>String(o.getMonth()+1));case"extract-day":return ws(t,o=>String(o.getDate()));case"extract-weekday":return ws(t,o=>o.toLocaleDateString("en",{weekday:"long"}));case"extract-hour":return ws(t,o=>String(o.getHours()));case"shift-date":return ws(t,o=>{const r=Number(n.amount)||0,i=n.unit||"days";return i==="years"?o.setFullYear(o.getFullYear()+r):i==="months"?o.setMonth(o.getMonth()+r):o.setDate(o.getDate()+r),o.toISOString()});case"truncate-date":return ws(t,o=>{const r=n.period||"month";return r==="year"?new Date(o.getFullYear(),0,1).toISOString():r==="quarter"?new Date(o.getFullYear(),Math.floor(o.getMonth()/3)*3,1).toISOString():r==="month"?new Date(o.getFullYear(),o.getMonth(),1).toISOString():(r==="week"&&(o.setDate(o.getDate()-o.getDay()),o.setHours(0,0,0,0)),o.toISOString())});case"date-diff":{const o=new Date(n.reference||new Date().toISOString());return Number.isNaN(o.getTime())?t:ws(t,r=>String(Math.round((r.getTime()-o.getTime())/(1e3*60*60*24))))}default:return t}}function tre(t,e,n){return e.startsWith("to-")||e==="parse-json"?Zoe(t,e,n):new Set(["round","floor","ceil","abs","clamp","log","exp","bin"]).has(e)?Joe(t,e,n):e.startsWith("extract-")||e.startsWith("shift-")||e.startsWith("truncate-")||e==="date-diff"?ere(t,e,n):Qoe(t,e,n)}const nre="";function ore(t,e){const n=t.rows.map(o=>{const r=[...o];return r[e]=nre,r});return{columns:[...t.columns],rows:n,columnTypes:[...t.columnTypes]}}function rre(t,e,n){const o=n.separator||",",r=n.limit?Number(n.limit):void 0;let i=0;const s=t.rows.map(d=>{const f=d[e].split(o),h=r?f.slice(0,r):f;return i=Math.max(i,h.length),h}),a=[...t.columns],l=[...t.columnTypes],c=[];for(let d=0;d<i;d++)c.push(`${n.column}_${d+1}`);a.splice(e,1,...c),l.splice(e,1,...Array(i).fill("string"));const u=t.rows.map((d,f)=>{const h=s[f],g=[...d],b=[...h,...Array(i-h.length).fill("")];return g.splice(e,1,...b),g});return{columns:a,rows:u,columnTypes:l}}function ire(t,e,n){const o=t.rows.map(s=>parseFloat(s[e])).filter(s=>!Number.isNaN(s));if(o.length===0)return t;const r=t.rows.map(s=>[...s]),i=[...t.columnTypes];if(i[e]="number",n==="normalize"){const s=Math.min(...o),l=Math.max(...o)-s;for(const c of r){const u=parseFloat(c[e]);c[e]=Number.isNaN(u)?c[e]:String(l===0?0:(u-s)/l)}}else{const s=o.reduce((c,u)=>c+u,0)/o.length,a=o.reduce((c,u)=>c+(u-s)**2,0)/o.length,l=Math.sqrt(a);for(const c of r){const u=parseFloat(c[e]);c[e]=Number.isNaN(u)?c[e]:String(l===0?0:(u-s)/l)}}return{columns:[...t.columns],rows:r,columnTypes:i}}function sre(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column||!e.operation)return t;const o=e.operation,r=t.columnTypes[n];if(!J$(o,r))return ore(t,n);if(o==="split")return rre(t,n,e);if(o==="normalize"||o==="standardize")return ire(t,n,o);const i=t.rows.map(a=>[...a]);for(const a of i)a[n]=tre(a[n],o,e);const s=[...t.columnTypes];return s[n]=Koe(o),{columns:[...t.columns],rows:i,columnTypes:s}}function sf(t){return Number(t.replace(/[,%$€£¥₹]/g,"").trim())||0}function are(t,e,n){if(n==="number")return sf(t)-sf(e);if(n==="date"){const o=Date.parse(t)||0,r=Date.parse(e)||0;return o-r}return t.localeCompare(e)}function D2(t){return t.columns?t.columns.split(",").map(e=>e.trim()).filter(Boolean):t.column?[t.column]:[]}function lre(t,e){const n=D2(e);if(n.length===0)return t;const o=n.map(a=>t.columns.indexOf(a)).filter(a=>a>=0);if(o.length===0)return t;const r=e.direction===Zt.Descending?-1:1,i=e.operation;if(i&&o.length>1){const a=[...t.rows].sort((l,c)=>{const u=o.map(g=>sf(l[g]??"")),d=o.map(g=>sf(c[g]??""));let f,h;return i==="avg"?(f=u.reduce((g,b)=>g+b,0)/u.length,h=d.reduce((g,b)=>g+b,0)/d.length):(f=u.reduce((g,b)=>g+b,0),h=d.reduce((g,b)=>g+b,0)),r*(f-h)});return{...t,rows:a}}const s=[...t.rows].sort((a,l)=>{for(const c of o){const u=t.columnTypes[c]??"string",d=are(a[c]??"",l[c]??"",u);if(d!==0)return r*d}return 0});return{...t,rows:s}}function cre(t,e,n){if(!n&&e!==go.Equals&&e!==go.NotEquals)return!0;switch(e){case go.Equals:return t===n;case go.NotEquals:return t!==n;case go.Contains:return t.toLowerCase().includes(n.toLowerCase());case go.GreaterThan:{const o=Number(t.replace(/[,%$€£¥₹]/g,"").trim()),r=Number(n);return!Number.isNaN(o)&&!Number.isNaN(r)&&o>r}case go.LessThan:{const o=Number(t.replace(/[,%$€£¥₹]/g,"").trim()),r=Number(n);return!Number.isNaN(o)&&!Number.isNaN(r)&&o<r}default:return!0}}function ure(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column)return t;const o=t.rows.filter(r=>cre(r[n]??"",e.condition??go.Equals,e.value??""));return{...t,rows:o}}function dre(t,e){const n=D2(e);if(n.length===0)return t;const o=t.columns.map((r,i)=>n.includes(r)?-1:i).filter(r=>r>=0);return o.length===t.columns.length?t:{columns:o.map(r=>t.columns[r]),rows:t.rows.map(r=>o.map(i=>r[i])),columnTypes:o.map(r=>t.columnTypes[r])}}function fre(t){if(t.rows.length===0||t.columns.length===0)return t;const e=["Field",...t.rows.map(r=>r[0]??"")],n=[],o=["string"];for(let r=1;r<t.columns.length;r++){const i=[t.columns[r]];for(let s=0;s<t.rows.length;s++)i.push(t.rows[s][r]??"");n.push(i)}for(let r=0;r<t.rows.length;r++){const i=n.map(s=>s[r+1]??"").filter(s=>s.length>0);i.length>0&&i.every(s=>!Number.isNaN(Number(s.replace(/[,%$€£¥₹]/g,"").trim()))&&s.trim().length>0)?o.push("number"):o.push("string")}return{columns:e,rows:n,columnTypes:o}}function hre(t,e){const n=t.columns.indexOf(e.column);if(n<0||!e.column||!e.newName)return t;const o=[...t.columns];return o[n]=e.newName,{...t,columns:o}}const eT={sum:t=>t.reduce((e,n)=>e+n,0),avg:t=>t.reduce((e,n)=>e+n,0)/t.length,min:t=>Math.min(...t),max:t=>Math.max(...t)};function pre(t,e){return t.split(",").map(n=>n.trim()).filter(Boolean).map(n=>{const o=n.lastIndexOf(":");if(o<0)return null;const r=n.slice(0,o),i=n.slice(o+1);if(i!=="count"&&!eT[i])return null;const s=i==="count"?-1:e.indexOf(r);return i!=="count"&&s<0?null:{col:r,fn:i,colIndex:s}}).filter(n=>n!==null)}function mre(t,e,n){if(t==="count")return String(e.length);const o=e.map(r=>sf(r[n]??""));return String(eT[t](o))}function gre(t,e){const n=D2({columns:e.groupColumns}).map(i=>t.columns.indexOf(i)).filter(i=>i>=0);if(n.length===0||!e.aggregates)return t;const o=pre(e.aggregates,t.columns);if(o.length===0)return t;const r=new Map;for(const i of t.rows){const s=n.map(c=>i[c]??""),a=s.join("\0"),l=r.get(a);l?l.rows.push(i):r.set(a,{key:s,rows:[i]})}return{columns:[...n.map(i=>t.columns[i]),...o.map(i=>`${i.col}_${i.fn}`)],columnTypes:[...n.map(i=>t.columnTypes[i]),...o.map(()=>"number")],rows:[...r.values()].map(({key:i,rows:s})=>[...i,...o.map(a=>mre(a.fn,s,a.colIndex))])}}const vre=Oo("dataTransforms",()=>{const t=Ve([]);let e=1;function n(h,g={}){const b=String(e++);return t.value.push({id:b,type:h,config:g}),b}function o(h){const g=t.value.findIndex(b=>b.id===h);g>=0&&t.value.splice(g,1)}function r(h,g){const b=t.value.find(m=>m.id===h);b&&(b.config={...g})}function i(h,g){const b=t.value.findIndex(v=>v.id===h);if(b<0||g<0||g>=t.value.length)return;const[m]=t.value.splice(b,1);t.value.splice(g,0,m)}function s(h,g,b,m){let v={columns:[...g],rows:b.map(y=>[...y]),columnTypes:[...m]};for(const y of h)switch(y.type){case Je.Sort:v=lre(v,y.config);break;case Je.Filter:v=ure(v,y.config);break;case Je.HideColumns:v=dre(v,y.config);break;case Je.Transpose:v=fre(v);break;case Je.Parse:v=sre(v,y.config);break;case Je.Rename:v=hre(v,y.config);break;case Je.GroupBy:v=gre(v,y.config);break}return v}function a(h,g,b){return s(t.value,h,g,b)}function l(h,g,b,m){const v=t.value.slice(0,h);return s(v,g,b,m)}function c(h,g,b){const{config:m}=h;if(m.column&&!g.includes(m.column))return`Column "${m.column}" not found`;if(h.type===Je.Parse&&m.column&&m.operation){const v=g.indexOf(m.column);if(v>=0&&!J$(m.operation,b[v])){const y=P2.get(m.operation);return`${(y==null?void 0:y.label)??m.operation} requires ${y==null?void 0:y.accepts.join(" or ")} column, got ${b[v]}`}}return h.type===Je.Rename?m.column?m.newName?null:"New name is required":"No column selected":h.type===Je.Filter&&!m.column||h.type===Je.Sort&&!m.column&&!m.columns?"No column selected":h.type===Je.GroupBy?m.groupColumns?m.aggregates?null:"No aggregates defined":"No group columns selected":null}function u(){t.value=[],e=1}function d(h){t.value=h.map(g=>({...g,config:{...g.config}})),e=h.reduce((g,b)=>Math.max(g,Number(b.id)||0),0)+1}function f(){return t.value.map(h=>({id:h.id,type:h.type,config:{...h.config}}))}return{steps:t,addStep:n,removeStep:o,updateStep:r,moveStep:i,applyStepList:s,applyTransforms:a,getColumnsAtStep:l,validateStep:c,reset:u,hydrate:d,snapshot:f}});function Lr(){const t=vre(),{steps:e}=Ct(t);return{steps:e,addStep:t.addStep,removeStep:t.removeStep,updateStep:t.updateStep,moveStep:t.moveStep,applyStepList:t.applyStepList,applyTransforms:t.applyTransforms,getColumnsAtStep:t.getColumnsAtStep,validateStep:t.validateStep,reset:t.reset,hydrate:t.hydrate,snapshot:t.snapshot}}function Ra(t,e){if(e<0||e>=t.length)return null;const n={id:t[e].id,name:t[e].name},o=new Set;for(let r=0;r<=e;r++){const i=t[r];if(i.chartType!==void 0&&(n.chartType=i.chartType),i.data!==void 0&&(n.data=i.data),i.chartTypeOptions!==void 0&&(n.chartTypeOptions=n.chartTypeOptions?{...n.chartTypeOptions,...i.chartTypeOptions}:{...i.chartTypeOptions}),i.colorizes!==void 0&&i.colorizes.length>0?n.colorizes=i.colorizes:i.data!==void 0&&(n.colorizes=[]),r===e&&(n.highlights=i.highlights),i.areaFills!==void 0&&i.areaFills.length>0&&(n.areaFills=i.areaFills),i.annotations!==void 0&&i.annotations.length>0&&(n.annotations=i.annotations),i.annotationVisibility)for(const s of i.annotationVisibility)s.action==="hide"?o.add(s.id):o.delete(s.id);i.seriesOverrides!==void 0&&i.seriesOverrides.length>0&&(n.seriesOverrides=i.seriesOverrides),i.transforms!==void 0&&(n.transforms=i.transforms),i.properties!==void 0&&(n.properties=n.properties?{...n.properties,...i.properties}:{...i.properties})}return o.size>0&&(n.hiddenAnnotationIds=o),n}function tT(t,e){var n;if(e<0||e>=t.length)return-1;for(let o=e;o>=0;o--)if(((n=t[o])==null?void 0:n.data)!==void 0)return o;return-1}function nT(t){var e,n;if((e=t==null?void 0:t.transforms)!=null&&e.length){for(let o=t.transforms.length-1;o>=0;o--)if(t.transforms[o].type===Je.Sort)return((n=t.transforms[o].config)==null?void 0:n.direction)??Zt.Ascending}}function F6(t){return/^-?\d+(\.\d+)?%?$/.test(t)?t:`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function cg(t,e){if(t.length<=2)return e.map(i=>{const s=i[0]??"",a=i[1]??"";return`"${s}" = ${F6(a)}`}).join(`
|
|
646
646
|
`);const o=`_series = ${t.slice(1).map(i=>`"${i}"`).join(",")}`,r=e.map(i=>{const s=i[0]??"",a=i.slice(1).map(l=>F6(l??"")).join(",");return`"${s}" = ${a}`});return[o,...r].join(`
|
|
647
|
-
`)}const
|
|
647
|
+
`)}const bre=Oo("dataTable",()=>{const t=ir({columns:[],rows:[],rawInput:"",columnTypes:[]}),e=Ie("delimited"),n=Ie(""),o=Ie(null),{steps:r,applyTransforms:i,applyStepList:s}=Lr(),{activeIndex:a,scenes:l}=wn(),c=A(()=>{var k;if(a.value>=0){const E=Ra(l.value,a.value);if(E!=null&&E.data)return Q$(E.data)}let _={columns:t.columns,rows:t.rows,columnTypes:t.columnTypes};if(r.value.length>0&&(_=i(t.columns,t.rows,t.columnTypes)),a.value>=0&&_.columns.length>0){const E=Ra(l.value,a.value);(k=E==null?void 0:E.transforms)!=null&&k.length&&(_=s(E.transforms,_.columns,_.rows,_.columnTypes))}return _}),u=A(()=>c.value.columns),d=A(()=>c.value.rows),f=A(()=>c.value.columnTypes),h=A(()=>r.value.length>0);function g(_,k){t.columns=[..._.columns],t.rows=_.rows.map(E=>[...E]),t.columnTypes=_.columnTypes?[..._.columnTypes]:_.columns.map(()=>"string"),o.value=Date.now(),k!=null&&k.label&&(n.value=k.label)}function b(_,k){_>=0&&_<t.columns.length&&(t.columns[_]=k)}function m(_,k){_>=0&&_<t.columnTypes.length&&(t.columnTypes[_]=k)}function v(){return cg(u.value,d.value)}function y(){t.columns=[],t.rows=[],t.rawInput="",t.columnTypes=[],n.value="",o.value=null}function x(_){t.columns=_.columns,t.rows=_.rows,t.rawInput=_.rawInput,t.columnTypes=_.columnTypes??_.columns.map(()=>"string")}return{...K0(t),sourceFormat:e,sourceLabel:n,loadedAt:o,displayColumns:u,displayRows:d,displayColumnTypes:f,hasTransforms:h,loadParsed:g,renameColumn:b,setColumnType:m,serialize:v,reset:y,hydrate:x}});function jo(){const t=bre(),{columns:e,rows:n,rawInput:o,columnTypes:r,sourceFormat:i,sourceLabel:s,loadedAt:a,displayColumns:l,displayRows:c,displayColumnTypes:u,hasTransforms:d}=Ct(t);return{columns:e,rows:n,rawInput:o,columnTypes:r,sourceFormat:i,sourceLabel:s,loadedAt:a,displayColumns:l,displayRows:c,displayColumnTypes:u,hasTransforms:d,loadParsed:t.loadParsed,renameColumn:t.renameColumn,setColumnType:t.setColumnType,serialize:t.serialize,reset:t.reset,hydrate:t.hydrate}}const yre=Oo("chartTypeOptions",()=>{const t=ir({});function e(d){G$(d),t[d]||(t[d]={})}const{chartType:n,_base:o}=dn(),r=A(()=>{var m,v;const d=t[n.value]??{},f=c0(n.value,d),{activeScene:h,activeIndex:g,scenes:b}=wn();if(g.value>=0){let y={...f};for(let x=0;x<=g.value;x++){const _=(m=b.value[x])==null?void 0:m.chartTypeOptions;_&&(y={...y,..._})}return y}return(v=h.value)!=null&&v.chartTypeOptions?{...f,...h.value.chartTypeOptions}:f}),i=A(()=>{const d=t[o.chartType.value]??{};return c0(o.chartType.value,d)}),s=A(()=>au(n.value)),a=A(()=>s.value.map(d=>d.key));function l(d,f){var m;const{activeIndex:h,activeScene:g,scenes:b}=wn();if(h.value>=0&&g.value){let y=(t[n.value]??{})[d];for(let x=h.value-1;x>=0;x--){const _=(m=b.value[x])==null?void 0:m.chartTypeOptions;if(_&&d in _){y=_[d];break}}if(g0(f,y)){const x={...g.value.chartTypeOptions};delete x[d];const _=Object.keys(x).length>0?x:void 0,k={...g.value};_?k.chartTypeOptions=_:delete k.chartTypeOptions,b.value[h.value]=k}else{const x=g.value.chartTypeOptions??{};b.value[h.value]={...g.value,chartTypeOptions:{...x,[d]:f}}}return}t[n.value]||(t[n.value]={}),t[n.value][d]=f}Ge(n,(d,f)=>{var _;e(d);const{activeIndex:h,activeScene:g,scenes:b}=wn(),m=h.value>=0&&g.value!=null;let v;if(m){let k={...t[f]??{}};for(let E=0;E<=h.value;E++){const B=(_=b.value[E])==null?void 0:_.chartTypeOptions;B&&(k={...k,...B})}v=k}else v=t[f]??{};if(Object.keys(v).length===0)return;const y=au(d).map(k=>k.key);if(y.length===0)return;const x=t[d]??{};for(const k of y)if(k in v){if(m){const E=g.value.chartTypeOptions??{};if(!(k in E)&&!(k in x)){const B=v[k],S=Array.isArray(B)?[...B]:B;b.value[h.value]={...g.value,chartTypeOptions:{...E,[k]:S}}}}else if(!(k in x)){const E=v[k],B=t[d];Array.isArray(E)?B[k]=[...E]:B[k]=E}}},{flush:"sync"});function c(){for(const d of Object.keys(t))delete t[d]}function u(d){c();for(const[f,h]of Object.entries(d))t[f]=h}return{currentOptions:r,baseOptions:i,availableOptionKeys:a,optionDefs:s,setOption:l,ensureDefaults:e,reset:c,hydrate:u,store:t}});function _n(){const t=yre(),{currentOptions:e,baseOptions:n,availableOptionKeys:o,optionDefs:r}=Ct(t);return{currentOptions:e,baseOptions:n,availableOptionKeys:o,optionDefs:r,setOption:t.setOption,ensureDefaults:t.ensureDefaults,reset:t.reset,hydrate:t.hydrate,store:t.store}}const oT=[{value:"blueprint",label:"Blueprint",description:"The default Blueprint Chart theme"},{value:"blueprint-framed",label:"Blueprint Framed",description:"Adds borders and a tinted footer"}],E2=Oo("chartTheme",()=>{const t=Ie("blueprint");function e(){t.value="blueprint"}return{chartTheme:t,chartThemeOptions:oT,reset:e}});function rT(){const t=E2(),{chartTheme:e}=Ct(t);return{chartTheme:e,availableThemes:oT,reset:t.reset}}const xre=new Set([Je.Sort,Je.Filter,Je.HideColumns,Je.Transpose,Je.Parse,Je.GroupBy,Je.Computed,"pivot"]);function Ic(){const t=dn(),e=E2(),n=Ct(e).chartTheme,{store:o,ensureDefaults:r}=_n(),i=Lr(),s=wn();function a(l){var c,u;try{const d=ag(l);s.setActive(-1),t.chartType.value=d.chartType;const f=Vr(d.properties);t.title.value=String(f.get("title")??""),t.description.value=String(f.get("description")??""),t.byline.value=String(f.get("byline")??""),t.source.value=String(f.get("source")??""),t.sourceUrl.value=String(f.get("sourceUrl")??"");const h=f.get("theme");n.value=h?String(h):"blueprint";const g={},b=f.get("sizing");b&&["responsive","fixed","max-width"].includes(String(b))&&(g.sizing=String(b));const v=f.get("fixedWidth");v!==void 0&&(g.fixedWidth=Number(v));const y=f.get("maxWidth");y!==void 0&&(g.maxWidth=Number(y));const x=f.get("heightMode");x&&["auto","fixed","aspect-ratio"].includes(String(x))&&(g.heightMode=String(x));const k=f.get("fixedHeight");k!==void 0&&(g.fixedHeight=Number(k));const E=f.get("aspectRatio");E!==void 0&&(g.aspectRatio=String(E));const B=f.get("padding");B!==void 0&&(g.padding=Number(B));const S=f.get("transparentBackground");S!==void 0&&(g.transparentBackground=S===!0||S==="true");const L=f.get("player");L&&["buttons","progress-bar","dot-stepper","minimal-arrows","none"].includes(String(L))&&(g.playerType=String(L));const I=f.get("playerPosition");I&&["left","center","right"].includes(String(I))&&(g.playerPosition=String(I)),t.layout.value={...rf,...g};const T=f.get("sort");T===Zt.Ascending||T===Zt.Descending?t.sort.value=T:t.sort.value=Zt.None;const P=d.data?u0(d.data):"";if(t.data.value=P,P){const $=jo(),F=Q$(P);$.loadParsed(F),$.rawInput.value=P,$.sourceFormat.value="bpc"}if(o[d.chartType]=lg(d.chartType,d.properties),r(d.chartType),t.colorizes.value=d.colorizes?d0(d.colorizes):[],t.highlights.value=d.highlights?f0(d.highlights):[],t.areaFills.value=d.areaFills?h0(d.areaFills):[],t.annotations.value=d.annotations?p0(d.annotations):[],t.seriesOverrides.value=d.series?m0(d.series):[],(c=d.transforms)!=null&&c.length){i.reset();for(const $ of d.transforms){if(!xre.has($.transformType))continue;const F=Vr($.properties),V={};for(const[U,K]of F)V[U]=String(K);if($.transformType===Je.Sort&&F.has("direction")){const U=String(F.get("direction"));(U===Zt.Ascending||U===Zt.Descending)&&(t.sort.value=U)}i.addStep($.transformType,V)}}else i.reset();if((u=d.scenes)!=null&&u.length){const $=d.scenes.map(F=>{const V=doe(F,d.chartType),U={id:Math.random().toString(36).slice(2,10),name:V.name};V.chartType&&(U.chartType=V.chartType),V.data&&(U.data=u0(V.data)),Object.keys(V.chartTypeOptions).length>0&&(U.chartTypeOptions=V.chartTypeOptions),V.colorizes.length>0&&(U.colorizes=d0(V.colorizes)),V.highlights.length>0&&(U.highlights=f0(V.highlights)),V.areaFills.length>0&&(U.areaFills=h0(V.areaFills)),V.annotations.length>0&&(U.annotations=p0(V.annotations)),V.series.length>0&&(U.seriesOverrides=m0(V.series)),V.annotationVisibility.length>0&&(U.annotationVisibility=V.annotationVisibility.map(se=>({action:se.action,kind:se.kind,id:se.id}))),V.transforms.length>0&&(U.transforms=V.transforms.map((se,he)=>({id:String(he),type:se.transformType,config:Object.fromEntries(se.properties.map(ce=>[ce.key,String(ce.value)]))})));const K=Object.fromEntries([...V.properties.entries()].filter(([se])=>!["type"].includes(se)));return Object.keys(K).length>0&&(U.properties=K),U});s.hydrate({scenes:$,activeIndex:-1})}else s.reset();return{success:!0}}catch(d){return{success:!1,error:d instanceof Error?d.message:String(d)}}}return{applyDsl:a}}function wh(t){if(typeof t=="number")return String(t);const e=String(t);return e.endsWith("%")?String(parseFloat(e)):`"${e}"`}function Xu(t){if(typeof t=="number")return String(t);const e=String(t);return e.endsWith("%")?`"${e}"`:String(parseFloat(e))}function Nf(){const e=dn()._base,n=Ct(E2()).chartTheme,{baseOptions:o}=_n(),{steps:r}=Lr(),{scenes:i}=wn(),s=jo(),a=Ie(!1);function l(){let u=`chart ${e.chartType.value} {
|
|
648
648
|
`;e.title.value&&(u+=` title = "${e.title.value}"
|
|
649
649
|
`),e.description.value&&(u+=` description = "${e.description.value}"
|
|
650
650
|
`),e.byline.value&&(u+=` byline = "${e.byline.value}"
|
|
@@ -838,22 +838,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
838
838
|
`);u+=` }
|
|
839
839
|
`}u+=` }
|
|
840
840
|
`}return u+=`}
|
|
841
|
-
`,u}const c=Ie("");return Q0(()=>{c.value=l()},{flush:"post"}),{dsl:c,compact:a,generateDsl:l}}function Sc(t){return`data:image/svg+xml;base64,${globalThis.btoa(unescape(encodeURIComponent(t)))}`}function iT(){return document.documentElement.getAttribute("data-bs-theme")??"light"}const sT=t=>`blueprint-chart:${t}:thumbnail:${iT()}`,aT=t=>`blueprint-chart:${t}:preview:${iT()}`;function lT(t){for(const e of t.querySelectorAll("*")){if(!(e instanceof SVGElement))continue;const n=globalThis.getComputedStyle(e),o=n.fill;if(o&&o!=="none"){const i=e.getAttribute("fill");(!i||i==="currentColor"||i.startsWith("var("))&&e.setAttribute("fill",o)}const r=n.stroke;if(r&&r!=="none"){const i=e.getAttribute("stroke");(!i||i==="currentColor"||i.startsWith("var("))&&e.setAttribute("stroke",r)}}}function cT(t){const e=t.querySelector("svg");if(!e)return null;const n=e.getAttribute("width"),o=e.getAttribute("height");return n&&o&&!e.getAttribute("viewBox")&&e.setAttribute("viewBox",`0 0 ${n} ${o}`),e.removeAttribute("width"),e.removeAttribute("height"),e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),lT(e),e.outerHTML}function
|
|
841
|
+
`,u}const c=Ie("");return Q0(()=>{c.value=l()},{flush:"post"}),{dsl:c,compact:a,generateDsl:l}}function Sc(t){return`data:image/svg+xml;base64,${globalThis.btoa(unescape(encodeURIComponent(t)))}`}function iT(){return document.documentElement.getAttribute("data-bs-theme")??"light"}const sT=t=>`blueprint-chart:${t}:thumbnail:${iT()}`,aT=t=>`blueprint-chart:${t}:preview:${iT()}`;function lT(t){for(const e of t.querySelectorAll("*")){if(!(e instanceof SVGElement))continue;const n=globalThis.getComputedStyle(e),o=n.fill;if(o&&o!=="none"){const i=e.getAttribute("fill");(!i||i==="currentColor"||i.startsWith("var("))&&e.setAttribute("fill",o)}const r=n.stroke;if(r&&r!=="none"){const i=e.getAttribute("stroke");(!i||i==="currentColor"||i.startsWith("var("))&&e.setAttribute("stroke",r)}}}function cT(t){const e=t.querySelector("svg");if(!e)return null;const n=e.getAttribute("width"),o=e.getAttribute("height");return n&&o&&!e.getAttribute("viewBox")&&e.setAttribute("viewBox",`0 0 ${n} ${o}`),e.removeAttribute("width"),e.removeAttribute("height"),e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),lT(e),e.outerHTML}function wre(t){const e=t.querySelector(".bc-frame");if(!e)return null;const n=e.querySelector("svg");if(!n)return null;const o=e.getBoundingClientRect(),r=globalThis.getComputedStyle(e).backgroundColor||"#ffffff",i=[],s=".bc-frame-title, .bc-frame-description, .bc-frame-byline, .bc-frame-source, .bc-frame-credit";for(const x of e.querySelectorAll(s)){const _=x.getBoundingClientRect();if(_.width===0)continue;const k=globalThis.getComputedStyle(x);i.push({text:x.textContent??"",x:_.left-o.left,y:_.top-o.top+parseFloat(k.fontSize),fontSize:parseFloat(k.fontSize),fontWeight:k.fontWeight,fontFamily:k.fontFamily,fill:k.color,fontStyle:k.fontStyle!=="normal"?k.fontStyle:void 0})}const a=n.getBoundingClientRect(),l=a.left-o.left,c=a.top-o.top,u=a.width,d=a.height;lT(n);const f=n.cloneNode(!0);f.removeAttribute("width"),f.removeAttribute("height");const g=new XMLSerializer().serializeToString(f),b=Math.ceil(o.width),m=Math.ceil(o.height),v=x=>x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),y=i.map(x=>`<text x="${x.x}" y="${x.y}" font-size="${x.fontSize}px" font-weight="${x.fontWeight}" font-family="${v(x.fontFamily)}" fill="${x.fill}"${x.fontStyle?` font-style="${x.fontStyle}"`:""}>${v(x.text)}</text>`).join(`
|
|
842
842
|
`);return[`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${b} ${m}">`,` <rect width="100%" height="100%" fill="${r}" />`,` ${y}`,` <g transform="translate(${l},${c})">`,` <svg width="${u}" height="${d}"${f.getAttribute("viewBox")?` viewBox="${f.getAttribute("viewBox")}"`:""}>`,g.replace(/^<svg[^>]*>/,"").replace(/<\/svg>$/,"")," </svg>"," </g>","</svg>"].join(`
|
|
843
|
-
`)}function N2(t,e,n,o,r,i){const s=document.createElement("div"),a=n?`height:${n}px;`:"";s.style.cssText=`position:fixed;left:-9999px;top:0;width:${e}px;${a}overflow:hidden;`,s.id=t,i!=null&&i.forceLightTheme&&s.setAttribute("data-bs-theme","light");const l=document.createElement("style");l.textContent=o,document.head.appendChild(l),document.body.appendChild(s);try{return r(s)}finally{document.body.removeChild(s),document.head.removeChild(l)}}function
|
|
844
|
-
`);function fT(t){return document.documentElement.getAttribute("data-bs-theme")==="dark"&&!
|
|
845
|
-
`);function pT(t){const e=fT(t);return N2("__bc_preview",
|
|
843
|
+
`)}function N2(t,e,n,o,r,i){const s=document.createElement("div"),a=n?`height:${n}px;`:"";s.style.cssText=`position:fixed;left:-9999px;top:0;width:${e}px;${a}overflow:hidden;`,s.id=t,i!=null&&i.forceLightTheme&&s.setAttribute("data-bs-theme","light");const l=document.createElement("style");l.textContent=o,document.head.appendChild(l),document.body.appendChild(s);try{return r(s)}finally{document.body.removeChild(s),document.head.removeChild(l)}}function _re(t){const e=t.match(/allowDarkMode\s*=\s*(true|false)/);return e?e[1]==="true":!0}const uT=600,I2=400,dT=[`#__bc_thumb .bc-frame { height:${I2}px; display:flex; flex-direction:column; }`,"#__bc_thumb .bc-frame-header, #__bc_thumb .bc-frame-footer { display:none; }","#__bc_thumb .bc-frame-body { flex:1; min-height:0; }"].join(`
|
|
844
|
+
`);function fT(t){return document.documentElement.getAttribute("data-bs-theme")==="dark"&&!_re(t)}function hT(t){const e=fT(t);return N2("__bc_thumb",uT,I2,dT,n=>(X$(n,t,{thumbnail:!0}),cT(n)),{forceLightTheme:e})}function R2(t,e,n,o,r){return e.labels.length===0?null:N2("__bc_thumb",uT,I2,dT,i=>(L2(i,{chartType:t,data:e,options:n,sort:o,colorizes:r==null?void 0:r.colorizes,seriesOverrides:r==null?void 0:r.seriesOverrides},{thumbnail:!0}),cT(i)))}const kre=600,Sre=500,Are=["#__bc_preview .bc-frame { display:flex; flex-direction:column; }",`#__bc_preview .bc-frame-body { height:${Sre}px; min-height:0; }`].join(`
|
|
845
|
+
`);function pT(t){const e=fT(t);return N2("__bc_preview",kre,null,Are,n=>(X$(n,t,{padding:"12px"}),wre(n)),{forceLightTheme:e})}function eb(t){return localStorage.getItem(sT(t))}function tb(t,e){localStorage.setItem(sT(t),e)}function mT(t){localStorage.removeItem(`blueprint-chart:${t}:thumbnail:light`),localStorage.removeItem(`blueprint-chart:${t}:thumbnail:dark`),localStorage.removeItem(`blueprint-chart:${t}:thumbnail`)}function Cre(t){return localStorage.getItem(aT(t))}function gT(t,e){localStorage.setItem(aT(t),e)}function $re(t){localStorage.removeItem(`blueprint-chart:${t}:preview:light`),localStorage.removeItem(`blueprint-chart:${t}:preview:dark`),localStorage.removeItem(`blueprint-chart:${t}:preview`)}function vT(t){return t.trimStart().startsWith("{")}function bT(t){if(!vT(t))return hT(t);const e=JSON.parse(t);if(!e.chartConfig)return null;const{chartConfig:n,chartTypeOptions:o}=e,r=fs(n.data),i=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];if(r.series&&r.series.length>0&&i.includes(n.chartType)){const a=r.series.find(l=>l.name===n.selectedColumn);a&&(r.values=a.values),delete r.series}const s=(o??{})[n.chartType]??{};return R2(n.chartType,r,s,n.sort)}function Tre(t){return vT(t)?bT(t):pT(t)}function Mre(){const t=dn(),{currentOptions:e}=_n(),{sessionId:n}=js();if(!n.value||!t.data.value)return;const o=fs(t.data.value),r=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];if(o.series&&o.series.length>0&&r.includes(t.chartType.value)){const l=o.series.find(c=>c.name===t.selectedColumn.value);l&&(o.values=l.values),delete o.series}const i=R2(t.chartType.value,o,e.value,t.sort.value,{colorizes:t.colorizes.value.length>0?t.colorizes.value:void 0,seriesOverrides:t.seriesOverrides.value.length>0?t.seriesOverrides.value:void 0});i&&tb(n.value,i);const{generateDsl:s}=Nf(),a=s();if(a){const l=pT(a);l&&gT(n.value,l)}}const V6="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";function rp(){let t="";for(let e=0;e<11;e++)t+=V6[Math.floor(Math.random()*V6.length)];return t}function Cv(t){return`blueprint-chart:${t}`}function _h(t){return`blueprint-chart:${t}:meta`}function z6(t){return t.trimStart().startsWith("{")}const Ore=Oo("chartSession",()=>{const t=Ie(""),e=Ie(null),n=Ve(null),o=Ve(""),r=dn(),i=jo(),s=Lr(),a=_n(),l=wn();function c(){if(!t.value)return;const{generateDsl:B}=Nf();localStorage.setItem(Cv(t.value),B());const S=new Date().toISOString(),L={savedAt:S,sheetNumber:n.value,sheetId:o.value};i.sourceFormat.value==="delimited"&&i.rawInput.value&&(L.rawInput=i.rawInput.value,L.sourceLabel=i.sourceLabel.value,L.sourceFormat="delimited"),localStorage.setItem(_h(t.value),JSON.stringify(L)),e.value=S}function u(B){const S=localStorage.getItem(Cv(B));if(!S)return!1;try{if(z6(S)){const T=JSON.parse(S);if(T.chartConfig)return d(B,T)}const{applyDsl:L}=Ic();if(!L(S).success)return!1;const I=localStorage.getItem(_h(B));let C;return I&&(C=JSON.parse(I),C.sourceFormat==="delimited"&&C.rawInput&&(i.rawInput.value=C.rawInput,i.sourceFormat.value="delimited",C.sourceLabel&&(i.sourceLabel.value=C.sourceLabel))),t.value=B,e.value=(C==null?void 0:C.savedAt)??null,n.value=(C==null?void 0:C.sheetNumber)??null,o.value=(C==null?void 0:C.sheetId)??crypto.randomUUID(),!0}catch{return!1}}function d(B,S){try{return r.hydrate(S.chartConfig),S.dataTable&&i.hydrate(S.dataTable),t.value=B,n.value=null,o.value=crypto.randomUUID(),!0}catch{return!1}}function f(){r.reset(),i.reset(),s.reset(),a.reset(),l.reset(),t.value=""}function h(){f(),e.value=null,n.value=null,o.value=crypto.randomUUID()}function g(){if(n.value!==null)return;const B=Object.keys(localStorage).filter(L=>L.startsWith("blueprint-chart:")&&L.endsWith(":meta"));let S=0;for(const L of B)try{const D=JSON.parse(localStorage.getItem(L)||"{}");if(D.sheetNumber){const I=parseInt(D.sheetNumber,10);Number.isFinite(I)&&I>S&&(S=I)}}catch{}n.value=String(S+1).padStart(3,"0"),c()}function b(){return t.value=rp(),c(),_(),t.value}function m(){f(),t.value=rp(),n.value=null,o.value=crypto.randomUUID()}function v(B){i.rawInput.value=B.tsvData;const S=J1(B.tsvData);i.loadParsed(S),r.data.value=i.serialize();const{applyDsl:L}=Ic();L(B.dsl)}function y(B){return u(B)}function x(B){if(!B)return null;try{ag(B)}catch{return null}f();const{applyDsl:S}=Ic();return S(B).success?(t.value=rp(),n.value=null,o.value=crypto.randomUUID(),c(),_(),t.value):(f(),null)}function _(){Ge([r.chartType,r.title,r.description,r.byline,r.note,r.source,r.sourceUrl,r.sort,r.data,r.selectedColumn,r.colorizes,r.highlights,r.areaFills,r.annotations,r.seriesOverrides,r.layout,i.columns,i.rows,i.rawInput,i.columnTypes,s.steps,l.scenes,l.activeIndex,()=>a.store],c,{deep:!0,flush:"post"})}function k(){var L;const B=[],S="blueprint-chart:";for(let D=0;D<localStorage.length;D++){const I=localStorage.key(D);if(!I||!I.startsWith(S))continue;const C=I.slice(S.length);if(C.includes(":"))continue;const T=localStorage.getItem(I);if(T)try{if(z6(T)){const oe=JSON.parse(T);if(oe.chartConfig){B.push({id:C,title:oe.chartConfig.title||"",description:oe.chartConfig.description||"",chartType:oe.chartConfig.chartType||"",savedAt:oe.savedAt??null,sceneCount:((L=oe.chartConfig.scenes)==null?void 0:L.length)??0,rowCount:oe.chartConfig.data?oe.chartConfig.data.split(`
|
|
846
846
|
`).filter(de=>de.trim()).length-1:0,allowDarkMode:oe.chartConfig.allowDarkMode??!0,sheetNumber:null,sheetId:""});continue}}const P=T.match(/title\s*=\s*"([^"]*)"/),$=T.match(/description\s*=\s*"([^"]*)"/),F=T.match(/^chart\s+(\S+)/),V=T.match(/\bscene\s+"/g),U=T.match(/data\s*\{([^}]*)\}/),K=U?U[1].split(`
|
|
847
|
-
`).filter(oe=>oe.trim()&&oe.includes("=")).length:0,se=T.match(/allowDarkMode\s*=\s*(true|false)/),he=localStorage.getItem(_h(C)),ce=he?JSON.parse(he):null,be=(ce==null?void 0:ce.savedAt)??null;B.push({id:C,title:(P==null?void 0:P[1])??"",description:($==null?void 0:$[1])??"",chartType:(F==null?void 0:F[1])??"",savedAt:be,sceneCount:(V==null?void 0:V.length)??0,rowCount:K,allowDarkMode:se?se[1]==="true":!0,sheetNumber:(ce==null?void 0:ce.sheetNumber)??null,sheetId:(ce==null?void 0:ce.sheetId)??""})}catch{}}return B.sort((D,I)=>!D.savedAt&&!I.savedAt?0:D.savedAt?I.savedAt?I.savedAt.localeCompare(D.savedAt):-1:1),B}function E(B){localStorage.removeItem(Cv(B)),localStorage.removeItem(_h(B)),mT(B)}return{sessionId:t,lastSavedAt:e,sheetNumber:n,sheetId:o,save:c,load:u,prepareNew:h,assignSheetNumber:g,createSession:b,newChart:m,loadSample:v,loadChart:y,createFromDsl:x,startAutoSave:_,listSavedCharts:k,deleteChart:E}});function js(){const t=Tre(),{sessionId:e,lastSavedAt:n,sheetNumber:o,sheetId:r}=Ct(t);return{sessionId:e,lastSavedAt:n,sheetNumber:o,sheetId:r,save:t.save,load:t.load,prepareNew:t.prepareNew,assignSheetNumber:t.assignSheetNumber,createSession:t.createSession,newChart:t.newChart,loadSample:t.loadSample,loadChart:t.loadChart,createFromDsl:t.createFromDsl,startAutoSave:t.startAutoSave,listSavedCharts:t.listSavedCharts,deleteChart:t.deleteChart}}const nb=260,H6=660,yT=220,Mre=nb+yT,ob=.22,Bu=Oo("panel",()=>{const t=Ie("docked"),e=Ie(ob),n=Ie("docked"),o=Ie(!1),r=Ie(!1);function i(){t.value="docked",o.value||(n.value="docked")}function s(){t.value="closed",o.value||(n.value="closed")}function a(){t.value==="closed"&&(t.value="docked",o.value||(n.value="docked"))}function l(){t.value!=="drawer"&&(n.value=t.value),t.value="drawer"}function c(){t.value=n.value}function u(){t.value==="docked"?s():t.value==="closed"&&(t.value="docked",o.value||(n.value="docked"))}function d(m){if(!Number.isFinite(m)||m<=0){e.value=ob;return}e.value=Math.min(1,m)}function f(m){o.value=m,m?t.value!=="drawer"&&(t.value="drawer"):t.value==="drawer"&&(t.value=n.value)}function h(m){o.value!==m&&(o.value=m,m?(t.value!=="drawer"&&(n.value=t.value),t.value="drawer"):t.value=n.value)}function g(m){r.value=m,m&&t.value!=="closed"&&t.value!=="drawer"&&(t.value="closed")}function b(m){r.value!==m&&(r.value=m,!o.value&&(m?(t.value!=="closed"&&t.value!=="drawer"&&(n.value=t.value),t.value="closed"):t.value==="closed"&&(t.value=n.value)))}return{mode:t,dockedWidth:e,lastDesktopMode:n,narrow:o,cramped:r,dock:i,close:s,open:a,openDrawer:l,closeDrawer:c,toggleMode:u,setDockedWidth:d,initBreakpoint:f,syncBreakpoint:h,initCramped:g,syncCramped:b}},{persist:{key:"blueprint-chart:panel:v3",pick:["mode","dockedWidth","lastDesktopMode"]}});function rc(){const t=Bu(),{mode:e,dockedWidth:n,lastDesktopMode:o,narrow:r,cramped:i}=Ct(t);return{mode:e,dockedWidth:n,lastDesktopMode:o,narrow:r,cramped:i,dock:t.dock,close:t.close,open:t.open,openDrawer:t.openDrawer,closeDrawer:t.closeDrawer,toggleMode:t.toggleMode,setDockedWidth:t.setDockedWidth,initBreakpoint:t.initBreakpoint,syncBreakpoint:t.syncBreakpoint,initCramped:t.initCramped,syncCramped:t.syncCramped}}const Ore=Oo("dashboardPanel",()=>{const t=Ie(null);function e(o){if(t.value===o){t.value=null;return}t.value=o;const r=Bu();r.mode==="closed"&&r.open()}function n(){t.value=null}return{selectedChartId:t,selectChart:e,reset:n}});function xT(){const t=Ore(),{selectedChartId:e}=Ct(t);return{selectedChartId:e,selectChart:t.selectChart,reset:t.reset}}function wT(){const{listSavedCharts:t,deleteChart:e}=js(),{selectedChartId:n}=xT(),{resolvedTheme:o}=Cf(),r=Ve([]),i=ir({}),s=ir({}),a=Ie("date-desc"),l=A(()=>{const b=[...r.value];return a.value==="date-desc"?b.sort((m,v)=>(v.savedAt??"").localeCompare(m.savedAt??"")):a.value==="date-asc"?b.sort((m,v)=>(m.savedAt??"").localeCompare(v.savedAt??"")):a.value==="name-asc"&&b.sort((m,v)=>(m.title||"").localeCompare(v.title||"")),b}),c=A(()=>r.value.find(b=>b.id===n.value)??null);function u(){r.value=t(),d()}function d(){for(const b of r.value){const m=eb(b.id),v=Sre(b.id);if(m&&(i[b.id]=Sc(m)),v&&(s[b.id]=Sc(v)),m&&v)continue;const y=localStorage.getItem(`blueprint-chart:${b.id}`);if(y)try{if(!m){const x=bT(y);x&&(tb(b.id,x),i[b.id]=Sc(x))}if(!v){const x=Cre(y);x&&(gT(b.id,x),s[b.id]=Sc(x))}}catch{}}}function f(b){const m=localStorage.getItem(`blueprint-chart:${b}`);if(!m)return null;const v=rp();localStorage.setItem(`blueprint-chart:${v}`,m);const y=localStorage.getItem(`blueprint-chart:${b}:meta`);y&&localStorage.setItem(`blueprint-chart:${v}:meta`,y);const x=eb(b);return x&&tb(v,x),u(),v}function h(b){n.value=null,e(b),delete i[b],delete s[b],u()}function g(){for(const b of r.value)mT(b.id),Are(b.id),delete i[b.id],delete s[b.id];d()}return Ge(o,()=>{g()}),{charts:r,sortedCharts:l,selectedChart:c,thumbnails:i,previews:s,sortValue:a,refresh:u,duplicateChart:f,removeChart:h}}const Bre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Lre(t,e){return w(),R("svg",Bre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m219.31 108.68l-80-80a16 16 0 0 0-22.62 0l-80 80A15.87 15.87 0 0 0 32 120v96a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-56h32v56a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-96a15.87 15.87 0 0 0-4.69-11.32M208 208h-48v-56a8 8 0 0 0-8-8h-48a8 8 0 0 0-8 8v56H48v-88l80-80l80 80Z"},null,-1)])])}const Pre=Oe({name:"ph-house",render:Lre}),Dre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ere(t,e){return w(),R("svg",Dre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M104 40H56a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 64H56V56h48zm96-64h-48a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 64h-48V56h48zm-96 32H56a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16m0 64H56v-48h48zm96-64h-48a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16m0 64h-48v-48h48z"},null,-1)])])}const _T=Oe({name:"ph-squares-four",render:Ere}),Nre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ire(t,e){return w(),R("svg",Nre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208.31 75.68A59.78 59.78 0 0 0 202.93 28a8 8 0 0 0-6.93-4a59.75 59.75 0 0 0-48 24h-24a59.75 59.75 0 0 0-48-24a8 8 0 0 0-6.93 4a59.78 59.78 0 0 0-5.38 47.68A58.14 58.14 0 0 0 56 104v8a56.06 56.06 0 0 0 48.44 55.47A39.8 39.8 0 0 0 96 192v8H72a24 24 0 0 1-24-24a40 40 0 0 0-40-40a8 8 0 0 0 0 16a24 24 0 0 1 24 24a40 40 0 0 0 40 40h24v16a8 8 0 0 0 16 0v-40a24 24 0 0 1 48 0v40a8 8 0 0 0 16 0v-40a39.8 39.8 0 0 0-8.44-24.53A56.06 56.06 0 0 0 216 112v-8a58.14 58.14 0 0 0-7.69-28.32M200 112a40 40 0 0 1-40 40h-48a40 40 0 0 1-40-40v-8a41.74 41.74 0 0 1 6.9-22.48a8 8 0 0 0 1.1-7.69a43.8 43.8 0 0 1 .79-33.58a43.88 43.88 0 0 1 32.32 20.06a8 8 0 0 0 6.71 3.69h32.35a8 8 0 0 0 6.74-3.69a43.87 43.87 0 0 1 32.32-20.06a43.8 43.8 0 0 1 .77 33.58a8.09 8.09 0 0 0 1 7.65a41.7 41.7 0 0 1 7 22.52Z"},null,-1)])])}const Rre=Oe({name:"ph-github-logo",render:Ire}),Fre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Vre(t,e){return w(),R("svg",Fre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 48h-72a40 40 0 0 0-32 16a40 40 0 0 0-32-16H24a8 8 0 0 0-8 8v144a8 8 0 0 0 8 8h72a24 24 0 0 1 24 24a8 8 0 0 0 16 0a24 24 0 0 1 24-24h72a8 8 0 0 0 8-8V56a8 8 0 0 0-8-8M96 192H32V64h64a24 24 0 0 1 24 24v112a39.8 39.8 0 0 0-24-8m128 0h-64a39.8 39.8 0 0 0-24 8V88a24 24 0 0 1 24-24h64Z"},null,-1)])])}const zre=Oe({name:"ph-book-open",render:Vre}),Hre={class:"layout-sidebar__header"},Wre=le({__name:"LayoutSidebar",setup(t){const e=Xl(),{sortedCharts:n}=wT(),{resolvedTheme:o}=Cf(),r=A(()=>n.value.slice(0,5)),i=A(()=>e.path==="/"),s=A(()=>e.path.startsWith("/charts")),a=A(()=>o.value==="dark"?JA:QA);return(l,c)=>(w(),J(p(yU),{"aria-label":"Workspace navigation"},{header:te(()=>[M("div",Hre,[H(p(HA),{name:"Blueprint Chart","logo-src":a.value,to:"/"},null,8,["logo-src"]),Ce(l.$slots,"trailing",{},void 0,!0)])]),default:te(()=>[H(p(rv),{eyebrow:"Workspace"},{default:te(()=>[H(p(Yu),{to:"/",label:"Home",active:i.value},{icon:te(()=>[H(p(Pre))]),_:1},8,["active"]),H(p(Yu),{to:"/charts",label:"My Charts",active:s.value,count:p(n).length||void 0},{icon:te(()=>[H(p(_T))]),_:1},8,["active","count"])]),_:1}),r.value.length?(w(),J(p(rv),{key:0,eyebrow:"Recent"},{default:te(()=>[(w(!0),R(He,null,ht(r.value,u=>(w(),J(p(Yu),{key:u.id,to:`/edit/${u.id}`,label:u.title||"Untitled"},null,8,["to","label"]))),128))]),_:1})):ie("",!0),H(p(rv),{eyebrow:"Resources"},{default:te(()=>[H(p(Yu),{href:"https://docs.blueprintchart.com",label:"Documentation"},{icon:te(()=>[H(p(zre))]),_:1}),H(p(Yu),{href:"https://github.com/blueprint-chart/blueprint-chart",label:"GitHub"},{icon:te(()=>[H(p(Rre))]),_:1})]),_:1})]),_:3}))}}),W6=Be(Wre,[["__scopeId","data-v-34084162"]]),Ure={class:"command-palette-modal"},Gre={class:"command-palette-modal__input-row"},qre={key:0,class:"command-palette-modal__results",role:"listbox","aria-label":"Chart results"},Yre=["aria-selected","onClick","onMousemove"],jre=["src"],Xre={class:"command-palette-modal__meta"},Kre={class:"command-palette-modal__title"},Zre={class:"command-palette-modal__desc"},Qre={key:1,class:"command-palette-modal__empty"},Jre=le({__name:"CommandPaletteModal",props:{open:{type:Boolean,required:!0},openModifiers:{}},emits:["update:open"],setup(t){const e=dt(t,"open"),n=Ay(),o=Xl(),{listSavedCharts:r}=js(),i=Ve(""),s=Ve(0),a=ft("inputRef"),l=Ve([]),c=A(()=>{const m=i.value.trim().toLowerCase();return m?l.value.filter(v=>{var y,x;return((y=v.title)==null?void 0:y.toLowerCase().includes(m))||((x=v.description)==null?void 0:x.toLowerCase().includes(m))}):l.value.slice(0,5)}),u=A(()=>{const m={};for(const v of l.value){const y=eb(v.id);y&&(m[v.id]=Sc(y))}return m});Ge(i,()=>{s.value=0}),Ge(()=>o.path,()=>{e.value&&(e.value=!1)}),Ge(e,m=>{m?l.value=r():(i.value="",s.value=0)},{immediate:!0});function d(){var m;(m=a.value)==null||m.focus()}function f(m){const v=c.value.length-1;if(v<0)return;let y=s.value+m;y<0&&(y=v),y>v&&(y=0),s.value=y}function h(){const m=c.value[s.value];m&&g(m.id)}function g(m){e.value=!1,n.push(`/edit/${m}`)}function b(m){return{"command-palette-modal__result":!0,"command-palette-modal__result--active":m===s.value}}return(m,v)=>(w(),J(p(zE),{modelValue:e.value,"onUpdate:modelValue":v[4]||(v[4]=y=>e.value=y),size:"lg",centered:"","no-header":"","no-footer":"",autofocus:!1,"body-class":"command-palette-modal__body","no-close-on-esc":"",onShown:d},{default:te(()=>[M("div",Ure,[M("div",Gre,[H(p(Fy),{class:"command-palette-modal__icon"}),H(p(ea),{ref_key:"inputRef",ref:a,modelValue:p(i),"onUpdate:modelValue":v[0]||(v[0]=y=>Ze(i)?i.value=y:null),"aria-label":"Search charts",placeholder:"Search charts…",autofocus:"",onKeydown:[v[1]||(v[1]=er(pn(y=>e.value=!1,["prevent"]),["escape"])),v[2]||(v[2]=er(pn(y=>f(1),["prevent"]),["down"])),v[3]||(v[3]=er(pn(y=>f(-1),["prevent"]),["up"])),er(pn(h,["prevent"]),["enter"])]},null,8,["modelValue","onKeydown"])]),p(c).length>0?(w(),R("div",qre,[(w(!0),R(He,null,ht(p(c),(y,x)=>(w(),R("div",{key:y.id,class:Me(b(x)),role:"option",tabindex:"-1","aria-selected":x===p(s),onClick:_=>g(y.id),onMousemove:_=>s.value=x},[p(u)[y.id]?(w(),R("img",{key:0,src:p(u)[y.id],class:"command-palette-modal__thumb",alt:""},null,8,jre)):ie("",!0),M("div",Xre,[M("span",Kre,ye(y.title||"Untitled"),1),M("span",Zre,ye(y.description),1)])],42,Yre))),128))])):p(i).trim()?(w(),R("div",Qre,' No charts match "'+ye(p(i))+'" ',1)):ie("",!0)])]),_:1},8,["modelValue"]))}}),U6=Be(Jre,[["__scopeId","data-v-09e7b11e"]]);function eie(){const{isNarrow:t}=Ji(),e=Bu();e.initBreakpoint(t.value),Ge(t,n=>{e.syncBreakpoint(n)})}const tie={key:0,class:"layout-shell layout-shell--landing"},nie={key:1,class:"layout-shell layout-shell--app"},oie={class:"layout-shell__sidebar"},rie={class:"layout-shell__topbar"},iie={class:"layout-shell__main"},sie=le({__name:"LayoutShell",setup(t){eie();const e=Xl(),n=A(()=>e.path==="/"),o=Ie(!1),r=KA("k"),{isNarrow:i}=Ji("xl"),s=Ve(!1);return Ge(()=>e.fullPath,()=>{s.value=!1}),Ge(i,a=>{a||(s.value=!1)}),Fs(document,"keydown",a=>{r.matches(a)&&(a.preventDefault(),o.value=!0)}),(a,l)=>{const c=GE;return n.value?(w(),R("div",tie,[Ce(a.$slots,"default",{},void 0,!0),H(U6,{open:o.value,"onUpdate:open":l[0]||(l[0]=u=>o.value=u)},null,8,["open"])])):(w(),R("div",nie,[M("aside",oie,[H(W6)]),M("div",rie,[H(Uq,{"sidebar-open":s.value,onSearchClick:l[1]||(l[1]=u=>o.value=!0),onToggleSidebar:l[2]||(l[2]=u=>s.value=!s.value)},null,8,["sidebar-open"])]),M("main",iie,[Ce(a.$slots,"default",{},void 0,!0)]),p(i)?(w(),J(c,{key:0,id:"layout-sidebar-offcanvas",modelValue:s.value,"onUpdate:modelValue":l[4]||(l[4]=u=>s.value=u),placement:"start","no-header":"","aria-label":"Workspace navigation",class:"layout-shell__sidebar-offcanvas"},{default:te(()=>[H(W6,null,{trailing:te(()=>[H(p(FA),{onClick:l[3]||(l[3]=u=>s.value=!1)})]),_:1})]),_:1},8,["modelValue"])):ie("",!0),H(U6,{open:o.value,"onUpdate:open":l[5]||(l[5]=u=>o.value=u)},null,8,["open"])]))}}}),aie=Be(sie,[["__scopeId","data-v-e550b95e"]]),lie=le({__name:"App",setup(t){const e=Xl();return(n,o)=>{const r=nm("router-view"),i=aie;return p(e).meta.bare?(w(),J(r,{key:0})):(w(),J(i,{key:1},{default:te(()=>[H(r)]),_:1}))}}}),cie="modulepreload",uie=function(t){return"/"+t},G6={},q6=function(e,n,o){let r=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=s(n.map(c=>{if(c=uie(c),c in G6)return;G6[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":cie,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,g)=>{f.addEventListener("load",h),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return r.then(s=>{for(const a of s||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},die=le({__name:"PanelDocked",props:it({collapsed:{type:Boolean},title:{},initialWidth:{default:ob},showClose:{type:Boolean,default:!0},canvasWidth:{default:void 0}},{modelValue:{},modelModifiers:{}}),emits:it(["close"],["update:modelValue"]),setup(t){const e=t,n=dt(t,"modelValue"),o=Ie(n.value??e.initialWidth);Ge(n,u=>{u!==void 0&&(o.value=u)});const r=Ie(!1),{width:i}=qI(),s=A(()=>({"panel-docked--collapsed":e.collapsed,"panel-docked--resizing":r.value})),a=A(()=>e.canvasWidth===void 0||e.canvasWidth<=0?H6:Math.min(H6,e.canvasWidth-yT)),l=A(()=>{const u=o.value*i.value;return Math.max(nb,Math.min(u,a.value))});function c(u){const d=u.clientX,f=o.value*i.value,h=u.currentTarget;h.setPointerCapture(u.pointerId),r.value=!0;function g(m){const v=d-m.clientX,y=f+v,x=Math.min(a.value,Math.max(nb,y)),_=i.value||window.innerWidth;o.value=_>0?x/_:o.value,n.value=o.value}function b(){r.value=!1,h.removeEventListener("pointermove",g),h.removeEventListener("pointerup",b)}h.addEventListener("pointermove",g),h.addEventListener("pointerup",b)}return(u,d)=>(w(),R("div",{class:Me(["panel-docked",p(s)]),style:Et({width:t.collapsed?void 0:`${p(l)}px`})},[M("div",{class:"panel-docked__resize-handle",onPointerdown:c},null,32),H(p(UW),{title:t.title},bi({actions:te(()=>[t.showClose?(w(),J(p(FA),{key:0,onClick:d[0]||(d[0]=f=>u.$emit("close"))})):ie("",!0)]),default:te(()=>[Ce(u.$slots,"default",{},void 0,!0)]),_:2},[u.$slots.toolbar?{name:"toolbar",fn:te(()=>[Ce(u.$slots,"toolbar",{},void 0,!0)]),key:"0"}:void 0,u.$slots.footer?{name:"footer",fn:te(()=>[Ce(u.$slots,"footer",{},void 0,!0)]),key:"1"}:void 0]),1032,["title"])],6))}}),fie=Be(die,[["__scopeId","data-v-02f78f79"]]),hie={class:"panel-drawer__body"},pie=le({__name:"PanelDrawer",props:it({title:{}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=dt(t,"modelValue");return(n,o)=>(w(),J(p(VA),{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=r=>e.value=r),title:t.title},{default:te(()=>[Ce(n.$slots,"header",{},void 0,!0),M("div",hie,[Ce(n.$slots,"default",{},void 0,!0)])]),_:3},8,["modelValue","title"]))}}),mie=Be(pie,[["__scopeId","data-v-46314d76"]]);function gie(t){const{width:e}=II(t),n=Bu(),o=A(()=>e.value>0&&e.value<Mre);return n.initCramped(o.value),Ge(o,r=>{n.syncCramped(r)}),{canvasWidth:e}}const ug=le({__name:"PanelShell",props:it({title:{},containerRef:{default:null},showClose:{type:Boolean,default:!0}},{drawerOpen:{type:Boolean,default:!1},drawerOpenModifiers:{}}),emits:it(["close"],["update:drawerOpen"]),setup(t,{emit:e}){const n=t,o=e,r=dt(t,"drawerOpen"),i=Bu(),{mode:s,dockedWidth:a}=Ct(i),{close:l}=i,c=A(()=>{var f;return((f=n.containerRef)==null?void 0:f.parentElement)??null}),{canvasWidth:u}=gie(c);function d(){l(),o("close")}return(f,h)=>{const g=mie,b=fie;return p(s)==="drawer"?(w(),J(g,{key:0,modelValue:r.value,"onUpdate:modelValue":h[0]||(h[0]=m=>r.value=m),title:t.title},bi({default:te(()=>[Ce(f.$slots,"default")]),_:2},[f.$slots.tabs||f.$slots.header?{name:"header",fn:te(()=>[Ce(f.$slots,"tabs"),Ce(f.$slots,"header")]),key:"0"}:void 0]),1032,["modelValue","title"])):p(s)==="docked"?(w(),J(b,{key:1,modelValue:p(a),"onUpdate:modelValue":h[1]||(h[1]=m=>Ze(a)?a.value=m:null),collapsed:!1,title:t.title,"show-close":t.showClose,"canvas-width":p(u),onClose:d},bi({default:te(()=>[Ce(f.$slots,"default")]),_:2},[f.$slots.header?{name:"toolbar",fn:te(()=>[Ce(f.$slots,"header")]),key:"0"}:void 0,f.$slots.footer?{name:"footer",fn:te(()=>[Ce(f.$slots,"footer")]),key:"1"}:void 0]),1032,["modelValue","title","show-close","canvas-width"])):ie("",!0)}}}),vie={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function bie(t,e){return w(),R("svg",vie,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M88 24v-8a8 8 0 0 1 16 0v8a8 8 0 0 1-16 0m-72 80h8a8 8 0 0 0 0-16h-8a8 8 0 0 0 0 16m108.42-64.84a8 8 0 0 0 10.74-3.58l8-16a8 8 0 0 0-14.31-7.16l-8 16a8 8 0 0 0 3.57 10.74m-96 81.69l-16 8a8 8 0 0 0 7.16 14.31l16-8a8 8 0 1 0-7.16-14.31M219.31 184a16 16 0 0 1 0 22.63l-12.68 12.68a16 16 0 0 1-22.63 0L132.7 168L115 214.09c0 .1-.08.21-.13.32a15.83 15.83 0 0 1-14.6 9.59h-.79a15.83 15.83 0 0 1-14.41-11L32.8 52.92A16 16 0 0 1 52.92 32.8L213 85.07a16 16 0 0 1 1.41 29.8l-.32.13L168 132.69ZM208 195.31L156.69 144a16 16 0 0 1 4.93-26l.32-.14l45.95-17.64L48 48l52.2 159.86l17.65-46c0-.11.08-.22.13-.33a16 16 0 0 1 11.69-9.34a16.7 16.7 0 0 1 3-.28a16 16 0 0 1 11.3 4.69l51.34 51.4Z"},null,-1)])])}const kT=Oe({name:"ph-cursor-click",render:bie}),yie={class:"dashboard-empty-state"},xie=le({__name:"DashboardEmptyState",setup(t){return(e,n)=>(w(),R("div",yie,[H(p(kT),{class:"dashboard-empty-state__icon"}),n[0]||(n[0]=M("p",{class:"dashboard-empty-state__text"}," Select a chart to see its details ",-1))]))}}),wie=Be(xie,[["__scopeId","data-v-f6c24334"]]),_ie={class:"dashboard-action-row__label"},kie={key:0,class:"dashboard-action-row__description"},Sie=le({__name:"DashboardActionRow",props:{icon:{},label:{},description:{},danger:{type:Boolean}},emits:["click"],setup(t){const e=t,n=A(()=>({"dashboard-action-row--danger":e.danger}));return(o,r)=>(w(),R("button",{class:Me(["dashboard-action-row",p(n)]),onClick:r[0]||(r[0]=i=>o.$emit("click"))},[(w(),J(Gt(t.icon),{class:"dashboard-action-row__icon"})),M("div",null,[M("div",_ie,ye(t.label),1),t.description?(w(),R("div",kie,ye(t.description),1)):ie("",!0)])],2))}}),Aie=Be(Sie,[["__scopeId","data-v-0f47d7d3"]]),Cie={class:"dashboard-detail-actions"},$ie={class:"dashboard-detail-actions__list"},Tie=le({__name:"DashboardDetailActions",emits:["duplicate","delete"],setup(t){return(e,n)=>{const o=Aie;return w(),R("div",Cie,[n[2]||(n[2]=M("div",{class:"dashboard-detail-actions__title"}," Actions ",-1)),M("div",$ie,[H(o,{icon:p(pA),label:"Duplicate",description:"Create a copy to edit",onClick:n[0]||(n[0]=r=>e.$emit("duplicate"))},null,8,["icon"]),H(o,{icon:p(UA),label:"Delete chart",description:"This cannot be undone",danger:"",onClick:n[1]||(n[1]=r=>e.$emit("delete"))},null,8,["icon"])])])}}}),Mie=Be(Tie,[["__scopeId","data-v-de396b53"]]),Oie={class:"dashboard-meta-chip"},Bie={class:"dashboard-meta-chip__label"},Lie={class:"dashboard-meta-chip__value"},Pie=le({__name:"DashboardMetaChip",props:{label:{},value:{}},setup(t){return(e,n)=>(w(),R("div",Oie,[M("div",Bie,ye(t.label),1),M("div",Lie,ye(t.value),1)]))}}),Die=Be(Pie,[["__scopeId","data-v-a1903aff"]]),Eie={class:"dashboard-detail-meta"},Nie={class:"dashboard-detail-meta__grid"},Iie=le({__name:"DashboardDetailMeta",props:{chartType:{},savedAt:{},sceneCount:{},rowCount:{}},setup(t){const e=t,n=A(()=>NA(e.chartType)),o=A(()=>{if(!e.savedAt)return"—";const r=new Date(e.savedAt);return Number.isNaN(r.getTime())?e.savedAt:r.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})});return(r,i)=>{const s=Die;return w(),R("div",Eie,[i[0]||(i[0]=M("div",{class:"dashboard-detail-meta__title"}," Details ",-1)),M("div",Nie,[H(s,{label:"Chart type",value:p(n)},null,8,["value"]),H(s,{label:"Last edited",value:p(o)},null,8,["value"]),H(s,{label:"Scenes",value:String(t.sceneCount)},null,8,["value"]),H(s,{label:"Data rows",value:String(t.rowCount)},null,8,["value"])])])}}}),Rie=Be(Iie,[["__scopeId","data-v-533a4b72"]]),Fie=["data-bs-theme"],Vie=["src"],zie=le({__name:"DashboardDetailPreview",props:{src:{},forceLightTheme:{type:Boolean}},setup(t){return(e,n)=>t.src?(w(),R("div",{key:0,class:"dashboard-detail-preview","data-bs-theme":t.forceLightTheme?"light":void 0},[M("img",{src:t.src,alt:"",class:"dashboard-detail-preview__img"},null,8,Vie)],8,Fie)):ie("",!0)}}),Hie=Be(zie,[["__scopeId","data-v-ddbd95be"]]),Wie={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Uie(t,e){return w(),R("svg",Wie,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m227.31 73.37l-44.68-44.69a16 16 0 0 0-22.63 0L36.69 152A15.86 15.86 0 0 0 32 163.31V208a16 16 0 0 0 16 16h44.69a15.86 15.86 0 0 0 11.31-4.69L227.31 96a16 16 0 0 0 0-22.63M92.69 208H48v-44.69l88-88L180.69 120ZM192 108.68L147.31 64l24-24L216 84.68Z"},null,-1)])])}const F2=Oe({name:"ph-pencil-simple",render:Uie}),Gie={class:"dashboard-detail-content"},qie={key:0,class:"dashboard-detail-content__subtitle"},Yie=le({__name:"DashboardDetailContent",props:{title:{},subtitle:{},previewSrc:{},forceLightTheme:{type:Boolean},chartType:{},savedAt:{},sceneCount:{},rowCount:{}},emits:["edit","duplicate","delete"],setup(t){return(e,n)=>{const o=Hie,r=Rie,i=Mie;return w(),R("div",Gie,[t.subtitle?(w(),R("div",qie,ye(t.subtitle),1)):ie("",!0),H(p(Kn),{"icon-left":p(F2),label:"Edit chart",variant:"primary",block:"",onClick:n[0]||(n[0]=s=>e.$emit("edit"))},null,8,["icon-left"]),H(o,{src:t.previewSrc,"force-light-theme":t.forceLightTheme},null,8,["src","force-light-theme"]),H(r,{"chart-type":t.chartType,"saved-at":t.savedAt,"scene-count":t.sceneCount,"row-count":t.rowCount},null,8,["chart-type","saved-at","scene-count","row-count"]),H(i,{onDuplicate:n[1]||(n[1]=s=>e.$emit("duplicate")),onDelete:n[2]||(n[2]=s=>e.$emit("delete"))})])}}}),jie=Be(Yie,[["__scopeId","data-v-3d8b1e29"]]),Xie=le({__name:"DashboardChartCard",props:{chart:{},thumbSrc:{},selected:{type:Boolean},layout:{}},emits:["select","edit"],setup(t){const{resolvedTheme:e}=Cf();return(n,o)=>(w(),J(p(oG),{title:t.chart.title||"Untitled",subtitle:t.chart.description,"thumb-src":t.thumbSrc,selected:t.selected,layout:t.layout,"force-light-thumb":!t.chart.allowDarkMode,"serif-title":!0,onClick:o[1]||(o[1]=r=>n.$emit("select",t.chart.id))},{actions:te(()=>[H(p(Kn),{"icon-left":p(F2),label:"Edit","hide-label":"",square:"",variant:"primary",size:"sm",class:"dashboard-chart-card__edit-btn",onClick:o[0]||(o[0]=r=>n.$emit("edit",t.chart.id))},null,8,["icon-left"])]),footer:te(()=>[H(p(XH),{"chart-type":t.chart.chartType,theme:p(e)},null,8,["chart-type","theme"]),t.chart.savedAt?(w(),J(p(BH),{key:0,value:t.chart.savedAt},null,8,["value"])):ie("",!0)]),_:1},8,["title","subtitle","thumb-src","selected","layout","force-light-thumb"]))}}),Kie=le({__name:"DashboardNewCard",props:{layout:{default:"grid"}},emits:["click"],setup(t){const e=t,n=A(()=>({"dashboard-new-card--row":e.layout==="row"}));return(o,r)=>(w(),R("div",{class:Me(["dashboard-new-card",p(n)]),role:"button",tabindex:"0",onClick:r[0]||(r[0]=i=>o.$emit("click")),onKeydown:[r[1]||(r[1]=er(i=>o.$emit("click"),["enter"])),r[2]||(r[2]=er(pn(i=>o.$emit("click"),["prevent"]),["space"]))]},[H(p(Py),{class:"dashboard-new-card__icon"}),r[3]||(r[3]=M("span",{class:"dashboard-new-card__label"},"New Chart",-1))],34))}}),Zie=Be(Kie,[["__scopeId","data-v-ef746b42"]]),Qie=le({__name:"DashboardGallery",props:{charts:{},thumbnails:{},selectedId:{},layout:{}},emits:["select","edit","new"],setup(t){return(e,n)=>{const o=Zie,r=Xie;return w(),J(p(iG),{layout:t.layout},{default:te(()=>[H(o,{layout:t.layout,onClick:n[0]||(n[0]=i=>e.$emit("new"))},null,8,["layout"]),(w(!0),R(He,null,ht(t.charts,i=>(w(),J(r,{key:i.id,chart:i,"thumb-src":t.thumbnails[i.id],selected:t.selectedId===i.id,layout:t.layout,onSelect:n[1]||(n[1]=s=>e.$emit("select",s)),onEdit:n[2]||(n[2]=s=>e.$emit("edit",s))},null,8,["chart","thumb-src","selected","layout"]))),128)),t.charts.length===0?(w(),J(p(OW),{key:0,message:"No saved charts yet. Create a new chart to get started."})):ie("",!0)]),_:1},8,["layout"])}}}),Jie={},ese={class:"layout-page-header"},tse={class:"layout-page-header__start"},nse={class:"layout-page-header__center"},ose={class:"layout-page-header__end"};function rse(t,e){return w(),R("div",ese,[M("div",tse,[Ce(t.$slots,"start",{},void 0,!0)]),M("div",nse,[Ce(t.$slots,"center",{},void 0,!0)]),M("div",ose,[Ce(t.$slots,"end",{},void 0,!0)])])}const ST=Be(Jie,[["render",rse],["__scopeId","data-v-c99b9b81"]]),ise={key:0,class:"layout-breadcrumb","aria-label":"Breadcrumb"},sse=["aria-current"],ase={key:2,class:"layout-breadcrumb__crumb-sep","aria-hidden":"true"},lse=le({__name:"LayoutBreadcrumb",setup(t){const e=Xl(),n=dn(),o=A(()=>{const r=e.path;if(r.startsWith("/edit/")){const i=n._base.title.value||"Untitled";return[{label:"My Charts",to:"/charts"},{label:i}]}return r.startsWith("/charts")?[{label:"My Charts"}]:r==="/new"?[{label:"My Charts",to:"/charts"},{label:"New chart"}]:[]});return(r,i)=>{const s=nm("router-link");return o.value.length?(w(),R("nav",ise,[(w(!0),R(He,null,ht(o.value,(a,l)=>(w(),R(He,{key:l},[a.to?(w(),J(s,{key:0,to:a.to,class:"layout-breadcrumb__crumb"},{default:te(()=>[Ye(ye(a.label),1)]),_:2},1032,["to"])):(w(),R("span",{key:1,class:"layout-breadcrumb__crumb layout-breadcrumb__crumb--active","aria-current":l===o.value.length-1?"page":void 0},ye(a.label),9,sse)),l<o.value.length-1?(w(),R("span",ase,"/")):ie("",!0)],64))),128))])):ie("",!0)}}}),AT=Be(lse,[["__scopeId","data-v-73a5f2ae"]]),cse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function use(t,e){return w(),R("svg",cse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208 136H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16v-40a16 16 0 0 0-16-16m0 56H48v-40h160zm0-144H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16m0 56H48V64h160z"},null,-1)])])}const dse=Oe({name:"ph-rows",render:use}),fse={class:"dashboard-toolbar__count"},hse=le({__name:"DashboardToolbar",props:{chartCount:{},sortValue:{},layout:{}},emits:["update:sortValue","update:layout","new"],setup(t){const e=t,n=[{value:"date-desc",label:"Last edited"},{value:"date-asc",label:"Oldest first"},{value:"name-asc",label:"Name A–Z"}],o=A(()=>[{key:"grid",text:"Grid",icon:_T,active:e.layout==="grid"},{key:"row",text:"List",icon:dse,active:e.layout==="row"}]);return(r,i)=>(w(),J(ST,{class:"dashboard-toolbar"},{start:te(()=>[H(AT),M("span",fse,ye(t.chartCount)+" "+ye(t.chartCount===1?"chart":"charts"),1)]),end:te(()=>[H(p(zA),{items:p(o),"aria-label":"View layout",onSelect:i[0]||(i[0]=s=>r.$emit("update:layout",s))},null,8,["items"]),H(p(En),{"model-value":t.sortValue,options:n,"onUpdate:modelValue":i[1]||(i[1]=s=>r.$emit("update:sortValue",s))},null,8,["model-value"]),H(p(Kn),{"icon-left":p(Py),label:"New chart",variant:"primary",onClick:i[2]||(i[2]=s=>r.$emit("new"))},null,8,["icon-left"])]),_:1}))}}),pse=Be(hse,[["__scopeId","data-v-de771377"]]),mse={class:"dashboard-page-wrapper d-flex flex-column flex-grow-1"},gse=le({__name:"DashboardPage",setup(t){const e=Ay(),{isNarrow:n}=Ji(),{selectedChartId:o,selectChart:r}=xT(),{mode:i}=Ct(Bu()),{sortedCharts:s,selectedChart:a,thumbnails:l,previews:c,sortValue:u,refresh:d,duplicateChart:f,removeChart:h}=wT(),g=ft("galleryRef"),b=Ie("grid"),m=A(()=>({"dashboard-page":!0,"dashboard-page--narrow":n.value})),v=A(()=>a.value?a.value.title||"Untitled":"Chart details");function y(){o.value=null}const x=A({get:()=>o.value!==null,set:S=>{S||(o.value=null)}});function _(){o.value&&e.push(`/edit/${o.value}`)}function k(){if(o.value){const S=f(o.value);S&&e.push(`/edit/${S}`)}}function E(){o.value&&h(o.value)}function B(S){S.key==="Escape"&&(o.value=null)}return un(()=>{d(),document.addEventListener("keydown",B)}),Qs(()=>{document.removeEventListener("keydown",B)}),(S,L)=>{const D=pse,I=Qie,C=jie,T=wie,P=ug;return w(),R("div",mse,[H(D,{"chart-count":p(s).length,"sort-value":p(u),layout:p(b),"onUpdate:sortValue":L[0]||(L[0]=$=>u.value=$),"onUpdate:layout":L[1]||(L[1]=$=>b.value=$),onNew:L[2]||(L[2]=$=>p(e).push("/new"))},null,8,["chart-count","sort-value","layout"]),M("div",{class:Me(p(m))},[M("div",{ref_key:"galleryRef",ref:g,class:"dashboard-page__gallery"},[H(I,{charts:p(s),thumbnails:p(l),"selected-id":p(o),layout:p(b),onSelect:p(r),onEdit:L[3]||(L[3]=$=>p(e).push(`/edit/${$}`)),onNew:L[4]||(L[4]=$=>p(e).push("/new"))},null,8,["charts","thumbnails","selected-id","layout","onSelect"])],512),H(P,{"drawer-open":p(x),"onUpdate:drawerOpen":L[5]||(L[5]=$=>Ze(x)?x.value=$:null),title:p(v),"container-ref":p(g),"show-close":!1,onClose:y},{default:te(()=>[p(a)?(w(),J(C,{key:0,title:p(a).title||"Untitled",subtitle:p(a).description,"preview-src":p(o)?p(c)[p(o)]:void 0,"force-light-theme":p(a)?!p(a).allowDarkMode:!1,"chart-type":p(a).chartType,"saved-at":p(a).savedAt??void 0,"scene-count":p(a).sceneCount,"row-count":p(a).rowCount,onEdit:_,onDuplicate:k,onDelete:E},null,8,["title","subtitle","preview-src","force-light-theme","chart-type","saved-at","scene-count","row-count"])):p(i)==="docked"?(w(),J(T,{key:1})):ie("",!0)]),_:1},8,["drawer-open","title","container-ref"])],2)])}}}),vse=Be(gse,[["__scopeId","data-v-fe7a5a93"]]),bse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function yse(t,e){return w(),R("svg",bse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 40H40a16 16 0 0 0-16 16v144a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16M40 56h40v144H40Zm176 144H96V56h120z"},null,-1)])])}const CT=Oe({name:"ph-sidebar-simple",render:yse}),V2=le({__name:"PanelIconRail",props:{activeTab:{},items:{}},emits:["select","toggle-mode"],setup(t,{emit:e}){const n=e,{mode:o,open:r}=rc();function i(a){o.value==="closed"&&r(),n("select",a)}const s=A(()=>o.value==="closed"?"Open panel":"Close panel");return(a,l)=>(w(),J(p(fU),{"model-value":t.activeTab,items:t.items,"onUpdate:modelValue":i},{footer:te(()=>[H(p(Kn),{"icon-left":p(CT),label:p(s),"hide-label":"",square:"",variant:"link",size:"sm",onClick:l[0]||(l[0]=c=>a.$emit("toggle-mode"))},null,8,["icon-left","label"])]),_:1},8,["model-value","items"]))}}),xse=Oo("exportPanel",()=>{const t=Ie("embed"),e=Ie("png"),n=Ie(2),o=Ie(!1),r=Ie(!1),i=Ie(!0),s=Ie(!1),a=Ie("embed");function l(f){t.value=f}function c(f){e.value=f}function u(f){a.value=f}function d(){t.value="embed",e.value="png",n.value=2,o.value=!1,r.value=!1,i.value=!0,s.value=!1,a.value="embed"}return{exportTab:t,selectedFormat:e,pngScale:n,svgInlineFonts:o,svgMinify:r,bpcIncludeData:i,bpcCompact:s,lastNarrowExportTab:a,setExportTab:l,setSelectedFormat:c,setLastNarrowExportTab:u,reset:d}});function dg(){const t=xse(),{exportTab:e,selectedFormat:n,pngScale:o,svgInlineFonts:r,svgMinify:i,bpcIncludeData:s,bpcCompact:a,lastNarrowExportTab:l}=Ct(t);return{exportTab:e,selectedFormat:n,pngScale:o,svgInlineFonts:r,svgMinify:i,bpcIncludeData:s,bpcCompact:a,lastNarrowExportTab:l,setExportTab:t.setExportTab,setSelectedFormat:t.setSelectedFormat,setLastNarrowExportTab:t.setLastNarrowExportTab,reset:t.reset}}const wse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function _se(t,e){return w(),R("svg",wse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M69.12 94.15L28.5 128l40.62 33.85a8 8 0 1 1-10.24 12.29l-48-40a8 8 0 0 1 0-12.29l48-40a8 8 0 0 1 10.24 12.3m176 27.7l-48-40a8 8 0 1 0-10.24 12.3L227.5 128l-40.62 33.85a8 8 0 1 0 10.24 12.29l48-40a8 8 0 0 0 0-12.29m-82.39-89.37a8 8 0 0 0-10.25 4.79l-64 176a8 8 0 0 0 4.79 10.26A8.1 8.1 0 0 0 96 224a8 8 0 0 0 7.52-5.27l64-176a8 8 0 0 0-4.79-10.25"},null,-1)])])}const kse=Oe({name:"ph-code",render:_se}),Sse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ase(t,e){return w(),R("svg",Sse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 144v64a8 8 0 0 1-8 8H40a8 8 0 0 1-8-8v-64a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0m-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 124.69V32a8 8 0 0 0-16 0v92.69L93.66 98.34a8 8 0 0 0-11.32 11.32Z"},null,-1)])])}const $T=Oe({name:"ph-download-simple",render:Ase});function TT(){return{sections:[{key:"embed",label:"Embed",icon:kse},{key:"download",label:"Download",icon:$T}]}}const Cse=le({__name:"ExportIconRail",setup(t){const{mode:e,toggleMode:n}=rc(),o=dg(),{exportTab:r}=Ct(o),{setExportTab:i}=o,{sections:s}=TT(),a=A(()=>s.map(c=>({value:c.key,icon:c.icon,tooltip:c.tooltip??c.label})));function l(c){i(c),e.value==="closed"&&n()}return(c,u)=>{const d=V2;return w(),J(d,{"active-tab":p(r),items:p(a),onSelect:l,onToggleMode:p(n)},null,8,["active-tab","items","onToggleMode"])}}}),Ni=[{label:"Data",key:"data"},{label:"Visualize",key:"edit"},{label:"Export",key:"export"}];function $se(t){return t.endsWith("/export")?"export":t.endsWith("/visualize")?"edit":(t.endsWith("/data"),"data")}function Tse(t,e){return e==="edit"?`/edit/${t}/visualize`:`/edit/${t}/${e}`}const $v=Ve(null);function z2(){const t=Xl(),e=Ay(),n=A(()=>{const h=$se((t==null?void 0:t.path)??"/new");return Ni.find(g=>g.key===h)??Ni[0]}),o=A({get:()=>Ni.indexOf(n.value),set:h=>{u(h)}}),r=A(()=>o.value===0),i=A(()=>o.value===Ni.length-1);function s(){var g;const h=(g=t==null?void 0:t.params)==null?void 0:g.id;return h||($v.value?$v.value():null)}function a(h){const g=s();g&&e&&e.replace(Tse(g,h))}function l(){const h=o.value;h<Ni.length-1&&a(Ni[h+1].key)}function c(){const h=o.value;h>0&&a(Ni[h-1].key)}function u(h){h>=0&&h<Ni.length&&a(Ni[h].key)}function d(){}function f(h){$v.value=h}return{currentIndex:o,steps:Ni,currentStep:n,isFirst:r,isLast:i,next:l,back:c,goTo:u,reset:d,registerCreateSession:f}}const Mse={class:"panel-stepper-footer"},Ose=le({__name:"PanelStepperFooter",setup(t){const{steps:e,currentIndex:n,isFirst:o,isLast:r,next:i,back:s}=z2(),a=A(()=>{var c;return((c=e[n.value-1])==null?void 0:c.label)??"Previous"}),l=A(()=>{var c;return((c=e[n.value+1])==null?void 0:c.label)??"Next"});return(c,u)=>(w(),R("div",Mse,[p(o)?ie("",!0):(w(),J(p(Kn),{key:0,"icon-left":p(GA),"icon-left-size":"1em",label:p(a),variant:"outline-secondary",size:"sm",onClick:p(s)},null,8,["icon-left","label","onClick"])),p(r)?ie("",!0):(w(),J(p(Kn),{key:1,"icon-right":p(qA),"icon-right-size":"1em",label:p(l),variant:"primary",size:"sm",class:"ms-auto",onClick:p(i)},null,8,["icon-right","label","onClick"]))]))}}),H2=Be(Ose,[["__scopeId","data-v-52b4dceb"]]),Bse={class:"format-card__header"},Lse={class:"format-card__header__text"},Pse={class:"format-card__header__text__label"},Dse={class:"format-card__header__text__desc"},Ese={key:0,class:"format-card__options"},Nse=le({__name:"ExportDownloadFormatCard",props:{selected:{type:Boolean},icon:{},label:{},description:{},iconBg:{},iconColor:{}},emits:["select","download"],setup(t){return(e,n)=>(w(),R("div",{class:Me(["format-card",{"format-card--selected":t.selected}]),onClick:n[1]||(n[1]=o=>e.$emit("select"))},[M("div",Bse,[M("span",{class:"format-card__header__icon",style:Et({background:t.iconBg,color:t.iconColor})},[(w(),J(Gt(t.icon)))],4),M("div",Lse,[M("div",Pse,ye(t.label),1),M("div",Dse,ye(t.description),1)]),H(p(Kn),{"icon-left":p($T),label:"Download","hide-label":"",variant:"primary",size:"sm",square:"",onClick:n[0]||(n[0]=pn(o=>e.$emit("download"),["stop"]))},null,8,["icon-left"])]),t.selected&&e.$slots.default?(w(),R("div",Ese,[Ce(e.$slots,"default",{},void 0,!0)])):ie("",!0)],2))}}),Ise=Be(Nse,[["__scopeId","data-v-f26129ef"]]);function If(t,e){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,o.click(),URL.revokeObjectURL(n)}function Rse(t,e="chart.svg"){const o=new XMLSerializer().serializeToString(t),r=new Blob([o],{type:"image/svg+xml;charset=utf-8"});If(r,e)}function Fse(t,e,n,o="chart.png"){const i=new XMLSerializer().serializeToString(t),s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s);return new Promise((l,c)=>{const u=new Image;u.onload=()=>{const d=document.createElement("canvas");d.width=e,d.height=n;const f=d.getContext("2d");if(!f){URL.revokeObjectURL(a),c(new Error("Could not get canvas context"));return}f.drawImage(u,0,0,e,n),d.toBlob(h=>{if(URL.revokeObjectURL(a),!h){c(new Error("Could not create PNG blob"));return}If(h,o),l()},"image/png")},u.onerror=()=>{URL.revokeObjectURL(a),c(new Error("Failed to load SVG image"))},u.src=a})}function MT(t,e){const n=globalThis.getComputedStyle(t),o=e;if(o.style)for(let s=0;s<n.length;s++){const a=n[s];o.style.setProperty(a,n.getPropertyValue(a))}const r=t.children,i=e.children;for(let s=0;s<r.length;s++)i[s]&&MT(r[s],i[s])}function Vse(t){const e=globalThis.getComputedStyle(t);return{top:parseFloat(e.paddingTop)||0,right:parseFloat(e.paddingRight)||0,bottom:parseFloat(e.paddingBottom)||0,left:parseFloat(e.paddingLeft)||0}}function zse(t,e=2,n="chart.png",o,r){const{width:i,height:s}=t.getBoundingClientRect(),a=r??{top:0,right:0,bottom:0,left:0},l=i+a.left+a.right,c=s+a.top+a.bottom,u=Math.ceil(l*e),d=Math.ceil(c*e),f=t.cloneNode(!0);MT(t,f),f.querySelectorAll("[data-scene-player]").forEach(k=>k.remove()),f.style.setProperty("pointer-events","auto"),f.style.setProperty("transition","none"),f.style.setProperty("animation","none");const g=new XMLSerializer().serializeToString(f),b=a.left,m=a.top,v=o?`<rect width="${l}" height="${c}" fill="${o}" />`:"",y=[`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${d}">`,`<g transform="scale(${e})">`,v,`<foreignObject x="${b}" y="${m}" width="${i}" height="${s}">`,g,"</foreignObject>","</g>","</svg>"].join(""),x=new Blob([y],{type:"image/svg+xml;charset=utf-8"}),_=URL.createObjectURL(x);return new Promise((k,E)=>{const B=new Image;B.onload=()=>{const S=document.createElement("canvas");S.width=u,S.height=d;const L=S.getContext("2d");if(!L){URL.revokeObjectURL(_),E(new Error("Could not get canvas context"));return}L.drawImage(B,0,0,u,d),S.toBlob(D=>{if(URL.revokeObjectURL(_),!D){E(new Error("Could not create PNG blob"));return}If(D,n),k()},"image/png")},B.onerror=()=>{URL.revokeObjectURL(_),E(new Error("Failed to render frame as image"))},B.src=_})}function Tv(t){const e=globalThis.getComputedStyle(t);return{fontSize:parseFloat(e.fontSize),fontWeight:e.fontWeight,fontFamily:e.fontFamily,fill:e.color,fontStyle:e.fontStyle}}function OT(t){let e=t;for(;e;){const n=globalThis.getComputedStyle(e).backgroundColor;if(n&&n!=="transparent"&&n!=="rgba(0, 0, 0, 0)")return n;e=e.parentElement}return"#ffffff"}function Hse(t,e="chart.svg"){const n=t.querySelector("svg");if(!n)return;const o=t.getBoundingClientRect(),r=OT(t),i=new XMLSerializer,s=[],a=t.querySelectorAll(".bc-frame-title, .bc-frame-description");for(const B of a){const S=B.getBoundingClientRect(),L=Tv(B);s.push({text:B.textContent??"",x:S.left-o.left,y:S.top-o.top+L.fontSize,...L})}const l=t.querySelector(".bc-frame-note");if(l&&l.textContent&&l.style.display!=="none"){const B=l.getBoundingClientRect(),S=Tv(l);s.push({text:l.textContent,x:B.left-o.left,y:B.top-o.top+S.fontSize,...S})}const c=t.querySelectorAll(".bc-frame-byline, .bc-frame-source, .bc-frame-credit");for(const B of c){const S=B.getBoundingClientRect();if(S.width===0)continue;const L=Tv(B);s.push({text:B.textContent??"",x:S.left-o.left,y:S.top-o.top+L.fontSize,...L})}const u=n.getBoundingClientRect(),d=u.left-o.left,f=u.top-o.top,h=u.width,g=u.height,b=n.cloneNode(!0);b.removeAttribute("width"),b.removeAttribute("height");const m=i.serializeToString(b),v=Math.ceil(o.width),y=Math.ceil(o.height),x=B=>B.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),_=s.map(B=>`<text x="${B.x}" y="${B.y}" font-size="${B.fontSize}px" font-weight="${B.fontWeight}" font-family="${x(B.fontFamily)}" fill="${B.fill}"${B.fontStyle&&B.fontStyle!=="normal"?` font-style="${B.fontStyle}"`:""}>${x(B.text)}</text>`).join(`
|
|
847
|
+
`).filter(oe=>oe.trim()&&oe.includes("=")).length:0,se=T.match(/allowDarkMode\s*=\s*(true|false)/),he=localStorage.getItem(_h(C)),ce=he?JSON.parse(he):null,be=(ce==null?void 0:ce.savedAt)??null;B.push({id:C,title:(P==null?void 0:P[1])??"",description:($==null?void 0:$[1])??"",chartType:(F==null?void 0:F[1])??"",savedAt:be,sceneCount:(V==null?void 0:V.length)??0,rowCount:K,allowDarkMode:se?se[1]==="true":!0,sheetNumber:(ce==null?void 0:ce.sheetNumber)??null,sheetId:(ce==null?void 0:ce.sheetId)??""})}catch{}}return B.sort((D,I)=>!D.savedAt&&!I.savedAt?0:D.savedAt?I.savedAt?I.savedAt.localeCompare(D.savedAt):-1:1),B}function E(B){localStorage.removeItem(Cv(B)),localStorage.removeItem(_h(B)),mT(B)}return{sessionId:t,lastSavedAt:e,sheetNumber:n,sheetId:o,save:c,load:u,prepareNew:h,assignSheetNumber:g,createSession:b,newChart:m,loadSample:v,loadChart:y,createFromDsl:x,startAutoSave:_,listSavedCharts:k,deleteChart:E}});function js(){const t=Ore(),{sessionId:e,lastSavedAt:n,sheetNumber:o,sheetId:r}=Ct(t);return{sessionId:e,lastSavedAt:n,sheetNumber:o,sheetId:r,save:t.save,load:t.load,prepareNew:t.prepareNew,assignSheetNumber:t.assignSheetNumber,createSession:t.createSession,newChart:t.newChart,loadSample:t.loadSample,loadChart:t.loadChart,createFromDsl:t.createFromDsl,startAutoSave:t.startAutoSave,listSavedCharts:t.listSavedCharts,deleteChart:t.deleteChart}}const nb=260,H6=660,yT=220,Bre=nb+yT,ob=.22,Bu=Oo("panel",()=>{const t=Ie("docked"),e=Ie(ob),n=Ie("docked"),o=Ie(!1),r=Ie(!1);function i(){t.value="docked",o.value||(n.value="docked")}function s(){t.value="closed",o.value||(n.value="closed")}function a(){t.value==="closed"&&(t.value="docked",o.value||(n.value="docked"))}function l(){t.value!=="drawer"&&(n.value=t.value),t.value="drawer"}function c(){t.value=n.value}function u(){t.value==="docked"?s():t.value==="closed"&&(t.value="docked",o.value||(n.value="docked"))}function d(m){if(!Number.isFinite(m)||m<=0){e.value=ob;return}e.value=Math.min(1,m)}function f(m){o.value=m,m?t.value!=="drawer"&&(t.value="drawer"):t.value==="drawer"&&(t.value=n.value)}function h(m){o.value!==m&&(o.value=m,m?(t.value!=="drawer"&&(n.value=t.value),t.value="drawer"):t.value=n.value)}function g(m){r.value=m,m&&t.value!=="closed"&&t.value!=="drawer"&&(t.value="closed")}function b(m){r.value!==m&&(r.value=m,!o.value&&(m?(t.value!=="closed"&&t.value!=="drawer"&&(n.value=t.value),t.value="closed"):t.value==="closed"&&(t.value=n.value)))}return{mode:t,dockedWidth:e,lastDesktopMode:n,narrow:o,cramped:r,dock:i,close:s,open:a,openDrawer:l,closeDrawer:c,toggleMode:u,setDockedWidth:d,initBreakpoint:f,syncBreakpoint:h,initCramped:g,syncCramped:b}},{persist:{key:"blueprint-chart:panel:v3",pick:["mode","dockedWidth","lastDesktopMode"]}});function rc(){const t=Bu(),{mode:e,dockedWidth:n,lastDesktopMode:o,narrow:r,cramped:i}=Ct(t);return{mode:e,dockedWidth:n,lastDesktopMode:o,narrow:r,cramped:i,dock:t.dock,close:t.close,open:t.open,openDrawer:t.openDrawer,closeDrawer:t.closeDrawer,toggleMode:t.toggleMode,setDockedWidth:t.setDockedWidth,initBreakpoint:t.initBreakpoint,syncBreakpoint:t.syncBreakpoint,initCramped:t.initCramped,syncCramped:t.syncCramped}}const Lre=Oo("dashboardPanel",()=>{const t=Ie(null);function e(o){if(t.value===o){t.value=null;return}t.value=o;const r=Bu();r.mode==="closed"&&r.open()}function n(){t.value=null}return{selectedChartId:t,selectChart:e,reset:n}});function xT(){const t=Lre(),{selectedChartId:e}=Ct(t);return{selectedChartId:e,selectChart:t.selectChart,reset:t.reset}}function wT(){const{listSavedCharts:t,deleteChart:e}=js(),{selectedChartId:n}=xT(),{resolvedTheme:o}=Cf(),r=Ve([]),i=ir({}),s=ir({}),a=Ie("date-desc"),l=A(()=>{const b=[...r.value];return a.value==="date-desc"?b.sort((m,v)=>(v.savedAt??"").localeCompare(m.savedAt??"")):a.value==="date-asc"?b.sort((m,v)=>(m.savedAt??"").localeCompare(v.savedAt??"")):a.value==="name-asc"&&b.sort((m,v)=>(m.title||"").localeCompare(v.title||"")),b}),c=A(()=>r.value.find(b=>b.id===n.value)??null);function u(){r.value=t(),d()}function d(){for(const b of r.value){const m=eb(b.id),v=Cre(b.id);if(m&&(i[b.id]=Sc(m)),v&&(s[b.id]=Sc(v)),m&&v)continue;const y=localStorage.getItem(`blueprint-chart:${b.id}`);if(y)try{if(!m){const x=bT(y);x&&(tb(b.id,x),i[b.id]=Sc(x))}if(!v){const x=Tre(y);x&&(gT(b.id,x),s[b.id]=Sc(x))}}catch{}}}function f(b){const m=localStorage.getItem(`blueprint-chart:${b}`);if(!m)return null;const v=rp();localStorage.setItem(`blueprint-chart:${v}`,m);const y=localStorage.getItem(`blueprint-chart:${b}:meta`);y&&localStorage.setItem(`blueprint-chart:${v}:meta`,y);const x=eb(b);return x&&tb(v,x),u(),v}function h(b){n.value=null,e(b),delete i[b],delete s[b],u()}function g(){for(const b of r.value)mT(b.id),$re(b.id),delete i[b.id],delete s[b.id];d()}return Ge(o,()=>{g()}),{charts:r,sortedCharts:l,selectedChart:c,thumbnails:i,previews:s,sortValue:a,refresh:u,duplicateChart:f,removeChart:h}}const Pre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Dre(t,e){return w(),R("svg",Pre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m219.31 108.68l-80-80a16 16 0 0 0-22.62 0l-80 80A15.87 15.87 0 0 0 32 120v96a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-56h32v56a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-96a15.87 15.87 0 0 0-4.69-11.32M208 208h-48v-56a8 8 0 0 0-8-8h-48a8 8 0 0 0-8 8v56H48v-88l80-80l80 80Z"},null,-1)])])}const Ere=Oe({name:"ph-house",render:Dre}),Nre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ire(t,e){return w(),R("svg",Nre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M104 40H56a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 64H56V56h48zm96-64h-48a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 64h-48V56h48zm-96 32H56a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16m0 64H56v-48h48zm96-64h-48a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h48a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16m0 64h-48v-48h48z"},null,-1)])])}const _T=Oe({name:"ph-squares-four",render:Ire}),Rre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Fre(t,e){return w(),R("svg",Rre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208.31 75.68A59.78 59.78 0 0 0 202.93 28a8 8 0 0 0-6.93-4a59.75 59.75 0 0 0-48 24h-24a59.75 59.75 0 0 0-48-24a8 8 0 0 0-6.93 4a59.78 59.78 0 0 0-5.38 47.68A58.14 58.14 0 0 0 56 104v8a56.06 56.06 0 0 0 48.44 55.47A39.8 39.8 0 0 0 96 192v8H72a24 24 0 0 1-24-24a40 40 0 0 0-40-40a8 8 0 0 0 0 16a24 24 0 0 1 24 24a40 40 0 0 0 40 40h24v16a8 8 0 0 0 16 0v-40a24 24 0 0 1 48 0v40a8 8 0 0 0 16 0v-40a39.8 39.8 0 0 0-8.44-24.53A56.06 56.06 0 0 0 216 112v-8a58.14 58.14 0 0 0-7.69-28.32M200 112a40 40 0 0 1-40 40h-48a40 40 0 0 1-40-40v-8a41.74 41.74 0 0 1 6.9-22.48a8 8 0 0 0 1.1-7.69a43.8 43.8 0 0 1 .79-33.58a43.88 43.88 0 0 1 32.32 20.06a8 8 0 0 0 6.71 3.69h32.35a8 8 0 0 0 6.74-3.69a43.87 43.87 0 0 1 32.32-20.06a43.8 43.8 0 0 1 .77 33.58a8.09 8.09 0 0 0 1 7.65a41.7 41.7 0 0 1 7 22.52Z"},null,-1)])])}const Vre=Oe({name:"ph-github-logo",render:Fre}),zre={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Hre(t,e){return w(),R("svg",zre,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 48h-72a40 40 0 0 0-32 16a40 40 0 0 0-32-16H24a8 8 0 0 0-8 8v144a8 8 0 0 0 8 8h72a24 24 0 0 1 24 24a8 8 0 0 0 16 0a24 24 0 0 1 24-24h72a8 8 0 0 0 8-8V56a8 8 0 0 0-8-8M96 192H32V64h64a24 24 0 0 1 24 24v112a39.8 39.8 0 0 0-24-8m128 0h-64a39.8 39.8 0 0 0-24 8V88a24 24 0 0 1 24-24h64Z"},null,-1)])])}const Wre=Oe({name:"ph-book-open",render:Hre}),Ure={class:"layout-sidebar__header"},Gre=le({__name:"LayoutSidebar",setup(t){const e=Xl(),{sortedCharts:n}=wT(),{resolvedTheme:o}=Cf(),r=A(()=>n.value.slice(0,5)),i=A(()=>e.path==="/"),s=A(()=>e.path.startsWith("/charts")),a=A(()=>o.value==="dark"?JA:QA);return(l,c)=>(w(),J(p(yU),{"aria-label":"Workspace navigation"},{header:te(()=>[M("div",Ure,[H(p(HA),{name:"Blueprint Chart","logo-src":a.value,to:"/"},null,8,["logo-src"]),Ce(l.$slots,"trailing",{},void 0,!0)])]),default:te(()=>[H(p(rv),{eyebrow:"Workspace"},{default:te(()=>[H(p(Yu),{to:"/",label:"Home",active:i.value},{icon:te(()=>[H(p(Ere))]),_:1},8,["active"]),H(p(Yu),{to:"/charts",label:"My Charts",active:s.value,count:p(n).length||void 0},{icon:te(()=>[H(p(_T))]),_:1},8,["active","count"])]),_:1}),r.value.length?(w(),J(p(rv),{key:0,eyebrow:"Recent"},{default:te(()=>[(w(!0),R(He,null,ht(r.value,u=>(w(),J(p(Yu),{key:u.id,to:`/edit/${u.id}`,label:u.title||"Untitled"},null,8,["to","label"]))),128))]),_:1})):ie("",!0),H(p(rv),{eyebrow:"Resources"},{default:te(()=>[H(p(Yu),{href:"https://docs.blueprintchart.com",label:"Documentation"},{icon:te(()=>[H(p(Wre))]),_:1}),H(p(Yu),{href:"https://github.com/blueprint-chart/blueprint-chart",label:"GitHub"},{icon:te(()=>[H(p(Vre))]),_:1})]),_:1})]),_:3}))}}),W6=Be(Gre,[["__scopeId","data-v-34084162"]]),qre={class:"command-palette-modal"},Yre={class:"command-palette-modal__input-row"},jre={key:0,class:"command-palette-modal__results",role:"listbox","aria-label":"Chart results"},Xre=["aria-selected","onClick","onMousemove"],Kre=["src"],Zre={class:"command-palette-modal__meta"},Qre={class:"command-palette-modal__title"},Jre={class:"command-palette-modal__desc"},eie={key:1,class:"command-palette-modal__empty"},tie=le({__name:"CommandPaletteModal",props:{open:{type:Boolean,required:!0},openModifiers:{}},emits:["update:open"],setup(t){const e=dt(t,"open"),n=Ay(),o=Xl(),{listSavedCharts:r}=js(),i=Ve(""),s=Ve(0),a=ft("inputRef"),l=Ve([]),c=A(()=>{const m=i.value.trim().toLowerCase();return m?l.value.filter(v=>{var y,x;return((y=v.title)==null?void 0:y.toLowerCase().includes(m))||((x=v.description)==null?void 0:x.toLowerCase().includes(m))}):l.value.slice(0,5)}),u=A(()=>{const m={};for(const v of l.value){const y=eb(v.id);y&&(m[v.id]=Sc(y))}return m});Ge(i,()=>{s.value=0}),Ge(()=>o.path,()=>{e.value&&(e.value=!1)}),Ge(e,m=>{m?l.value=r():(i.value="",s.value=0)},{immediate:!0});function d(){var m;(m=a.value)==null||m.focus()}function f(m){const v=c.value.length-1;if(v<0)return;let y=s.value+m;y<0&&(y=v),y>v&&(y=0),s.value=y}function h(){const m=c.value[s.value];m&&g(m.id)}function g(m){e.value=!1,n.push(`/edit/${m}`)}function b(m){return{"command-palette-modal__result":!0,"command-palette-modal__result--active":m===s.value}}return(m,v)=>(w(),J(p(zE),{modelValue:e.value,"onUpdate:modelValue":v[4]||(v[4]=y=>e.value=y),size:"lg",centered:"","no-header":"","no-footer":"",autofocus:!1,"body-class":"command-palette-modal__body","no-close-on-esc":"",onShown:d},{default:te(()=>[M("div",qre,[M("div",Yre,[H(p(Fy),{class:"command-palette-modal__icon"}),H(p(ea),{ref_key:"inputRef",ref:a,modelValue:p(i),"onUpdate:modelValue":v[0]||(v[0]=y=>Ze(i)?i.value=y:null),"aria-label":"Search charts",placeholder:"Search charts…",autofocus:"",onKeydown:[v[1]||(v[1]=er(pn(y=>e.value=!1,["prevent"]),["escape"])),v[2]||(v[2]=er(pn(y=>f(1),["prevent"]),["down"])),v[3]||(v[3]=er(pn(y=>f(-1),["prevent"]),["up"])),er(pn(h,["prevent"]),["enter"])]},null,8,["modelValue","onKeydown"])]),p(c).length>0?(w(),R("div",jre,[(w(!0),R(He,null,ht(p(c),(y,x)=>(w(),R("div",{key:y.id,class:Me(b(x)),role:"option",tabindex:"-1","aria-selected":x===p(s),onClick:_=>g(y.id),onMousemove:_=>s.value=x},[p(u)[y.id]?(w(),R("img",{key:0,src:p(u)[y.id],class:"command-palette-modal__thumb",alt:""},null,8,Kre)):ie("",!0),M("div",Zre,[M("span",Qre,ye(y.title||"Untitled"),1),M("span",Jre,ye(y.description),1)])],42,Xre))),128))])):p(i).trim()?(w(),R("div",eie,' No charts match "'+ye(p(i))+'" ',1)):ie("",!0)])]),_:1},8,["modelValue"]))}}),U6=Be(tie,[["__scopeId","data-v-09e7b11e"]]);function nie(){const{isNarrow:t}=Ji(),e=Bu();e.initBreakpoint(t.value),Ge(t,n=>{e.syncBreakpoint(n)})}const oie={key:0,class:"layout-shell layout-shell--landing"},rie={key:1,class:"layout-shell layout-shell--app"},iie={class:"layout-shell__sidebar"},sie={class:"layout-shell__topbar"},aie={class:"layout-shell__main"},lie=le({__name:"LayoutShell",setup(t){nie();const e=Xl(),n=A(()=>e.path==="/"),o=Ie(!1),r=KA("k"),{isNarrow:i}=Ji("xl"),s=Ve(!1);return Ge(()=>e.fullPath,()=>{s.value=!1}),Ge(i,a=>{a||(s.value=!1)}),Fs(document,"keydown",a=>{r.matches(a)&&(a.preventDefault(),o.value=!0)}),(a,l)=>{const c=GE;return n.value?(w(),R("div",oie,[Ce(a.$slots,"default",{},void 0,!0),H(U6,{open:o.value,"onUpdate:open":l[0]||(l[0]=u=>o.value=u)},null,8,["open"])])):(w(),R("div",rie,[M("aside",iie,[H(W6)]),M("div",sie,[H(Uq,{"sidebar-open":s.value,onSearchClick:l[1]||(l[1]=u=>o.value=!0),onToggleSidebar:l[2]||(l[2]=u=>s.value=!s.value)},null,8,["sidebar-open"])]),M("main",aie,[Ce(a.$slots,"default",{},void 0,!0)]),p(i)?(w(),J(c,{key:0,id:"layout-sidebar-offcanvas",modelValue:s.value,"onUpdate:modelValue":l[4]||(l[4]=u=>s.value=u),placement:"start","no-header":"","aria-label":"Workspace navigation",class:"layout-shell__sidebar-offcanvas"},{default:te(()=>[H(W6,null,{trailing:te(()=>[H(p(FA),{onClick:l[3]||(l[3]=u=>s.value=!1)})]),_:1})]),_:1},8,["modelValue"])):ie("",!0),H(U6,{open:o.value,"onUpdate:open":l[5]||(l[5]=u=>o.value=u)},null,8,["open"])]))}}}),cie=Be(lie,[["__scopeId","data-v-e550b95e"]]),uie=le({__name:"App",setup(t){const e=Xl();return(n,o)=>{const r=nm("router-view"),i=cie;return p(e).meta.bare?(w(),J(r,{key:0})):(w(),J(i,{key:1},{default:te(()=>[H(r)]),_:1}))}}}),die="modulepreload",fie=function(t){return"/"+t},G6={},q6=function(e,n,o){let r=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=s(n.map(c=>{if(c=fie(c),c in G6)return;G6[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":die,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,g)=>{f.addEventListener("load",h),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return r.then(s=>{for(const a of s||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},hie=le({__name:"PanelDocked",props:it({collapsed:{type:Boolean},title:{},initialWidth:{default:ob},showClose:{type:Boolean,default:!0},canvasWidth:{default:void 0}},{modelValue:{},modelModifiers:{}}),emits:it(["close"],["update:modelValue"]),setup(t){const e=t,n=dt(t,"modelValue"),o=Ie(n.value??e.initialWidth);Ge(n,u=>{u!==void 0&&(o.value=u)});const r=Ie(!1),{width:i}=qI(),s=A(()=>({"panel-docked--collapsed":e.collapsed,"panel-docked--resizing":r.value})),a=A(()=>e.canvasWidth===void 0||e.canvasWidth<=0?H6:Math.min(H6,e.canvasWidth-yT)),l=A(()=>{const u=o.value*i.value;return Math.max(nb,Math.min(u,a.value))});function c(u){const d=u.clientX,f=o.value*i.value,h=u.currentTarget;h.setPointerCapture(u.pointerId),r.value=!0;function g(m){const v=d-m.clientX,y=f+v,x=Math.min(a.value,Math.max(nb,y)),_=i.value||window.innerWidth;o.value=_>0?x/_:o.value,n.value=o.value}function b(){r.value=!1,h.removeEventListener("pointermove",g),h.removeEventListener("pointerup",b)}h.addEventListener("pointermove",g),h.addEventListener("pointerup",b)}return(u,d)=>(w(),R("div",{class:Me(["panel-docked",p(s)]),style:Et({width:t.collapsed?void 0:`${p(l)}px`})},[M("div",{class:"panel-docked__resize-handle",onPointerdown:c},null,32),H(p(UW),{title:t.title},bi({actions:te(()=>[t.showClose?(w(),J(p(FA),{key:0,onClick:d[0]||(d[0]=f=>u.$emit("close"))})):ie("",!0)]),default:te(()=>[Ce(u.$slots,"default",{},void 0,!0)]),_:2},[u.$slots.toolbar?{name:"toolbar",fn:te(()=>[Ce(u.$slots,"toolbar",{},void 0,!0)]),key:"0"}:void 0,u.$slots.footer?{name:"footer",fn:te(()=>[Ce(u.$slots,"footer",{},void 0,!0)]),key:"1"}:void 0]),1032,["title"])],6))}}),pie=Be(hie,[["__scopeId","data-v-02f78f79"]]),mie={class:"panel-drawer__body"},gie=le({__name:"PanelDrawer",props:it({title:{}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=dt(t,"modelValue");return(n,o)=>(w(),J(p(VA),{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=r=>e.value=r),title:t.title},{default:te(()=>[Ce(n.$slots,"header",{},void 0,!0),M("div",mie,[Ce(n.$slots,"default",{},void 0,!0)])]),_:3},8,["modelValue","title"]))}}),vie=Be(gie,[["__scopeId","data-v-46314d76"]]);function bie(t){const{width:e}=II(t),n=Bu(),o=A(()=>e.value>0&&e.value<Bre);return n.initCramped(o.value),Ge(o,r=>{n.syncCramped(r)}),{canvasWidth:e}}const ug=le({__name:"PanelShell",props:it({title:{},containerRef:{default:null},showClose:{type:Boolean,default:!0}},{drawerOpen:{type:Boolean,default:!1},drawerOpenModifiers:{}}),emits:it(["close"],["update:drawerOpen"]),setup(t,{emit:e}){const n=t,o=e,r=dt(t,"drawerOpen"),i=Bu(),{mode:s,dockedWidth:a}=Ct(i),{close:l}=i,c=A(()=>{var f;return((f=n.containerRef)==null?void 0:f.parentElement)??null}),{canvasWidth:u}=bie(c);function d(){l(),o("close")}return(f,h)=>{const g=vie,b=pie;return p(s)==="drawer"?(w(),J(g,{key:0,modelValue:r.value,"onUpdate:modelValue":h[0]||(h[0]=m=>r.value=m),title:t.title},bi({default:te(()=>[Ce(f.$slots,"default")]),_:2},[f.$slots.tabs||f.$slots.header?{name:"header",fn:te(()=>[Ce(f.$slots,"tabs"),Ce(f.$slots,"header")]),key:"0"}:void 0]),1032,["modelValue","title"])):p(s)==="docked"?(w(),J(b,{key:1,modelValue:p(a),"onUpdate:modelValue":h[1]||(h[1]=m=>Ze(a)?a.value=m:null),collapsed:!1,title:t.title,"show-close":t.showClose,"canvas-width":p(u),onClose:d},bi({default:te(()=>[Ce(f.$slots,"default")]),_:2},[f.$slots.header?{name:"toolbar",fn:te(()=>[Ce(f.$slots,"header")]),key:"0"}:void 0,f.$slots.footer?{name:"footer",fn:te(()=>[Ce(f.$slots,"footer")]),key:"1"}:void 0]),1032,["modelValue","title","show-close","canvas-width"])):ie("",!0)}}}),yie={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function xie(t,e){return w(),R("svg",yie,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M88 24v-8a8 8 0 0 1 16 0v8a8 8 0 0 1-16 0m-72 80h8a8 8 0 0 0 0-16h-8a8 8 0 0 0 0 16m108.42-64.84a8 8 0 0 0 10.74-3.58l8-16a8 8 0 0 0-14.31-7.16l-8 16a8 8 0 0 0 3.57 10.74m-96 81.69l-16 8a8 8 0 0 0 7.16 14.31l16-8a8 8 0 1 0-7.16-14.31M219.31 184a16 16 0 0 1 0 22.63l-12.68 12.68a16 16 0 0 1-22.63 0L132.7 168L115 214.09c0 .1-.08.21-.13.32a15.83 15.83 0 0 1-14.6 9.59h-.79a15.83 15.83 0 0 1-14.41-11L32.8 52.92A16 16 0 0 1 52.92 32.8L213 85.07a16 16 0 0 1 1.41 29.8l-.32.13L168 132.69ZM208 195.31L156.69 144a16 16 0 0 1 4.93-26l.32-.14l45.95-17.64L48 48l52.2 159.86l17.65-46c0-.11.08-.22.13-.33a16 16 0 0 1 11.69-9.34a16.7 16.7 0 0 1 3-.28a16 16 0 0 1 11.3 4.69l51.34 51.4Z"},null,-1)])])}const kT=Oe({name:"ph-cursor-click",render:xie}),wie={class:"dashboard-empty-state"},_ie=le({__name:"DashboardEmptyState",setup(t){return(e,n)=>(w(),R("div",wie,[H(p(kT),{class:"dashboard-empty-state__icon"}),n[0]||(n[0]=M("p",{class:"dashboard-empty-state__text"}," Select a chart to see its details ",-1))]))}}),kie=Be(_ie,[["__scopeId","data-v-f6c24334"]]),Sie={class:"dashboard-action-row__label"},Aie={key:0,class:"dashboard-action-row__description"},Cie=le({__name:"DashboardActionRow",props:{icon:{},label:{},description:{},danger:{type:Boolean}},emits:["click"],setup(t){const e=t,n=A(()=>({"dashboard-action-row--danger":e.danger}));return(o,r)=>(w(),R("button",{class:Me(["dashboard-action-row",p(n)]),onClick:r[0]||(r[0]=i=>o.$emit("click"))},[(w(),J(Gt(t.icon),{class:"dashboard-action-row__icon"})),M("div",null,[M("div",Sie,ye(t.label),1),t.description?(w(),R("div",Aie,ye(t.description),1)):ie("",!0)])],2))}}),$ie=Be(Cie,[["__scopeId","data-v-0f47d7d3"]]),Tie={class:"dashboard-detail-actions"},Mie={class:"dashboard-detail-actions__list"},Oie=le({__name:"DashboardDetailActions",emits:["duplicate","delete"],setup(t){return(e,n)=>{const o=$ie;return w(),R("div",Tie,[n[2]||(n[2]=M("div",{class:"dashboard-detail-actions__title"}," Actions ",-1)),M("div",Mie,[H(o,{icon:p(pA),label:"Duplicate",description:"Create a copy to edit",onClick:n[0]||(n[0]=r=>e.$emit("duplicate"))},null,8,["icon"]),H(o,{icon:p(UA),label:"Delete chart",description:"This cannot be undone",danger:"",onClick:n[1]||(n[1]=r=>e.$emit("delete"))},null,8,["icon"])])])}}}),Bie=Be(Oie,[["__scopeId","data-v-de396b53"]]),Lie={class:"dashboard-meta-chip"},Pie={class:"dashboard-meta-chip__label"},Die={class:"dashboard-meta-chip__value"},Eie=le({__name:"DashboardMetaChip",props:{label:{},value:{}},setup(t){return(e,n)=>(w(),R("div",Lie,[M("div",Pie,ye(t.label),1),M("div",Die,ye(t.value),1)]))}}),Nie=Be(Eie,[["__scopeId","data-v-a1903aff"]]),Iie={class:"dashboard-detail-meta"},Rie={class:"dashboard-detail-meta__grid"},Fie=le({__name:"DashboardDetailMeta",props:{chartType:{},savedAt:{},sceneCount:{},rowCount:{}},setup(t){const e=t,n=A(()=>NA(e.chartType)),o=A(()=>{if(!e.savedAt)return"—";const r=new Date(e.savedAt);return Number.isNaN(r.getTime())?e.savedAt:r.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})});return(r,i)=>{const s=Nie;return w(),R("div",Iie,[i[0]||(i[0]=M("div",{class:"dashboard-detail-meta__title"}," Details ",-1)),M("div",Rie,[H(s,{label:"Chart type",value:p(n)},null,8,["value"]),H(s,{label:"Last edited",value:p(o)},null,8,["value"]),H(s,{label:"Scenes",value:String(t.sceneCount)},null,8,["value"]),H(s,{label:"Data rows",value:String(t.rowCount)},null,8,["value"])])])}}}),Vie=Be(Fie,[["__scopeId","data-v-533a4b72"]]),zie=["data-bs-theme"],Hie=["src"],Wie=le({__name:"DashboardDetailPreview",props:{src:{},forceLightTheme:{type:Boolean}},setup(t){return(e,n)=>t.src?(w(),R("div",{key:0,class:"dashboard-detail-preview","data-bs-theme":t.forceLightTheme?"light":void 0},[M("img",{src:t.src,alt:"",class:"dashboard-detail-preview__img"},null,8,Hie)],8,zie)):ie("",!0)}}),Uie=Be(Wie,[["__scopeId","data-v-ddbd95be"]]),Gie={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function qie(t,e){return w(),R("svg",Gie,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m227.31 73.37l-44.68-44.69a16 16 0 0 0-22.63 0L36.69 152A15.86 15.86 0 0 0 32 163.31V208a16 16 0 0 0 16 16h44.69a15.86 15.86 0 0 0 11.31-4.69L227.31 96a16 16 0 0 0 0-22.63M92.69 208H48v-44.69l88-88L180.69 120ZM192 108.68L147.31 64l24-24L216 84.68Z"},null,-1)])])}const F2=Oe({name:"ph-pencil-simple",render:qie}),Yie={class:"dashboard-detail-content"},jie={key:0,class:"dashboard-detail-content__subtitle"},Xie=le({__name:"DashboardDetailContent",props:{title:{},subtitle:{},previewSrc:{},forceLightTheme:{type:Boolean},chartType:{},savedAt:{},sceneCount:{},rowCount:{}},emits:["edit","duplicate","delete"],setup(t){return(e,n)=>{const o=Uie,r=Vie,i=Bie;return w(),R("div",Yie,[t.subtitle?(w(),R("div",jie,ye(t.subtitle),1)):ie("",!0),H(p(Kn),{"icon-left":p(F2),label:"Edit chart",variant:"primary",block:"",onClick:n[0]||(n[0]=s=>e.$emit("edit"))},null,8,["icon-left"]),H(o,{src:t.previewSrc,"force-light-theme":t.forceLightTheme},null,8,["src","force-light-theme"]),H(r,{"chart-type":t.chartType,"saved-at":t.savedAt,"scene-count":t.sceneCount,"row-count":t.rowCount},null,8,["chart-type","saved-at","scene-count","row-count"]),H(i,{onDuplicate:n[1]||(n[1]=s=>e.$emit("duplicate")),onDelete:n[2]||(n[2]=s=>e.$emit("delete"))})])}}}),Kie=Be(Xie,[["__scopeId","data-v-3d8b1e29"]]),Zie=le({__name:"DashboardChartCard",props:{chart:{},thumbSrc:{},selected:{type:Boolean},layout:{}},emits:["select","edit"],setup(t){const{resolvedTheme:e}=Cf();return(n,o)=>(w(),J(p(oG),{title:t.chart.title||"Untitled",subtitle:t.chart.description,"thumb-src":t.thumbSrc,selected:t.selected,layout:t.layout,"force-light-thumb":!t.chart.allowDarkMode,"serif-title":!0,onClick:o[1]||(o[1]=r=>n.$emit("select",t.chart.id))},{actions:te(()=>[H(p(Kn),{"icon-left":p(F2),label:"Edit","hide-label":"",square:"",variant:"primary",size:"sm",class:"dashboard-chart-card__edit-btn",onClick:o[0]||(o[0]=r=>n.$emit("edit",t.chart.id))},null,8,["icon-left"])]),footer:te(()=>[H(p(XH),{"chart-type":t.chart.chartType,theme:p(e)},null,8,["chart-type","theme"]),t.chart.savedAt?(w(),J(p(BH),{key:0,value:t.chart.savedAt},null,8,["value"])):ie("",!0)]),_:1},8,["title","subtitle","thumb-src","selected","layout","force-light-thumb"]))}}),Qie=le({__name:"DashboardNewCard",props:{layout:{default:"grid"}},emits:["click"],setup(t){const e=t,n=A(()=>({"dashboard-new-card--row":e.layout==="row"}));return(o,r)=>(w(),R("div",{class:Me(["dashboard-new-card",p(n)]),role:"button",tabindex:"0",onClick:r[0]||(r[0]=i=>o.$emit("click")),onKeydown:[r[1]||(r[1]=er(i=>o.$emit("click"),["enter"])),r[2]||(r[2]=er(pn(i=>o.$emit("click"),["prevent"]),["space"]))]},[H(p(Py),{class:"dashboard-new-card__icon"}),r[3]||(r[3]=M("span",{class:"dashboard-new-card__label"},"New Chart",-1))],34))}}),Jie=Be(Qie,[["__scopeId","data-v-ef746b42"]]),ese=le({__name:"DashboardGallery",props:{charts:{},thumbnails:{},selectedId:{},layout:{}},emits:["select","edit","new"],setup(t){return(e,n)=>{const o=Jie,r=Zie;return w(),J(p(iG),{layout:t.layout},{default:te(()=>[H(o,{layout:t.layout,onClick:n[0]||(n[0]=i=>e.$emit("new"))},null,8,["layout"]),(w(!0),R(He,null,ht(t.charts,i=>(w(),J(r,{key:i.id,chart:i,"thumb-src":t.thumbnails[i.id],selected:t.selectedId===i.id,layout:t.layout,onSelect:n[1]||(n[1]=s=>e.$emit("select",s)),onEdit:n[2]||(n[2]=s=>e.$emit("edit",s))},null,8,["chart","thumb-src","selected","layout"]))),128)),t.charts.length===0?(w(),J(p(OW),{key:0,message:"No saved charts yet. Create a new chart to get started."})):ie("",!0)]),_:1},8,["layout"])}}}),tse={},nse={class:"layout-page-header"},ose={class:"layout-page-header__start"},rse={class:"layout-page-header__center"},ise={class:"layout-page-header__end"};function sse(t,e){return w(),R("div",nse,[M("div",ose,[Ce(t.$slots,"start",{},void 0,!0)]),M("div",rse,[Ce(t.$slots,"center",{},void 0,!0)]),M("div",ise,[Ce(t.$slots,"end",{},void 0,!0)])])}const ST=Be(tse,[["render",sse],["__scopeId","data-v-c99b9b81"]]),ase={key:0,class:"layout-breadcrumb","aria-label":"Breadcrumb"},lse=["aria-current"],cse={key:2,class:"layout-breadcrumb__crumb-sep","aria-hidden":"true"},use=le({__name:"LayoutBreadcrumb",setup(t){const e=Xl(),n=dn(),o=A(()=>{const r=e.path;if(r.startsWith("/edit/")){const i=n._base.title.value||"Untitled";return[{label:"My Charts",to:"/charts"},{label:i}]}return r.startsWith("/charts")?[{label:"My Charts"}]:r==="/new"?[{label:"My Charts",to:"/charts"},{label:"New chart"}]:[]});return(r,i)=>{const s=nm("router-link");return o.value.length?(w(),R("nav",ase,[(w(!0),R(He,null,ht(o.value,(a,l)=>(w(),R(He,{key:l},[a.to?(w(),J(s,{key:0,to:a.to,class:"layout-breadcrumb__crumb"},{default:te(()=>[Ye(ye(a.label),1)]),_:2},1032,["to"])):(w(),R("span",{key:1,class:"layout-breadcrumb__crumb layout-breadcrumb__crumb--active","aria-current":l===o.value.length-1?"page":void 0},ye(a.label),9,lse)),l<o.value.length-1?(w(),R("span",cse,"/")):ie("",!0)],64))),128))])):ie("",!0)}}}),AT=Be(use,[["__scopeId","data-v-73a5f2ae"]]),dse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function fse(t,e){return w(),R("svg",dse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208 136H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16v-40a16 16 0 0 0-16-16m0 56H48v-40h160zm0-144H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16m0 56H48V64h160z"},null,-1)])])}const hse=Oe({name:"ph-rows",render:fse}),pse={class:"dashboard-toolbar__count"},mse=le({__name:"DashboardToolbar",props:{chartCount:{},sortValue:{},layout:{}},emits:["update:sortValue","update:layout","new"],setup(t){const e=t,n=[{value:"date-desc",label:"Last edited"},{value:"date-asc",label:"Oldest first"},{value:"name-asc",label:"Name A–Z"}],o=A(()=>[{key:"grid",text:"Grid",icon:_T,active:e.layout==="grid"},{key:"row",text:"List",icon:hse,active:e.layout==="row"}]);return(r,i)=>(w(),J(ST,{class:"dashboard-toolbar"},{start:te(()=>[H(AT),M("span",pse,ye(t.chartCount)+" "+ye(t.chartCount===1?"chart":"charts"),1)]),end:te(()=>[H(p(zA),{items:p(o),"aria-label":"View layout",onSelect:i[0]||(i[0]=s=>r.$emit("update:layout",s))},null,8,["items"]),H(p(En),{"model-value":t.sortValue,options:n,"onUpdate:modelValue":i[1]||(i[1]=s=>r.$emit("update:sortValue",s))},null,8,["model-value"]),H(p(Kn),{"icon-left":p(Py),label:"New chart",variant:"primary",onClick:i[2]||(i[2]=s=>r.$emit("new"))},null,8,["icon-left"])]),_:1}))}}),gse=Be(mse,[["__scopeId","data-v-de771377"]]),vse={class:"dashboard-page-wrapper d-flex flex-column flex-grow-1"},bse=le({__name:"DashboardPage",setup(t){const e=Ay(),{isNarrow:n}=Ji(),{selectedChartId:o,selectChart:r}=xT(),{mode:i}=Ct(Bu()),{sortedCharts:s,selectedChart:a,thumbnails:l,previews:c,sortValue:u,refresh:d,duplicateChart:f,removeChart:h}=wT(),g=ft("galleryRef"),b=Ie("grid"),m=A(()=>({"dashboard-page":!0,"dashboard-page--narrow":n.value})),v=A(()=>a.value?a.value.title||"Untitled":"Chart details");function y(){o.value=null}const x=A({get:()=>o.value!==null,set:S=>{S||(o.value=null)}});function _(){o.value&&e.push(`/edit/${o.value}`)}function k(){if(o.value){const S=f(o.value);S&&e.push(`/edit/${S}`)}}function E(){o.value&&h(o.value)}function B(S){S.key==="Escape"&&(o.value=null)}return un(()=>{d(),document.addEventListener("keydown",B)}),Qs(()=>{document.removeEventListener("keydown",B)}),(S,L)=>{const D=gse,I=ese,C=Kie,T=kie,P=ug;return w(),R("div",vse,[H(D,{"chart-count":p(s).length,"sort-value":p(u),layout:p(b),"onUpdate:sortValue":L[0]||(L[0]=$=>u.value=$),"onUpdate:layout":L[1]||(L[1]=$=>b.value=$),onNew:L[2]||(L[2]=$=>p(e).push("/new"))},null,8,["chart-count","sort-value","layout"]),M("div",{class:Me(p(m))},[M("div",{ref_key:"galleryRef",ref:g,class:"dashboard-page__gallery"},[H(I,{charts:p(s),thumbnails:p(l),"selected-id":p(o),layout:p(b),onSelect:p(r),onEdit:L[3]||(L[3]=$=>p(e).push(`/edit/${$}`)),onNew:L[4]||(L[4]=$=>p(e).push("/new"))},null,8,["charts","thumbnails","selected-id","layout","onSelect"])],512),H(P,{"drawer-open":p(x),"onUpdate:drawerOpen":L[5]||(L[5]=$=>Ze(x)?x.value=$:null),title:p(v),"container-ref":p(g),"show-close":!1,onClose:y},{default:te(()=>[p(a)?(w(),J(C,{key:0,title:p(a).title||"Untitled",subtitle:p(a).description,"preview-src":p(o)?p(c)[p(o)]:void 0,"force-light-theme":p(a)?!p(a).allowDarkMode:!1,"chart-type":p(a).chartType,"saved-at":p(a).savedAt??void 0,"scene-count":p(a).sceneCount,"row-count":p(a).rowCount,onEdit:_,onDuplicate:k,onDelete:E},null,8,["title","subtitle","preview-src","force-light-theme","chart-type","saved-at","scene-count","row-count"])):p(i)==="docked"?(w(),J(T,{key:1})):ie("",!0)]),_:1},8,["drawer-open","title","container-ref"])],2)])}}}),yse=Be(bse,[["__scopeId","data-v-fe7a5a93"]]),xse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function wse(t,e){return w(),R("svg",xse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 40H40a16 16 0 0 0-16 16v144a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16M40 56h40v144H40Zm176 144H96V56h120z"},null,-1)])])}const CT=Oe({name:"ph-sidebar-simple",render:wse}),V2=le({__name:"PanelIconRail",props:{activeTab:{},items:{}},emits:["select","toggle-mode"],setup(t,{emit:e}){const n=e,{mode:o,open:r}=rc();function i(a){o.value==="closed"&&r(),n("select",a)}const s=A(()=>o.value==="closed"?"Open panel":"Close panel");return(a,l)=>(w(),J(p(fU),{"model-value":t.activeTab,items:t.items,"onUpdate:modelValue":i},{footer:te(()=>[H(p(Kn),{"icon-left":p(CT),label:p(s),"hide-label":"",square:"",variant:"link",size:"sm",onClick:l[0]||(l[0]=c=>a.$emit("toggle-mode"))},null,8,["icon-left","label"])]),_:1},8,["model-value","items"]))}}),_se=Oo("exportPanel",()=>{const t=Ie("embed"),e=Ie("png"),n=Ie(2),o=Ie(!1),r=Ie(!1),i=Ie(!0),s=Ie(!1),a=Ie("embed");function l(f){t.value=f}function c(f){e.value=f}function u(f){a.value=f}function d(){t.value="embed",e.value="png",n.value=2,o.value=!1,r.value=!1,i.value=!0,s.value=!1,a.value="embed"}return{exportTab:t,selectedFormat:e,pngScale:n,svgInlineFonts:o,svgMinify:r,bpcIncludeData:i,bpcCompact:s,lastNarrowExportTab:a,setExportTab:l,setSelectedFormat:c,setLastNarrowExportTab:u,reset:d}});function dg(){const t=_se(),{exportTab:e,selectedFormat:n,pngScale:o,svgInlineFonts:r,svgMinify:i,bpcIncludeData:s,bpcCompact:a,lastNarrowExportTab:l}=Ct(t);return{exportTab:e,selectedFormat:n,pngScale:o,svgInlineFonts:r,svgMinify:i,bpcIncludeData:s,bpcCompact:a,lastNarrowExportTab:l,setExportTab:t.setExportTab,setSelectedFormat:t.setSelectedFormat,setLastNarrowExportTab:t.setLastNarrowExportTab,reset:t.reset}}const kse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Sse(t,e){return w(),R("svg",kse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M69.12 94.15L28.5 128l40.62 33.85a8 8 0 1 1-10.24 12.29l-48-40a8 8 0 0 1 0-12.29l48-40a8 8 0 0 1 10.24 12.3m176 27.7l-48-40a8 8 0 1 0-10.24 12.3L227.5 128l-40.62 33.85a8 8 0 1 0 10.24 12.29l48-40a8 8 0 0 0 0-12.29m-82.39-89.37a8 8 0 0 0-10.25 4.79l-64 176a8 8 0 0 0 4.79 10.26A8.1 8.1 0 0 0 96 224a8 8 0 0 0 7.52-5.27l64-176a8 8 0 0 0-4.79-10.25"},null,-1)])])}const Ase=Oe({name:"ph-code",render:Sse}),Cse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function $se(t,e){return w(),R("svg",Cse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 144v64a8 8 0 0 1-8 8H40a8 8 0 0 1-8-8v-64a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0m-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 124.69V32a8 8 0 0 0-16 0v92.69L93.66 98.34a8 8 0 0 0-11.32 11.32Z"},null,-1)])])}const $T=Oe({name:"ph-download-simple",render:$se});function TT(){return{sections:[{key:"embed",label:"Embed",icon:Ase},{key:"download",label:"Download",icon:$T}]}}const Tse=le({__name:"ExportIconRail",setup(t){const{mode:e,toggleMode:n}=rc(),o=dg(),{exportTab:r}=Ct(o),{setExportTab:i}=o,{sections:s}=TT(),a=A(()=>s.map(c=>({value:c.key,icon:c.icon,tooltip:c.tooltip??c.label})));function l(c){i(c),e.value==="closed"&&n()}return(c,u)=>{const d=V2;return w(),J(d,{"active-tab":p(r),items:p(a),onSelect:l,onToggleMode:p(n)},null,8,["active-tab","items","onToggleMode"])}}}),Ni=[{label:"Data",key:"data"},{label:"Visualize",key:"edit"},{label:"Export",key:"export"}];function Mse(t){return t.endsWith("/export")?"export":t.endsWith("/visualize")?"edit":(t.endsWith("/data"),"data")}function Ose(t,e){return e==="edit"?`/edit/${t}/visualize`:`/edit/${t}/${e}`}const $v=Ve(null);function z2(){const t=Xl(),e=Ay(),n=A(()=>{const h=Mse((t==null?void 0:t.path)??"/new");return Ni.find(g=>g.key===h)??Ni[0]}),o=A({get:()=>Ni.indexOf(n.value),set:h=>{u(h)}}),r=A(()=>o.value===0),i=A(()=>o.value===Ni.length-1);function s(){var g;const h=(g=t==null?void 0:t.params)==null?void 0:g.id;return h||($v.value?$v.value():null)}function a(h){const g=s();g&&e&&e.replace(Ose(g,h))}function l(){const h=o.value;h<Ni.length-1&&a(Ni[h+1].key)}function c(){const h=o.value;h>0&&a(Ni[h-1].key)}function u(h){h>=0&&h<Ni.length&&a(Ni[h].key)}function d(){}function f(h){$v.value=h}return{currentIndex:o,steps:Ni,currentStep:n,isFirst:r,isLast:i,next:l,back:c,goTo:u,reset:d,registerCreateSession:f}}const Bse={class:"panel-stepper-footer"},Lse=le({__name:"PanelStepperFooter",setup(t){const{steps:e,currentIndex:n,isFirst:o,isLast:r,next:i,back:s}=z2(),a=A(()=>{var c;return((c=e[n.value-1])==null?void 0:c.label)??"Previous"}),l=A(()=>{var c;return((c=e[n.value+1])==null?void 0:c.label)??"Next"});return(c,u)=>(w(),R("div",Bse,[p(o)?ie("",!0):(w(),J(p(Kn),{key:0,"icon-left":p(GA),"icon-left-size":"1em",label:p(a),variant:"outline-secondary",size:"sm",onClick:p(s)},null,8,["icon-left","label","onClick"])),p(r)?ie("",!0):(w(),J(p(Kn),{key:1,"icon-right":p(qA),"icon-right-size":"1em",label:p(l),variant:"primary",size:"sm",class:"ms-auto",onClick:p(i)},null,8,["icon-right","label","onClick"]))]))}}),H2=Be(Lse,[["__scopeId","data-v-52b4dceb"]]),Pse={class:"format-card__header"},Dse={class:"format-card__header__text"},Ese={class:"format-card__header__text__label"},Nse={class:"format-card__header__text__desc"},Ise={key:0,class:"format-card__options"},Rse=le({__name:"ExportDownloadFormatCard",props:{selected:{type:Boolean},icon:{},label:{},description:{},iconBg:{},iconColor:{}},emits:["select","download"],setup(t){return(e,n)=>(w(),R("div",{class:Me(["format-card",{"format-card--selected":t.selected}]),onClick:n[1]||(n[1]=o=>e.$emit("select"))},[M("div",Pse,[M("span",{class:"format-card__header__icon",style:Et({background:t.iconBg,color:t.iconColor})},[(w(),J(Gt(t.icon)))],4),M("div",Dse,[M("div",Ese,ye(t.label),1),M("div",Nse,ye(t.description),1)]),H(p(Kn),{"icon-left":p($T),label:"Download","hide-label":"",variant:"primary",size:"sm",square:"",onClick:n[0]||(n[0]=pn(o=>e.$emit("download"),["stop"]))},null,8,["icon-left"])]),t.selected&&e.$slots.default?(w(),R("div",Ise,[Ce(e.$slots,"default",{},void 0,!0)])):ie("",!0)],2))}}),Fse=Be(Rse,[["__scopeId","data-v-f26129ef"]]);function If(t,e){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,o.click(),URL.revokeObjectURL(n)}function Vse(t,e="chart.svg"){const o=new XMLSerializer().serializeToString(t),r=new Blob([o],{type:"image/svg+xml;charset=utf-8"});If(r,e)}function zse(t,e,n,o="chart.png"){const i=new XMLSerializer().serializeToString(t),s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s);return new Promise((l,c)=>{const u=new Image;u.onload=()=>{const d=document.createElement("canvas");d.width=e,d.height=n;const f=d.getContext("2d");if(!f){URL.revokeObjectURL(a),c(new Error("Could not get canvas context"));return}f.drawImage(u,0,0,e,n),d.toBlob(h=>{if(URL.revokeObjectURL(a),!h){c(new Error("Could not create PNG blob"));return}If(h,o),l()},"image/png")},u.onerror=()=>{URL.revokeObjectURL(a),c(new Error("Failed to load SVG image"))},u.src=a})}function MT(t,e){const n=globalThis.getComputedStyle(t),o=e;if(o.style)for(let s=0;s<n.length;s++){const a=n[s];o.style.setProperty(a,n.getPropertyValue(a))}const r=t.children,i=e.children;for(let s=0;s<r.length;s++)i[s]&&MT(r[s],i[s])}function Hse(t){const e=globalThis.getComputedStyle(t);return{top:parseFloat(e.paddingTop)||0,right:parseFloat(e.paddingRight)||0,bottom:parseFloat(e.paddingBottom)||0,left:parseFloat(e.paddingLeft)||0}}function Wse(t,e=2,n="chart.png",o,r){const{width:i,height:s}=t.getBoundingClientRect(),a=r??{top:0,right:0,bottom:0,left:0},l=i+a.left+a.right,c=s+a.top+a.bottom,u=Math.ceil(l*e),d=Math.ceil(c*e),f=t.cloneNode(!0);MT(t,f),f.querySelectorAll("[data-scene-player]").forEach(k=>k.remove()),f.style.setProperty("pointer-events","auto"),f.style.setProperty("transition","none"),f.style.setProperty("animation","none");const g=new XMLSerializer().serializeToString(f),b=a.left,m=a.top,v=o?`<rect width="${l}" height="${c}" fill="${o}" />`:"",y=[`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${d}">`,`<g transform="scale(${e})">`,v,`<foreignObject x="${b}" y="${m}" width="${i}" height="${s}">`,g,"</foreignObject>","</g>","</svg>"].join(""),x=new Blob([y],{type:"image/svg+xml;charset=utf-8"}),_=URL.createObjectURL(x);return new Promise((k,E)=>{const B=new Image;B.onload=()=>{const S=document.createElement("canvas");S.width=u,S.height=d;const L=S.getContext("2d");if(!L){URL.revokeObjectURL(_),E(new Error("Could not get canvas context"));return}L.drawImage(B,0,0,u,d),S.toBlob(D=>{if(URL.revokeObjectURL(_),!D){E(new Error("Could not create PNG blob"));return}If(D,n),k()},"image/png")},B.onerror=()=>{URL.revokeObjectURL(_),E(new Error("Failed to render frame as image"))},B.src=_})}function Tv(t){const e=globalThis.getComputedStyle(t);return{fontSize:parseFloat(e.fontSize),fontWeight:e.fontWeight,fontFamily:e.fontFamily,fill:e.color,fontStyle:e.fontStyle}}function OT(t){let e=t;for(;e;){const n=globalThis.getComputedStyle(e).backgroundColor;if(n&&n!=="transparent"&&n!=="rgba(0, 0, 0, 0)")return n;e=e.parentElement}return"#ffffff"}function Use(t,e="chart.svg"){const n=t.querySelector("svg");if(!n)return;const o=t.getBoundingClientRect(),r=OT(t),i=new XMLSerializer,s=[],a=t.querySelectorAll(".bc-frame-title, .bc-frame-description");for(const B of a){const S=B.getBoundingClientRect(),L=Tv(B);s.push({text:B.textContent??"",x:S.left-o.left,y:S.top-o.top+L.fontSize,...L})}const l=t.querySelector(".bc-frame-note");if(l&&l.textContent&&l.style.display!=="none"){const B=l.getBoundingClientRect(),S=Tv(l);s.push({text:l.textContent,x:B.left-o.left,y:B.top-o.top+S.fontSize,...S})}const c=t.querySelectorAll(".bc-frame-byline, .bc-frame-source, .bc-frame-credit");for(const B of c){const S=B.getBoundingClientRect();if(S.width===0)continue;const L=Tv(B);s.push({text:B.textContent??"",x:S.left-o.left,y:S.top-o.top+L.fontSize,...L})}const u=n.getBoundingClientRect(),d=u.left-o.left,f=u.top-o.top,h=u.width,g=u.height,b=n.cloneNode(!0);b.removeAttribute("width"),b.removeAttribute("height");const m=i.serializeToString(b),v=Math.ceil(o.width),y=Math.ceil(o.height),x=B=>B.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),_=s.map(B=>`<text x="${B.x}" y="${B.y}" font-size="${B.fontSize}px" font-weight="${B.fontWeight}" font-family="${x(B.fontFamily)}" fill="${B.fill}"${B.fontStyle&&B.fontStyle!=="normal"?` font-style="${B.fontStyle}"`:""}>${x(B.text)}</text>`).join(`
|
|
848
848
|
`),k=[`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${v}" height="${y}" viewBox="0 0 ${v} ${y}">`,` <rect width="100%" height="100%" fill="${r}" />`,` ${_}`,` <g transform="translate(${d},${f})">`,` <svg width="${h}" height="${g}"${b.getAttribute("viewBox")?` viewBox="${b.getAttribute("viewBox")}"`:""}>`,m.replace(/^<svg[^>]*>/,"").replace(/<\/svg>$/,"")," </svg>"," </g>","</svg>"].join(`
|
|
849
|
-
`),E=new Blob([k],{type:"image/svg+xml;charset=utf-8"});If(E,e)}const Wse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Use(t,e){return w(),R("svg",Wse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 40H40a16 16 0 0 0-16 16v144a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 16v102.75l-26.07-26.06a16 16 0 0 0-22.63 0l-20 20l-44-44a16 16 0 0 0-22.62 0L40 149.37V56ZM40 172l52-52l80 80H40Zm176 28h-21.37l-36-36l20-20L216 181.38zm-72-100a12 12 0 1 1 12 12a12 12 0 0 1-12-12"},null,-1)])])}const Gse=Oe({name:"ph-image",render:Use}),qse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Yse(t,e){return w(),R("svg",qse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M181.66 146.34a8 8 0 0 1 0 11.32l-24 24a8 8 0 0 1-11.32-11.32L164.69 152l-18.35-18.34a8 8 0 0 1 11.32-11.32Zm-72-24a8 8 0 0 0-11.32 0l-24 24a8 8 0 0 0 0 11.32l24 24a8 8 0 0 0 11.32-11.32L91.31 152l18.35-18.34a8 8 0 0 0 0-11.32M216 88v128a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16V40a16 16 0 0 1 16-16h96a8 8 0 0 1 5.66 2.34l56 56A8 8 0 0 1 216 88m-56-8h28.69L160 51.31Zm40 136V96h-48a8 8 0 0 1-8-8V40H56v176z"},null,-1)])])}const jse=Oe({name:"ph-file-code",render:Yse}),Xse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Kse(t,e){return w(),R("svg",Xse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m213.66 82.34l-56-56A8 8 0 0 0 152 24H56a16 16 0 0 0-16 16v176a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16V88a8 8 0 0 0-2.34-5.66M160 51.31L188.69 80H160ZM200 216H56V40h88v48a8 8 0 0 0 8 8h48zm-32-80a8 8 0 0 1-8 8H96a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8m0 32a8 8 0 0 1-8 8H96a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8"},null,-1)])])}const BT=Oe({name:"ph-file-text",render:Kse}),Zse={class:"export-download-panel"},Qse=le({__name:"ExportDownloadPanel",emits:["download-png","download-svg"],setup(t,{emit:e}){const n=dg(),{selectedFormat:o,pngScale:r,svgInlineFonts:i,svgMinify:s,bpcCompact:a}=Ct(n),{setSelectedFormat:l}=n,{dsl:c}=Nf(),u=e;function d(){u("download-png",r.value)}function f(){u("download-svg")}function h(){If(new globalThis.Blob([c.value],{type:"text/plain"}),"chart.bpc")}return(g,b)=>{const m=Ise,v=Rs;return w(),R("div",Zse,[H(m,{selected:p(o)==="png",icon:p(Gse),label:"PNG",description:"Raster image, best for presentations","icon-bg":"var(--bs-info-bg-subtle)","icon-color":"var(--bs-info-text-emphasis)",onSelect:b[1]||(b[1]=y=>p(l)("png")),onDownload:d},{default:te(()=>[H(p(xr),{id:"png-scale","model-value":p(r),label:"Scale",min:1,max:4,step:1,"onUpdate:modelValue":b[0]||(b[0]=y=>r.value=y)},null,8,["model-value"])]),_:1},8,["selected","icon"]),H(m,{selected:p(o)==="svg",icon:p(jse),label:"SVG",description:"Vector image, best for print and web","icon-bg":"var(--bs-success-bg-subtle)","icon-color":"var(--bs-success-text-emphasis)",onSelect:b[4]||(b[4]=y=>p(l)("svg")),onDownload:f},{default:te(()=>[H(v,{modelValue:p(i),"onUpdate:modelValue":b[2]||(b[2]=y=>Ze(i)?i.value=y:null),switch:""},{default:te(()=>[...b[7]||(b[7]=[Ye(" Inline fonts ",-1)])]),_:1},8,["modelValue"]),H(v,{modelValue:p(s),"onUpdate:modelValue":b[3]||(b[3]=y=>Ze(s)?s.value=y:null),switch:""},{default:te(()=>[...b[8]||(b[8]=[Ye(" Minify ",-1)])]),_:1},8,["modelValue"])]),_:1},8,["selected","icon"]),H(m,{selected:p(o)==="bpc",icon:p(BT),label:"BPC",description:"Blueprint Chart DSL file","icon-bg":"var(--bs-warning-bg-subtle)","icon-color":"var(--bs-warning-text-emphasis)",onSelect:b[6]||(b[6]=y=>p(l)("bpc")),onDownload:h},{default:te(()=>[H(v,{modelValue:p(a),"onUpdate:modelValue":b[5]||(b[5]=y=>Ze(a)?a.value=y:null),switch:""},{default:te(()=>[...b[9]||(b[9]=[Ye(" Compact ",-1)])]),_:1},8,["modelValue"])]),_:1},8,["selected","icon"])])}}}),Jse=Be(Qse,[["__scopeId","data-v-f6670dcb"]]),eae={class:"export-embed-panel"},tae={class:"export-embed-panel__code-block"},nae={class:"export-embed-panel__code-block__header"},oae={class:"export-embed-panel__code-block__pre"},rae=["href"],iae=le({__name:"ExportEmbedPanel",setup(t){const{dsl:e,generateDsl:n}=Nf(),{layout:o}=dn();function r(a){const l=new TextEncoder().encode(a);let c="";for(const u of l)c+=String.fromCharCode(u);return globalThis.btoa(c)}const i=A(()=>{const a=r(e.value||n());return`${window.location.origin}${window.location.pathname}#/render?bpc64=${encodeURIComponent(a)}`}),s=A(()=>{const a=Pt(o.value),l=a.heightMode==="fixed"?a.fixedHeight:400,c=[];return a.sizing==="responsive"?c.push(`width="100%" height="${l}"`):a.sizing==="max-width"?c.push(`style="width:100%;max-width:${a.maxWidth}px" height="${l}"`):c.push(`width="${a.fixedWidth}" height="${l}"`),`<iframe src="${i.value}" ${c.join(" ")} frameborder="0"></iframe>`});return(a,l)=>(w(),R("div",eae,[M("div",tae,[M("div",nae,[l[0]||(l[0]=M("span",{class:"export-embed-panel__code-block__label"},"Embed code",-1)),H(p(O_),{text:p(s),label:"Copy",variant:"outline-secondary",size:"sm"},null,8,["text"])]),M("pre",oae,[M("code",null,ye(p(s)),1)])]),l[1]||(l[1]=M("div",{class:"export-embed-panel__info"}," Paste this iframe into your HTML page. The chart renders automatically. ",-1)),H(p(O_),{text:p(s),label:"Copy embed code",variant:"primary",size:"sm"},null,8,["text"]),M("a",{href:p(i),target:"_blank",rel:"noopener",class:"export-embed-panel__link"}," Preview in new tab ",8,rae)]))}}),sae=Be(iae,[["__scopeId","data-v-030ab97a"]]),aae=["onClick"],lae=le({__name:"PanelTabBar",props:it({tabs:{},sticky:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=dt(t,"modelValue"),n=ft("tabsRef");let o=null;function r(){xn(()=>{o!=null&&o.scrollIntoView&&n.value&&o.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})})}return Ge(()=>o,r),(i,s)=>(w(),R("div",{ref_key:"tabsRef",ref:n,class:Me(["panel-tab-bar",{"panel-tab-bar--sticky":t.sticky}])},[(w(!0),R(He,null,ht(t.tabs,a=>(w(),R("button",{key:a.key,ref_for:!0,ref:l=>{a.key===e.value&&(Ze(o)?o.value=l:o=l)},class:Me(["panel-tab-bar__tab",{"panel-tab-bar__tab--active":e.value===a.key}]),onClick:l=>e.value=a.key},[a.icon?(w(),J(Gt(a.icon),{key:0,class:"panel-tab-bar__tab__icon","aria-hidden":"true"})):ie("",!0),Ye(" "+ye(a.label),1)],10,aae))),128))],2))}}),W2=Be(lae,[["__scopeId","data-v-1a1009cc"]]),cae=le({__name:"CanvasModePickerOptionSwatch",props:{mode:{}},setup(t){return(e,n)=>(w(),R("span",{class:Me(["canvas-mode-swatch",`canvas-mode-swatch--${t.mode}`])},null,2))}}),LT=Be(cae,[["__scopeId","data-v-81dabc6c"]]),uae=Oo("editorPanel",()=>{const t=Ie("type"),e=Ie("preview"),n=Ie("blueprint"),o=Ie(!0),r=Ie(null),i=Ie("upload"),s=Ie(""),a=Ie(!1),l=Ie(-1),c=Ie("type"),u=Ie("column");function d(S){t.value=S}function f(S){r.value=S,d("annotate")}function h(S){e.value=S}function g(S){n.value=S}function b(S){i.value=S,S==="structure"&&v("column")}function m(S){s.value=S}function v(S){s.value=S,a.value=!0}function y(){a.value=!1,s.value=""}function x(){a.value=!a.value}function _(S){if(l.value===S){l.value=-1;return}l.value=S,v("column")}function k(S){c.value=S}function E(S){u.value=S}function B(){t.value="type",e.value="preview",n.value="blueprint",o.value=!0,r.value=null,i.value="upload",s.value="",a.value=!1,l.value=-1,c.value="type",u.value="column"}return{activeTab:t,viewMode:e,canvasMode:n,showDimensions:o,pendingAnnotationIndex:r,dataView:i,dataPanelTab:s,dataPanelOpen:a,selectedColumnIndex:l,lastNarrowEditTab:c,lastNarrowDataTab:u,selectTab:d,selectAnnotation:f,setViewMode:h,setCanvasMode:g,setDataView:b,setDataPanelTab:m,openDataPanel:v,closeDataPanel:y,toggleDataPanel:x,selectColumn:_,setLastNarrowEditTab:k,setLastNarrowDataTab:E,reset:B}});function cr(){const t=uae(),{activeTab:e,viewMode:n,canvasMode:o,showDimensions:r,pendingAnnotationIndex:i,dataView:s,dataPanelTab:a,dataPanelOpen:l,selectedColumnIndex:c,lastNarrowEditTab:u,lastNarrowDataTab:d}=Ct(t);return{activeTab:e,viewMode:n,canvasMode:o,showDimensions:r,pendingAnnotationIndex:i,dataView:s,dataPanelTab:a,dataPanelOpen:l,selectedColumnIndex:c,lastNarrowEditTab:u,lastNarrowDataTab:d,selectTab:t.selectTab,selectAnnotation:t.selectAnnotation,setViewMode:t.setViewMode,setCanvasMode:t.setCanvasMode,setDataView:t.setDataView,setDataPanelTab:t.setDataPanelTab,openDataPanel:t.openDataPanel,closeDataPanel:t.closeDataPanel,toggleDataPanel:t.toggleDataPanel,selectColumn:t.selectColumn,setLastNarrowEditTab:t.setLastNarrowEditTab,setLastNarrowDataTab:t.setLastNarrowDataTab,reset:t.reset}}const dae={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function fae(t,e){return w(),R("svg",dae,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m235.32 73.37l-52.69-52.68a16 16 0 0 0-22.63 0L20.68 160a16 16 0 0 0 0 22.63l52.69 52.68a16 16 0 0 0 22.63 0L235.32 96a16 16 0 0 0 0-22.63M84.68 224L32 171.31l32-32l26.34 26.35a8 8 0 0 0 11.32-11.32L75.31 128L96 107.31l26.34 26.35a8 8 0 0 0 11.32-11.32L107.31 96L128 75.31l26.34 26.35a8 8 0 0 0 11.32-11.32L139.31 64l32-32L224 84.69Z"},null,-1)])])}const hae=Oe({name:"ph-ruler",render:fae}),pae=le({__name:"CanvasDimensionsToggle",setup(t){const{showDimensions:e}=Ct(cr());return(n,o)=>(w(),R("button",{class:Me(["canvas-dimensions-toggle",{"canvas-dimensions-toggle--active":p(e)}]),title:"Show dimensions",onClick:o[0]||(o[0]=r=>e.value=!p(e))},[H(p(hae))],2))}}),mae=Be(pae,[["__scopeId","data-v-0920c699"]]),gae=["title"],vae={class:"canvas-mode-picker-option__label"},bae=le({__name:"CanvasModePickerOption",props:{mode:{},label:{},active:{type:Boolean}},emits:["select"],setup(t){return(e,n)=>{const o=LT;return w(),R("button",{class:Me(["canvas-mode-picker-option",{"canvas-mode-picker-option--active":t.active}]),title:t.label,onClick:n[0]||(n[0]=r=>e.$emit("select"))},[H(o,{mode:t.mode},null,8,["mode"]),M("span",vae,ye(t.label),1)],10,gae)}}}),yae=Be(bae,[["__scopeId","data-v-b7a042b3"]]),xae={class:"canvas-mode-picker__extra"},wae={key:1,class:"canvas-mode-picker__trigger",title:"Canvas mode"},_ae=le({__name:"CanvasModePicker",setup(t){const e=cr(),{canvasMode:n}=Ct(e),{setCanvasMode:o}=e,r=Ie(!1),i=[{value:"blueprint",label:"Blueprint"},{value:"auto",label:"Auto"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}];function s(a){o(a),r.value=!1}return(a,l)=>{const c=yae,u=mae,d=LT;return w(),R("div",{class:"canvas-mode-picker",onMouseenter:l[0]||(l[0]=f=>r.value=!0),onMouseleave:l[1]||(l[1]=f=>r.value=!1)},[p(r)?(w(),R(He,{key:0},[(w(),R(He,null,ht(i,f=>H(c,{key:f.value,mode:f.value,label:f.label,active:p(n)===f.value,onSelect:h=>s(f.value)},null,8,["mode","label","active","onSelect"])),64)),l[3]||(l[3]=M("div",{class:"canvas-mode-picker__divider"},null,-1)),M("div",xae,[H(u),l[2]||(l[2]=M("span",{class:"canvas-mode-picker__extra__label"},"Dims",-1))])],64)):(w(),R("button",wae,[H(d,{mode:p(n)},null,8,["mode"])]))],32)}}}),PT=Be(_ae,[["__scopeId","data-v-beb08053"]]),kae={transform:"translate(0.5, 0.5)"},Sae={class:"canvas-dimensions__line"},Aae=["x1","y1","x2","y2"],Cae=["x1","y1","x2","y2"],$ae=["x1","y1","x2","y2"],Tae=["x","y"],Mae={class:"canvas-dimensions__line"},Oae=["x1","y1","x2","y2"],Bae=["x1","y1","x2","y2"],Lae=["x1","y1","x2","y2"],Pae=["x","y"],Dae={class:"canvas-dimensions__line canvas-dimensions__line--padding"},Eae=["x1","y1","x2","y2"],Nae=["x1","y1","x2","y2"],Iae=["x1","y1","x2","y2"],Rae=["x","y"],Fae=["x1","y1","x2","y2"],Vae=["x1","y1","x2","y2"],zae=["x1","y1","x2","y2"],Hae=["x","y"],Wae={class:"canvas-dimensions__line canvas-dimensions__line--padding"},Uae=["x1","y1","x2","y2"],Gae=["x1","y1","x2","y2"],qae=["x1","y1","x2","y2"],Yae=["x","y"],jae=["x1","y1","x2","y2"],Xae=["x1","y1","x2","y2"],Kae=["x1","y1","x2","y2"],Zae=["x","y"],Y6=20,en=3,kh=4,j6=20,Qae=le({__name:"CanvasDimensions",props:{cardRef:{},canvasRef:{},layout:{}},setup(t){const e=t,n=Ve(null);function o(){const v=e.cardRef;if(!v){n.value=null;return}n.value={left:v.offsetLeft,top:v.offsetTop,width:v.offsetWidth,height:v.offsetHeight}}is(()=>e.canvasRef,o),is(()=>e.cardRef,o);const r=A(()=>({position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"})),i=A(()=>{const v=n.value;return{x1:v.left,x2:v.left+v.width,y:v.top+v.height+Y6}}),s=A(()=>{const v=n.value;return{x:v.left-Y6,y1:v.top,y2:v.top+v.height}}),a=A(()=>{const v=i.value,y=e.layout.padding;return y>0&&!c.value?{x1:v.x1+y+kh,x2:v.x2-y-kh}:{x1:v.x1,x2:v.x2}}),l=A(()=>{const v=s.value,y=e.layout.padding;return y>0&&!u.value?{y1:v.y1+y+kh,y2:v.y2-y-kh}:{y1:v.y1,y2:v.y2}}),c=A(()=>e.layout.sizing!=="responsive"),u=A(()=>e.layout.heightMode!=="auto"),d=A(()=>e.layout.padding>0),f=A(()=>`${e.layout.padding}px`),h=A(()=>i.value.y+j6),g=A(()=>s.value.x-j6),b=A(()=>{const v=e.layout;return v.sizing==="fixed"?`${v.fixedWidth}px`:v.sizing==="max-width"?`max ${v.maxWidth}px`:"auto"}),m=A(()=>{const v=e.layout;return v.heightMode==="fixed"?`${v.fixedHeight}px`:v.heightMode==="aspect-ratio"?v.aspectRatio:"auto"});return(v,y)=>p(n)?(w(),R("svg",{key:0,class:"canvas-dimensions",style:Et(p(r))},[M("g",kae,[M("g",Sae,[M("line",{x1:p(a).x1,y1:p(i).y,x2:p(a).x2,y2:p(i).y},null,8,Aae),M("line",{x1:p(a).x1,y1:p(i).y-en,x2:p(a).x1,y2:p(i).y+en},null,8,Cae),M("line",{x1:p(a).x2,y1:p(i).y-en,x2:p(a).x2,y2:p(i).y+en},null,8,$ae),M("text",{x:(p(i).x1+p(i).x2)/2,y:p(i).y+en+12,"text-anchor":"middle"},ye(p(b)),9,Tae)]),M("g",Mae,[M("line",{x1:p(s).x,y1:p(l).y1,x2:p(s).x,y2:p(l).y2},null,8,Oae),M("line",{x1:p(s).x-en,y1:p(l).y1,x2:p(s).x+en,y2:p(l).y1},null,8,Bae),M("line",{x1:p(s).x-en,y1:p(l).y2,x2:p(s).x+en,y2:p(l).y2},null,8,Lae),M("text",{x:p(s).x-5,y:(p(s).y1+p(s).y2)/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(m)),9,Pae)]),p(d)?(w(),R(He,{key:0},[M("g",Dae,[M("line",{x1:p(i).x1,y1:p(c)?p(h):p(i).y,x2:p(i).x1+t.layout.padding,y2:p(c)?p(h):p(i).y},null,8,Eae),M("line",{x1:p(i).x1,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x1,y2:(p(c)?p(h):p(i).y)+en},null,8,Nae),M("line",{x1:p(i).x1+t.layout.padding,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x1+t.layout.padding,y2:(p(c)?p(h):p(i).y)+en},null,8,Iae),M("text",{x:p(i).x1+t.layout.padding/2,y:(p(c)?p(h):p(i).y)+en+12,"text-anchor":"middle"},ye(p(f)),9,Rae),M("line",{x1:p(i).x2-t.layout.padding,y1:p(c)?p(h):p(i).y,x2:p(i).x2,y2:p(c)?p(h):p(i).y},null,8,Fae),M("line",{x1:p(i).x2-t.layout.padding,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x2-t.layout.padding,y2:(p(c)?p(h):p(i).y)+en},null,8,Vae),M("line",{x1:p(i).x2,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x2,y2:(p(c)?p(h):p(i).y)+en},null,8,zae),M("text",{x:p(i).x2-t.layout.padding/2,y:(p(c)?p(h):p(i).y)+en+12,"text-anchor":"middle"},ye(p(f)),9,Hae)]),M("g",Wae,[M("line",{x1:p(u)?p(g):p(s).x,y1:p(s).y1,x2:p(u)?p(g):p(s).x,y2:p(s).y1+t.layout.padding},null,8,Uae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y1,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y1},null,8,Gae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y1+t.layout.padding,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y1+t.layout.padding},null,8,qae),M("text",{x:(p(u)?p(g):p(s).x)-en-4,y:p(s).y1+t.layout.padding/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(f)),9,Yae),M("line",{x1:p(u)?p(g):p(s).x,y1:p(s).y2-t.layout.padding,x2:p(u)?p(g):p(s).x,y2:p(s).y2},null,8,jae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y2-t.layout.padding,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y2-t.layout.padding},null,8,Xae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y2,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y2},null,8,Kae),M("text",{x:(p(u)?p(g):p(s).x)-en-4,y:p(s).y2-t.layout.padding/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(f)),9,Zae)])],64)):ie("",!0)])],4)):ie("",!0)}}),DT=Be(Qae,[["__scopeId","data-v-394e6d5d"]]);function Jae(t){const e=t.split(":");if(e.length!==2)return;const n=Number(e[0]),o=Number(e[1]);return n&&o?n/o:void 0}function U2(t,e){const n=A(()=>t.value.heightMode==="fixed"||t.value.heightMode==="aspect-ratio"),o=A(()=>({[`${e}--fixed`]:t.value.sizing==="fixed",[`${e}--max-width`]:t.value.sizing==="max-width",[`${e}--transparent`]:t.value.transparentBackground,[`${e}--constrained-height`]:n.value})),r=A(()=>{const i=t.value,s={};if(i.sizing==="fixed"?s.width=`${i.fixedWidth}px`:i.sizing==="max-width"&&(s.maxWidth=`${i.maxWidth}px`,s.width="100%"),i.heightMode==="fixed")s.height=`${i.fixedHeight}px`;else if(i.heightMode==="aspect-ratio"){const a=Jae(i.aspectRatio);a&&(s.aspectRatio=String(a))}return s});return{cardClass:o,cardStyle:r,hasConstrainedHeight:n}}function ele(t,e){t.replaceChildren();const n=document.createElement("div");n.className="text-center text-muted p-5",n.textContent=e,t.appendChild(n)}const tle=150;function G2(t){const e=dn(),{currentOptions:n}=_n(),{scenes:o,activeIndex:r,activeScene:i}=wn(),{columns:s,rows:a,columnTypes:l}=jo(),{applyStepList:c}=Lr(),{theme:u}=Cf(),{chartTheme:d}=rT(),f=Symbol("unset");let h=f,g=!1;function b(){if(!(!t.value||g)){g=!0;try{m()}finally{g=!1}}}function m(){var oe;if(!t.value)return;const _=i.value,k=Ra(o.value,r.value),E=(k==null?void 0:k.chartType)??e.chartType.value;let B;if((k==null?void 0:k.data)!==void 0)B=k.data;else if((oe=k==null?void 0:k.transforms)!=null&&oe.length&&s.value.length>0){const de=c(k.transforms,s.value,a.value,l.value);B=cg(de.columns,de.rows)}else B=e.data.value;const S=fs(B),L=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];if(S.series&&S.series.length>0&&L.includes(E)){const de=S.series.find(we=>we.name===e.selectedColumn.value);de&&(S.values=de.values),delete S.series}if(S.labels.length===0){ele(t.value,"No data to preview");return}const D=n.value.allowDarkMode??!0,I=t.value.parentElement;I&&(!D&&u.value!=="light"?I.setAttribute("data-bs-theme","light"):I.removeAttribute("data-bs-theme"));const C=h!==f&&_!==h,T=k!=null&&k.chartTypeOptions?{...n.value,...k.chartTypeOptions}:n.value,P=(k==null?void 0:k.colorizes)??e.colorizes.value,$=k?k.highlights??[]:e._base.highlights.value,F=(k==null?void 0:k.areaFills)??e.areaFills.value,V=e._base.annotations.value,U=(k==null?void 0:k.annotations)??[],K=[...V,...U],se=k!=null&&k.hiddenAnnotationIds?K.filter(de=>!de.id||!k.hiddenAnnotationIds.has(de.id)):K,he=(k==null?void 0:k.seriesOverrides)??e.seriesOverrides.value,ce=k==null?void 0:k.properties,be={title:(ce==null?void 0:ce.title)??(e.title.value||void 0),description:(ce==null?void 0:ce.description)??(e.description.value||void 0),byline:e.byline.value||void 0,note:e.note.value||void 0,source:(ce==null?void 0:ce.source)??(e.source.value||void 0),sourceUrl:(ce==null?void 0:ce.sourceUrl)??(e.sourceUrl.value||void 0),padding:`${e.layout.value.padding}px`,transparentBackground:e.layout.value.transparentBackground||void 0};L2(t.value,{chartType:E,data:S,options:T,frame:be,colorizes:P,highlights:$,areaFills:F,annotations:se,seriesOverrides:he,sort:nT(k)??e.sort.value,sortMode:e.sortMode.value!=="none"?e.sortMode.value:void 0,theme:d.value},{transition:C,ignoreLayout:!0}),h=_}is(t,MI(b,tle));const y=A(()=>JSON.stringify(e.layout.value)),x=A(()=>JSON.stringify(n.value));return Ge([t,e.chartType,e.title,e.data,e.sort,e.sortMode,e.description,e.byline,e.note,e.source,e.sourceUrl,e.selectedColumn,e.colorizes,e.highlights,e.areaFills,e.annotations,e.seriesOverrides,y,x,o,i,u,d],b,{immediate:!0,flush:"post"}),{config:e}}function nle(t,e){function n(){var s;return((s=t.value)==null?void 0:s.querySelector("svg"))??null}function o(){var s;return((s=t.value)==null?void 0:s.querySelector(".bc-frame"))??null}function r(){const s=(e==null?void 0:e.value)??o();if(s){Hse(s);return}const a=n();a&&Rse(a)}async function i(s=2){const a=o();if(a){const d=e!=null&&e.value?OT(e.value):void 0,f=e!=null&&e.value?Vse(e.value):void 0;await zse(a,s,"chart.png",d,f);return}const l=n();if(!l)return;const{width:c,height:u}=l.getBoundingClientRect();await Fse(l,c*s,u*s)}return{downloadSvg:r,downloadPng:i}}const ole=le({__name:"ExportPanel",setup(t){const e=cr(),{canvasMode:n,showDimensions:o}=Ct(e),{setViewMode:r}=e,{mode:i}=rc();r("preview");const s=dg(),{exportTab:a}=Ct(s),{setExportTab:l,setLastNarrowExportTab:c}=s,{isNarrow:u}=Ji();Ge(i,$=>{$==="drawer"&&a.value&&(c(a.value),l(""))},{immediate:!0});const{layout:d}=dn(),{cardClass:f,cardStyle:h}=U2(d,"export-panel__canvas__card"),g=ft("canvasRef"),b=ft("cardRef"),m=ft("previewRef");G2(m);const{downloadSvg:v,downloadPng:y}=nle(m,b),x=Ie(0),_=Ie(0);let k=0;function E(){globalThis.cancelAnimationFrame(k),k=globalThis.requestAnimationFrame(()=>{const $=b.value;if($){const F=$.offsetLeft,V=$.offsetTop;(F!==x.value||V!==_.value)&&(x.value=F,_.value=V)}})}is(g,E),is(b,E);const B=A(()=>({"--grid-offset-x":`${x.value}px`,"--grid-offset-y":`${_.value}px`})),{lastNarrowExportTab:S}=Ct(s),L=A({get:()=>!!a.value,set:$=>{l($?S.value:"")}});function D($){c($),l($)}const{sections:I}=TT(),C={embed:"Embed",download:"Download"},T=A(()=>C[a.value]??"Export"),P=A(()=>({[`export-panel__canvas--${n.value}`]:n.value!=="blueprint"}));return($,F)=>{const V=DT,U=PT,K=W2,se=sae,he=Jse,ce=H2,be=ug,oe=Cse;return w(),R("div",{class:Me(["export-panel",{"export-panel--narrow":p(u)}])},[M("div",{ref_key:"canvasRef",ref:g,class:Me(["export-panel__canvas",p(P)]),style:Et(p(B))},[M("div",{ref_key:"cardRef",ref:b,class:Me(["export-panel__canvas__card",p(f)]),style:Et(p(h))},[M("div",{ref_key:"previewRef",ref:m,class:"export-panel__canvas__preview w-100 h-100"},null,512)],6),p(o)?(w(),J(V,{key:0,"card-ref":p(b),"canvas-ref":p(g),layout:p(d)},null,8,["card-ref","canvas-ref","layout"])):ie("",!0),H(U)],6),H(be,{"drawer-open":p(L),"onUpdate:drawerOpen":F[0]||(F[0]=de=>Ze(L)?L.value=de:null),title:p(T),"container-ref":p(g)},bi({default:te(()=>[p(a)==="embed"?(w(),J(se,{key:0})):p(a)==="download"?(w(),J(he,{key:1,onDownloadPng:p(y),onDownloadSvg:p(v)},null,8,["onDownloadPng","onDownloadSvg"])):ie("",!0)]),_:2},[p(i)==="drawer"?{name:"tabs",fn:te(()=>[H(K,{tabs:p(I),"model-value":p(a),sticky:"","onUpdate:modelValue":D},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(i)!=="drawer"?{name:"footer",fn:te(()=>[H(ce)]),key:"1"}:void 0]),1032,["drawer-open","title","container-ref"]),p(u)?ie("",!0):(w(),J(oe,{key:0}))],2)}}}),rle=Be(ole,[["__scopeId","data-v-6f293e9b"]]),ile={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function sle(t,e){return w(),R("svg",ile,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M87.24 52.59a8 8 0 0 0-14.48 0l-64 136a8 8 0 1 0 14.48 6.81L39.9 160h80.2l16.66 35.4a8 8 0 1 0 14.48-6.81ZM47.43 144L80 74.79L112.57 144ZM200 96c-12.76 0-22.73 3.47-29.63 10.32a8 8 0 0 0 11.26 11.36c3.8-3.77 10-5.68 18.37-5.68c13.23 0 24 9 24 20v3.22a42.76 42.76 0 0 0-24-7.22c-22.06 0-40 16.15-40 36s17.94 36 40 36a42.73 42.73 0 0 0 24-7.25a8 8 0 0 0 16-.75v-60c0-19.85-17.94-36-40-36m0 88c-13.23 0-24-9-24-20s10.77-20 24-20s24 9 24 20s-10.77 20-24 20"},null,-1)])])}const ET=Oe({name:"ph-text-aa",render:sle}),ale={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function lle(t,e){return w(),R("svg",ale,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M200.77 53.89A103.27 103.27 0 0 0 128 24h-1.07A104 104 0 0 0 24 128c0 43 26.58 79.06 69.36 94.17A32 32 0 0 0 136 192a16 16 0 0 1 16-16h46.21a31.81 31.81 0 0 0 31.2-24.88a104.4 104.4 0 0 0 2.59-24a103.28 103.28 0 0 0-31.23-73.23m13 93.71a15.89 15.89 0 0 1-15.56 12.4H152a32 32 0 0 0-32 32a16 16 0 0 1-21.31 15.07C62.49 194.3 40 164 40 128a88 88 0 0 1 87.09-88h.9a88.35 88.35 0 0 1 88 87.25a89 89 0 0 1-2.18 20.35ZM140 76a12 12 0 1 1-12-12a12 12 0 0 1 12 12m-44 24a12 12 0 1 1-12-12a12 12 0 0 1 12 12m0 56a12 12 0 1 1-12-12a12 12 0 0 1 12 12m88-56a12 12 0 1 1-12-12a12 12 0 0 1 12 12"},null,-1)])])}const NT=Oe({name:"ph-palette",render:lle}),cle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function ule(t,e){return w(),R("svg",cle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M220.27 158.54a8 8 0 0 0-7.7-.46a20 20 0 1 1 0-36.16a8 8 0 0 0 11.43-7.23V72a16 16 0 0 0-16-16h-36.22a35 35 0 0 0 .22-4a36.1 36.1 0 0 0-11.36-26.24a36 36 0 0 0-60.55 23.62a36.6 36.6 0 0 0 .14 6.62H64a16 16 0 0 0-16 16v32.22a35 35 0 0 0-4-.22a36.12 36.12 0 0 0-26.24 11.36a35.7 35.7 0 0 0-9.69 27a36.08 36.08 0 0 0 33.31 33.6a35.7 35.7 0 0 0 6.62-.14V208a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16v-42.69a8 8 0 0 0-3.73-6.77M208 208H64v-42.69a8 8 0 0 0-11.43-7.23a20 20 0 1 1 0-36.16A8 8 0 0 0 64 114.69V72h46.69a8 8 0 0 0 7.23-11.43a20 20 0 1 1 36.16 0A8 8 0 0 0 161.31 72H208v32.23a35.7 35.7 0 0 0-6.62-.14A36 36 0 0 0 204 176a35 35 0 0 0 4-.22Z"},null,-1)])])}const dle=Oe({name:"ph-puzzle-piece",render:ule}),fle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function hle(t,e){return w(),R("svg",fle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M222.16 177.25a8 8 0 0 1-1 11.25c-17.36 14.39-32.86 19.5-47 19.5c-18.58 0-34.82-8.82-49.93-17c-25.35-13.76-47.24-25.64-79.07.74a8 8 0 1 1-10.22-12.31c40.17-33.28 70.32-16.92 96.93-2.48c25.35 13.75 47.24 25.63 79.07-.74a8 8 0 0 1 11.22 1.04m-11.27-57c-31.83 26.38-53.72 14.5-79.07.74c-26.61-14.43-56.76-30.79-96.93 2.49a8 8 0 0 0 10.22 12.31c31.83-26.38 53.72-14.5 79.07-.74c15.11 8.19 31.35 17 49.93 17c14.14 0 29.64-5.11 47-19.5a8 8 0 1 0-10.22-12.31ZM45.11 79.8c31.83-26.37 53.72-14.49 79.07-.74c15.11 8.2 31.35 17 49.93 17c14.14 0 29.64-5.12 47-19.5a8 8 0 1 0-10.22-12.31c-31.83 26.38-53.72 14.5-79.07.74c-26.61-14.41-56.76-30.77-96.93 2.51a8 8 0 1 0 10.22 12.3"},null,-1)])])}const ple=Oe({name:"ph-waves",render:hle}),mle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function gle(t,e){return w(),R("svg",mle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m229.66 197.66l-32 32a8 8 0 0 1-11.32-11.32L204.69 200H80a8 8 0 0 1-8-8V59.31L53.66 77.66a8 8 0 0 1-11.32-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L88 59.31V184h116.69l-18.35-18.34a8 8 0 0 1 11.32-11.32l32 32a8 8 0 0 1 0 11.32"},null,-1)])])}const vle=Oe({name:"ph-vector-two",render:gle}),ble={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function yle(t,e){return w(),R("svg",ble,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m235.32 81.37l-60.69-60.68a16 16 0 0 0-22.63 0l-53.63 53.8c-10.66-3.34-35-7.37-60.4 13.14a16 16 0 0 0-1.29 23.78L85 159.71l-42.66 42.63a8 8 0 0 0 11.32 11.32L96.29 171l48.29 48.29A16 16 0 0 0 155.9 224h1.13a15.93 15.93 0 0 0 11.64-6.33c19.64-26.1 17.75-47.32 13.19-60L235.33 104a16 16 0 0 0-.01-22.63M224 92.69l-57.27 57.46a8 8 0 0 0-1.49 9.22c9.46 18.93-1.8 38.59-9.34 48.62L48 100.08c12.08-9.74 23.64-12.31 32.48-12.31A40.1 40.1 0 0 1 96.81 91a8 8 0 0 0 9.25-1.51L163.32 32L224 92.68Z"},null,-1)])])}const xle=Oe({name:"ph-push-pin",render:yle}),wle=["showVerticalAxis","verticalAxisDirection","showVerticalTicks","verticalLabelPosition","verticalGridStyle","verticalNumberFormat","verticalScaleType","verticalRangeMin","verticalRangeMax","showHorizontalAxis","showHorizontalTicks","horizontalLabelPosition","horizontalGridStyle","horizontalNumberFormat","horizontalScaleType","horizontalRangeMin","horizontalRangeMax"];function IT(){const{chartType:t}=dn(),{availableOptionKeys:e}=_n(),{scenes:n}=wn(),o=A(()=>e.value.some(s=>wle.includes(s))),r=A(()=>e.value.includes("tooltips")||e.value.includes("crosshair")||n.value.length>=1);return{sections:A(()=>{const s=[{key:"type",label:"Type",icon:Ls,tooltip:"Chart Type"},{key:"text",label:"Text",icon:ET},{key:"style",label:"Style",icon:NT}];return["line-multi","bar-multi","bar-split"].includes(t.value)&&s.push({key:"series",label:"Series",icon:ple}),o.value&&s.push({key:"axes",label:"Axes",icon:vle}),s.push({key:"layout",label:"Layout",icon:dle}),s.push({key:"annotate",label:"Annotate",icon:xle}),r.value&&s.push({key:"interactions",label:"Interactions",icon:kT}),s})}}const _le=le({__name:"ChartEditIconRail",setup(t){const e=cr(),{activeTab:n}=Ct(e),{selectTab:o}=e,{toggleMode:r}=rc(),{sections:i}=IT(),s=A(()=>i.value.map(a=>({value:a.key,icon:a.icon,tooltip:a.tooltip??a.label})));return(a,l)=>{const c=V2;return w(),J(c,{"active-tab":p(n),items:p(s),onSelect:p(o),onToggleMode:p(r)},null,8,["active-tab","items","onSelect","onToggleMode"])}}}),kle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Sle(t,e){return w(),R("svg",kle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M90.34 61.66a8 8 0 0 1 0-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L136 43.31V96a8 8 0 0 1-16 0V43.31l-18.34 18.35a8 8 0 0 1-11.32 0m64 132.68L136 212.69V160a8 8 0 0 0-16 0v52.69l-18.34-18.35a8 8 0 0 0-11.32 11.32l32 32a8 8 0 0 0 11.32 0l32-32a8 8 0 0 0-11.32-11.32m83.32-72l-32-32a8 8 0 0 0-11.32 11.32L212.69 120H160a8 8 0 0 0 0 16h52.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32M43.31 136H96a8 8 0 0 0 0-16H43.31l18.35-18.34a8 8 0 0 0-11.32-11.32l-32 32a8 8 0 0 0 0 11.32l32 32a8 8 0 0 0 11.32-11.32Z"},null,-1)])])}const Ale=Oe({name:"ph-arrows-out-cardinal",render:Sle}),Cle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function $le(t,e){return w(),R("svg",Cle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M165.66 194.34a8 8 0 0 1 0 11.32l-32 32a8 8 0 0 1-11.32 0l-32-32a8 8 0 0 1 11.32-11.32L120 212.69V43.31l-18.34 18.35a8 8 0 0 1-11.32-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L136 43.31v169.38l18.34-18.35a8 8 0 0 1 11.32 0"},null,-1)])])}const RT=Oe({name:"ph-arrows-vertical",render:$le}),Tle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Mle(t,e){return w(),R("svg",Tle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m237.66 133.66l-32 32a8 8 0 0 1-11.32-11.32L212.69 136H43.31l18.35 18.34a8 8 0 0 1-11.32 11.32l-32-32a8 8 0 0 1 0-11.32l32-32a8 8 0 0 1 11.32 11.32L43.31 120h169.38l-18.35-18.34a8 8 0 0 1 11.32-11.32l32 32a8 8 0 0 1 0 11.32"},null,-1)])])}const FT=Oe({name:"ph-arrows-horizontal",render:Mle}),Ole={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ble(t,e){return w(),R("svg",Ole,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M2 9.75A.75.75 0 0 1 2.75 9h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 9.75"},null,-1)])])}const q2=Oe({name:"fluent-line-horizontal-1-20-filled",render:Ble}),Lle={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ple(t,e){return w(),R("svg",Lle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M2 9.75A.75.75 0 0 1 2.75 9h2.5a.75.75 0 0 1 0 1.5h-2.5A.75.75 0 0 1 2 9.75m6 0A.75.75 0 0 1 8.75 9h2.5a.75.75 0 0 1 0 1.5h-2.5A.75.75 0 0 1 8 9.75m6 0a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75"},null,-1)])])}const VT=Oe({name:"fluent-line-horizontal-1-dashes-20-filled",render:Ple}),Dle={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ele(t,e){return w(),R("svg",Dle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M3.5 11a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3M8 11a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m4.5 0a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m6-1.5a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0"},null,-1)])])}const zT=Oe({name:"fluent-line-horizontal-1-dot-20-filled",render:Ele}),Nle={class:"d-flex flex-column gap-3"},Ile=le({__name:"EditorInteractionSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),{layout:r}=dn(),{scenes:i}=wn(),s=A(()=>n.value.includes("tooltips")),a=A(()=>n.value.includes("crosshair")),l=A(()=>i.value.length>=1),c=[{value:"both",text:"Both",icon:Ale},{value:"vertical",text:"Vertical",icon:RT},{value:"horizontal",text:"Horizontal",icon:FT}],u=[{value:"solid",text:"Solid",icon:q2},{value:"dashed",text:"Dashed",icon:VT},{value:"dotted",text:"Dotted",icon:zT}],d=A({get:()=>r.value.playerType,set:b=>{r.value.playerType=b}}),f=A({get:()=>r.value.playerPosition,set:b=>{r.value.playerPosition=b}}),h=[{value:"buttons",label:"Buttons"},{value:"progress-bar",label:"Progress Bar"},{value:"dot-stepper",label:"Dot Stepper"},{value:"minimal-arrows",label:"Minimal Arrows"},{value:"none",label:"None"}],g=[{value:"left",text:"Left"},{value:"center",text:"Center"},{value:"right",text:"Right"}];return(b,m)=>(w(),R("div",Nle,[p(s)?(w(),J(p(nn),{key:0,"model-value":p(e).tooltips??!1,label:"Tooltips","onUpdate:modelValue":m[0]||(m[0]=v=>p(o)("tooltips",v))},null,8,["model-value"])):ie("",!0),p(a)?(w(),J(p(nn),{key:1,"model-value":p(e).crosshair??!1,label:"Crosshair","onUpdate:modelValue":m[1]||(m[1]=v=>p(o)("crosshair",v))},null,8,["model-value"])):ie("",!0),p(a)&&p(e).crosshair?(w(),R(He,{key:2},[H(p(Cn),{label:"Direction","model-value":p(e).crosshairDirection??"both",options:c,block:"","onUpdate:modelValue":m[2]||(m[2]=v=>p(o)("crosshairDirection",v))},null,8,["model-value"]),H(p(Cn),{label:"Line style","model-value":p(e).crosshairStyle??"dashed",options:u,block:"","onUpdate:modelValue":m[3]||(m[3]=v=>p(o)("crosshairStyle",v))},null,8,["model-value"]),H(p(Pa),{id:"opt-crosshair-color",label:"Color","model-value":p(e).crosshairColor??"#999999","onUpdate:modelValue":m[4]||(m[4]=v=>p(o)("crosshairColor",v))},null,8,["model-value"])],64)):ie("",!0),p(l)?(w(),R(He,{key:3},[H(p(En),{id:"layout-player-type",modelValue:p(d),"onUpdate:modelValue":m[5]||(m[5]=v=>Ze(d)?d.value=v:null),label:"Scene player",options:h,block:""},null,8,["modelValue"]),p(d)==="buttons"||p(d)==="dot-stepper"||p(d)==="minimal-arrows"?(w(),J(p(Cn),{key:0,modelValue:p(f),"onUpdate:modelValue":m[6]||(m[6]=v=>Ze(f)?f.value=v:null),label:"Player position",options:g,block:""},null,8,["modelValue"])):ie("",!0)],64)):ie("",!0)]))}}),Rle={},Fle={class:"d-flex flex-column gap-3"};function Vle(t,e){const n=Ile;return w(),R("div",Fle,[H(n)])}const zle=Be(Rle,[["render",Vle]]),Hle={class:"border rounded overflow-hidden bg-body-tertiary"},Wle={class:"d-flex align-items-center justify-content-between px-2 py-1 border-bottom"},Ule={class:"fw-medium"},Gle={class:"p-2 d-flex flex-column gap-2"},qle={class:"d-flex align-items-center gap-2"},Yle={class:"text-nowrap",style:{width:"3em"}},jle=le({__name:"EditorAreaFillItem",props:it({id:{},seriesNames:{}},{fill:{required:!0},fillModifiers:{}}),emits:it(["remove"],["update:fill"]),setup(t){const e=t,n=dt(t,"fill"),o=A(()=>e.seriesNames.map(s=>({value:s,text:s}))),r=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}];function i(s,a){const l={...n.value};a===void 0?delete l[s]:l[s]=a,n.value=l}return(s,a)=>{const l=Vo,c=Ga,u=Mn,d=ea,f=Rs;return w(),R("div",Hle,[M("div",Wle,[M("small",Ule,ye(n.value.from)+" – "+ye(n.value.to),1),H(l,{variant:"link",size:"sm",class:"text-danger p-0",onClick:a[0]||(a[0]=h=>s.$emit("remove"))},{default:te(()=>[...a[8]||(a[8]=[M("span",{"aria-hidden":"true"},"×",-1)])]),_:1})]),M("div",Gle,[H(u,{label:"From","label-for":`af-from-${t.id}`},{default:te(()=>[H(c,{id:`af-from-${t.id}`,"model-value":n.value.from,options:p(o),"onUpdate:modelValue":a[1]||(a[1]=h=>i("from",h))},null,8,["id","model-value","options"])]),_:1},8,["label-for"]),H(u,{label:"To","label-for":`af-to-${t.id}`},{default:te(()=>[H(c,{id:`af-to-${t.id}`,"model-value":n.value.to,options:p(o),"onUpdate:modelValue":a[2]||(a[2]=h=>i("to",h))},null,8,["id","model-value","options"])]),_:1},8,["label-for"]),H(u,{label:"Color","label-for":`af-color-${t.id}`},{default:te(()=>[H(d,{id:`af-color-${t.id}`,type:"color","model-value":n.value.color??"#cccccc","onUpdate:modelValue":a[3]||(a[3]=h=>i("color",h))},null,8,["id","model-value"])]),_:1},8,["label-for"]),H(u,null,{default:te(()=>[H(f,{"model-value":!!n.value.negativeColor,switch:"","onUpdate:modelValue":a[4]||(a[4]=h=>i("negativeColor",h?"#f28e2b":void 0))},{default:te(()=>[...a[9]||(a[9]=[Ye(" Use different color for negative differences ",-1)])]),_:1},8,["model-value"])]),_:1}),n.value.negativeColor?(w(),J(u,{key:0,label:"Negative color","label-for":`af-neg-color-${t.id}`},{default:te(()=>[H(d,{id:`af-neg-color-${t.id}`,type:"color","model-value":n.value.negativeColor,"onUpdate:modelValue":a[5]||(a[5]=h=>i("negativeColor",h))},null,8,["id","model-value"])]),_:1},8,["label-for"])):ie("",!0),H(u,{label:"Opacity","label-for":`af-opacity-${t.id}`},{default:te(()=>[M("div",qle,[H(d,{id:`af-opacity-${t.id}`,type:"range","model-value":String(n.value.opacity??30),min:"0",max:"100",class:"flex-grow-1","onUpdate:modelValue":a[6]||(a[6]=h=>i("opacity",Number(h)))},null,8,["id","model-value"]),M("small",Yle,ye(n.value.opacity??30)+"%",1)])]),_:1},8,["label-for"]),H(u,{label:"Interpolation","label-for":`af-interp-${t.id}`},{default:te(()=>[H(c,{id:`af-interp-${t.id}`,"model-value":n.value.interpolation??"linear",options:r,"onUpdate:modelValue":a[7]||(a[7]=h=>i("interpolation",h))},null,8,["id","model-value"])]),_:1},8,["label-for"])])])}}}),Xle={class:"d-flex flex-column gap-2"},Kle=le({__name:"EditorAreaFills",props:it({seriesNames:{},seriesOverrides:{},globalInterpolation:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=t,n=dt(t,"modelValue"),o=A(()=>n.value);function r(a,l){const c=[...o.value];c[a]=l,n.value=c}function i(){const a=e.seriesNames[0]??"",l=e.seriesNames[1]??e.seriesNames[0]??"",c=x2(a,e.globalInterpolation,e.seriesOverrides);n.value=[...o.value,{from:a,to:l,color:"#cccccc",opacity:30,interpolation:c}]}function s(a){const l=[...o.value];l.splice(a,1),n.value=l}return(a,l)=>{const c=jle;return w(),R(He,null,[M("div",Xle,[(w(!0),R(He,null,ht(p(o),(u,d)=>(w(),J(c,{id:d,key:d,fill:u,"series-names":t.seriesNames,"onUpdate:fill":f=>r(d,f),onRemove:f=>s(d)},null,8,["id","fill","series-names","onUpdate:fill","onRemove"]))),128))]),H(p(Sl),{label:"Add",onClick:i})],64)}}}),Zle={class:"d-flex flex-column gap-3"},Qle=le({__name:"EditorHighlightSection",setup(t){const{chartType:e,data:n,highlights:o}=dn(),r=A(()=>fs(n.value)),i=A(()=>[Le.LineMulti,Le.AreaStacked].includes(e.value)),s=A(()=>{var u;return i.value?((u=r.value.series)==null?void 0:u.map(d=>d.name))??[]:r.value.labels}),a=Ie(o.value.length>0),l=A({get(){return o.value.map(u=>u.target)},set(u){o.value=u.map(d=>({target:d}))}});function c(u){a.value=u,u||(o.value=[])}return(u,d)=>(w(),R("div",Zle,[H(p(nn),{"model-value":p(a),label:"Highlight specific items","onUpdate:modelValue":c},null,8,["model-value"]),p(a)?(w(),J(p(Vy),{key:0,selected:p(l),"onUpdate:selected":d[0]||(d[0]=f=>Ze(l)?l.value=f:null),items:p(s)},null,8,["selected","items"])):ie("",!0)]))}}),Jle=Oo("previewContainer",()=>({containerRef:Ve(null)}));function HT(){const t=Jle();return Ct(t)}const ece={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function tce(t,e){return w(),R("svg",ece,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M174 47.75a254.2 254.2 0 0 0-41.45-38.3a8 8 0 0 0-9.18 0A254.2 254.2 0 0 0 82 47.75C54.51 79.32 40 112.6 40 144a88 88 0 0 0 176 0c0-31.4-14.51-64.68-42-96.25M200 144a71 71 0 0 1-.46 8H136v-16h63.64q.36 4 .36 8m-16.61-56H136V72h36.89a176 176 0 0 1 10.5 16M136 200h37.19A71.67 71.67 0 0 1 136 215.54Zm0-16v-16h59.87a72 72 0 0 1-8 16Zm0-64v-16h55.39a117 117 0 0 1 5.45 16Zm23.89-64H136V32.6A257 257 0 0 1 159.89 56M56 144c0-50 42.26-92.71 64-111.4v182.94A72.08 72.08 0 0 1 56 144"},null,-1)])])}const nce=Oe({name:"ph-drop-half",render:tce}),oce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function rce(t,e){return w(),R("svg",oce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M201.54 54.46A104 104 0 0 0 54.46 201.54A104 104 0 0 0 201.54 54.46M96 210v-58h64v58a88.33 88.33 0 0 1-64 0m48-74h-32v-35.06l32-16Zm46.22 54.22A88 88 0 0 1 176 201.77V152a16 16 0 0 0-16-16V72a8 8 0 0 0-11.58-7.16l-48 24A8 8 0 0 0 96 96v40a16 16 0 0 0-16 16v49.77a88 88 0 1 1 110.22-11.55"},null,-1)])])}const ice=Oe({name:"ph-highlighter-circle",render:rce}),sce={class:"d-flex flex-column gap-2"},ace={class:"d-flex gap-2"},lce=le({__name:"EditorAnnotationFree",props:it({chartWidth:{},chartHeight:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=dt(t,"annotation");function n(s){return typeof s=="number"?`${s}%`:String(s)}function o(s){return s==null?"150px":typeof s=="number"?`${s}px`:String(s)}function r(s,a){const l={...e.value};a===void 0?delete l[s]:l[s]=a,e.value=l}const i=Ve(null);return un(()=>{var a;const s=(a=i.value)==null?void 0:a.$el;s&&(s.focus(),s.select())}),(s,a)=>{const l=_y,c=Mn;return w(),R("div",sce,[H(c,{label:"Text"},{default:te(()=>[H(l,{ref_key:"textRef",ref:i,"model-value":e.value.text,placeholder:"Annotation text",rows:"2","onUpdate:modelValue":a[0]||(a[0]=u=>r("text",u))},null,8,["model-value"])]),_:1}),M("div",ace,[H(p(Yh),{id:"ann-free-x","model-value":n(e.value.x),label:"X position",min:"-50",max:String(t.chartWidth??600),step:"0.1",units:["%","px"],"no-slider":"","center-relative":"",class:"flex-fill","onUpdate:modelValue":a[1]||(a[1]=u=>r("x",u))},null,8,["model-value","max"]),H(p(Yh),{id:"ann-free-y","model-value":n(e.value.y),label:"Y position",min:"-50",max:String(t.chartHeight??400),step:"0.1",units:["%","px"],"no-slider":"","center-relative":"",class:"flex-fill","onUpdate:modelValue":a[2]||(a[2]=u=>r("y",u))},null,8,["model-value","max"])]),H(p(Pa),{id:"ann-free-text-color","model-value":e.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":a[3]||(a[3]=u=>r("textColor",u))},null,8,["model-value"]),H(p(nn),{"model-value":e.value.textOutline??!0,label:"Text outline","onUpdate:modelValue":a[4]||(a[4]=u=>r("textOutline",u))},null,8,["model-value"]),H(p(Yh),{id:"ann-free-max-width","model-value":o(e.value.maxWidth),label:"Max width",min:"0",max:String(t.chartWidth??600),units:["px","%"],"onUpdate:modelValue":a[5]||(a[5]=u=>r("maxWidth",u))},null,8,["model-value","max"])])}}}),cce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function uce(t,e){return w(),R("svg",cce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M48 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m16 64V64a16 16 0 0 1 16-16h96a16 16 0 0 1 16 16v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16m16 0h96V64H80Zm152 48v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16v-40a16 16 0 0 1 16-16h136a16 16 0 0 1 16 16m-16 40v-40H80v40z"},null,-1)])])}const af=Oe({name:"ph-align-left",render:uce}),dce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function fce(t,e){return w(),R("svg",dce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208 136h-72v-16h48a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16h-48V32a8 8 0 0 0-16 0v16H72a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h48v16H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h72v16a8 8 0 0 0 16 0v-16h72a16 16 0 0 0 16-16v-40a16 16 0 0 0-16-16M72 64h112v40H72Zm136 128H48v-40h160z"},null,-1)])])}const v0=Oe({name:"ph-align-center-horizontal",render:fce}),hce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function pce(t,e){return w(),R("svg",hce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m-32 24v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16V64a16 16 0 0 1 16-16h96a16 16 0 0 1 16 16m-16 0H80v40h96Zm16 88v40a16 16 0 0 1-16 16H40a16 16 0 0 1-16-16v-40a16 16 0 0 1 16-16h136a16 16 0 0 1 16 16m-16 0H40v40h136Z"},null,-1)])])}const lf=Oe({name:"ph-align-right",render:pce}),mce={class:"d-flex flex-column gap-2"},gce={class:"d-flex gap-2"},vce={key:0,class:"d-flex gap-2"},bce=le({__name:"EditorAnnotationRange",props:it({labels:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=t,n=dt(t,"annotation"),o=[{value:"vertical",text:"Vertical"},{value:"horizontal",text:"Horizontal"}],r=A(()=>(n.value.orientation??"vertical")==="vertical"&&e.labels.length>0),i=A(()=>e.labels.map(l=>({value:l,text:l})));function s(l,c){const u={...n.value};c===void 0?delete u[l]:u[l]=c,n.value=u}const a=Ve(null);return un(()=>{var c;const l=(c=a.value)==null?void 0:c.$el;l&&(l.focus(),l.select())}),(l,c)=>{const u=ea,d=Mn,f=Ga;return w(),R("div",mce,[H(d,{label:"Text"},{default:te(()=>[H(u,{ref_key:"textRef",ref:a,"model-value":n.value.text??"",placeholder:"Optional label","onUpdate:modelValue":c[0]||(c[0]=h=>s("text",h||void 0))},null,8,["model-value"])]),_:1}),H(d,{label:"Orientation"},{default:te(()=>[H(f,{"model-value":n.value.orientation??"vertical",options:o,"onUpdate:modelValue":c[1]||(c[1]=h=>s("orientation",h))},null,8,["model-value"])]),_:1}),M("div",gce,[H(d,{label:"Start",class:"flex-fill"},{default:te(()=>[p(r)?(w(),J(f,{key:0,"model-value":String(n.value.start),options:p(i),"onUpdate:modelValue":c[2]||(c[2]=h=>s("start",h))},null,8,["model-value","options"])):(w(),J(u,{key:1,"model-value":String(n.value.start),"onUpdate:modelValue":c[3]||(c[3]=h=>s("start",isNaN(Number(h))?h:Number(h)))},null,8,["model-value"]))]),_:1}),H(d,{label:"End",class:"flex-fill"},{default:te(()=>[p(r)?(w(),J(f,{key:0,"model-value":String(n.value.end),options:p(i),"onUpdate:modelValue":c[4]||(c[4]=h=>s("end",h))},null,8,["model-value","options"])):(w(),J(u,{key:1,"model-value":String(n.value.end),"onUpdate:modelValue":c[5]||(c[5]=h=>s("end",isNaN(Number(h))?h:Number(h)))},null,8,["model-value"]))]),_:1})]),p(r)?(w(),R("div",vce,[H(p(En),{id:`ann-range-start-anchor-${l.$.uid}`,"model-value":n.value.startAnchor??"center",label:"Start anchor","light-label":"",block:"",class:"flex-fill","onUpdate:modelValue":c[6]||(c[6]=h=>s("startAnchor",h))},{default:te(()=>[H(p(uc),{value:"start",label:"Start"},{icon:te(()=>[H(p(af))]),_:1}),H(p(uc),{value:"center",label:"Center"},{icon:te(()=>[H(p(v0))]),_:1}),H(p(uc),{value:"end",label:"End"},{icon:te(()=>[H(p(lf))]),_:1})]),_:1},8,["id","model-value"]),H(p(En),{id:`ann-range-end-anchor-${l.$.uid}`,"model-value":n.value.endAnchor??"center",label:"End anchor","light-label":"",block:"",class:"flex-fill","onUpdate:modelValue":c[7]||(c[7]=h=>s("endAnchor",h))},{default:te(()=>[H(p(uc),{value:"start",label:"Start"},{icon:te(()=>[H(p(af))]),_:1}),H(p(uc),{value:"center",label:"Center"},{icon:te(()=>[H(p(v0))]),_:1}),H(p(uc),{value:"end",label:"End"},{icon:te(()=>[H(p(lf))]),_:1})]),_:1},8,["id","model-value"])])):ie("",!0),H(p(Pa),{id:"ann-range-bg-color","model-value":n.value.bgColor??"#cccccc",label:"Background color","onUpdate:modelValue":c[8]||(c[8]=h=>s("bgColor",h))},null,8,["model-value"]),H(p(xr),{id:"ann-range-bg-opacity","model-value":String(n.value.bgOpacity??20),label:"Background opacity",min:"0",max:"100",suffix:"%","onUpdate:modelValue":c[9]||(c[9]=h=>s("bgOpacity",Number(h)))},null,8,["model-value"]),n.value.text?(w(),R(He,{key:1},[H(p(Pa),{id:"ann-range-text-color","model-value":n.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":c[10]||(c[10]=h=>s("textColor",h))},null,8,["model-value"]),H(p(kA),{"model-value":n.value.direction??"center",label:"Direction","onUpdate:modelValue":c[11]||(c[11]=h=>s("direction",h))},null,8,["model-value"])],64)):ie("",!0)])}}}),yce={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function xce(t,e){return w(),R("svg",yce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M6 15.25c0 .414.336.75.75.75h4.5c1.586 0 2.696-.621 3.53-1.588C15.6 13.46 16 12.216 16 11s-.3-2.46-1.12-3.412C14.046 6.621 12.836 6 11.25 6H6.56l2.22-2.22a.75.75 0 0 0-1.06-1.06l-3.5 3.5a.75.75 0 0 0 .02 1.08l3.5 3.25a.75.75 0 0 0 1.02-1.1L6.66 7.5h4.59c1.164 0 1.86.441 2.4 1.068c.554.642.85 1.523.85 2.432s-.296 1.79-.85 2.432c-.54.627-1.236 1.068-2.4 1.068h-4.5a.75.75 0 0 0-.75.75"},null,-1)])])}const wce=Oe({name:"fluent-arrow-hook-up-left-20-filled",render:xce}),_ce={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function kce(t,e){return w(),R("svg",_ce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M9 6c.06 0-.06-.002 0 0c.023-.002.227 0 .25 0h4.393l-2.268-2.268a.75.75 0 1 1 1.061-1.06l3.353 3.352a.75.75 0 0 1 .212.639a.75.75 0 0 1-.215.443l-3.247 3.248a.75.75 0 1 1-1.06-1.061L13.27 7.5H9a3.5 3.5 0 1 0 0 7h4.25a.75.75 0 0 1 0 1.5H9A5 5 0 0 1 9 6"},null,-1)])])}const Sce=Oe({name:"fluent-arrow-hook-up-right-20-filled",render:kce}),Ace={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Cce(t,e){return w(),R("svg",Ace,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M16.78 10.72a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V7A1.5 1.5 0 0 0 10 5.5H3.75a.75.75 0 0 1 0-1.5H10a3 3 0 0 1 3 3v6.44l2.72-2.72a.75.75 0 0 1 1.06 0"},null,-1)])])}const $ce=Oe({name:"fluent-arrow-turn-right-down-20-filled",render:Cce}),Tce={class:"d-flex flex-column gap-2"},Mce={class:"d-flex flex-column gap-2 mt-2"},Oce={class:"d-flex flex-column gap-2 mt-2"},Bce=le({__name:"EditorAnnotationPoint",props:it({labels:{},chartWidth:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=t,n=dt(t,"annotation"),o=A(()=>e.labels.map(l=>({value:l,text:l}))),r=[{value:"solid",text:"Solid"},{value:"dotted",text:"Dotted"},{value:"dashed",text:"Dashed"}];function i(l){return l==null?"150px":typeof l=="number"?`${l}px`:String(l)}function s(l,c){const u={...n.value};c===void 0?delete u[l]:u[l]=c,n.value=u}const a=Ve(null);return un(()=>{var c;const l=(c=a.value)==null?void 0:c.$el;l&&(l.focus(),l.select())}),(l,c)=>{const u=_y,d=Mn,f=Ga,h=ea,g=Rs;return w(),R("div",Tce,[H(d,{label:"Text"},{default:te(()=>[H(u,{ref_key:"textRef",ref:a,"model-value":n.value.text,placeholder:"Annotation text",rows:"2","onUpdate:modelValue":c[0]||(c[0]=b=>s("text",b))},null,8,["model-value"])]),_:1}),H(d,{label:"Target"},{default:te(()=>[H(f,{"model-value":n.value.target,options:p(o),"onUpdate:modelValue":c[1]||(c[1]=b=>s("target",b))},null,8,["model-value","options"])]),_:1}),H(p(Pa),{id:"ann-point-text-color","model-value":n.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":c[2]||(c[2]=b=>s("textColor",b))},null,8,["model-value"]),H(p(nn),{"model-value":n.value.textOutline??!0,label:"Text outline","onUpdate:modelValue":c[3]||(c[3]=b=>s("textOutline",b))},null,8,["model-value"]),H(p(Yh),{id:"ann-point-max-width","model-value":i(n.value.maxWidth),label:"Max width",min:"0",max:String(t.chartWidth??600),units:["px","%"],"onUpdate:modelValue":c[4]||(c[4]=b=>s("maxWidth",b))},null,8,["model-value","max"]),H(p(nn),{"model-value":n.value.showLine??!0,label:"Show line","onUpdate:modelValue":c[10]||(c[10]=b=>s("showLine",b))},bi({_:2},[n.value.showLine?{name:"section",fn:te(()=>[M("div",Mce,[H(p(Cn),{"model-value":n.value.lineStyle??"direct",label:"Line style",block:"","onUpdate:modelValue":c[5]||(c[5]=b=>s("lineStyle",b))},{default:te(()=>[H(p(oh),{value:"direct",text:"Direct","icon-left":p(q2)},null,8,["icon-left"]),H(p(oh),{value:"curve-left",text:"Curve left","icon-left":p(wce)},null,8,["icon-left"]),H(p(oh),{value:"curve-right",text:"Curve right","icon-left":p(Sce)},null,8,["icon-left"]),H(p(oh),{value:"elbow",text:"Elbow","icon-left":p($ce)},null,8,["icon-left"])]),_:1},8,["model-value"]),H(d,{label:"Line weight"},{default:te(()=>[H(h,{"model-value":String(n.value.lineWeight??1),type:"number",min:"1",max:"10","onUpdate:modelValue":c[6]||(c[6]=b=>s("lineWeight",Number(b)))},null,8,["model-value"])]),_:1}),H(p(kA),{"model-value":n.value.anchorDirection??"N",label:"Anchor position","onUpdate:modelValue":c[7]||(c[7]=b=>s("anchorDirection",b))},null,8,["model-value"]),H(d,null,{default:te(()=>[H(g,{"model-value":n.value.showArrow??!0,switch:"","onUpdate:modelValue":c[8]||(c[8]=b=>s("showArrow",b))},{default:te(()=>[...c[14]||(c[14]=[Ye(" Show arrow ",-1)])]),_:1},8,["model-value"])]),_:1}),H(d,{label:"Line target distance"},{default:te(()=>[H(h,{"model-value":String(n.value.lineTargetDistance??0),type:"number","onUpdate:modelValue":c[9]||(c[9]=b=>s("lineTargetDistance",Number(b)))},null,8,["model-value"])]),_:1})])]),key:"0"}:void 0]),1032,["model-value"]),H(p(nn),{"model-value":n.value.showCircle??!1,label:"Show circle","onUpdate:modelValue":c[13]||(c[13]=b=>s("showCircle",b))},bi({_:2},[n.value.showCircle?{name:"section",fn:te(()=>[M("div",Oce,[H(d,{label:"Circle size"},{default:te(()=>[H(h,{"model-value":String(n.value.circleSize??4),type:"number",min:"1","onUpdate:modelValue":c[11]||(c[11]=b=>s("circleSize",Number(b)))},null,8,["model-value"])]),_:1}),H(d,{label:"Circle style"},{default:te(()=>[H(f,{"model-value":n.value.circleStyle??"solid",options:r,"onUpdate:modelValue":c[12]||(c[12]=b=>s("circleStyle",b))},null,8,["model-value"])]),_:1})])]),key:"0"}:void 0]),1032,["model-value"])])}}}),Lce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Pce(t,e){return w(),R("svg",Lce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M247.31 124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57 61.26 162.88 48 128 48S61.43 61.26 36.34 86.35C17.51 105.18 9 124 8.69 124.76a8 8 0 0 0 0 6.5c.35.79 8.82 19.57 27.65 38.4C61.43 194.74 93.12 208 128 208s66.57-13.26 91.66-38.34c18.83-18.83 27.3-37.61 27.65-38.4a8 8 0 0 0 0-6.5M128 192c-30.78 0-57.67-11.19-79.93-33.25A133.5 133.5 0 0 1 25 128a133.3 133.3 0 0 1 23.07-30.75C70.33 75.19 97.22 64 128 64s57.67 11.19 79.93 33.25A133.5 133.5 0 0 1 231.05 128c-7.21 13.46-38.62 64-103.05 64m0-112a48 48 0 1 0 48 48a48.05 48.05 0 0 0-48-48m0 80a32 32 0 1 1 32-32a32 32 0 0 1-32 32"},null,-1)])])}const WT=Oe({name:"ph-eye",render:Pce}),Dce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ece(t,e){return w(),R("svg",Dce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M53.92 34.62a8 8 0 1 0-11.84 10.76l19.24 21.17C25 88.84 9.38 123.2 8.69 124.76a8 8 0 0 0 0 6.5c.35.79 8.82 19.57 27.65 38.4C61.43 194.74 93.12 208 128 208a127.1 127.1 0 0 0 52.07-10.83l22 24.21a8 8 0 1 0 11.84-10.76Zm47.33 75.84l41.67 45.85a32 32 0 0 1-41.67-45.85M128 192c-30.78 0-57.67-11.19-79.93-33.25A133.2 133.2 0 0 1 25 128c4.69-8.79 19.66-33.39 47.35-49.38l18 19.75a48 48 0 0 0 63.66 70l14.73 16.2A112 112 0 0 1 128 192m6-95.43a8 8 0 0 1 3-15.72a48.16 48.16 0 0 1 38.77 42.64a8 8 0 0 1-7.22 8.71a6 6 0 0 1-.75 0a8 8 0 0 1-8-7.26A32.09 32.09 0 0 0 134 96.57m113.28 34.69c-.42.94-10.55 23.37-33.36 43.8a8 8 0 1 1-10.67-11.92a132.8 132.8 0 0 0 27.8-35.14a133.2 133.2 0 0 0-23.12-30.77C185.67 75.19 158.78 64 128 64a118.4 118.4 0 0 0-19.36 1.57A8 8 0 1 1 106 49.79A134 134 0 0 1 128 48c34.88 0 66.57 13.26 91.66 38.35c18.83 18.83 27.3 37.62 27.65 38.41a8 8 0 0 1 0 6.5Z"},null,-1)])])}const cf=Oe({name:"ph-eye-slash",render:Ece}),Nce={class:"badge bg-secondary-subtle text-secondary-emphasis"},Ice=le({__name:"EditorAnnotationHeader",props:{kindLabel:{},summary:{},collapsed:{type:Boolean},hidden:{type:Boolean},canToggleVisibility:{type:Boolean}},emits:["duplicate","remove","toggleCollapse","toggleVisibility"],setup(t){return(e,n)=>(w(),J(p(WA),{label:t.summary,class:Me({"opacity-50":t.hidden}),onClick:n[3]||(n[3]=o=>e.$emit("toggleCollapse"))},{leading:te(()=>[M("span",Nce,ye(t.kindLabel),1)]),actions:te(()=>[t.canToggleVisibility?(w(),J(p(Vo),{key:0,variant:"link",size:"sm",class:"annotation-header__btn text-body-secondary",title:t.hidden?"Show in scene":"Hide in scene",onClick:n[0]||(n[0]=pn(o=>e.$emit("toggleVisibility"),["stop"]))},{default:te(()=>[H(p(Sf),{name:t.hidden?p(cf):p(WT)},null,8,["name"])]),_:1},8,["title"])):ie("",!0),H(p(jU),{onDuplicate:n[1]||(n[1]=o=>e.$emit("duplicate")),onRemove:n[2]||(n[2]=o=>e.$emit("remove"))})]),_:1},8,["label","class"]))}}),Rce=Be(Ice,[["__scopeId","data-v-acf3aff5"]]),Fce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Vce(t,e){return w(),R("svg",Fce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 64a40 40 0 1 0 40 40a40 40 0 0 0-40-40m0 64a24 24 0 1 1 24-24a24 24 0 0 1-24 24m0-112a88.1 88.1 0 0 0-88 88c0 31.4 14.51 64.68 42 96.25a254.2 254.2 0 0 0 41.45 38.3a8 8 0 0 0 9.18 0a254.2 254.2 0 0 0 41.37-38.3c27.45-31.57 42-64.85 42-96.25a88.1 88.1 0 0 0-88-88m0 206c-16.53-13-72-60.75-72-118a72 72 0 0 1 144 0c0 57.23-55.47 105-72 118"},null,-1)])])}const zce=Oe({name:"ph-map-pin",render:Vce}),Hce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Wce(t,e){return w(),R("svg",Hce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M136 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m-40 80H35.31l18.35-18.34a8 8 0 0 0-11.32-11.32l-32 32a8 8 0 0 0 0 11.32l32 32a8 8 0 0 0 11.32-11.32L35.31 136H96a8 8 0 0 0 0-16m149.66 2.34l-32-32a8 8 0 0 0-11.32 11.32L220.69 120H160a8 8 0 0 0 0 16h60.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32"},null,-1)])])}const Uce=Oe({name:"ph-arrows-out-line-horizontal",render:Wce}),Gce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function qce(t,e){return w(),R("svg",Gce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M88 96a8 8 0 0 1 8-8h64a8 8 0 0 1 0 16H96a8 8 0 0 1-8-8m8 40h64a8 8 0 0 0 0-16H96a8 8 0 0 0 0 16m32 16H96a8 8 0 0 0 0 16h32a8 8 0 0 0 0-16m96-104v108.69a15.86 15.86 0 0 1-4.69 11.31L168 219.31a15.86 15.86 0 0 1-11.31 4.69H48a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h160a16 16 0 0 1 16 16M48 208h104v-48a8 8 0 0 1 8-8h48V48H48Zm120-40v28.7l28.69-28.7Z"},null,-1)])])}const Yce=Oe({name:"ph-note",render:qce}),jce={class:"d-flex flex-column gap-4"},Xce={class:"d-flex flex-column gap-2"},Kce={class:"d-flex flex-column gap-2"},Zce={class:"d-flex flex-column gap-2"},X6="abcdefghijklmnopqrstuvwxyz0123456789",Qce=le({__name:"EditorAnnotations",props:it({labels:{},chartType:{},chartWidth:{},chartHeight:{},hiddenAnnotationIds:{},canToggleVisibility:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:it(["toggle-visibility"],["update:modelValue"]),setup(t,{expose:e,emit:n}){const o=t,r=n,i=dt(t,"modelValue"),s=A(()=>i.value);function a(){let S="";for(let L=0;L<5;L++)S+=X6[Math.floor(Math.random()*X6.length)];return S}const l=A(()=>o.chartType===Le.Pie||o.chartType===Le.Donut),c=Ve(null);function u(S){c.value=c.value===S?null:S}e({openIndex:c});const d=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Point)),f=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Range)),h=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Free));function g(S){var L;return!!S.id&&!!((L=o.hiddenAnnotationIds)!=null&&L.has(S.id))}function b(S){S.id&&r("toggle-visibility",S.id,S.kind)}function m(S){return S.kind===Dt.Point?"Point":S.kind===Dt.Range?"Range":"Note"}function v(S){return S.kind===Dt.Point?S.text||S.target||"Empty":S.kind===Dt.Range?S.text||`${S.start} - ${S.end}`:S.text||"Empty"}function y(S,L){const D=s.value.map(I=>({...I}));D[S]=L,i.value=D}function x(){const S={kind:Dt.Point,id:a(),target:o.labels[0]??"",text:"Enter an annotation",showLine:!0,showArrow:!0},L=[...s.value,S];i.value=L,c.value=L.length-1}function _(){const S=o.labels.length>0,L={kind:Dt.Range,id:a(),start:S?o.labels[0]:0,end:S?o.labels[o.labels.length-1]:100},D=[...s.value,L];i.value=D,c.value=D.length-1}function k(){const S={kind:Dt.Free,id:a(),text:"Enter an annotation",x:0,y:0},L=[...s.value,S];i.value=L,c.value=L.length-1}function E(S){const L=[...s.value];L.splice(S+1,0,{...L[S],id:a()}),i.value=L}function B(S){const L=[...s.value];L.splice(S,1),i.value=L,c.value===S?c.value=null:c.value!==null&&c.value>S&&c.value--}return(S,L)=>{const D=Rce,I=Bce,C=bce,T=lce;return w(),R("div",jce,[p(l)?ie("",!0):(w(),J(p(Fo),{key:0,title:"Points",icon:p(zce)},{default:te(()=>[M("div",Xce,[(w(!0),R(He,null,ht(p(d),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(I,{key:0,annotation:P,labels:t.labels,"chart-width":t.chartWidth,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","labels","chart-width","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:x})]),_:1},8,["icon"])),p(l)?ie("",!0):(w(),J(p(Fo),{key:1,title:"Ranges",icon:p(Uce)},{default:te(()=>[M("div",Kce,[(w(!0),R(He,null,ht(p(f),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(C,{key:0,annotation:P,labels:t.labels,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","labels","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:_})]),_:1},8,["icon"])),H(p(Fo),{title:"Notes",icon:p(Yce)},{default:te(()=>[M("div",Zce,[(w(!0),R(He,null,ht(p(h),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(T,{key:0,annotation:P,"chart-width":t.chartWidth,"chart-height":t.chartHeight,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","chart-width","chart-height","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:k})]),_:1},8,["icon"])])}}});function Jce(t,e,n,o){let r=null,i=null;function s(){r!=null&&r.parentNode&&r.parentNode.removeChild(r),r=null,i&&(i(),i=null)}function a(){s();const l=t.value,c=n.value;if(!l||c===null)return;const u=e.value[c];if(!u||u.kind==="range")return;const d=l.querySelector("svg");if(!d)return;const f=u.id,h=f?d.querySelector(`g[data-annotation-id="${f}"]`):d.querySelector(`g[data-annotation-index="${c}"]`);if(!h)return;const g=h.querySelector(".bc-annotation-text");if(!g)return;const b=h.querySelector(".bc-annotation-circle"),m=h.querySelector(".bc-annotation-line");let v=null,y=null,x=0;if(b&&(v=parseFloat(b.getAttribute("cx")||"0"),y=parseFloat(b.getAttribute("cy")||"0"),x=parseFloat(b.getAttribute("r")||"0")),v===null&&m){const N=(m.getAttribute("d")||"").split(/[MLA]\s*/).filter(Boolean);if(N.length>=2){const G=N[N.length-1].trim().split(/[\s,]+/);G.length>=2&&(v=parseFloat(G[G.length-2]),y=parseFloat(G[G.length-1]))}}const _=v!==null&&y!==null,k=(u&&"lineStyle"in u?u.lineStyle:"direct")||"direct",E=x>0?x+((u&&"lineTargetDistance"in u?u.lineTargetDistance:5)||5):0,B=parseFloat(g.getAttribute("x")||"0"),S=parseFloat(g.getAttribute("y")||"0"),L=g.getBBox(),I=(g.getAttribute("transform")||"").match(/translate\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)/),C=I?parseFloat(I[1]):0,T=I?parseFloat(I[2]):0,P={x:L.x+C,y:L.y+T,width:L.width,height:L.height},$=4,F=u?u.maxWidth:void 0;let V=P.width;if(F!=null){const ve=parseFloat(d.getAttribute("width")||"0");if(typeof F=="number"&&F>0)V=F;else if(typeof F=="string")if(F.endsWith("%")&&ve>0)V=parseFloat(F)/100*ve;else{const N=parseFloat(F);N>0&&(V=N)}}const U=g.getAttribute("text-anchor")||"middle";let K;U==="middle"?K=B-V/2:U==="end"?K=B-V:K=B,r=document.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("x",String(K-$)),r.setAttribute("y",String(P.y-$)),r.setAttribute("width",String(V+$*2)),r.setAttribute("height",String(P.height+$*2)),r.setAttribute("fill","rgba(255,245,157,0.4)"),r.setAttribute("rx","3"),r.style.cursor="grab",r.style.pointerEvents="all",h.appendChild(r);let se=!1,he=0,ce=0,be=0,oe=0,de=0;function we(){return d.getScreenCTM()}function ee(){const ve=we();if(!ve)return;const N=(oe-he)/ve.a,G=(de-ce)/ve.d,Y=B+N,ue=S+G;g.setAttribute("x",String(Y)),g.setAttribute("y",String(ue));const ae=g.querySelectorAll("tspan");for(const Z of ae)Z.setAttribute("x",String(Y));const q=g.getBBox(),ne={x:q.x+C,y:q.y+T,width:q.width,height:q.height};let j;const X=g.getAttribute("text-anchor")||"middle";if(X==="middle"?j=Y-V/2:X==="end"?j=Y-V:j=Y,r.setAttribute("x",String(j-$)),r.setAttribute("y",String(ne.y-$)),r.setAttribute("width",String(V+$*2)),r.setAttribute("height",String(ne.height+$*2)),m&&_){const Z=bboxEdgeToward(ne,v,y),fe=E>0?shortenToward({x:v,y},Z,E):{x:v,y},pe=ne.x+ne.width/2,me=Math.abs(Z.x-pe)<1;m.setAttribute("d",buildPathD(Z,fe,k,me))}be=0}function ge(ve){ve.preventDefault(),ve.stopPropagation(),se=!0,he=ve.clientX,ce=ve.clientY,oe=ve.clientX,de=ve.clientY,r.style.cursor="grabbing",r.setPointerCapture(ve.pointerId)}function Q(ve){se&&(ve.preventDefault(),oe=ve.clientX,de=ve.clientY,be||(be=requestAnimationFrame(ee)))}function re(ve){if(!se)return;se=!1,r.style.cursor="grab",be&&(cancelAnimationFrame(be),be=0);const N=we();if(!N)return;const G=(ve.clientX-he)/N.a,Y=(ve.clientY-ce)/N.d;if(Math.abs(G)<1&&Math.abs(Y)<1){g.setAttribute("x",String(B)),g.setAttribute("y",String(S));const q=g.querySelectorAll("tspan");for(const ne of q)ne.setAttribute("x",String(B));return}const ue=e.value[c];if(!ue)return;const ae={...ue};if(ue.kind==="free"){const q=h.closest(".bc-annotations"),ne=parseFloat((q==null?void 0:q.getAttribute("data-ctx-width"))||"")||parseFloat(d.getAttribute("width")||"600"),j=parseFloat((q==null?void 0:q.getAttribute("data-ctx-height"))||"")||parseFloat(d.getAttribute("height")||"400"),X=ue.x,Z=ue.y;if(typeof X=="number")ae.x=+(X+G/ne*100).toFixed(1);else{const fe=String(X);fe.endsWith("px")?ae.x=`${Math.round(parseFloat(fe)+G)}px`:ae.x=+((parseFloat(fe)||0)+G/ne*100).toFixed(1)}if(typeof Z=="number")ae.y=+(Z+Y/j*100).toFixed(1);else{const fe=String(Z);fe.endsWith("px")?ae.y=`${Math.round(parseFloat(fe)+Y)}px`:ae.y=+((parseFloat(fe)||0)+Y/j*100).toFixed(1)}}else if(ue.kind==="point"){const q=ae.textOffsetX??-42,ne=ae.textOffsetY??-42;ae.textOffsetX=Math.round(q+G),ae.textOffsetY=Math.round(ne+Y)}o(c,ae)}r.addEventListener("pointerdown",ge),r.addEventListener("pointermove",Q),r.addEventListener("pointerup",re),i=()=>{be&&cancelAnimationFrame(be),r==null||r.removeEventListener("pointerdown",ge),r==null||r.removeEventListener("pointermove",Q),r==null||r.removeEventListener("pointerup",re)}}Ge(n,()=>{requestAnimationFrame(a)}),Ge(e,()=>{n.value!==null&&requestAnimationFrame(a)},{deep:!0}),Ta(s)}const eue={class:"d-flex flex-column gap-4"},tue=le({__name:"EditorAnnotateTab",setup(t){const e=dn(),{chartType:n,data:o,areaFills:r,seriesOverrides:i}=e,{currentOptions:s}=_n(),a=A(()=>s.value.interpolation??"linear"),{pendingAnnotationIndex:l}=Ct(cr()),{scenes:c,activeIndex:u,activeScene:d,update:f}=wn(),h=A(()=>u.value>=0),g=[Le.BarVertical,Le.BarHorizontal,Le.LineMulti,Le.AreaStacked],b=A(()=>g.includes(n.value)),m=A({get(){const $=e._base.annotations.value;if(u.value>=0){const F=Ra(c.value,u.value),V=(F==null?void 0:F.annotations)??[];return[...$,...V]}return $},set($){if(u.value>=0&&d.value){const F=new Set(e._base.annotations.value.map(K=>K.id).filter(Boolean)),V=$.filter(K=>K.id&&F.has(K.id)),U=$.filter(K=>!K.id||!F.has(K.id));e._base.annotations.value=V,f(u.value,{annotations:U.length>0?U:void 0});return}e._base.annotations.value=$}}),v=A(()=>{if(u.value<0)return;const $=Ra(c.value,u.value);return $==null?void 0:$.hiddenAnnotationIds});function y($,F){var se;if(u.value<0)return;const V=d.value;if(!V)return;const U=V.annotationVisibility??[];((se=v.value)==null?void 0:se.has($))?U.find(ce=>ce.id===$&&ce.action==="hide")?f(u.value,{annotationVisibility:U.filter(ce=>!(ce.id===$&&ce.action==="hide"))}):f(u.value,{annotationVisibility:[...U,{action:"show",kind:F,id:$}]}):U.find(ce=>ce.id===$&&ce.action==="show")?f(u.value,{annotationVisibility:U.filter(ce=>!(ce.id===$&&ce.action==="show"))}):f(u.value,{annotationVisibility:[...U,{action:"hide",kind:F,id:$}]})}const x=A(()=>n.value===Le.LineMulti),_=A(()=>fs(o.value)),k=A(()=>_.value.labels),E=A(()=>{var $;return(($=_.value.series)==null?void 0:$.map(F=>F.name))??[]}),B=Ve(null),S=A(()=>{var $;return(($=B.value)==null?void 0:$.openIndex)??null}),{containerRef:L}=HT(),D=Ie(600),I=Ie(400);function C(){var F;const $=(F=L.value)==null?void 0:F.querySelector("svg");$&&(D.value=parseFloat($.getAttribute("width")||"600")||600,I.value=parseFloat($.getAttribute("height")||"400")||400)}let T;un(()=>{C(),T=new ResizeObserver(C),L.value&&T.observe(L.value)}),Gs(()=>T==null?void 0:T.disconnect());function P($,F){const V=m.value.map(U=>({...U}));V[$]=F,m.value=V}return Jce(L,m,S,P),Ge(l,async $=>{if($!==null&&(await xn(),B.value)){const F=typeof $=="string"?m.value.findIndex(V=>V.id===$):$;if(F<0){l.value=null;return}B.value.openIndex=B.value.openIndex===F?null:F,l.value=null}},{immediate:!0}),($,F)=>{const V=Qle,U=Kle;return w(),R("div",eue,[p(b)?(w(),J(p(Fo),{key:0,title:"Highlight",icon:p(ice)},{default:te(()=>[H(V)]),_:1},8,["icon"])):ie("",!0),H(Qce,{ref_key:"annotationsRef",ref:B,modelValue:p(m),"onUpdate:modelValue":F[0]||(F[0]=K=>Ze(m)?m.value=K:null),labels:p(k),"chart-type":p(n),"chart-width":p(D),"chart-height":p(I),"hidden-annotation-ids":p(v),"can-toggle-visibility":p(h),onToggleVisibility:y},null,8,["modelValue","labels","chart-type","chart-width","chart-height","hidden-annotation-ids","can-toggle-visibility"]),p(x)?(w(),J(p(Fo),{key:1,title:"Area Fills",icon:p(nce)},{default:te(()=>[H(U,{modelValue:p(r),"onUpdate:modelValue":F[1]||(F[1]=K=>Ze(r)?r.value=K:null),"series-names":p(E),"series-overrides":p(i),"global-interpolation":p(a)},null,8,["modelValue","series-names","series-overrides","global-interpolation"])]),_:1},8,["icon"])):ie("",!0)])}}}),nue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function oue(t,e){return w(),R("svg",nue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M243.31 136L144 36.69A15.86 15.86 0 0 0 132.69 32H40a8 8 0 0 0-8 8v92.69A15.86 15.86 0 0 0 36.69 144L136 243.31a16 16 0 0 0 22.63 0l84.68-84.68a16 16 0 0 0 0-22.63m-96 96L48 132.69V48h84.69L232 147.31ZM96 84a12 12 0 1 1-12-12a12 12 0 0 1 12 12"},null,-1)])])}const rue=Oe({name:"ph-tag",render:oue}),iue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function sue(t,e){return w(),R("svg",iue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M48 64a8 8 0 0 1 8-8h16V40a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16H88v16a8 8 0 0 1-16 0V72H56a8 8 0 0 1-8-8m136 128h-8v-8a8 8 0 0 0-16 0v8h-8a8 8 0 0 0 0 16h8v8a8 8 0 0 0 16 0v-8h8a8 8 0 0 0 0-16m56-48h-16v-16a8 8 0 0 0-16 0v16h-16a8 8 0 0 0 0 16h16v16a8 8 0 0 0 16 0v-16h16a8 8 0 0 0 0-16m-20.69-64L80 219.31a16 16 0 0 1-22.62 0l-20.7-20.68a16 16 0 0 1 0-22.63L176 36.69a16 16 0 0 1 22.63 0l20.68 20.68a16 16 0 0 1 0 22.63m-54.63 32L144 91.31l-96 96L68.68 208ZM208 68.69L187.31 48l-32 32L176 100.69Z"},null,-1)])])}const rb=Oe({name:"ph-magic-wand",render:sue}),aue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function lue(t,e){return w(),R("svg",aue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M205.66 138.34a8 8 0 0 1-11.32 11.32L136 91.31V224a8 8 0 0 1-16 0V91.31l-58.34 58.35a8 8 0 0 1-11.32-11.32l72-72a8 8 0 0 1 11.32 0ZM216 32H40a8 8 0 0 0 0 16h176a8 8 0 0 0 0-16"},null,-1)])])}const cue=Oe({name:"ph-arrow-line-up",render:lue}),uue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function due(t,e){return w(),R("svg",uue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M50.34 117.66a8 8 0 0 1 11.32-11.32L120 164.69V32a8 8 0 0 1 16 0v132.69l58.34-58.35a8 8 0 0 1 11.32 11.32l-72 72a8 8 0 0 1-11.32 0ZM216 208H40a8 8 0 0 0 0 16h176a8 8 0 0 0 0-16"},null,-1)])])}const fue=Oe({name:"ph-arrow-line-down",render:due}),hue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function pue(t,e){return w(),R("svg",hue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 128a8 8 0 0 1-8 8H91.31l58.35 58.34a8 8 0 0 1-11.32 11.32l-72-72a8 8 0 0 1 0-11.32l72-72a8 8 0 0 1 11.32 11.32L91.31 120H224a8 8 0 0 1 8 8M40 32a8 8 0 0 0-8 8v176a8 8 0 0 0 16 0V40a8 8 0 0 0-8-8"},null,-1)])])}const mue=Oe({name:"ph-arrow-line-left",render:pue}),gue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function vue(t,e){return w(),R("svg",gue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M189.66 122.34a8 8 0 0 1 0 11.32l-72 72a8 8 0 0 1-11.32-11.32L164.69 136H32a8 8 0 0 1 0-16h132.69l-58.35-58.34a8 8 0 0 1 11.32-11.32ZM216 32a8 8 0 0 0-8 8v176a8 8 0 0 0 16 0V40a8 8 0 0 0-8-8"},null,-1)])])}const bue=Oe({name:"ph-arrow-line-right",render:vue}),yue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function xue(t,e){return w(),R("svg",yue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 136v64a8 8 0 0 1-16 0v-44.68l-66.34 66.34a8 8 0 0 1-11.32-11.32L100.68 144H56a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8m80-104H80a16 16 0 0 0-16 16v48a8 8 0 0 0 16 0V48h128v128h-48a8 8 0 0 0 0 16h48a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16"},null,-1)])])}const ib=Oe({name:"ph-arrow-square-in",render:xue}),wue={class:"d-flex flex-column gap-3"},_ue=le({__name:"EditorLegendSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("legend")),i=A(()=>n.value.includes("legendPosition")),s=A(()=>n.value.includes("legendAnchor")),a=A(()=>n.value.includes("directLabelling")),l=A(()=>a.value),c=A(()=>n.value.includes("directLabelAnchor")),u=A(()=>e.value.directLabelling?"direct":e.value.legend===!1?"none":"legend"),d=A(()=>{const v=[{value:"legend",text:"Legend",icon:ZA},{value:"none",text:"None",icon:cf}];return a.value&&v.splice(1,0,{value:"direct",text:"Direct labelling",icon:rue}),v});function f(v){v==="legend"?(o("legend",!0),o("directLabelling","")):v==="direct"?(o("legend",!1),o("directLabelling","auto")):(o("legend",!1),o("directLabelling",""))}const h=[{value:"auto",text:"Auto",icon:rb},{value:"outside",text:"Outside",icon:Fp},{value:"inside",text:"Inside",icon:ib}],g=[{value:"start",text:"Start",icon:af},{value:"middle",text:"Middle",icon:v0},{value:"end",text:"End",icon:lf}],b=[{value:"top",text:"Top",icon:cue},{value:"bottom",text:"Bottom",icon:fue},{value:"left",text:"Left",icon:mue},{value:"right",text:"Right",icon:bue}],m=[{value:"start",text:"Start",icon:af},{value:"middle",text:"Middle",icon:v0},{value:"end",text:"End",icon:lf}];return(v,y)=>(w(),R("div",wue,[p(r)?(w(),J(p(Cn),{key:0,label:"Labels","model-value":p(u),options:p(d),block:"","onUpdate:modelValue":f},null,8,["model-value","options"])):ie("",!0),p(l)&&p(u)==="direct"?(w(),J(p(Cn),{key:1,label:"Direct label style","model-value":p(e).directLabelling||"auto",options:h,block:"","onUpdate:modelValue":y[0]||(y[0]=x=>p(o)("directLabelling",x))},null,8,["model-value"])):ie("",!0),p(c)&&p(u)==="direct"&&p(e).directLabelling==="inside"?(w(),J(p(Cn),{key:2,label:"Label anchor","model-value":p(e).directLabelAnchor||"middle",options:g,block:"","onUpdate:modelValue":y[1]||(y[1]=x=>p(o)("directLabelAnchor",x))},null,8,["model-value"])):ie("",!0),p(i)&&p(u)==="legend"?(w(),J(p(Cn),{key:3,label:"Legend position","model-value":p(e).legendPosition??"top",options:b,block:"","onUpdate:modelValue":y[2]||(y[2]=x=>p(o)("legendPosition",x))},null,8,["model-value"])):ie("",!0),p(s)&&p(u)==="legend"?(w(),J(p(Cn),{key:4,label:"Legend anchor","model-value":p(e).legendAnchor??"start",options:m,block:"","onUpdate:modelValue":y[3]||(y[3]=x=>p(o)("legendAnchor",x))},null,8,["model-value"])):ie("",!0)]))}}),kue={class:"d-flex flex-column gap-3"},Sue={class:"pt-2"},Aue={class:"pt-2"},Cue={class:"pt-2"},$ue={class:"pt-2"},Tue=le({__name:"EditorLayoutSection",setup(t){const{layout:e}=dn(),n=A({get:()=>e.value.sizing,set:h=>{e.value.sizing=h}}),o=A({get:()=>e.value.heightMode,set:h=>{e.value.heightMode=h}}),r=A({get:()=>String(e.value.fixedWidth),set:h=>{e.value.fixedWidth=Number(h)||600}}),i=A({get:()=>String(e.value.fixedHeight),set:h=>{e.value.fixedHeight=Number(h)||400}}),s=A({get:()=>String(e.value.padding),set:h=>{e.value.padding=Number(h)||0}}),a=A({get:()=>e.value.aspectRatio,set:h=>{e.value.aspectRatio=h}}),l=A({get:()=>e.value.transparentBackground,set:h=>{e.value.transparentBackground=h}}),c=A({get:()=>String(e.value.maxWidth),set:h=>{e.value.maxWidth=Number(h)||660}}),u=[{value:"responsive",text:"Responsive"},{value:"max-width",text:"Max width"},{value:"fixed",text:"Fixed"}],d=[{value:"auto",text:"Auto"},{value:"fixed",text:"Fixed"},{value:"aspect-ratio",text:"Aspect ratio"}],f=[{value:"16:9",label:"16:9"},{value:"4:3",label:"4:3"},{value:"3:2",label:"3:2"},{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"9:16",label:"9:16"}];return(h,g)=>(w(),R("div",kue,[H(p(Cn),{modelValue:p(n),"onUpdate:modelValue":g[2]||(g[2]=b=>Ze(n)?n.value=b:null),label:"Width",options:u,block:""},{"section:fixed":te(()=>[M("div",Sue,[H(p(xr),{id:"layout-fixed-width",modelValue:p(r),"onUpdate:modelValue":g[0]||(g[0]=b=>Ze(r)?r.value=b:null),label:"",min:"200",max:"1200",suffix:"px"},null,8,["modelValue"])])]),"section:max-width":te(()=>[M("div",Aue,[H(p(xr),{id:"layout-max-width",modelValue:p(c),"onUpdate:modelValue":g[1]||(g[1]=b=>Ze(c)?c.value=b:null),label:"",min:"200",max:"1200",suffix:"px"},null,8,["modelValue"])])]),_:1},8,["modelValue"]),H(p(Cn),{modelValue:p(o),"onUpdate:modelValue":g[5]||(g[5]=b=>Ze(o)?o.value=b:null),label:"Height",options:d,block:""},{"section:fixed":te(()=>[M("div",Cue,[H(p(xr),{id:"layout-fixed-height",modelValue:p(i),"onUpdate:modelValue":g[3]||(g[3]=b=>Ze(i)?i.value=b:null),label:"",min:"100",max:"800",suffix:"px"},null,8,["modelValue"])])]),"section:aspect-ratio":te(()=>[M("div",$ue,[H(p(En),{id:"layout-aspect-ratio",modelValue:p(a),"onUpdate:modelValue":g[4]||(g[4]=b=>Ze(a)?a.value=b:null),options:f,block:""},null,8,["modelValue"])])]),_:1},8,["modelValue"]),H(p(xr),{id:"layout-padding",modelValue:p(s),"onUpdate:modelValue":g[6]||(g[6]=b=>Ze(s)?s.value=b:null),label:"Padding",min:"0",max:"80",suffix:"px"},null,8,["modelValue"]),H(p(nn),{modelValue:p(l),"onUpdate:modelValue":g[7]||(g[7]=b=>Ze(l)?l.value=b:null),label:"Transparent background"},null,8,["modelValue"])]))}}),Mue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Oue(t,e){return w(),R("svg",Mue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M80 64a8 8 0 0 1 8-8h128a8 8 0 0 1 0 16H88a8 8 0 0 1-8-8m136 56H88a8 8 0 0 0 0 16h128a8 8 0 0 0 0-16m0 64H88a8 8 0 0 0 0 16h128a8 8 0 0 0 0-16M44 52a12 12 0 1 0 12 12a12 12 0 0 0-12-12m0 64a12 12 0 1 0 12 12a12 12 0 0 0-12-12m0 64a12 12 0 1 0 12 12a12 12 0 0 0-12-12"},null,-1)])])}const Bue=Oe({name:"ph-list-bullets",render:Oue}),Lue={class:"d-flex flex-column gap-4"},Pue=le({__name:"EditorLayoutTab",setup(t){const{availableOptionKeys:e}=_n(),n=A(()=>e.value.includes("legend"));return(o,r)=>{const i=Tue,s=_ue;return w(),R("div",Lue,[H(i),p(n)?(w(),J(p(Fo),{key:0,title:"Legend",icon:p(Bue)},{default:te(()=>[H(s)]),_:1},8,["icon"])):ie("",!0)])}}}),Due={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Eue(t,e){return w(),R("svg",Due,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M239.24 131.4c-22 46.8-41.4 68.6-61.2 68.6c-25.1 0-40.73-33.32-57.28-68.6C107.7 103.56 92.9 72 78 72c-16.4 0-36.31 37.21-46.72 59.4a8 8 0 0 1-14.48-6.8C38.71 77.8 58.16 56 78 56c25.1 0 40.73 33.32 57.28 68.6C148.3 152.44 163.1 184 178 184c16.4 0 36.31-37.21 46.72-59.4a8 8 0 0 1 14.48 6.8Z"},null,-1)])])}const Nue=Oe({name:"ph-wave-sine",render:Eue}),Iue={key:0,class:"d-flex flex-column gap-4"},Rue={class:"d-flex flex-column gap-2"},Fue={key:1,class:"text-muted small"},Vue=le({__name:"EditorAxisOptions",setup(t){const e=A(()=>l.value.includes("valueLabels")),n=A(()=>l.value.includes("swapLabelValue")),o=[{value:"auto",text:"Auto",icon:rb},{value:"outside",text:"Outside",icon:Fp},{value:"inside",text:"Inside",icon:ib}],r=new Set(["showVerticalAxis","verticalAxisDirection","showVerticalTicks","verticalLabelPosition","verticalGridStyle","verticalNumberFormat","verticalScaleType","verticalRangeMin","verticalRangeMax"]),i=new Set(["showHorizontalAxis","showHorizontalTicks","horizontalLabelPosition","horizontalGridStyle","horizontalNumberFormat","horizontalScaleType","horizontalRangeMin","horizontalRangeMax"]),{currentOptions:s,optionDefs:a,availableOptionKeys:l,setOption:c}=_n();function u(T,P){c(T,P)}const{displayColumnTypes:d}=jo(),f=A(()=>d.value[0]??"string"),h=A(()=>d.value[1]??"number"),g=A(()=>a.value.some(T=>T.key==="verticalScaleType"));function b(T){return T.replace(/^(Show\s+)?(vertical|horizontal)\s+/i,(P,$)=>$??"").replace(/^./,P=>P.toUpperCase())}function m(T){return(T?!g.value:g.value)?h.value:f.value}function v(T,P){if(T.type!=="numberFormat")return T;const $=m(P);return $==="date"?{...T,type:"dateFormat",label:T.label.replace(/number\s+format/i,"Date format")}:$==="string"?{...T,type:"__hidden"}:T}const y=A(()=>a.value.filter(T=>r.has(T.key)).map(T=>v({...T,label:b(T.label)},!1)).filter(T=>T.type!=="__hidden")),x=A(()=>a.value.filter(T=>i.has(T.key)).map(T=>v({...T,label:b(T.label)},!0)).filter(T=>T.type!=="__hidden")),_={solid:q2,dashed:VT,dotted:zT,none:cf},k={auto:rb,inside:ib,outside:Fp,off:cf},E={left:af,right:lf},B={linear:rd,log:Nue},S={verticalGridStyle:_,horizontalGridStyle:_,verticalLabelPosition:k,horizontalLabelPosition:k,verticalAxisDirection:E,verticalScaleType:B,horizontalScaleType:B},L=(T,{emit:P})=>{const{def:$,value:F}=T;if($.type==="boolean")return Vt(nn,{label:$.label,modelValue:F??$.default??!1,"onUpdate:modelValue":V=>P("update",V)});if($.type==="select"&&$.choices){const V=S[$.key],U=$.choices.map(K=>({value:K.value,text:K.text,...V!=null&&V[K.value]?{icon:V[K.value]}:{}}));return Vt(Cn,{label:$.label,options:U,block:!0,modelValue:F??$.default??"","onUpdate:modelValue":K=>P("update",K)})}return $.type==="text"?Vt(wm,{label:$.label,id:`opt-${$.key}`,placeholder:$.placeholder??"",modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):$.type==="numberFormat"?Vt(FV,{label:$.label,id:`opt-${$.key}`,modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):$.type==="dateFormat"?Vt(TH,{label:$.label,id:`opt-${$.key}`,modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):null};L.props=["def","value"],L.emits=["update"];function D(T){return T.endsWith("RangeMin")}function I(T){return T.endsWith("RangeMax")}const C=(T,{emit:P})=>{const $=[],{defs:F,currentOptions:V}=T;let U=0;for(;U<F.length;){const K=F[U];if(D(K.key)&&U+1<F.length&&I(F[U+1].key)){const se=F[U+1];$.push(Vt("div",{class:"d-flex gap-2",key:K.key},[Vt("div",{class:"flex-fill",style:"min-width:0"},[Vt(L,{def:K,value:V[K.key],onUpdate:he=>P("update",K.key,he)})]),Vt("div",{class:"flex-fill",style:"min-width:0"},[Vt(L,{def:se,value:V[se.key],onUpdate:he=>P("update",se.key,he)})])])),U+=2}else $.push(Vt(L,{key:K.key,def:K,value:V[K.key],onUpdate:se=>P("update",K.key,se)})),U++}return Vt("div",{class:"d-flex flex-column gap-2"},$)};return C.props=["defs","currentOptions"],C.emits=["update"],(T,P)=>p(e)||p(y).length>0||p(x).length>0?(w(),R("div",Iue,[p(e)?(w(),J(p(Fo),{key:0,title:"Value Labels",icon:p(ET)},{default:te(()=>[M("div",Rue,[H(p(nn),{"model-value":p(s).valueLabels??!1,label:"Show value labels","onUpdate:modelValue":P[0]||(P[0]=$=>u("valueLabels",$))},null,8,["model-value"]),p(s).valueLabels?(w(),J(p(Cn),{key:0,label:"Position","model-value":p(s).valueLabelPosition??"auto",options:o,block:"","onUpdate:modelValue":P[1]||(P[1]=$=>u("valueLabelPosition",$))},null,8,["model-value"])):ie("",!0),p(s).valueLabels&&p(n)?(w(),J(p(nn),{key:1,"model-value":p(s).swapLabelValue??!1,label:"Swap labels and values","onUpdate:modelValue":P[2]||(P[2]=$=>u("swapLabelValue",$))},null,8,["model-value"])):ie("",!0)])]),_:1},8,["icon"])):ie("",!0),p(y).length>0?(w(),J(p(Fo),{key:1,title:"Vertical Axis",icon:p(RT)},{default:te(()=>[H(C,{defs:p(y),"current-options":p(s),onUpdate:u},null,8,["defs","current-options"])]),_:1},8,["icon"])):ie("",!0),p(x).length>0?(w(),J(p(Fo),{key:2,title:"Horizontal Axis",icon:p(FT)},{default:te(()=>[H(C,{defs:p(x),"current-options":p(s),onUpdate:u},null,8,["defs","current-options"])]),_:1},8,["icon"])):ie("",!0)])):(w(),R("p",Fue," No axis options for this chart type. "))}}),zue={class:"d-flex flex-column gap-3"},UT=le({__name:"EditorSymbolOptions",props:{shape:{},showOn:{},style:{},size:{},opacity:{},idPrefix:{default:"symbol"}},emits:["update:shape","update:showOn","update:style","update:size","update:opacity"],setup(t){const e=[{value:"circle",text:"Circle"},{value:"square",text:"Square"},{value:"diamond",text:"Diamond"},{value:"triangle",text:"Triangle Up"},{value:"triangleDown",text:"Triangle Down"},{value:"cross",text:"Cross"},{value:"star",text:"Star"}],n=[{value:"firstLast",text:"First & Last"},{value:"first",text:"First"},{value:"last",text:"Last"},{value:"all",text:"All"}],o=[{value:"filled",text:"Filled"},{value:"hollow",text:"Hollow"}];return(r,i)=>{const s=Ga,a=Mn;return w(),R("div",zue,[H(a,{label:"Symbol","label-for":`${t.idPrefix}-shape`},{default:te(()=>[H(s,{id:`${t.idPrefix}-shape`,"model-value":t.shape,options:e,"onUpdate:modelValue":i[0]||(i[0]=l=>r.$emit("update:shape",l))},null,8,["id","model-value"])]),_:1},8,["label-for"]),H(p(Cn),{label:"Show on","model-value":t.showOn,options:n,"onUpdate:modelValue":i[1]||(i[1]=l=>r.$emit("update:showOn",l))},null,8,["model-value"]),H(p(Cn),{label:"Style","model-value":t.style,options:o,"onUpdate:modelValue":i[2]||(i[2]=l=>r.$emit("update:style",l))},null,8,["model-value"]),H(p(xr),{id:`${t.idPrefix}-size`,label:"Size","model-value":t.size,min:"0.5",max:"10",step:"0.5","onUpdate:modelValue":i[3]||(i[3]=l=>r.$emit("update:size",l))},null,8,["id","model-value"]),H(p(xr),{id:`${t.idPrefix}-opacity`,label:"Opacity","model-value":t.opacity,min:"0",max:"1",step:"0.1","onUpdate:modelValue":i[4]||(i[4]=l=>r.$emit("update:opacity",l))},null,8,["id","model-value"])])}}}),Hue={class:"d-flex flex-column gap-3"},Wue={class:"d-flex gap-2 justify-content-end"},Uue=le({__name:"EditorSeriesOptions",props:{selected:{},overrides:{},colors:{},chartType:{}},emits:["update:overrides"],setup(t,{emit:e}){const n=t,o=e;function r(C){return n.overrides.find(T=>T.name===C)}function i(){return n.selected.length>0?r(n.selected[0]):void 0}const s=A(()=>n.chartType==="bar-multi"),a=A(()=>n.chartType==="line-multi"),l=A(()=>{var C;return((C=i())==null?void 0:C.color)??"#4e79a7"}),c=A(()=>{var C;return String(((C=i())==null?void 0:C.opacity)??1)}),u=A(()=>{var C;return String(((C=i())==null?void 0:C.lineWidth)??2)}),d=A(()=>{var C;return((C=i())==null?void 0:C.dash)??"solid"}),f=A(()=>{var C;return((C=i())==null?void 0:C.interpolation)??"global"}),h=A(()=>{var C;return((C=i())==null?void 0:C.labelMode)??"global"}),g=A(()=>{var C;return((C=i())==null?void 0:C.valueLabels)??!1}),b=A(()=>{var C;return((C=i())==null?void 0:C.lineSymbols)??!1}),m=A(()=>{var C;return((C=i())==null?void 0:C.symbolShape)??"circle"}),v=A(()=>{var C;return((C=i())==null?void 0:C.symbolShowOn)??"firstLast"}),y=A(()=>{var C;return((C=i())==null?void 0:C.symbolStyle)??"filled"}),x=A(()=>{var C;return String(((C=i())==null?void 0:C.symbolSize)??3.5)}),_=A(()=>{var C;return String(((C=i())==null?void 0:C.symbolOpacity)??1)});function k(C,T){const P=n.overrides.map($=>({...$}));for(const $ of n.selected){let F=P.find(V=>V.name===$);F||(F={name:$},P.push(F)),F[C]=T}o("update:overrides",P)}function E(){if(n.selected.length<2)return;const C=r(n.selected[0]);if(!C)return;const T=n.overrides.map(P=>({...P}));for(let P=1;P<n.selected.length;P++){const $=n.selected[P];let F=T.find(V=>V.name===$);F||(F={name:$},T.push(F)),Object.assign(F,{...C,name:$})}o("update:overrides",T)}function B(){const C=new Set(n.selected),T=n.overrides.filter(P=>!C.has(P.name));o("update:overrides",T)}const S=[{value:"1",text:"1"},{value:"2",text:"2"},{value:"3",text:"3"},{value:"4",text:"4"},{value:"5",text:"5"}],L=[{value:"solid",text:"Solid"},{value:"dotted",text:"Dotted"},{value:"dashed",text:"Dashed"},{value:"dash-dot",text:"Dash-dot"}],D=[{value:"global",text:"Global"},{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}],I=[{value:"global",text:"Global"},{value:"legend",text:"Legend"},{value:"direct",text:"Direct"},{value:"none",text:"None"}];return(C,T)=>{const P=Ga,$=Mn,F=UT,V=Vo;return w(),R("div",Hue,[H(p(Pa),{id:"series-color",label:"Color","model-value":p(l),"onUpdate:modelValue":T[0]||(T[0]=U=>k("color",U))},null,8,["model-value"]),H(p(Cn),{label:"Label mode","model-value":p(h),options:I,block:"","onUpdate:modelValue":T[1]||(T[1]=U=>k("labelMode",U))},null,8,["model-value"]),H(p(nn),{"model-value":p(g),label:"Value labels","onUpdate:modelValue":T[2]||(T[2]=U=>k("valueLabels",U))},null,8,["model-value"]),p(s)?(w(),J(p(xr),{key:0,id:"series-opacity",label:"Opacity","model-value":p(c),min:"0",max:"1",step:"0.1","onUpdate:modelValue":T[3]||(T[3]=U=>k("opacity",Number(U)))},null,8,["model-value"])):ie("",!0),p(a)?(w(),R(He,{key:1},[H(p(Cn),{label:"Line width","model-value":p(u),options:S,"onUpdate:modelValue":T[4]||(T[4]=U=>k("lineWidth",Number(U)))},null,8,["model-value"]),H(p(Cn),{label:"Dash style","model-value":p(d),options:L,"onUpdate:modelValue":T[5]||(T[5]=U=>k("dash",U))},null,8,["model-value"]),H($,{label:"Interpolation","label-for":"series-interpolation"},{default:te(()=>[H(P,{id:"series-interpolation","model-value":p(f),options:D,"onUpdate:modelValue":T[6]||(T[6]=U=>k("interpolation",U))},null,8,["model-value"])]),_:1}),H(p(nn),{"model-value":p(b),label:"Line symbols","onUpdate:modelValue":T[7]||(T[7]=U=>k("lineSymbols",U))},null,8,["model-value"]),p(b)?(w(),J(F,{key:0,"id-prefix":"series-symbol",shape:p(m),"show-on":p(v),style:Et(p(y)),size:p(x),opacity:p(_),"onUpdate:shape":T[8]||(T[8]=U=>k("symbolShape",U)),"onUpdate:showOn":T[9]||(T[9]=U=>k("symbolShowOn",U)),"onUpdate:style":T[10]||(T[10]=U=>k("symbolStyle",U)),"onUpdate:size":T[11]||(T[11]=U=>k("symbolSize",Number(U))),"onUpdate:opacity":T[12]||(T[12]=U=>k("symbolOpacity",Number(U)))},null,8,["shape","show-on","style","size","opacity"])):ie("",!0)],64)):ie("",!0),M("div",Wue,[t.selected.length>1?(w(),J(V,{key:0,variant:"outline-secondary",size:"sm",onClick:E},{default:te(()=>[...T[13]||(T[13]=[Ye(" Copy from first ",-1)])]),_:1})):ie("",!0),H(V,{variant:"outline-danger",size:"sm",onClick:B},{default:te(()=>[...T[14]||(T[14]=[Ye(" Reset to default ",-1)])]),_:1})])])}}}),Gue=le({__name:"EditorSeriesList",props:{seriesNames:{},selected:{},colors:{},overrides:{}},emits:["update:selected","toggleVisibility"],setup(t){const e=t;function n(r,i){return an(r,i,e.colors,e.overrides)}function o(r){return Ja(r,e.overrides)}return(r,i)=>{const s=Rs;return w(),J(p(Vy),{items:t.seriesNames,selected:t.selected,"onUpdate:selected":i[1]||(i[1]=a=>r.$emit("update:selected",a))},{"item-leading":te(({item:a,index:l})=>[H(p(xm),{color:n(a,l)},null,8,["color"])]),"item-actions":te(({item:a})=>[H(s,{"model-value":!o(a),switch:"",size:"sm",onClick:i[0]||(i[0]=pn(()=>{},["stop"])),"onUpdate:modelValue":l=>r.$emit("toggleVisibility",a,!l)},null,8,["model-value","onUpdate:modelValue"])]),_:1},8,["items","selected"])}}}),que={class:"d-flex flex-column gap-3"},Yue=le({__name:"EditorSeriesPanel",setup(t){const{chartType:e,data:n,seriesOverrides:o}=dn(),{currentOptions:r}=_n(),i=Ve([]),s=A(()=>{var u;return((u=fs(n.value).series)==null?void 0:u.map(d=>d.name))??[]}),a=A(()=>U$(r.value).colors??["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"]);function l(c,u){const d=o.value.map(h=>({...h}));let f=d.find(h=>h.name===c);f||(f={name:c},d.push(f)),f.hidden=u,o.value=d}return(c,u)=>{const d=Gue,f=Uue;return w(),R("div",que,[u[2]||(u[2]=M("h6",{class:"fw-bold mb-0"}," Series ",-1)),H(d,{"series-names":p(s),selected:p(i),colors:p(a),overrides:p(o),"onUpdate:selected":u[0]||(u[0]=h=>i.value=h),onToggleVisibility:l},null,8,["series-names","selected","colors","overrides"]),p(i).length>0?(w(),J(p(Ad),{key:0,label:"Editing "+p(i).length+" "+(p(i).length===1?"series: "+p(i)[0]:"series")},{default:te(()=>[H(f,{selected:p(i),overrides:p(o),colors:p(a),"chart-type":p(e),"onUpdate:overrides":u[1]||(u[1]=h=>o.value=h)},null,8,["selected","overrides","colors","chart-type"])]),_:1},8,["label"])):ie("",!0)])}}}),jue={class:"d-flex flex-column gap-3"},Xue={class:"bc-area-stack-options"},Kue=le({__name:"EditorAreaSection",setup(t){const{currentOptions:e,setOption:n}=_n(),o=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}],r=[{value:"none",text:"Keep order"},{value:"ascending",text:"Smallest first"},{value:"descending",text:"Largest first"}];return(i,s)=>{const a=Ga,l=Mn,c=KD,u=Rs;return w(),R("div",jue,[H(p(xr),{id:"opt-area-opacity","model-value":String(p(e).areaFillOpacity??"0.85"),label:"Opacity",min:"0",max:"1",step:"0.05","onUpdate:modelValue":s[0]||(s[0]=d=>p(n)("areaFillOpacity",d))},null,8,["model-value"]),H(l,{label:"Interpolation","label-for":"opt-area-interpolation"},{default:te(()=>[H(a,{id:"opt-area-interpolation","model-value":p(e).interpolation??"monotoneX",options:o,"onUpdate:modelValue":s[1]||(s[1]=d=>p(n)("interpolation",String(d)))},null,8,["model-value"])]),_:1}),H(l,{label:"Sort areas"},{default:te(()=>[H(c,{"model-value":p(e).areaSortMode??"none",options:r,stacked:"","onUpdate:modelValue":s[2]||(s[2]=d=>p(n)("areaSortMode",String(d)))},null,8,["model-value"])]),_:1}),H(p(nn),{"model-value":p(e).stacked!==!1,label:"Stack areas","onUpdate:modelValue":s[5]||(s[5]=d=>p(n)("stacked",d))},{section:te(()=>[M("div",Xue,[H(u,{"model-value":p(e).stackPercent??!1,"onUpdate:modelValue":s[3]||(s[3]=d=>p(n)("stackPercent",d))},{default:te(()=>[...s[6]||(s[6]=[Ye(" Stack to 100% ",-1)])]),_:1},8,["model-value"]),H(u,{"model-value":p(e).areaLines!==!1,"onUpdate:modelValue":s[4]||(s[4]=d=>p(n)("areaLines",d))},{default:te(()=>[...s[7]||(s[7]=[Ye(" Separate areas with lines ",-1)])]),_:1},8,["model-value"])])]),_:1},8,["model-value"])])}}}),Zue=Be(Kue,[["__scopeId","data-v-3bf56010"]]),Que={class:"d-flex flex-column gap-3"},Jue=le({__name:"EditorSliceSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n();function r(i){return n.value.includes(i)}return(i,s)=>{const a=ea,l=Mn;return w(),R("div",Que,[r("displayAsPercentage")?(w(),J(p(nn),{key:0,"model-value":p(e).displayAsPercentage??!1,label:"Display as percentage","onUpdate:modelValue":s[0]||(s[0]=c=>p(o)("displayAsPercentage",c))},null,8,["model-value"])):ie("",!0),r("showTotal")?(w(),J(p(nn),{key:1,"model-value":p(e).showTotal??!1,label:"Show total","onUpdate:modelValue":s[1]||(s[1]=c=>p(o)("showTotal",c))},null,8,["model-value"])):ie("",!0),r("showLabels")?(w(),J(p(nn),{key:2,"model-value":p(e).showLabels??!0,label:"Show labels","onUpdate:modelValue":s[2]||(s[2]=c=>p(o)("showLabels",c))},null,8,["model-value"])):ie("",!0),r("showValues")?(w(),J(p(nn),{key:3,"model-value":p(e).showValues??!0,label:"Show values","onUpdate:modelValue":s[3]||(s[3]=c=>p(o)("showValues",c))},null,8,["model-value"])):ie("",!0),r("sliceMax")?(w(),J(p(xr),{key:4,id:"opt-sliceMax",label:"Max slices","model-value":p(e).sliceMax??"6",min:"2",max:"20","onUpdate:modelValue":s[4]||(s[4]=c=>p(o)("sliceMax",String(c)))},null,8,["model-value"])):ie("",!0),r("sliceGroupLabel")?(w(),J(l,{key:5,label:"Group label","label-for":"opt-sliceGroupLabel"},{default:te(()=>[H(a,{id:"opt-sliceGroupLabel","model-value":p(e).sliceGroupLabel??"Others",placeholder:"Others","onUpdate:modelValue":s[5]||(s[5]=c=>p(o)("sliceGroupLabel",c))},null,8,["model-value"])]),_:1})):ie("",!0)])}}}),ede={class:"d-flex flex-column gap-3"},K6=.15,tde=le({__name:"EditorBarStyleSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("barBackground")),i=A(()=>n.value.includes("barSeparators")),s=A(()=>n.value.includes("barGap")),a=A(()=>n.value.includes("connectedColumns")),l=A(()=>n.value.includes("waterfall")),c=A(()=>n.value.includes("waterfallTotal")),u=A(()=>n.value.includes("categoryLabelLine"));function d(y){return Math.max(0,Math.min(100,y))}const f=A(()=>{const y=parseFloat(e.value.barGap??""),x=isNaN(y)?ef:y;return String(d(x))});function h(y){const x=parseFloat(y),_=isNaN(x)?ef:x;o("barGap",String(d(_)))}function g(y){const x=parseFloat(y??""),_=isNaN(x)?K6:x,k=Math.max(0,Math.min(1,_));return String(Math.round(k*100))}function b(y){const x=parseFloat(y);if(isNaN(x))return String(K6);const _=Math.max(0,Math.min(100,x));return String(_/100)}const m=A(()=>g(e.value.connectionsOpacity));function v(y){o("connectionsOpacity",b(y))}return(y,x)=>(w(),R("div",ede,[p(r)?(w(),J(p(nn),{key:0,"model-value":p(e).barBackground??!1,label:"Bar background","onUpdate:modelValue":x[0]||(x[0]=_=>p(o)("barBackground",_))},null,8,["model-value"])):ie("",!0),p(i)?(w(),J(p(nn),{key:1,"model-value":p(e).barSeparators??!1,label:"Bar separators","onUpdate:modelValue":x[1]||(x[1]=_=>p(o)("barSeparators",_))},null,8,["model-value"])):ie("",!0),p(s)?(w(),J(p(xr),{key:2,id:"opt-bar-gap","model-value":p(f),label:"Bar gap",min:"0",max:"100",step:"1",suffix:"%","onUpdate:modelValue":h},null,8,["model-value"])):ie("",!0),p(a)?(w(),J(p(nn),{key:3,"model-value":p(e).connectedColumns??!1,label:"Connected columns","onUpdate:modelValue":x[2]||(x[2]=_=>p(o)("connectedColumns",_))},null,8,["model-value"])):ie("",!0),p(a)&&p(e).connectedColumns?(w(),J(p(xr),{key:4,id:"opt-connections-opacity","model-value":p(m),label:"Opacity",min:"0",max:"100",step:"1",suffix:"%","onUpdate:modelValue":v},null,8,["model-value"])):ie("",!0),p(l)?(w(),J(p(nn),{key:5,"model-value":p(e).waterfall??!1,label:"Waterfall","onUpdate:modelValue":x[3]||(x[3]=_=>p(o)("waterfall",_))},null,8,["model-value"])):ie("",!0),p(c)&&p(e).waterfall?(w(),J(p(nn),{key:6,"model-value":p(e).waterfallTotal??!1,label:"Waterfall total","onUpdate:modelValue":x[4]||(x[4]=_=>p(o)("waterfallTotal",_))},null,8,["model-value"])):ie("",!0),p(u)?(w(),J(p(nn),{key:7,"model-value":p(e).categoryLabelLine??!1,label:"Labels on separate line","onUpdate:modelValue":x[5]||(x[5]=_=>p(o)("categoryLabelLine",_))},null,8,["model-value"])):ie("",!0)]))}}),nde={class:"d-flex flex-column gap-3"},ode=le({__name:"EditorLineSymbols",setup(t){const{currentOptions:e,setOption:n}=_n();return(o,r)=>{const i=UT;return w(),R("div",nde,[H(p(nn),{"model-value":p(e).lineSymbols??!1,label:"Show line symbols","onUpdate:modelValue":r[0]||(r[0]=s=>p(n)("lineSymbols",s))},null,8,["model-value"]),p(e).lineSymbols?(w(),J(i,{key:0,"id-prefix":"opt-line-symbol",shape:p(e).lineSymbolShape??"circle","show-on":p(e).lineSymbolShowOn??"firstLast",style:Et(p(e).lineSymbolStyle??"filled"),size:p(e).lineSymbolSize??"3.5",opacity:p(e).lineSymbolOpacity??"1","onUpdate:shape":r[1]||(r[1]=s=>p(n)("lineSymbolShape",s)),"onUpdate:showOn":r[2]||(r[2]=s=>p(n)("lineSymbolShowOn",s)),"onUpdate:style":r[3]||(r[3]=s=>p(n)("lineSymbolStyle",s)),"onUpdate:size":r[4]||(r[4]=s=>p(n)("lineSymbolSize",s)),"onUpdate:opacity":r[5]||(r[5]=s=>p(n)("lineSymbolOpacity",s))},null,8,["shape","show-on","style","size","opacity"])):ie("",!0)])}}}),rde={class:"d-flex flex-column gap-3"},ide=le({__name:"EditorLineSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("interpolation")),i=A(()=>n.value.includes("edgePadding")),s=A(()=>n.value.includes("lineSymbols")),a=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}];return(l,c)=>{const u=Ga,d=Mn,f=ode;return w(),R("div",rde,[p(r)?(w(),J(d,{key:0,label:"Line interpolation","label-for":"opt-interpolation"},{default:te(()=>[H(u,{id:"opt-interpolation","model-value":p(e).interpolation??"linear",options:a,"onUpdate:modelValue":c[0]||(c[0]=h=>p(o)("interpolation",h))},null,8,["model-value"])]),_:1})):ie("",!0),p(i)?(w(),J(p(nn),{key:1,"model-value":p(e).edgePadding??!1,label:"Edge padding","onUpdate:modelValue":c[1]||(c[1]=h=>p(o)("edgePadding",h))},null,8,["model-value"])):ie("",!0),p(s)?(w(),J(f,{key:2})):ie("",!0)])}}}),sde={class:"d-flex flex-column gap-3"},ade=le({__name:"EditorBarAppearance",props:{labels:{},colorizes:{},baseColor:{}},emits:["update:colorizes","update:baseColor"],setup(t,{emit:e}){const n=t,o=e,r=Ve([]),i=Ie(n.colorizes.length>0),s=A(()=>{const h=new Map;for(const g of n.colorizes)h.set(g.target,g.color);return h});function a(h){return s.value.get(h)??n.baseColor}const l=A(()=>r.value.length===0?n.baseColor:s.value.get(r.value[0])??n.baseColor);function c(h,g,b){b.ctrlKey||b.metaKey?r.value.indexOf(h)>=0?r.value=r.value.filter(v=>v!==h):r.value=[...r.value,h]:r.value.length===1&&r.value[0]===h?r.value=[]:r.value=[h]}function u(h){const g=new Map(n.colorizes.map(b=>[b.target,b]));for(const b of r.value)g.set(b,{target:b,color:h,label:""});o("update:colorizes",[...g.values()])}function d(){o("update:colorizes",[]),r.value=[]}function f(h){i.value=h,h||(o("update:colorizes",[]),r.value=[])}return(h,g)=>(w(),R("div",sde,[H(p(Pa),{id:"bar-base-color",label:"Base color","model-value":t.baseColor,"onUpdate:modelValue":g[0]||(g[0]=b=>h.$emit("update:baseColor",b))},null,8,["model-value"]),H(p(nn),{"model-value":p(i),label:"Customize colors","onUpdate:modelValue":f},null,8,["model-value"]),p(i)?(w(),R(He,{key:0},[H(p(Vy),{items:t.labels,selected:p(r),"on-item-click":c,"onUpdate:selected":g[1]||(g[1]=b=>r.value=b)},{"item-leading":te(({item:b})=>[H(p(xm),{color:a(b)},null,8,["color"])]),_:1},8,["items","selected"]),p(r).length>0?(w(),J(p(Ad),{key:0,label:"Editing "+p(r).length+" "+(p(r).length===1?"label":"labels")},{default:te(()=>[H(p(Pa),{id:"bar-highlight-color",label:"Color for selected","model-value":p(l),"onUpdate:modelValue":u},null,8,["model-value"]),t.colorizes.length>0?(w(),J(p(Vo),{key:0,variant:"outline-danger",size:"sm",onClick:d},{default:te(()=>[...g[2]||(g[2]=[Ye(" Reset all changes ",-1)])]),_:1})):ie("",!0)]),_:1},8,["label"])):ie("",!0)],64)):ie("",!0)]))}}),lde=Oo("cvdMode",()=>({cvdMode:Ie("")}));function GT(){const t=lde(),{cvdMode:e}=Ct(t);return{cvdMode:e}}const cde="#ffffff",ude="#1a1a1a",dde={protanopia:"Protan",deuteranopia:"Deutan",tritanopia:"Tritan"};function Z6(t,e,n){const r=(n?o$(t,e):t).map(s=>mte(s,e)),i=Math.min(...r);return{level:gte(i),ratio:`${i.toFixed(1)}:1`}}function fde(t,e,n){const o=A(()=>{const s=gt(t);return s.length===0?null:Z6(s,cde,gt(e))}),r=A(()=>{const s=gt(t);return s.length===0||!gt(n)?null:Z6(s,ude,gt(e))}),i=A(()=>{const s=gt(t);if(s.length===0)return null;const a=s.length>=2?ooe(s):[];return a.length===0?{safe:!0,issues:[]}:{safe:!1,issues:a.map(l=>({type:l.type,shortLabel:dde[l.type],tooltip:`${l.label}: ${l.pairs.length} color ${l.pairs.length===1?"pair":"pairs"} may be hard to distinguish.`}))}});return{lightContrastInfo:o,darkContrastInfo:r,cvdInfo:i}}const hde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#2563A0" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#D4A63A" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#C94044" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},pde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#4767a2" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#baa62a" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#655e43" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},mde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#345b9f" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#c5b23f" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#887c40" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},gde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#00717a" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#e69790" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#dc1a43" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},vde={class:"d-flex flex-column gap-3"},bde={key:4,class:"d-flex align-items-center gap-2"},yde={key:5,class:"d-flex align-items-center gap-2"},xde={key:6,class:"d-flex align-items-center gap-2"},wde=le({__name:"EditorColorSection",setup(t){const{chartType:e,data:n,colorizes:o}=dn(),{currentOptions:r,availableOptionKeys:i,setOption:s}=_n(),{cvdMode:a}=Ct(GT()),l=A(()=>[Le.BarVertical,Le.BarHorizontal,Le.VerticalBar,Le.HorizontalBar].includes(e.value)),c=A(()=>i.value.includes("colors")),u=A(()=>i.value.includes("colorPalette")),d=A(()=>fs(n.value)),f=A(()=>d.value.labels),h=A(()=>{const L=r.value.colorPalette;return L?QC(L)??[]:r.value.colors??[]}),g=A(()=>h.value[0]??"#4e79a7");function b(L){r.value.colorPalette&&s("colorPalette",""),s("colors",[L])}const m=A(()=>{if(l.value){const L=o.value.map(I=>I.color),D=g.value;return L.length>0?[D,...L]:[D]}return h.value}),{lightContrastInfo:v,darkContrastInfo:y,cvdInfo:x}=fde(m,()=>!!r.value.autoContrast,()=>r.value.allowDarkMode??!0),_=ft("cvdSafeBadgeRef"),k=ft("cvdBadgeRefs");function E(L){var I;const D=((I=x.value)==null?void 0:I.issues.findIndex(C=>C.type===L))??-1;return D>=0?k.value[D]:void 0}const B=[{value:"",text:"None",description:"Normal color vision",visual:Oe(hde)},{value:"protanopia",text:"Protanopia",description:"No red cones (1% of males)",visual:Oe(pde)},{value:"deuteranopia",text:"Deuteranopia",description:"No green cones (1% of males)",visual:Oe(mde)},{value:"tritanopia",text:"Tritanopia",description:"No blue cones (very rare)",visual:Oe(gde)}],S=[{value:"",label:"Custom",colors:[]},...JC().map(L=>({value:L.name,label:L.label,colors:[...L.colors]}))];return(L,D)=>{const I=ade;return w(),R("div",vde,[p(l)?(w(),J(I,{key:0,labels:p(f),colorizes:p(o),"base-color":p(g),"onUpdate:colorizes":D[0]||(D[0]=C=>o.value=C),"onUpdate:baseColor":b},null,8,["labels","colorizes","base-color"])):(w(),R(He,{key:1},[p(u)?(w(),J(p(uV),{key:0,id:"opt-palette",label:"Color palette","model-value":p(r).colorPalette??"",palettes:S,"onUpdate:modelValue":D[1]||(D[1]=C=>p(s)("colorPalette",C))},null,8,["model-value"])):ie("",!0),p(c)&&!p(r).colorPalette?(w(),J(p(EF),{key:1,id:"opt-colors",label:"Colors","model-value":p(r).colors??[],"onUpdate:modelValue":D[2]||(D[2]=C=>p(s)("colors",C))},null,8,["model-value"])):ie("",!0)],64)),p(u)||p(c)?(w(),J(p(nn),{key:2,id:"opt-allow-dark-mode",label:"Allow dark mode","model-value":p(r).allowDarkMode??!0,"onUpdate:modelValue":D[3]||(D[3]=C=>p(s)("allowDarkMode",C))},null,8,["model-value"])):ie("",!0),p(u)||p(c)?(w(),J(p(nn),{key:3,id:"opt-auto-contrast",label:"Auto-adjust contrast","model-value":p(r).autoContrast??!1,"onUpdate:modelValue":D[4]||(D[4]=C=>p(s)("autoContrast",C))},null,8,["model-value"])):ie("",!0),p(v)?(w(),R("div",bde,[D[6]||(D[6]=M("span",{class:"form-label mb-0"},"Light contrast",-1)),H(p(o8),{level:p(v).level,ratio:p(v).ratio},null,8,["level","ratio"])])):ie("",!0),p(y)?(w(),R("div",yde,[D[7]||(D[7]=M("span",{class:"form-label mb-0"},"Dark contrast",-1)),H(p(o8),{level:p(y).level,ratio:p(y).ratio},null,8,["level","ratio"])])):ie("",!0),p(x)?(w(),R("div",xde,[D[9]||(D[9]=M("span",{class:"form-label mb-0"},"Colorblind",-1)),p(x).safe?(w(),R("span",{key:0,ref_key:"cvdSafeBadgeRef",ref:_,class:"editor-color-section__cvd-badge editor-color-section__cvd-badge--safe"},[H(p(My)),D[8]||(D[8]=Ye(" Safe ",-1)),H(p($1),{class:"editor-color-section__cvd-badge__info"}),H(p(Ud),{"teleport-to":"body",target:p(_),title:"All colors remain distinguishable under protanopia, deuteranopia, and tritanopia simulations.",placement:"top"},null,8,["target"])],512)):(w(!0),R(He,{key:1},ht(p(x).issues,C=>(w(),R("span",{key:C.type,ref_for:!0,ref_key:"cvdBadgeRefs",ref:k,class:"editor-color-section__cvd-badge editor-color-section__cvd-badge--warn"},[H(p(WT)),Ye(" "+ye(C.shortLabel)+" ",1),H(p($1),{class:"editor-color-section__cvd-badge__info"}),H(p(Ud),{"teleport-to":"body",target:()=>E(C.type),title:C.tooltip,placement:"top"},null,8,["target","title"])]))),128))])):ie("",!0),H(p(Cn),{modelValue:p(a),"onUpdate:modelValue":D[5]||(D[5]=C=>Ze(a)?a.value=C:null),label:"Colorblind simulation",options:B,block:""},null,8,["modelValue"])])}}}),_de=Be(wde,[["__scopeId","data-v-bbe9fd0a"]]),kde=le({__name:"EditorThemeSection",setup(t){const{chartTheme:e,availableThemes:n}=rT();return(o,r)=>(w(),J(p(En),{modelValue:p(e),"onUpdate:modelValue":r[0]||(r[0]=i=>Ze(e)?e.value=i:null),label:"Chart Theme",options:p(n),block:""},null,8,["modelValue","options"]))}}),Sde={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ade(t,e){return w(),R("svg",Sde,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M238.64 33.36a32 32 0 0 0-45.26 0a32 32 0 0 0 0 45.26c.29.29.6.57.9.85l-26.63 49.46a32.2 32.2 0 0 0-23.9 3.5l-20.18-20.18a32 32 0 0 0-50.2-38.89a32 32 0 0 0 0 45.26c.29.29.59.57.89.85l-26.63 49.47a32 32 0 0 0-30.27 8.44a32 32 0 1 0 45.26 0c-.29-.29-.6-.57-.9-.85l26.63-49.46A32.4 32.4 0 0 0 96 128a32 32 0 0 0 16.25-4.41l20.18 20.18a32 32 0 1 0 50.2-6.38c-.29-.29-.59-.57-.89-.85l26.63-49.46A32.3 32.3 0 0 0 216 88a32 32 0 0 0 22.63-54.62ZM51.3 211.33a16 16 0 0 1-22.63-22.64a16 16 0 1 1 22.63 22.64m33.38-104a16 16 0 0 1 0-22.63a16 16 0 1 1 0 22.63m86.64 64a16 16 0 0 1-22.63-22.63a16 16 0 0 1 22.63 22.63m56-104a16 16 0 1 1-22.62-22.66a16 16 0 0 1 22.63 22.64Z"},null,-1)])])}const Cde=Oe({name:"ph-line-segments",render:Ade}),$de={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Tde(t,e){return w(),R("svg",$de,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 32a8 8 0 0 0-8-8c-44.08 0-89.31 49.71-114.43 82.63A60 60 0 0 0 32 164c0 30.88-19.54 44.73-20.47 45.37A8 8 0 0 0 16 224h76a60 60 0 0 0 57.37-77.57C182.3 121.31 232 76.08 232 32M92 208H34.63C41.38 198.41 48 183.92 48 164a44 44 0 1 1 44 44m32.42-94.45q5.14-6.66 10.09-12.55A76.2 76.2 0 0 1 155 121.49q-5.9 4.94-12.55 10.09a60.5 60.5 0 0 0-18.03-18.03m42.7-2.68a92.6 92.6 0 0 0-22-22c31.78-34.53 55.75-45 69.9-47.91c-2.85 14.16-13.37 38.13-47.9 69.91"},null,-1)])])}const Mde=Oe({name:"ph-paint-brush",render:Tde}),Ode={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Bde(t,e){return w(),R("svg",Ode,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 208a8 8 0 0 1-8 8H32a8 8 0 0 1-8-8V48a8 8 0 0 1 16 0v94.37L90.73 98a8 8 0 0 1 10.07-.38l58.81 44.11L218.73 90a8 8 0 1 1 10.54 12l-64 56a8 8 0 0 1-10.07.38l-58.81-44.09L40 163.63V200h184a8 8 0 0 1 8 8"},null,-1)])])}const Lde=Oe({name:"ph-chart-line",render:Bde}),Pde={class:"d-flex flex-column gap-4"},Dde=le({__name:"EditorAppearanceTab",setup(t){const{chartType:e}=dn(),{availableOptionKeys:n}=_n(),o=A(()=>e.value.includes("horizontal")||e.value===Le.BarStacked||e.value===Le.BarSplit||e.value===Le.BarGrouped?od:Ls),r=A(()=>n.value.includes("stacked")),i=A(()=>n.value.includes("interpolation")||n.value.includes("lineSymbols")),s=A(()=>!r.value&&i.value),a=A(()=>n.value.includes("barBackground")||n.value.includes("barSeparators")||n.value.includes("barGap")||n.value.includes("connectedColumns")||n.value.includes("categoryLabelLine")),l=A(()=>n.value.includes("displayAsPercentage"));return(c,u)=>{const d=kde,f=_de,h=ide,g=tde,b=Jue,m=Zue;return w(),R("div",Pde,[H(p(Fo),{title:"Theme",icon:p(Mde)},{default:te(()=>[H(d)]),_:1},8,["icon"]),H(p(Fo),{title:"Colors",icon:p(NT)},{default:te(()=>[H(f)]),_:1},8,["icon"]),p(s)?(w(),J(p(Fo),{key:0,title:"Line Style",icon:p(Cde)},{default:te(()=>[H(h)]),_:1},8,["icon"])):ie("",!0),p(a)?(w(),J(p(Fo),{key:1,title:"Bar Style",icon:p(o)},{default:te(()=>[H(g)]),_:1},8,["icon"])):ie("",!0),p(l)?(w(),J(p(Fo),{key:2,title:"Slices",icon:p(IA)},{default:te(()=>[H(b)]),_:1},8,["icon"])):ie("",!0),p(r)?(w(),J(p(Fo),{key:3,title:"Areas",icon:p(Lde)},{default:te(()=>[H(m)]),_:1},8,["icon"])):ie("",!0)])}}}),Ede={class:"d-flex flex-column gap-3"},Nde=le({__name:"EditorPropertyForm",setup(t){const{title:e,description:n,byline:o,note:r,source:i,sourceUrl:s}=dn();return(a,l)=>{const c=ea,u=Mn,d=_y;return w(),R("div",Ede,[H(u,{label:"Title","label-for":"prop-title"},{default:te(()=>[H(c,{id:"prop-title",modelValue:p(e),"onUpdate:modelValue":l[0]||(l[0]=f=>Ze(e)?e.value=f:null),placeholder:"Chart title"},null,8,["modelValue"])]),_:1}),H(u,{label:"Description","label-for":"prop-description"},{default:te(()=>[H(d,{id:"prop-description",modelValue:p(n),"onUpdate:modelValue":l[1]||(l[1]=f=>Ze(n)?n.value=f:null),placeholder:"Short description",rows:"2","max-rows":"5"},null,8,["modelValue"])]),_:1}),H(u,{label:"Byline","label-for":"prop-byline"},{default:te(()=>[H(c,{id:"prop-byline",modelValue:p(o),"onUpdate:modelValue":l[2]||(l[2]=f=>Ze(o)?o.value=f:null),placeholder:"Author or byline"},null,8,["modelValue"])]),_:1}),H(u,{label:"Note","label-for":"prop-note"},{default:te(()=>[H(d,{id:"prop-note",modelValue:p(r),"onUpdate:modelValue":l[3]||(l[3]=f=>Ze(r)?r.value=f:null),placeholder:"Additional note or caveat",rows:"2","max-rows":"4"},null,8,["modelValue"])]),_:1}),H(u,{label:"Source","label-for":"prop-source"},{default:te(()=>[H(c,{id:"prop-source",modelValue:p(i),"onUpdate:modelValue":l[4]||(l[4]=f=>Ze(i)?i.value=f:null),placeholder:"Data source"},null,8,["modelValue"])]),_:1}),H(u,{label:"Source URL","label-for":"prop-source-url"},{default:te(()=>[H(c,{id:"prop-source-url",modelValue:p(s),"onUpdate:modelValue":l[5]||(l[5]=f=>Ze(s)?s.value=f:null),type:"url",placeholder:"https://..."},null,8,["modelValue"])]),_:1})])}}}),qT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.466666666666666" y="20.666666666666668" width="11.733333333333334" height="13.333333333333332" fill="#2563A0" rx="0.5"/><rect x="18.13333333333333" y="4" width="11.733333333333334" height="30" fill="#2563A0" rx="0.5"/><rect x="32.8" y="14" width="11.733333333333334" height="20" fill="#2563A0" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},YT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2.8" width="26.727272727272727" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="10.8" width="42" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="18.8" width="17.181818181818183" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="26.8" width="34.36363636363637" height="6.4" fill="#2563A0" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},jT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.65" y="17.64" width="5.61" height="16.36" fill="#2563A0" rx="0.5"/><rect x="9.88" y="23.09" width="5.61" height="10.91" fill="#D4A63A" rx="0.5"/><rect x="16.12" y="13.55" width="5.61" height="20.45" fill="#C94044" rx="0.5"/><rect x="25.65" y="9.45" width="5.61" height="24.55" fill="#2563A0" rx="0.5"/><rect x="31.88" y="4.00" width="5.61" height="30.00" fill="#D4A63A" rx="0.5"/><rect x="38.12" y="20.36" width="5.61" height="13.64" fill="#C94044" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},XT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><polyline points="2.00,32.00 10.80,21.50 19.60,26.75 28.40,11.00 37.20,16.25 46.00,4.00" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},KT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><polyline points="2.00,32.00 13.00,20.00 24.00,26.00 35.00,8.00 46.00,14.00" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="2.00,12.00 13.00,18.00 24.00,4.00 35.00,22.00 46.00,8.00" fill="none" stroke="#D4A63A" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="2.00,24.00 13.00,16.00 24.00,20.00 35.00,10.00 46.00,4.00" fill="none" stroke="#C94044" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},Ide={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><path d="M 2.00,22.67 L 13.00,10.22 L 24.00,16.44 L 35.00,4.00 L 46.00,13.33 L 46.00,34 L 2.00,34 Z" fill="#2563A0" opacity="0.3"/><polyline points="2.00,22.67 13.00,10.22 24.00,16.44 35.00,4.00 46.00,13.33" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},Rde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><path d="M 2.00,16.92 L 13.00,8.31 L 24.00,12.62 L 35.00,4.00 L 46.00,12.62 L 46.00,23.38 L 35.00,16.92 L 24.00,21.23 L 13.00,19.08 L 2.00,23.38 Z" fill="#D4A63A" opacity="0.7"/><path d="M 2.00,23.38 L 13.00,19.08 L 24.00,21.23 L 35.00,16.92 L 46.00,23.38 L 46.00,34 L 35.00,34 L 24.00,34 L 13.00,34 L 2.00,34 Z" fill="#2563A0" opacity="0.7"/></svg>',style:"width:100%;height:100%"})}},Fde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.10" y="24.77" width="8.80" height="9.23" fill="#2563A0" rx="0.5"/><rect x="3.10" y="17.85" width="8.80" height="6.92" fill="#D4A63A" rx="0.5"/><rect x="14.10" y="20.15" width="8.80" height="13.85" fill="#2563A0" rx="0.5"/><rect x="14.10" y="8.62" width="8.80" height="11.54" fill="#D4A63A" rx="0.5"/><rect x="25.10" y="22.46" width="8.80" height="11.54" fill="#2563A0" rx="0.5"/><rect x="25.10" y="13.23" width="8.80" height="9.23" fill="#D4A63A" rx="0.5"/><rect x="36.10" y="17.85" width="8.80" height="16.15" fill="#2563A0" rx="0.5"/><rect x="36.10" y="4.00" width="8.80" height="13.85" fill="#D4A63A" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},Vde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2.00" y="2.80" width="12.92" height="6.40" fill="#2563A0" rx="0.5"/><rect x="14.92" y="2.80" width="9.69" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="10.80" width="19.38" height="6.40" fill="#2563A0" rx="0.5"/><rect x="21.38" y="10.80" width="16.15" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="18.80" width="16.15" height="6.40" fill="#2563A0" rx="0.5"/><rect x="18.15" y="18.80" width="12.92" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="26.80" width="22.62" height="6.40" fill="#2563A0" rx="0.5"/><rect x="24.62" y="26.80" width="19.38" height="6.40" fill="#D4A63A" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},zde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2.00" y="2.80" width="12.08" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="10.80" width="9.17" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="18.80" width="5.83" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="26.80" width="4.17" height="6.40" fill="#6878E8" rx="0.5"/><rect x="17.33" y="2.80" width="13.33" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="10.80" width="10.42" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="18.80" width="6.67" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="26.80" width="5.00" height="6.40" fill="#E07B38" rx="0.5"/><rect x="32.67" y="2.80" width="11.25" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="10.80" width="8.33" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="18.80" width="5.00" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="26.80" width="3.33" height="6.40" fill="#B83B5E" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},Hde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2.60" width="38.06" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="4.87" width="28.88" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="7.13" width="18.38" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="10.60" width="42.00" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="12.87" width="32.81" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="15.13" width="21.00" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="18.60" width="35.44" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="20.87" width="26.25" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="23.13" width="15.75" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="26.60" width="15.75" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="28.87" width="10.50" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="31.13" width="6.56" height="2.04" fill="#B83B5E" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},ZT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M 20.000 2.000 A 18 18 0 0 1 34.562 30.580 L 28.737 26.348 A 10.799999999999999 10.799999999999999 0 0 0 20.000 9.200 Z" fill="#2563A0"/><path d="M 34.562 30.580 A 18 18 0 0 1 9.420 34.562 L 13.652 28.737 A 10.799999999999999 10.799999999999999 0 0 0 28.737 26.348 Z" fill="#D4A63A"/><path d="M 9.420 34.562 A 18 18 0 0 1 3.713 12.336 L 10.228 15.402 A 10.799999999999999 10.799999999999999 0 0 0 13.652 28.737 Z" fill="#C94044"/><path d="M 3.713 12.336 A 18 18 0 0 1 20.000 2.000 L 20.000 9.200 A 10.799999999999999 10.799999999999999 0 0 0 10.228 15.402 Z" fill="#2D8659"/></svg>',style:"width:100%;height:100%"})}},QT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M 20 20 L 20.000 2.000 A 18 18 0 0 1 34.562 30.580 Z" fill="#2563A0"/><path d="M 20 20 L 34.562 30.580 A 18 18 0 0 1 9.420 34.562 Z" fill="#D4A63A"/><path d="M 20 20 L 9.420 34.562 A 18 18 0 0 1 3.713 12.336 Z" fill="#C94044"/><path d="M 20 20 L 3.713 12.336 A 18 18 0 0 1 20.000 2.000 Z" fill="#2D8659"/></svg>',style:"width:100%;height:100%"})}},Wde=le({__name:"EditorChartTypePicker",setup(t){const{chartType:e,selectedColumn:n}=dn(),{currentOptions:o,availableOptionKeys:r,setOption:i}=_n(),s=jo(),a=A(()=>r.value.includes("stackMode")),l=[{value:"normal",text:"Normal"},{value:"percent",text:"Percentage (100%)"}],c=[{value:Le.BarVertical,label:"Columns",description:"Compare values across categories",visual:Oe(qT)},{value:Le.BarHorizontal,label:"Bars",description:"Compare values with long labels",visual:Oe(YT)},{value:Le.BarMulti,label:"Grouped Columns",description:"Compare multiple series side by side",visual:Oe(jT)},{value:Le.ColumnStacked,label:"Stacked Columns",description:"Compare stacked totals",visual:Oe(Fde)},{value:Le.BarStacked,label:"Stacked Bars",description:"Compare stacked totals horizontally",visual:Oe(Vde)},{value:Le.BarSplit,label:"Split Bars",description:"Compare multiple metrics in separate bar panels",visual:Oe(zde)},{value:Le.BarGrouped,label:"Grouped Bars",description:"Compare multiple series side by side horizontally",visual:Oe(Hde)},{value:Le.Line,label:"Line",description:"Show trends over time",visual:Oe(XT)},{value:Le.LineMulti,label:"Lines",description:"Compare trends across series",visual:Oe(KT)},{value:Le.Area,label:"Area",description:"Show magnitude over time",visual:Oe(Ide)},{value:Le.AreaStacked,label:"Areas",description:"Compare and stack multiple area series",visual:Oe(Rde)},{value:Le.Donut,label:"Donut",description:"Show proportions with a center space",visual:Oe(ZT)},{value:Le.Pie,label:"Pie",description:"Show parts of a whole",visual:Oe(QT)}],u=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.Area,Le.VerticalBar,Le.HorizontalBar],d=A(()=>u.includes(e.value)&&s.columns.value.length>2),f=A(()=>s.columns.value.slice(1).map(h=>({value:h,text:h})));return Ge([e,()=>s.columns.value],()=>{d.value&&!n.value&&s.columns.value.length>2&&(n.value=s.columns.value[1])},{immediate:!0}),(h,g)=>{const b=Mn,m=Ga;return w(),R(He,null,[H(b,{label:"Chart type","label-for":"chart-type-select"},{default:te(()=>[H(p(En),{id:"chart-type-select",modelValue:p(e),"onUpdate:modelValue":g[0]||(g[0]=v=>Ze(e)?e.value=v:null),block:"",options:c},null,8,["modelValue"])]),_:1}),p(d)?(w(),J(b,{key:0,label:"Data column","label-for":"column-select",class:"mt-3"},{default:te(()=>[H(m,{id:"column-select",modelValue:p(n),"onUpdate:modelValue":g[1]||(g[1]=v=>Ze(n)?n.value=v:null),options:p(f)},null,8,["modelValue","options"])]),_:1})):ie("",!0),p(a)?(w(),J(b,{key:1,label:"Stack mode","label-for":"opt-stack-mode",class:"mt-3"},{default:te(()=>[H(m,{id:"opt-stack-mode","model-value":p(o).stackMode??"normal",options:l,"onUpdate:modelValue":g[2]||(g[2]=v=>p(i)("stackMode",v))},null,8,["model-value"])]),_:1})):ie("",!0)],64)}}}),Ude=100,Gde=Oo("chartHistory",()=>{const t=new Map,e=Ie(!1),n=Ie(!1);let o="",r=!1,i=!1;function s(d){let f=t.get(d);return f||(f={undoStack:[],redoStack:[],currentState:""},t.set(d,f)),f}function a(d,f){const h={config:{chartType:d.chartType,title:d.title,description:d.description,byline:d.byline,note:d.note,source:d.source,sourceUrl:d.sourceUrl,sort:d.sort,data:d.data,selectedColumn:d.selectedColumn,colorizes:JSON.parse(JSON.stringify(d.colorizes)),highlights:JSON.parse(JSON.stringify(d.highlights)),areaFills:JSON.parse(JSON.stringify(d.areaFills)),annotations:JSON.parse(JSON.stringify(d.annotations)),seriesOverrides:JSON.parse(JSON.stringify(d.seriesOverrides??[])),layout:JSON.parse(JSON.stringify(d.layout??rf))},typeOptions:JSON.parse(JSON.stringify(f))};return JSON.stringify(h)}function l(){const d=t.get(o);e.value=d?d.undoStack.length>0:!1,n.value=d?d.redoStack.length>0:!1}function c(d){const f=s(o);d!==f.currentState&&(f.undoStack.push(f.currentState),f.undoStack.length>Ude&&f.undoStack.shift(),f.redoStack.length=0,f.currentState=d,l())}function u(){const d=dn(),{store:f,hydrate:h}=_n(),{sessionId:g}=js();function b(){return a({chartType:d.chartType.value,title:d.title.value,description:d.description.value,byline:d.byline.value,note:d.note.value,source:d.source.value,sourceUrl:d.sourceUrl.value,sort:d.sort.value,data:d.data.value,selectedColumn:d.selectedColumn.value,colorizes:d.colorizes.value,highlights:d.highlights.value,areaFills:d.areaFills.value,annotations:d.annotations.value,seriesOverrides:d.seriesOverrides.value,layout:d.layout.value},f)}i||(i=!0,U0(!0).run(()=>{Ge(g,_=>{if(r=!0,o=_,_){const k=s(_);k.currentState||(k.currentState=b())}l(),xn(()=>{r=!1})},{immediate:!0,flush:"sync"}),Ge([d.chartType,d.title,d.description,d.byline,d.note,d.source,d.sourceUrl,d.sort,d.data,d.selectedColumn,d.colorizes,d.highlights,d.areaFills,d.annotations,d.layout,()=>JSON.stringify(f)],()=>{r||!o||c(b())},{deep:!0})}));function m(x){r=!0;const _=JSON.parse(x);d.hydrate(_.config),h(_.typeOptions),xn(()=>{r=!1})}function v(){const x=t.get(o);!x||x.undoStack.length===0||(x.redoStack.push(x.currentState),x.currentState=x.undoStack.pop(),l(),m(x.currentState))}function y(){const x=t.get(o);!x||x.redoStack.length===0||(x.undoStack.push(x.currentState),x.currentState=x.redoStack.pop(),l(),m(x.currentState))}return{undo:v,redo:y}}return{canUndo:A(()=>e.value),canRedo:A(()=>n.value),init:u}});function qde(){const t=Gde(),{canUndo:e,canRedo:n}=Ct(t),{undo:o,redo:r}=t.init();return{canUndo:e,canRedo:n,undo:o,redo:r}}const Yde={class:"chart-edit-toolbar"},jde=le({__name:"ChartEditToolbar",setup(t){const e=cr(),{viewMode:n}=Ct(e),{setViewMode:o}=e,{canUndo:r,canRedo:i,undo:s,redo:a}=qde(),l=A({get:()=>n.value,set:u=>o(u)}),c=[{value:"preview",text:"Preview"},{value:"dsl",text:"DSL"}];return(u,d)=>(w(),R("div",Yde,[H(p(CW),{disabled:!p(r),onClick:p(s)},null,8,["disabled","onClick"]),H(p(_W),{disabled:!p(i),onClick:p(a)},null,8,["disabled","onClick"]),H(p(tU),{modelValue:p(l),"onUpdate:modelValue":d[0]||(d[0]=f=>Ze(l)?l.value=f:null),options:c,size:"sm"},null,8,["modelValue"])]))}}),Xde=Be(jde,[["__scopeId","data-v-de044834"]]);let sb=[],JT=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?JT:sb).push(n=n+t[e])})();function Kde(t){if(t<768)return!1;for(let e=0,n=sb.length;;){let o=e+n>>1;if(t<sb[o])n=o;else if(t>=JT[o])e=o+1;else return!0;if(e==n)return!1}}function Q6(t){return t>=127462&&t<=127487}const J6=8205;function Zde(t,e,n=!0,o=!0){return(n?eM:Qde)(t,e,o)}function eM(t,e,n){if(e==t.length)return e;e&&tM(t.charCodeAt(e))&&nM(t.charCodeAt(e-1))&&e--;let o=Mv(t,e);for(e+=ek(o);e<t.length;){let r=Mv(t,e);if(o==J6||r==J6||n&&Kde(r))e+=ek(r),o=r;else if(Q6(r)){let i=0,s=e-2;for(;s>=0&&Q6(Mv(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function Qde(t,e,n){for(;e>0;){let o=eM(t,e-2,n);if(o<e)return o;e--}return 0}function Mv(t,e){let n=t.charCodeAt(e);if(!nM(n)||e+1==t.length)return n;let o=t.charCodeAt(e+1);return tM(o)?(n-55296<<10)+(o-56320)+65536:n}function tM(t){return t>=56320&&t<57344}function nM(t){return t>=55296&&t<56320}function ek(t){return t<65536?1:2}class Ut{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,o){[e,n]=lu(this,e,n);let r=[];return this.decompose(0,e,r,2),o.length&&o.decompose(0,o.length,r,3),this.decompose(n,this.length,r,1),Ui.from(r,this.length-(n-e)+o.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=lu(this,e,n);let o=[];return this.decompose(e,n,o,0),Ui.from(o,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),o=this.length-this.scanIdentical(e,-1),r=new Md(this),i=new Md(e);for(let s=n,a=n;;){if(r.next(s),i.next(s),s=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=o)return!0}}iter(e=1){return new Md(this,e)}iterRange(e,n=this.length){return new oM(this,e,n)}iterLines(e,n){let o;if(e==null)o=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;o=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new rM(o)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Ut.empty:e.length<=32?new An(e):Ui.from(An.split(e,[]))}}class An extends Ut{constructor(e,n=Jde(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,o,r){for(let i=0;;i++){let s=this.text[i],a=r+s.length;if((n?o:a)>=e)return new efe(r,a,o,s);r=a+1,o++}}decompose(e,n,o,r){let i=e<=0&&n>=this.length?this:new An(tk(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let s=o.pop(),a=ip(i.text,s.text.slice(),0,i.length);if(a.length<=32)o.push(new An(a,s.length+i.length));else{let l=a.length>>1;o.push(new An(a.slice(0,l)),new An(a.slice(l)))}}else o.push(i)}replace(e,n,o){if(!(o instanceof An))return super.replace(e,n,o);[e,n]=lu(this,e,n);let r=ip(this.text,ip(o.text,tk(this.text,0,e)),n),i=this.length+o.length-(n-e);return r.length<=32?new An(r,i):Ui.from(An.split(r,[]),i)}sliceString(e,n=this.length,o=`
|
|
849
|
+
`),E=new Blob([k],{type:"image/svg+xml;charset=utf-8"});If(E,e)}const Gse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function qse(t,e){return w(),R("svg",Gse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 40H40a16 16 0 0 0-16 16v144a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16m0 16v102.75l-26.07-26.06a16 16 0 0 0-22.63 0l-20 20l-44-44a16 16 0 0 0-22.62 0L40 149.37V56ZM40 172l52-52l80 80H40Zm176 28h-21.37l-36-36l20-20L216 181.38zm-72-100a12 12 0 1 1 12 12a12 12 0 0 1-12-12"},null,-1)])])}const Yse=Oe({name:"ph-image",render:qse}),jse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Xse(t,e){return w(),R("svg",jse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M181.66 146.34a8 8 0 0 1 0 11.32l-24 24a8 8 0 0 1-11.32-11.32L164.69 152l-18.35-18.34a8 8 0 0 1 11.32-11.32Zm-72-24a8 8 0 0 0-11.32 0l-24 24a8 8 0 0 0 0 11.32l24 24a8 8 0 0 0 11.32-11.32L91.31 152l18.35-18.34a8 8 0 0 0 0-11.32M216 88v128a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16V40a16 16 0 0 1 16-16h96a8 8 0 0 1 5.66 2.34l56 56A8 8 0 0 1 216 88m-56-8h28.69L160 51.31Zm40 136V96h-48a8 8 0 0 1-8-8V40H56v176z"},null,-1)])])}const Kse=Oe({name:"ph-file-code",render:Xse}),Zse={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Qse(t,e){return w(),R("svg",Zse,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m213.66 82.34l-56-56A8 8 0 0 0 152 24H56a16 16 0 0 0-16 16v176a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16V88a8 8 0 0 0-2.34-5.66M160 51.31L188.69 80H160ZM200 216H56V40h88v48a8 8 0 0 0 8 8h48zm-32-80a8 8 0 0 1-8 8H96a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8m0 32a8 8 0 0 1-8 8H96a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8"},null,-1)])])}const BT=Oe({name:"ph-file-text",render:Qse}),Jse={class:"export-download-panel"},eae=le({__name:"ExportDownloadPanel",emits:["download-png","download-svg"],setup(t,{emit:e}){const n=dg(),{selectedFormat:o,pngScale:r,svgInlineFonts:i,svgMinify:s,bpcCompact:a}=Ct(n),{setSelectedFormat:l}=n,{dsl:c}=Nf(),u=e;function d(){u("download-png",r.value)}function f(){u("download-svg")}function h(){If(new globalThis.Blob([c.value],{type:"text/plain"}),"chart.bpc")}return(g,b)=>{const m=Fse,v=Rs;return w(),R("div",Jse,[H(m,{selected:p(o)==="png",icon:p(Yse),label:"PNG",description:"Raster image, best for presentations","icon-bg":"var(--bs-info-bg-subtle)","icon-color":"var(--bs-info-text-emphasis)",onSelect:b[1]||(b[1]=y=>p(l)("png")),onDownload:d},{default:te(()=>[H(p(xr),{id:"png-scale","model-value":p(r),label:"Scale",min:1,max:4,step:1,"onUpdate:modelValue":b[0]||(b[0]=y=>r.value=y)},null,8,["model-value"])]),_:1},8,["selected","icon"]),H(m,{selected:p(o)==="svg",icon:p(Kse),label:"SVG",description:"Vector image, best for print and web","icon-bg":"var(--bs-success-bg-subtle)","icon-color":"var(--bs-success-text-emphasis)",onSelect:b[4]||(b[4]=y=>p(l)("svg")),onDownload:f},{default:te(()=>[H(v,{modelValue:p(i),"onUpdate:modelValue":b[2]||(b[2]=y=>Ze(i)?i.value=y:null),switch:""},{default:te(()=>[...b[7]||(b[7]=[Ye(" Inline fonts ",-1)])]),_:1},8,["modelValue"]),H(v,{modelValue:p(s),"onUpdate:modelValue":b[3]||(b[3]=y=>Ze(s)?s.value=y:null),switch:""},{default:te(()=>[...b[8]||(b[8]=[Ye(" Minify ",-1)])]),_:1},8,["modelValue"])]),_:1},8,["selected","icon"]),H(m,{selected:p(o)==="bpc",icon:p(BT),label:"BPC",description:"Blueprint Chart DSL file","icon-bg":"var(--bs-warning-bg-subtle)","icon-color":"var(--bs-warning-text-emphasis)",onSelect:b[6]||(b[6]=y=>p(l)("bpc")),onDownload:h},{default:te(()=>[H(v,{modelValue:p(a),"onUpdate:modelValue":b[5]||(b[5]=y=>Ze(a)?a.value=y:null),switch:""},{default:te(()=>[...b[9]||(b[9]=[Ye(" Compact ",-1)])]),_:1},8,["modelValue"])]),_:1},8,["selected","icon"])])}}}),tae=Be(eae,[["__scopeId","data-v-f6670dcb"]]),nae={class:"export-embed-panel"},oae={class:"export-embed-panel__code-block"},rae={class:"export-embed-panel__code-block__header"},iae={class:"export-embed-panel__code-block__pre"},sae=["href"],aae=le({__name:"ExportEmbedPanel",setup(t){const{dsl:e,generateDsl:n}=Nf(),{layout:o}=dn();function r(a){const l=new TextEncoder().encode(a);let c="";for(const u of l)c+=String.fromCharCode(u);return globalThis.btoa(c)}const i=A(()=>{const a=r(e.value||n());return`${window.location.origin}${window.location.pathname}#/render?bpc64=${encodeURIComponent(a)}`}),s=A(()=>{const a=Pt(o.value),l=a.heightMode==="fixed"?a.fixedHeight:400,c=[];return a.sizing==="responsive"?c.push(`width="100%" height="${l}"`):a.sizing==="max-width"?c.push(`style="width:100%;max-width:${a.maxWidth}px" height="${l}"`):c.push(`width="${a.fixedWidth}" height="${l}"`),`<iframe src="${i.value}" ${c.join(" ")} frameborder="0"></iframe>`});return(a,l)=>(w(),R("div",nae,[M("div",oae,[M("div",rae,[l[0]||(l[0]=M("span",{class:"export-embed-panel__code-block__label"},"Embed code",-1)),H(p(O_),{text:p(s),label:"Copy",variant:"outline-secondary",size:"sm"},null,8,["text"])]),M("pre",iae,[M("code",null,ye(p(s)),1)])]),l[1]||(l[1]=M("div",{class:"export-embed-panel__info"}," Paste this iframe into your HTML page. The chart renders automatically. ",-1)),H(p(O_),{text:p(s),label:"Copy embed code",variant:"primary",size:"sm"},null,8,["text"]),M("a",{href:p(i),target:"_blank",rel:"noopener",class:"export-embed-panel__link"}," Preview in new tab ",8,sae)]))}}),lae=Be(aae,[["__scopeId","data-v-030ab97a"]]),cae=["onClick"],uae=le({__name:"PanelTabBar",props:it({tabs:{},sticky:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=dt(t,"modelValue"),n=ft("tabsRef");let o=null;function r(){xn(()=>{o!=null&&o.scrollIntoView&&n.value&&o.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})})}return Ge(()=>o,r),(i,s)=>(w(),R("div",{ref_key:"tabsRef",ref:n,class:Me(["panel-tab-bar",{"panel-tab-bar--sticky":t.sticky}])},[(w(!0),R(He,null,ht(t.tabs,a=>(w(),R("button",{key:a.key,ref_for:!0,ref:l=>{a.key===e.value&&(Ze(o)?o.value=l:o=l)},class:Me(["panel-tab-bar__tab",{"panel-tab-bar__tab--active":e.value===a.key}]),onClick:l=>e.value=a.key},[a.icon?(w(),J(Gt(a.icon),{key:0,class:"panel-tab-bar__tab__icon","aria-hidden":"true"})):ie("",!0),Ye(" "+ye(a.label),1)],10,cae))),128))],2))}}),W2=Be(uae,[["__scopeId","data-v-1a1009cc"]]),dae=le({__name:"CanvasModePickerOptionSwatch",props:{mode:{}},setup(t){return(e,n)=>(w(),R("span",{class:Me(["canvas-mode-swatch",`canvas-mode-swatch--${t.mode}`])},null,2))}}),LT=Be(dae,[["__scopeId","data-v-81dabc6c"]]),fae=Oo("editorPanel",()=>{const t=Ie("type"),e=Ie("preview"),n=Ie("blueprint"),o=Ie(!0),r=Ie(null),i=Ie("upload"),s=Ie(""),a=Ie(!1),l=Ie(-1),c=Ie("type"),u=Ie("column");function d(S){t.value=S}function f(S){r.value=S,d("annotate")}function h(S){e.value=S}function g(S){n.value=S}function b(S){i.value=S,S==="structure"&&v("column")}function m(S){s.value=S}function v(S){s.value=S,a.value=!0}function y(){a.value=!1,s.value=""}function x(){a.value=!a.value}function _(S){if(l.value===S){l.value=-1;return}l.value=S,v("column")}function k(S){c.value=S}function E(S){u.value=S}function B(){t.value="type",e.value="preview",n.value="blueprint",o.value=!0,r.value=null,i.value="upload",s.value="",a.value=!1,l.value=-1,c.value="type",u.value="column"}return{activeTab:t,viewMode:e,canvasMode:n,showDimensions:o,pendingAnnotationIndex:r,dataView:i,dataPanelTab:s,dataPanelOpen:a,selectedColumnIndex:l,lastNarrowEditTab:c,lastNarrowDataTab:u,selectTab:d,selectAnnotation:f,setViewMode:h,setCanvasMode:g,setDataView:b,setDataPanelTab:m,openDataPanel:v,closeDataPanel:y,toggleDataPanel:x,selectColumn:_,setLastNarrowEditTab:k,setLastNarrowDataTab:E,reset:B}});function cr(){const t=fae(),{activeTab:e,viewMode:n,canvasMode:o,showDimensions:r,pendingAnnotationIndex:i,dataView:s,dataPanelTab:a,dataPanelOpen:l,selectedColumnIndex:c,lastNarrowEditTab:u,lastNarrowDataTab:d}=Ct(t);return{activeTab:e,viewMode:n,canvasMode:o,showDimensions:r,pendingAnnotationIndex:i,dataView:s,dataPanelTab:a,dataPanelOpen:l,selectedColumnIndex:c,lastNarrowEditTab:u,lastNarrowDataTab:d,selectTab:t.selectTab,selectAnnotation:t.selectAnnotation,setViewMode:t.setViewMode,setCanvasMode:t.setCanvasMode,setDataView:t.setDataView,setDataPanelTab:t.setDataPanelTab,openDataPanel:t.openDataPanel,closeDataPanel:t.closeDataPanel,toggleDataPanel:t.toggleDataPanel,selectColumn:t.selectColumn,setLastNarrowEditTab:t.setLastNarrowEditTab,setLastNarrowDataTab:t.setLastNarrowDataTab,reset:t.reset}}const hae={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function pae(t,e){return w(),R("svg",hae,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m235.32 73.37l-52.69-52.68a16 16 0 0 0-22.63 0L20.68 160a16 16 0 0 0 0 22.63l52.69 52.68a16 16 0 0 0 22.63 0L235.32 96a16 16 0 0 0 0-22.63M84.68 224L32 171.31l32-32l26.34 26.35a8 8 0 0 0 11.32-11.32L75.31 128L96 107.31l26.34 26.35a8 8 0 0 0 11.32-11.32L107.31 96L128 75.31l26.34 26.35a8 8 0 0 0 11.32-11.32L139.31 64l32-32L224 84.69Z"},null,-1)])])}const mae=Oe({name:"ph-ruler",render:pae}),gae=le({__name:"CanvasDimensionsToggle",setup(t){const{showDimensions:e}=Ct(cr());return(n,o)=>(w(),R("button",{class:Me(["canvas-dimensions-toggle",{"canvas-dimensions-toggle--active":p(e)}]),title:"Show dimensions",onClick:o[0]||(o[0]=r=>e.value=!p(e))},[H(p(mae))],2))}}),vae=Be(gae,[["__scopeId","data-v-0920c699"]]),bae=["title"],yae={class:"canvas-mode-picker-option__label"},xae=le({__name:"CanvasModePickerOption",props:{mode:{},label:{},active:{type:Boolean}},emits:["select"],setup(t){return(e,n)=>{const o=LT;return w(),R("button",{class:Me(["canvas-mode-picker-option",{"canvas-mode-picker-option--active":t.active}]),title:t.label,onClick:n[0]||(n[0]=r=>e.$emit("select"))},[H(o,{mode:t.mode},null,8,["mode"]),M("span",yae,ye(t.label),1)],10,bae)}}}),wae=Be(xae,[["__scopeId","data-v-b7a042b3"]]),_ae={class:"canvas-mode-picker__extra"},kae={key:1,class:"canvas-mode-picker__trigger",title:"Canvas mode"},Sae=le({__name:"CanvasModePicker",setup(t){const e=cr(),{canvasMode:n}=Ct(e),{setCanvasMode:o}=e,r=Ie(!1),i=[{value:"blueprint",label:"Blueprint"},{value:"auto",label:"Auto"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}];function s(a){o(a),r.value=!1}return(a,l)=>{const c=wae,u=vae,d=LT;return w(),R("div",{class:"canvas-mode-picker",onMouseenter:l[0]||(l[0]=f=>r.value=!0),onMouseleave:l[1]||(l[1]=f=>r.value=!1)},[p(r)?(w(),R(He,{key:0},[(w(),R(He,null,ht(i,f=>H(c,{key:f.value,mode:f.value,label:f.label,active:p(n)===f.value,onSelect:h=>s(f.value)},null,8,["mode","label","active","onSelect"])),64)),l[3]||(l[3]=M("div",{class:"canvas-mode-picker__divider"},null,-1)),M("div",_ae,[H(u),l[2]||(l[2]=M("span",{class:"canvas-mode-picker__extra__label"},"Dims",-1))])],64)):(w(),R("button",kae,[H(d,{mode:p(n)},null,8,["mode"])]))],32)}}}),PT=Be(Sae,[["__scopeId","data-v-beb08053"]]),Aae={transform:"translate(0.5, 0.5)"},Cae={class:"canvas-dimensions__line"},$ae=["x1","y1","x2","y2"],Tae=["x1","y1","x2","y2"],Mae=["x1","y1","x2","y2"],Oae=["x","y"],Bae={class:"canvas-dimensions__line"},Lae=["x1","y1","x2","y2"],Pae=["x1","y1","x2","y2"],Dae=["x1","y1","x2","y2"],Eae=["x","y"],Nae={class:"canvas-dimensions__line canvas-dimensions__line--padding"},Iae=["x1","y1","x2","y2"],Rae=["x1","y1","x2","y2"],Fae=["x1","y1","x2","y2"],Vae=["x","y"],zae=["x1","y1","x2","y2"],Hae=["x1","y1","x2","y2"],Wae=["x1","y1","x2","y2"],Uae=["x","y"],Gae={class:"canvas-dimensions__line canvas-dimensions__line--padding"},qae=["x1","y1","x2","y2"],Yae=["x1","y1","x2","y2"],jae=["x1","y1","x2","y2"],Xae=["x","y"],Kae=["x1","y1","x2","y2"],Zae=["x1","y1","x2","y2"],Qae=["x1","y1","x2","y2"],Jae=["x","y"],Y6=20,en=3,kh=4,j6=20,ele=le({__name:"CanvasDimensions",props:{cardRef:{},canvasRef:{},layout:{}},setup(t){const e=t,n=Ve(null);function o(){const v=e.cardRef;if(!v){n.value=null;return}n.value={left:v.offsetLeft,top:v.offsetTop,width:v.offsetWidth,height:v.offsetHeight}}is(()=>e.canvasRef,o),is(()=>e.cardRef,o);const r=A(()=>({position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"})),i=A(()=>{const v=n.value;return{x1:v.left,x2:v.left+v.width,y:v.top+v.height+Y6}}),s=A(()=>{const v=n.value;return{x:v.left-Y6,y1:v.top,y2:v.top+v.height}}),a=A(()=>{const v=i.value,y=e.layout.padding;return y>0&&!c.value?{x1:v.x1+y+kh,x2:v.x2-y-kh}:{x1:v.x1,x2:v.x2}}),l=A(()=>{const v=s.value,y=e.layout.padding;return y>0&&!u.value?{y1:v.y1+y+kh,y2:v.y2-y-kh}:{y1:v.y1,y2:v.y2}}),c=A(()=>e.layout.sizing!=="responsive"),u=A(()=>e.layout.heightMode!=="auto"),d=A(()=>e.layout.padding>0),f=A(()=>`${e.layout.padding}px`),h=A(()=>i.value.y+j6),g=A(()=>s.value.x-j6),b=A(()=>{const v=e.layout;return v.sizing==="fixed"?`${v.fixedWidth}px`:v.sizing==="max-width"?`max ${v.maxWidth}px`:"auto"}),m=A(()=>{const v=e.layout;return v.heightMode==="fixed"?`${v.fixedHeight}px`:v.heightMode==="aspect-ratio"?v.aspectRatio:"auto"});return(v,y)=>p(n)?(w(),R("svg",{key:0,class:"canvas-dimensions",style:Et(p(r))},[M("g",Aae,[M("g",Cae,[M("line",{x1:p(a).x1,y1:p(i).y,x2:p(a).x2,y2:p(i).y},null,8,$ae),M("line",{x1:p(a).x1,y1:p(i).y-en,x2:p(a).x1,y2:p(i).y+en},null,8,Tae),M("line",{x1:p(a).x2,y1:p(i).y-en,x2:p(a).x2,y2:p(i).y+en},null,8,Mae),M("text",{x:(p(i).x1+p(i).x2)/2,y:p(i).y+en+12,"text-anchor":"middle"},ye(p(b)),9,Oae)]),M("g",Bae,[M("line",{x1:p(s).x,y1:p(l).y1,x2:p(s).x,y2:p(l).y2},null,8,Lae),M("line",{x1:p(s).x-en,y1:p(l).y1,x2:p(s).x+en,y2:p(l).y1},null,8,Pae),M("line",{x1:p(s).x-en,y1:p(l).y2,x2:p(s).x+en,y2:p(l).y2},null,8,Dae),M("text",{x:p(s).x-5,y:(p(s).y1+p(s).y2)/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(m)),9,Eae)]),p(d)?(w(),R(He,{key:0},[M("g",Nae,[M("line",{x1:p(i).x1,y1:p(c)?p(h):p(i).y,x2:p(i).x1+t.layout.padding,y2:p(c)?p(h):p(i).y},null,8,Iae),M("line",{x1:p(i).x1,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x1,y2:(p(c)?p(h):p(i).y)+en},null,8,Rae),M("line",{x1:p(i).x1+t.layout.padding,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x1+t.layout.padding,y2:(p(c)?p(h):p(i).y)+en},null,8,Fae),M("text",{x:p(i).x1+t.layout.padding/2,y:(p(c)?p(h):p(i).y)+en+12,"text-anchor":"middle"},ye(p(f)),9,Vae),M("line",{x1:p(i).x2-t.layout.padding,y1:p(c)?p(h):p(i).y,x2:p(i).x2,y2:p(c)?p(h):p(i).y},null,8,zae),M("line",{x1:p(i).x2-t.layout.padding,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x2-t.layout.padding,y2:(p(c)?p(h):p(i).y)+en},null,8,Hae),M("line",{x1:p(i).x2,y1:(p(c)?p(h):p(i).y)-en,x2:p(i).x2,y2:(p(c)?p(h):p(i).y)+en},null,8,Wae),M("text",{x:p(i).x2-t.layout.padding/2,y:(p(c)?p(h):p(i).y)+en+12,"text-anchor":"middle"},ye(p(f)),9,Uae)]),M("g",Gae,[M("line",{x1:p(u)?p(g):p(s).x,y1:p(s).y1,x2:p(u)?p(g):p(s).x,y2:p(s).y1+t.layout.padding},null,8,qae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y1,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y1},null,8,Yae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y1+t.layout.padding,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y1+t.layout.padding},null,8,jae),M("text",{x:(p(u)?p(g):p(s).x)-en-4,y:p(s).y1+t.layout.padding/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(f)),9,Xae),M("line",{x1:p(u)?p(g):p(s).x,y1:p(s).y2-t.layout.padding,x2:p(u)?p(g):p(s).x,y2:p(s).y2},null,8,Kae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y2-t.layout.padding,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y2-t.layout.padding},null,8,Zae),M("line",{x1:(p(u)?p(g):p(s).x)-en,y1:p(s).y2,x2:(p(u)?p(g):p(s).x)+en,y2:p(s).y2},null,8,Qae),M("text",{x:(p(u)?p(g):p(s).x)-en-4,y:p(s).y2-t.layout.padding/2,"text-anchor":"end","dominant-baseline":"central"},ye(p(f)),9,Jae)])],64)):ie("",!0)])],4)):ie("",!0)}}),DT=Be(ele,[["__scopeId","data-v-394e6d5d"]]);function tle(t){const e=t.split(":");if(e.length!==2)return;const n=Number(e[0]),o=Number(e[1]);return n&&o?n/o:void 0}function U2(t,e){const n=A(()=>t.value.heightMode==="fixed"||t.value.heightMode==="aspect-ratio"),o=A(()=>({[`${e}--fixed`]:t.value.sizing==="fixed",[`${e}--max-width`]:t.value.sizing==="max-width",[`${e}--transparent`]:t.value.transparentBackground,[`${e}--constrained-height`]:n.value})),r=A(()=>{const i=t.value,s={};if(i.sizing==="fixed"?s.width=`${i.fixedWidth}px`:i.sizing==="max-width"&&(s.maxWidth=`${i.maxWidth}px`,s.width="100%"),i.heightMode==="fixed")s.height=`${i.fixedHeight}px`;else if(i.heightMode==="aspect-ratio"){const a=tle(i.aspectRatio);a&&(s.aspectRatio=String(a))}return s});return{cardClass:o,cardStyle:r,hasConstrainedHeight:n}}function nle(t,e){t.replaceChildren();const n=document.createElement("div");n.className="text-center text-muted p-5",n.textContent=e,t.appendChild(n)}const ole=150;function G2(t){const e=dn(),{currentOptions:n}=_n(),{scenes:o,activeIndex:r,activeScene:i}=wn(),{columns:s,rows:a,columnTypes:l}=jo(),{applyStepList:c}=Lr(),{theme:u}=Cf(),{chartTheme:d}=rT(),f=Symbol("unset");let h=f,g=!1;function b(){if(!(!t.value||g)){g=!0;try{m()}finally{g=!1}}}function m(){var oe;if(!t.value)return;const _=i.value,k=Ra(o.value,r.value),E=(k==null?void 0:k.chartType)??e.chartType.value;let B;if((k==null?void 0:k.data)!==void 0)B=k.data;else if((oe=k==null?void 0:k.transforms)!=null&&oe.length&&s.value.length>0){const de=c(k.transforms,s.value,a.value,l.value);B=cg(de.columns,de.rows)}else B=e.data.value;const S=fs(B),L=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];if(S.series&&S.series.length>0&&L.includes(E)){const de=S.series.find(we=>we.name===e.selectedColumn.value);de&&(S.values=de.values),delete S.series}if(S.labels.length===0){nle(t.value,"No data to preview");return}const D=n.value.allowDarkMode??!0,I=t.value.parentElement;I&&(!D&&u.value!=="light"?I.setAttribute("data-bs-theme","light"):I.removeAttribute("data-bs-theme"));const C=h!==f&&_!==h,T=k!=null&&k.chartTypeOptions?{...n.value,...k.chartTypeOptions}:n.value,P=(k==null?void 0:k.colorizes)??e.colorizes.value,$=k?k.highlights??[]:e._base.highlights.value,F=(k==null?void 0:k.areaFills)??e.areaFills.value,V=e._base.annotations.value,U=(k==null?void 0:k.annotations)??[],K=[...V,...U],se=k!=null&&k.hiddenAnnotationIds?K.filter(de=>!de.id||!k.hiddenAnnotationIds.has(de.id)):K,he=(k==null?void 0:k.seriesOverrides)??e.seriesOverrides.value,ce=k==null?void 0:k.properties,be={title:(ce==null?void 0:ce.title)??(e.title.value||void 0),description:(ce==null?void 0:ce.description)??(e.description.value||void 0),byline:e.byline.value||void 0,note:e.note.value||void 0,source:(ce==null?void 0:ce.source)??(e.source.value||void 0),sourceUrl:(ce==null?void 0:ce.sourceUrl)??(e.sourceUrl.value||void 0),padding:`${e.layout.value.padding}px`,transparentBackground:e.layout.value.transparentBackground||void 0};L2(t.value,{chartType:E,data:S,options:T,frame:be,colorizes:P,highlights:$,areaFills:F,annotations:se,seriesOverrides:he,sort:nT(k)??e.sort.value,sortMode:e.sortMode.value!=="none"?e.sortMode.value:void 0,theme:d.value},{transition:C,ignoreLayout:!0}),h=_}is(t,MI(b,ole));const y=A(()=>JSON.stringify(e.layout.value)),x=A(()=>JSON.stringify(n.value));return Ge([t,e.chartType,e.title,e.data,e.sort,e.sortMode,e.description,e.byline,e.note,e.source,e.sourceUrl,e.selectedColumn,e.colorizes,e.highlights,e.areaFills,e.annotations,e.seriesOverrides,y,x,o,i,u,d],b,{immediate:!0,flush:"post"}),{config:e}}function rle(t,e){function n(){var s;return((s=t.value)==null?void 0:s.querySelector("svg"))??null}function o(){var s;return((s=t.value)==null?void 0:s.querySelector(".bc-frame"))??null}function r(){const s=(e==null?void 0:e.value)??o();if(s){Use(s);return}const a=n();a&&Vse(a)}async function i(s=2){const a=o();if(a){const d=e!=null&&e.value?OT(e.value):void 0,f=e!=null&&e.value?Hse(e.value):void 0;await Wse(a,s,"chart.png",d,f);return}const l=n();if(!l)return;const{width:c,height:u}=l.getBoundingClientRect();await zse(l,c*s,u*s)}return{downloadSvg:r,downloadPng:i}}const ile=le({__name:"ExportPanel",setup(t){const e=cr(),{canvasMode:n,showDimensions:o}=Ct(e),{setViewMode:r}=e,{mode:i}=rc();r("preview");const s=dg(),{exportTab:a}=Ct(s),{setExportTab:l,setLastNarrowExportTab:c}=s,{isNarrow:u}=Ji();Ge(i,$=>{$==="drawer"&&a.value&&(c(a.value),l(""))},{immediate:!0});const{layout:d}=dn(),{cardClass:f,cardStyle:h}=U2(d,"export-panel__canvas__card"),g=ft("canvasRef"),b=ft("cardRef"),m=ft("previewRef");G2(m);const{downloadSvg:v,downloadPng:y}=rle(m,b),x=Ie(0),_=Ie(0);let k=0;function E(){globalThis.cancelAnimationFrame(k),k=globalThis.requestAnimationFrame(()=>{const $=b.value;if($){const F=$.offsetLeft,V=$.offsetTop;(F!==x.value||V!==_.value)&&(x.value=F,_.value=V)}})}is(g,E),is(b,E);const B=A(()=>({"--grid-offset-x":`${x.value}px`,"--grid-offset-y":`${_.value}px`})),{lastNarrowExportTab:S}=Ct(s),L=A({get:()=>!!a.value,set:$=>{l($?S.value:"")}});function D($){c($),l($)}const{sections:I}=TT(),C={embed:"Embed",download:"Download"},T=A(()=>C[a.value]??"Export"),P=A(()=>({[`export-panel__canvas--${n.value}`]:n.value!=="blueprint"}));return($,F)=>{const V=DT,U=PT,K=W2,se=lae,he=tae,ce=H2,be=ug,oe=Tse;return w(),R("div",{class:Me(["export-panel",{"export-panel--narrow":p(u)}])},[M("div",{ref_key:"canvasRef",ref:g,class:Me(["export-panel__canvas",p(P)]),style:Et(p(B))},[M("div",{ref_key:"cardRef",ref:b,class:Me(["export-panel__canvas__card",p(f)]),style:Et(p(h))},[M("div",{ref_key:"previewRef",ref:m,class:"export-panel__canvas__preview w-100 h-100"},null,512)],6),p(o)?(w(),J(V,{key:0,"card-ref":p(b),"canvas-ref":p(g),layout:p(d)},null,8,["card-ref","canvas-ref","layout"])):ie("",!0),H(U)],6),H(be,{"drawer-open":p(L),"onUpdate:drawerOpen":F[0]||(F[0]=de=>Ze(L)?L.value=de:null),title:p(T),"container-ref":p(g)},bi({default:te(()=>[p(a)==="embed"?(w(),J(se,{key:0})):p(a)==="download"?(w(),J(he,{key:1,onDownloadPng:p(y),onDownloadSvg:p(v)},null,8,["onDownloadPng","onDownloadSvg"])):ie("",!0)]),_:2},[p(i)==="drawer"?{name:"tabs",fn:te(()=>[H(K,{tabs:p(I),"model-value":p(a),sticky:"","onUpdate:modelValue":D},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(i)!=="drawer"?{name:"footer",fn:te(()=>[H(ce)]),key:"1"}:void 0]),1032,["drawer-open","title","container-ref"]),p(u)?ie("",!0):(w(),J(oe,{key:0}))],2)}}}),sle=Be(ile,[["__scopeId","data-v-6f293e9b"]]),ale={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function lle(t,e){return w(),R("svg",ale,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M87.24 52.59a8 8 0 0 0-14.48 0l-64 136a8 8 0 1 0 14.48 6.81L39.9 160h80.2l16.66 35.4a8 8 0 1 0 14.48-6.81ZM47.43 144L80 74.79L112.57 144ZM200 96c-12.76 0-22.73 3.47-29.63 10.32a8 8 0 0 0 11.26 11.36c3.8-3.77 10-5.68 18.37-5.68c13.23 0 24 9 24 20v3.22a42.76 42.76 0 0 0-24-7.22c-22.06 0-40 16.15-40 36s17.94 36 40 36a42.73 42.73 0 0 0 24-7.25a8 8 0 0 0 16-.75v-60c0-19.85-17.94-36-40-36m0 88c-13.23 0-24-9-24-20s10.77-20 24-20s24 9 24 20s-10.77 20-24 20"},null,-1)])])}const ET=Oe({name:"ph-text-aa",render:lle}),cle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function ule(t,e){return w(),R("svg",cle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M200.77 53.89A103.27 103.27 0 0 0 128 24h-1.07A104 104 0 0 0 24 128c0 43 26.58 79.06 69.36 94.17A32 32 0 0 0 136 192a16 16 0 0 1 16-16h46.21a31.81 31.81 0 0 0 31.2-24.88a104.4 104.4 0 0 0 2.59-24a103.28 103.28 0 0 0-31.23-73.23m13 93.71a15.89 15.89 0 0 1-15.56 12.4H152a32 32 0 0 0-32 32a16 16 0 0 1-21.31 15.07C62.49 194.3 40 164 40 128a88 88 0 0 1 87.09-88h.9a88.35 88.35 0 0 1 88 87.25a89 89 0 0 1-2.18 20.35ZM140 76a12 12 0 1 1-12-12a12 12 0 0 1 12 12m-44 24a12 12 0 1 1-12-12a12 12 0 0 1 12 12m0 56a12 12 0 1 1-12-12a12 12 0 0 1 12 12m88-56a12 12 0 1 1-12-12a12 12 0 0 1 12 12"},null,-1)])])}const NT=Oe({name:"ph-palette",render:ule}),dle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function fle(t,e){return w(),R("svg",dle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M220.27 158.54a8 8 0 0 0-7.7-.46a20 20 0 1 1 0-36.16a8 8 0 0 0 11.43-7.23V72a16 16 0 0 0-16-16h-36.22a35 35 0 0 0 .22-4a36.1 36.1 0 0 0-11.36-26.24a36 36 0 0 0-60.55 23.62a36.6 36.6 0 0 0 .14 6.62H64a16 16 0 0 0-16 16v32.22a35 35 0 0 0-4-.22a36.12 36.12 0 0 0-26.24 11.36a35.7 35.7 0 0 0-9.69 27a36.08 36.08 0 0 0 33.31 33.6a35.7 35.7 0 0 0 6.62-.14V208a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16v-42.69a8 8 0 0 0-3.73-6.77M208 208H64v-42.69a8 8 0 0 0-11.43-7.23a20 20 0 1 1 0-36.16A8 8 0 0 0 64 114.69V72h46.69a8 8 0 0 0 7.23-11.43a20 20 0 1 1 36.16 0A8 8 0 0 0 161.31 72H208v32.23a35.7 35.7 0 0 0-6.62-.14A36 36 0 0 0 204 176a35 35 0 0 0 4-.22Z"},null,-1)])])}const hle=Oe({name:"ph-puzzle-piece",render:fle}),ple={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function mle(t,e){return w(),R("svg",ple,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M222.16 177.25a8 8 0 0 1-1 11.25c-17.36 14.39-32.86 19.5-47 19.5c-18.58 0-34.82-8.82-49.93-17c-25.35-13.76-47.24-25.64-79.07.74a8 8 0 1 1-10.22-12.31c40.17-33.28 70.32-16.92 96.93-2.48c25.35 13.75 47.24 25.63 79.07-.74a8 8 0 0 1 11.22 1.04m-11.27-57c-31.83 26.38-53.72 14.5-79.07.74c-26.61-14.43-56.76-30.79-96.93 2.49a8 8 0 0 0 10.22 12.31c31.83-26.38 53.72-14.5 79.07-.74c15.11 8.19 31.35 17 49.93 17c14.14 0 29.64-5.11 47-19.5a8 8 0 1 0-10.22-12.31ZM45.11 79.8c31.83-26.37 53.72-14.49 79.07-.74c15.11 8.2 31.35 17 49.93 17c14.14 0 29.64-5.12 47-19.5a8 8 0 1 0-10.22-12.31c-31.83 26.38-53.72 14.5-79.07.74c-26.61-14.41-56.76-30.77-96.93 2.51a8 8 0 1 0 10.22 12.3"},null,-1)])])}const gle=Oe({name:"ph-waves",render:mle}),vle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function ble(t,e){return w(),R("svg",vle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m229.66 197.66l-32 32a8 8 0 0 1-11.32-11.32L204.69 200H80a8 8 0 0 1-8-8V59.31L53.66 77.66a8 8 0 0 1-11.32-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L88 59.31V184h116.69l-18.35-18.34a8 8 0 0 1 11.32-11.32l32 32a8 8 0 0 1 0 11.32"},null,-1)])])}const yle=Oe({name:"ph-vector-two",render:ble}),xle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function wle(t,e){return w(),R("svg",xle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m235.32 81.37l-60.69-60.68a16 16 0 0 0-22.63 0l-53.63 53.8c-10.66-3.34-35-7.37-60.4 13.14a16 16 0 0 0-1.29 23.78L85 159.71l-42.66 42.63a8 8 0 0 0 11.32 11.32L96.29 171l48.29 48.29A16 16 0 0 0 155.9 224h1.13a15.93 15.93 0 0 0 11.64-6.33c19.64-26.1 17.75-47.32 13.19-60L235.33 104a16 16 0 0 0-.01-22.63M224 92.69l-57.27 57.46a8 8 0 0 0-1.49 9.22c9.46 18.93-1.8 38.59-9.34 48.62L48 100.08c12.08-9.74 23.64-12.31 32.48-12.31A40.1 40.1 0 0 1 96.81 91a8 8 0 0 0 9.25-1.51L163.32 32L224 92.68Z"},null,-1)])])}const _le=Oe({name:"ph-push-pin",render:wle}),kle=["showVerticalAxis","verticalAxisDirection","showVerticalTicks","verticalLabelPosition","verticalGridStyle","verticalNumberFormat","verticalScaleType","verticalRangeMin","verticalRangeMax","showHorizontalAxis","showHorizontalTicks","horizontalLabelPosition","horizontalGridStyle","horizontalNumberFormat","horizontalScaleType","horizontalRangeMin","horizontalRangeMax"];function IT(){const{chartType:t}=dn(),{availableOptionKeys:e}=_n(),{scenes:n}=wn(),o=A(()=>e.value.some(s=>kle.includes(s))),r=A(()=>e.value.includes("tooltips")||e.value.includes("crosshair")||n.value.length>=1);return{sections:A(()=>{const s=[{key:"type",label:"Type",icon:Ls,tooltip:"Chart Type"},{key:"text",label:"Text",icon:ET},{key:"style",label:"Style",icon:NT}];return["line-multi","bar-multi","bar-split"].includes(t.value)&&s.push({key:"series",label:"Series",icon:gle}),o.value&&s.push({key:"axes",label:"Axes",icon:yle}),s.push({key:"layout",label:"Layout",icon:hle}),s.push({key:"annotate",label:"Annotate",icon:_le}),r.value&&s.push({key:"interactions",label:"Interactions",icon:kT}),s})}}const Sle=le({__name:"ChartEditIconRail",setup(t){const e=cr(),{activeTab:n}=Ct(e),{selectTab:o}=e,{toggleMode:r}=rc(),{sections:i}=IT(),s=A(()=>i.value.map(a=>({value:a.key,icon:a.icon,tooltip:a.tooltip??a.label})));return(a,l)=>{const c=V2;return w(),J(c,{"active-tab":p(n),items:p(s),onSelect:p(o),onToggleMode:p(r)},null,8,["active-tab","items","onSelect","onToggleMode"])}}}),Ale={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Cle(t,e){return w(),R("svg",Ale,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M90.34 61.66a8 8 0 0 1 0-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L136 43.31V96a8 8 0 0 1-16 0V43.31l-18.34 18.35a8 8 0 0 1-11.32 0m64 132.68L136 212.69V160a8 8 0 0 0-16 0v52.69l-18.34-18.35a8 8 0 0 0-11.32 11.32l32 32a8 8 0 0 0 11.32 0l32-32a8 8 0 0 0-11.32-11.32m83.32-72l-32-32a8 8 0 0 0-11.32 11.32L212.69 120H160a8 8 0 0 0 0 16h52.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32M43.31 136H96a8 8 0 0 0 0-16H43.31l18.35-18.34a8 8 0 0 0-11.32-11.32l-32 32a8 8 0 0 0 0 11.32l32 32a8 8 0 0 0 11.32-11.32Z"},null,-1)])])}const $le=Oe({name:"ph-arrows-out-cardinal",render:Cle}),Tle={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Mle(t,e){return w(),R("svg",Tle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M165.66 194.34a8 8 0 0 1 0 11.32l-32 32a8 8 0 0 1-11.32 0l-32-32a8 8 0 0 1 11.32-11.32L120 212.69V43.31l-18.34 18.35a8 8 0 0 1-11.32-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1-11.32 11.32L136 43.31v169.38l18.34-18.35a8 8 0 0 1 11.32 0"},null,-1)])])}const RT=Oe({name:"ph-arrows-vertical",render:Mle}),Ole={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ble(t,e){return w(),R("svg",Ole,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m237.66 133.66l-32 32a8 8 0 0 1-11.32-11.32L212.69 136H43.31l18.35 18.34a8 8 0 0 1-11.32 11.32l-32-32a8 8 0 0 1 0-11.32l32-32a8 8 0 0 1 11.32 11.32L43.31 120h169.38l-18.35-18.34a8 8 0 0 1 11.32-11.32l32 32a8 8 0 0 1 0 11.32"},null,-1)])])}const FT=Oe({name:"ph-arrows-horizontal",render:Ble}),Lle={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ple(t,e){return w(),R("svg",Lle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M2 9.75A.75.75 0 0 1 2.75 9h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 9.75"},null,-1)])])}const q2=Oe({name:"fluent-line-horizontal-1-20-filled",render:Ple}),Dle={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ele(t,e){return w(),R("svg",Dle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M2 9.75A.75.75 0 0 1 2.75 9h2.5a.75.75 0 0 1 0 1.5h-2.5A.75.75 0 0 1 2 9.75m6 0A.75.75 0 0 1 8.75 9h2.5a.75.75 0 0 1 0 1.5h-2.5A.75.75 0 0 1 8 9.75m6 0a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75"},null,-1)])])}const VT=Oe({name:"fluent-line-horizontal-1-dashes-20-filled",render:Ele}),Nle={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ile(t,e){return w(),R("svg",Nle,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M3.5 11a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3M8 11a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m4.5 0a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m6-1.5a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0"},null,-1)])])}const zT=Oe({name:"fluent-line-horizontal-1-dot-20-filled",render:Ile}),Rle={class:"d-flex flex-column gap-3"},Fle=le({__name:"EditorInteractionSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),{layout:r}=dn(),{scenes:i}=wn(),s=A(()=>n.value.includes("tooltips")),a=A(()=>n.value.includes("crosshair")),l=A(()=>i.value.length>=1),c=[{value:"both",text:"Both",icon:$le},{value:"vertical",text:"Vertical",icon:RT},{value:"horizontal",text:"Horizontal",icon:FT}],u=[{value:"solid",text:"Solid",icon:q2},{value:"dashed",text:"Dashed",icon:VT},{value:"dotted",text:"Dotted",icon:zT}],d=A({get:()=>r.value.playerType,set:b=>{r.value.playerType=b}}),f=A({get:()=>r.value.playerPosition,set:b=>{r.value.playerPosition=b}}),h=[{value:"buttons",label:"Buttons"},{value:"progress-bar",label:"Progress Bar"},{value:"dot-stepper",label:"Dot Stepper"},{value:"minimal-arrows",label:"Minimal Arrows"},{value:"none",label:"None"}],g=[{value:"left",text:"Left"},{value:"center",text:"Center"},{value:"right",text:"Right"}];return(b,m)=>(w(),R("div",Rle,[p(s)?(w(),J(p(nn),{key:0,"model-value":p(e).tooltips??!1,label:"Tooltips","onUpdate:modelValue":m[0]||(m[0]=v=>p(o)("tooltips",v))},null,8,["model-value"])):ie("",!0),p(a)?(w(),J(p(nn),{key:1,"model-value":p(e).crosshair??!1,label:"Crosshair","onUpdate:modelValue":m[1]||(m[1]=v=>p(o)("crosshair",v))},null,8,["model-value"])):ie("",!0),p(a)&&p(e).crosshair?(w(),R(He,{key:2},[H(p(Cn),{label:"Direction","model-value":p(e).crosshairDirection??"both",options:c,block:"","onUpdate:modelValue":m[2]||(m[2]=v=>p(o)("crosshairDirection",v))},null,8,["model-value"]),H(p(Cn),{label:"Line style","model-value":p(e).crosshairStyle??"dashed",options:u,block:"","onUpdate:modelValue":m[3]||(m[3]=v=>p(o)("crosshairStyle",v))},null,8,["model-value"]),H(p(Pa),{id:"opt-crosshair-color",label:"Color","model-value":p(e).crosshairColor??"#999999","onUpdate:modelValue":m[4]||(m[4]=v=>p(o)("crosshairColor",v))},null,8,["model-value"])],64)):ie("",!0),p(l)?(w(),R(He,{key:3},[H(p(En),{id:"layout-player-type",modelValue:p(d),"onUpdate:modelValue":m[5]||(m[5]=v=>Ze(d)?d.value=v:null),label:"Scene player",options:h,block:""},null,8,["modelValue"]),p(d)==="buttons"||p(d)==="dot-stepper"||p(d)==="minimal-arrows"?(w(),J(p(Cn),{key:0,modelValue:p(f),"onUpdate:modelValue":m[6]||(m[6]=v=>Ze(f)?f.value=v:null),label:"Player position",options:g,block:""},null,8,["modelValue"])):ie("",!0)],64)):ie("",!0)]))}}),Vle={},zle={class:"d-flex flex-column gap-3"};function Hle(t,e){const n=Fle;return w(),R("div",zle,[H(n)])}const Wle=Be(Vle,[["render",Hle]]),Ule={class:"border rounded overflow-hidden bg-body-tertiary"},Gle={class:"d-flex align-items-center justify-content-between px-2 py-1 border-bottom"},qle={class:"fw-medium"},Yle={class:"p-2 d-flex flex-column gap-2"},jle={class:"d-flex align-items-center gap-2"},Xle={class:"text-nowrap",style:{width:"3em"}},Kle=le({__name:"EditorAreaFillItem",props:it({id:{},seriesNames:{}},{fill:{required:!0},fillModifiers:{}}),emits:it(["remove"],["update:fill"]),setup(t){const e=t,n=dt(t,"fill"),o=A(()=>e.seriesNames.map(s=>({value:s,text:s}))),r=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}];function i(s,a){const l={...n.value};a===void 0?delete l[s]:l[s]=a,n.value=l}return(s,a)=>{const l=Vo,c=Ga,u=Mn,d=ea,f=Rs;return w(),R("div",Ule,[M("div",Gle,[M("small",qle,ye(n.value.from)+" – "+ye(n.value.to),1),H(l,{variant:"link",size:"sm",class:"text-danger p-0",onClick:a[0]||(a[0]=h=>s.$emit("remove"))},{default:te(()=>[...a[8]||(a[8]=[M("span",{"aria-hidden":"true"},"×",-1)])]),_:1})]),M("div",Yle,[H(u,{label:"From","label-for":`af-from-${t.id}`},{default:te(()=>[H(c,{id:`af-from-${t.id}`,"model-value":n.value.from,options:p(o),"onUpdate:modelValue":a[1]||(a[1]=h=>i("from",h))},null,8,["id","model-value","options"])]),_:1},8,["label-for"]),H(u,{label:"To","label-for":`af-to-${t.id}`},{default:te(()=>[H(c,{id:`af-to-${t.id}`,"model-value":n.value.to,options:p(o),"onUpdate:modelValue":a[2]||(a[2]=h=>i("to",h))},null,8,["id","model-value","options"])]),_:1},8,["label-for"]),H(u,{label:"Color","label-for":`af-color-${t.id}`},{default:te(()=>[H(d,{id:`af-color-${t.id}`,type:"color","model-value":n.value.color??"#cccccc","onUpdate:modelValue":a[3]||(a[3]=h=>i("color",h))},null,8,["id","model-value"])]),_:1},8,["label-for"]),H(u,null,{default:te(()=>[H(f,{"model-value":!!n.value.negativeColor,switch:"","onUpdate:modelValue":a[4]||(a[4]=h=>i("negativeColor",h?"#f28e2b":void 0))},{default:te(()=>[...a[9]||(a[9]=[Ye(" Use different color for negative differences ",-1)])]),_:1},8,["model-value"])]),_:1}),n.value.negativeColor?(w(),J(u,{key:0,label:"Negative color","label-for":`af-neg-color-${t.id}`},{default:te(()=>[H(d,{id:`af-neg-color-${t.id}`,type:"color","model-value":n.value.negativeColor,"onUpdate:modelValue":a[5]||(a[5]=h=>i("negativeColor",h))},null,8,["id","model-value"])]),_:1},8,["label-for"])):ie("",!0),H(u,{label:"Opacity","label-for":`af-opacity-${t.id}`},{default:te(()=>[M("div",jle,[H(d,{id:`af-opacity-${t.id}`,type:"range","model-value":String(n.value.opacity??30),min:"0",max:"100",class:"flex-grow-1","onUpdate:modelValue":a[6]||(a[6]=h=>i("opacity",Number(h)))},null,8,["id","model-value"]),M("small",Xle,ye(n.value.opacity??30)+"%",1)])]),_:1},8,["label-for"]),H(u,{label:"Interpolation","label-for":`af-interp-${t.id}`},{default:te(()=>[H(c,{id:`af-interp-${t.id}`,"model-value":n.value.interpolation??"linear",options:r,"onUpdate:modelValue":a[7]||(a[7]=h=>i("interpolation",h))},null,8,["id","model-value"])]),_:1},8,["label-for"])])])}}}),Zle={class:"d-flex flex-column gap-2"},Qle=le({__name:"EditorAreaFills",props:it({seriesNames:{},seriesOverrides:{},globalInterpolation:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=t,n=dt(t,"modelValue"),o=A(()=>n.value);function r(a,l){const c=[...o.value];c[a]=l,n.value=c}function i(){const a=e.seriesNames[0]??"",l=e.seriesNames[1]??e.seriesNames[0]??"",c=x2(a,e.globalInterpolation,e.seriesOverrides);n.value=[...o.value,{from:a,to:l,color:"#cccccc",opacity:30,interpolation:c}]}function s(a){const l=[...o.value];l.splice(a,1),n.value=l}return(a,l)=>{const c=Kle;return w(),R(He,null,[M("div",Zle,[(w(!0),R(He,null,ht(p(o),(u,d)=>(w(),J(c,{id:d,key:d,fill:u,"series-names":t.seriesNames,"onUpdate:fill":f=>r(d,f),onRemove:f=>s(d)},null,8,["id","fill","series-names","onUpdate:fill","onRemove"]))),128))]),H(p(Sl),{label:"Add",onClick:i})],64)}}}),Jle={class:"d-flex flex-column gap-3"},ece=le({__name:"EditorHighlightSection",setup(t){const{chartType:e,data:n,highlights:o}=dn(),r=A(()=>fs(n.value)),i=A(()=>[Le.LineMulti,Le.AreaStacked].includes(e.value)),s=A(()=>{var u;return i.value?((u=r.value.series)==null?void 0:u.map(d=>d.name))??[]:r.value.labels}),a=Ie(o.value.length>0),l=A({get(){return o.value.map(u=>u.target)},set(u){o.value=u.map(d=>({target:d}))}});function c(u){a.value=u,u||(o.value=[])}return(u,d)=>(w(),R("div",Jle,[H(p(nn),{"model-value":p(a),label:"Highlight specific items","onUpdate:modelValue":c},null,8,["model-value"]),p(a)?(w(),J(p(Vy),{key:0,selected:p(l),"onUpdate:selected":d[0]||(d[0]=f=>Ze(l)?l.value=f:null),items:p(s)},null,8,["selected","items"])):ie("",!0)]))}}),tce=Oo("previewContainer",()=>({containerRef:Ve(null)}));function HT(){const t=tce();return Ct(t)}const nce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function oce(t,e){return w(),R("svg",nce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M174 47.75a254.2 254.2 0 0 0-41.45-38.3a8 8 0 0 0-9.18 0A254.2 254.2 0 0 0 82 47.75C54.51 79.32 40 112.6 40 144a88 88 0 0 0 176 0c0-31.4-14.51-64.68-42-96.25M200 144a71 71 0 0 1-.46 8H136v-16h63.64q.36 4 .36 8m-16.61-56H136V72h36.89a176 176 0 0 1 10.5 16M136 200h37.19A71.67 71.67 0 0 1 136 215.54Zm0-16v-16h59.87a72 72 0 0 1-8 16Zm0-64v-16h55.39a117 117 0 0 1 5.45 16Zm23.89-64H136V32.6A257 257 0 0 1 159.89 56M56 144c0-50 42.26-92.71 64-111.4v182.94A72.08 72.08 0 0 1 56 144"},null,-1)])])}const rce=Oe({name:"ph-drop-half",render:oce}),ice={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function sce(t,e){return w(),R("svg",ice,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M201.54 54.46A104 104 0 0 0 54.46 201.54A104 104 0 0 0 201.54 54.46M96 210v-58h64v58a88.33 88.33 0 0 1-64 0m48-74h-32v-35.06l32-16Zm46.22 54.22A88 88 0 0 1 176 201.77V152a16 16 0 0 0-16-16V72a8 8 0 0 0-11.58-7.16l-48 24A8 8 0 0 0 96 96v40a16 16 0 0 0-16 16v49.77a88 88 0 1 1 110.22-11.55"},null,-1)])])}const ace=Oe({name:"ph-highlighter-circle",render:sce}),lce={class:"d-flex flex-column gap-2"},cce={class:"d-flex gap-2"},uce=le({__name:"EditorAnnotationFree",props:it({chartWidth:{},chartHeight:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=dt(t,"annotation");function n(s){return typeof s=="number"?`${s}%`:String(s)}function o(s){return s==null?"150px":typeof s=="number"?`${s}px`:String(s)}function r(s,a){const l={...e.value};a===void 0?delete l[s]:l[s]=a,e.value=l}const i=Ve(null);return un(()=>{var a;const s=(a=i.value)==null?void 0:a.$el;s&&(s.focus(),s.select())}),(s,a)=>{const l=_y,c=Mn;return w(),R("div",lce,[H(c,{label:"Text"},{default:te(()=>[H(l,{ref_key:"textRef",ref:i,"model-value":e.value.text,placeholder:"Annotation text",rows:"2","onUpdate:modelValue":a[0]||(a[0]=u=>r("text",u))},null,8,["model-value"])]),_:1}),M("div",cce,[H(p(Yh),{id:"ann-free-x","model-value":n(e.value.x),label:"X position",min:"-50",max:String(t.chartWidth??600),step:"0.1",units:["%","px"],"no-slider":"","center-relative":"",class:"flex-fill","onUpdate:modelValue":a[1]||(a[1]=u=>r("x",u))},null,8,["model-value","max"]),H(p(Yh),{id:"ann-free-y","model-value":n(e.value.y),label:"Y position",min:"-50",max:String(t.chartHeight??400),step:"0.1",units:["%","px"],"no-slider":"","center-relative":"",class:"flex-fill","onUpdate:modelValue":a[2]||(a[2]=u=>r("y",u))},null,8,["model-value","max"])]),H(p(Pa),{id:"ann-free-text-color","model-value":e.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":a[3]||(a[3]=u=>r("textColor",u))},null,8,["model-value"]),H(p(nn),{"model-value":e.value.textOutline??!0,label:"Text outline","onUpdate:modelValue":a[4]||(a[4]=u=>r("textOutline",u))},null,8,["model-value"]),H(p(Yh),{id:"ann-free-max-width","model-value":o(e.value.maxWidth),label:"Max width",min:"0",max:String(t.chartWidth??600),units:["px","%"],"onUpdate:modelValue":a[5]||(a[5]=u=>r("maxWidth",u))},null,8,["model-value","max"])])}}}),dce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function fce(t,e){return w(),R("svg",dce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M48 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m16 64V64a16 16 0 0 1 16-16h96a16 16 0 0 1 16 16v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16m16 0h96V64H80Zm152 48v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16v-40a16 16 0 0 1 16-16h136a16 16 0 0 1 16 16m-16 40v-40H80v40z"},null,-1)])])}const af=Oe({name:"ph-align-left",render:fce}),hce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function pce(t,e){return w(),R("svg",hce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M208 136h-72v-16h48a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16h-48V32a8 8 0 0 0-16 0v16H72a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h48v16H48a16 16 0 0 0-16 16v40a16 16 0 0 0 16 16h72v16a8 8 0 0 0 16 0v-16h72a16 16 0 0 0 16-16v-40a16 16 0 0 0-16-16M72 64h112v40H72Zm136 128H48v-40h160z"},null,-1)])])}const v0=Oe({name:"ph-align-center-horizontal",render:pce}),mce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function gce(t,e){return w(),R("svg",mce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m-32 24v40a16 16 0 0 1-16 16H80a16 16 0 0 1-16-16V64a16 16 0 0 1 16-16h96a16 16 0 0 1 16 16m-16 0H80v40h96Zm16 88v40a16 16 0 0 1-16 16H40a16 16 0 0 1-16-16v-40a16 16 0 0 1 16-16h136a16 16 0 0 1 16 16m-16 0H40v40h136Z"},null,-1)])])}const lf=Oe({name:"ph-align-right",render:gce}),vce={class:"d-flex flex-column gap-2"},bce={class:"d-flex gap-2"},yce={key:0,class:"d-flex gap-2"},xce=le({__name:"EditorAnnotationRange",props:it({labels:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=t,n=dt(t,"annotation"),o=[{value:"vertical",text:"Vertical"},{value:"horizontal",text:"Horizontal"}],r=A(()=>(n.value.orientation??"vertical")==="vertical"&&e.labels.length>0),i=A(()=>e.labels.map(l=>({value:l,text:l})));function s(l,c){const u={...n.value};c===void 0?delete u[l]:u[l]=c,n.value=u}const a=Ve(null);return un(()=>{var c;const l=(c=a.value)==null?void 0:c.$el;l&&(l.focus(),l.select())}),(l,c)=>{const u=ea,d=Mn,f=Ga;return w(),R("div",vce,[H(d,{label:"Text"},{default:te(()=>[H(u,{ref_key:"textRef",ref:a,"model-value":n.value.text??"",placeholder:"Optional label","onUpdate:modelValue":c[0]||(c[0]=h=>s("text",h||void 0))},null,8,["model-value"])]),_:1}),H(d,{label:"Orientation"},{default:te(()=>[H(f,{"model-value":n.value.orientation??"vertical",options:o,"onUpdate:modelValue":c[1]||(c[1]=h=>s("orientation",h))},null,8,["model-value"])]),_:1}),M("div",bce,[H(d,{label:"Start",class:"flex-fill"},{default:te(()=>[p(r)?(w(),J(f,{key:0,"model-value":String(n.value.start),options:p(i),"onUpdate:modelValue":c[2]||(c[2]=h=>s("start",h))},null,8,["model-value","options"])):(w(),J(u,{key:1,"model-value":String(n.value.start),"onUpdate:modelValue":c[3]||(c[3]=h=>s("start",isNaN(Number(h))?h:Number(h)))},null,8,["model-value"]))]),_:1}),H(d,{label:"End",class:"flex-fill"},{default:te(()=>[p(r)?(w(),J(f,{key:0,"model-value":String(n.value.end),options:p(i),"onUpdate:modelValue":c[4]||(c[4]=h=>s("end",h))},null,8,["model-value","options"])):(w(),J(u,{key:1,"model-value":String(n.value.end),"onUpdate:modelValue":c[5]||(c[5]=h=>s("end",isNaN(Number(h))?h:Number(h)))},null,8,["model-value"]))]),_:1})]),p(r)?(w(),R("div",yce,[H(p(En),{id:`ann-range-start-anchor-${l.$.uid}`,"model-value":n.value.startAnchor??"center",label:"Start anchor","light-label":"",block:"",class:"flex-fill","onUpdate:modelValue":c[6]||(c[6]=h=>s("startAnchor",h))},{default:te(()=>[H(p(uc),{value:"start",label:"Start"},{icon:te(()=>[H(p(af))]),_:1}),H(p(uc),{value:"center",label:"Center"},{icon:te(()=>[H(p(v0))]),_:1}),H(p(uc),{value:"end",label:"End"},{icon:te(()=>[H(p(lf))]),_:1})]),_:1},8,["id","model-value"]),H(p(En),{id:`ann-range-end-anchor-${l.$.uid}`,"model-value":n.value.endAnchor??"center",label:"End anchor","light-label":"",block:"",class:"flex-fill","onUpdate:modelValue":c[7]||(c[7]=h=>s("endAnchor",h))},{default:te(()=>[H(p(uc),{value:"start",label:"Start"},{icon:te(()=>[H(p(af))]),_:1}),H(p(uc),{value:"center",label:"Center"},{icon:te(()=>[H(p(v0))]),_:1}),H(p(uc),{value:"end",label:"End"},{icon:te(()=>[H(p(lf))]),_:1})]),_:1},8,["id","model-value"])])):ie("",!0),H(p(Pa),{id:"ann-range-bg-color","model-value":n.value.bgColor??"#cccccc",label:"Background color","onUpdate:modelValue":c[8]||(c[8]=h=>s("bgColor",h))},null,8,["model-value"]),H(p(xr),{id:"ann-range-bg-opacity","model-value":String(n.value.bgOpacity??20),label:"Background opacity",min:"0",max:"100",suffix:"%","onUpdate:modelValue":c[9]||(c[9]=h=>s("bgOpacity",Number(h)))},null,8,["model-value"]),n.value.text?(w(),R(He,{key:1},[H(p(Pa),{id:"ann-range-text-color","model-value":n.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":c[10]||(c[10]=h=>s("textColor",h))},null,8,["model-value"]),H(p(kA),{"model-value":n.value.direction??"center",label:"Direction","onUpdate:modelValue":c[11]||(c[11]=h=>s("direction",h))},null,8,["model-value"])],64)):ie("",!0)])}}}),wce={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function _ce(t,e){return w(),R("svg",wce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M6 15.25c0 .414.336.75.75.75h4.5c1.586 0 2.696-.621 3.53-1.588C15.6 13.46 16 12.216 16 11s-.3-2.46-1.12-3.412C14.046 6.621 12.836 6 11.25 6H6.56l2.22-2.22a.75.75 0 0 0-1.06-1.06l-3.5 3.5a.75.75 0 0 0 .02 1.08l3.5 3.25a.75.75 0 0 0 1.02-1.1L6.66 7.5h4.59c1.164 0 1.86.441 2.4 1.068c.554.642.85 1.523.85 2.432s-.296 1.79-.85 2.432c-.54.627-1.236 1.068-2.4 1.068h-4.5a.75.75 0 0 0-.75.75"},null,-1)])])}const kce=Oe({name:"fluent-arrow-hook-up-left-20-filled",render:_ce}),Sce={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Ace(t,e){return w(),R("svg",Sce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M9 6c.06 0-.06-.002 0 0c.023-.002.227 0 .25 0h4.393l-2.268-2.268a.75.75 0 1 1 1.061-1.06l3.353 3.352a.75.75 0 0 1 .212.639a.75.75 0 0 1-.215.443l-3.247 3.248a.75.75 0 1 1-1.06-1.061L13.27 7.5H9a3.5 3.5 0 1 0 0 7h4.25a.75.75 0 0 1 0 1.5H9A5 5 0 0 1 9 6"},null,-1)])])}const Cce=Oe({name:"fluent-arrow-hook-up-right-20-filled",render:Ace}),$ce={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"};function Tce(t,e){return w(),R("svg",$ce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M16.78 10.72a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V7A1.5 1.5 0 0 0 10 5.5H3.75a.75.75 0 0 1 0-1.5H10a3 3 0 0 1 3 3v6.44l2.72-2.72a.75.75 0 0 1 1.06 0"},null,-1)])])}const Mce=Oe({name:"fluent-arrow-turn-right-down-20-filled",render:Tce}),Oce={class:"d-flex flex-column gap-2"},Bce={class:"d-flex flex-column gap-2 mt-2"},Lce={class:"d-flex flex-column gap-2 mt-2"},Pce=le({__name:"EditorAnnotationPoint",props:it({labels:{},chartWidth:{}},{annotation:{required:!0},annotationModifiers:{}}),emits:["update:annotation"],setup(t){const e=t,n=dt(t,"annotation"),o=A(()=>e.labels.map(l=>({value:l,text:l}))),r=[{value:"solid",text:"Solid"},{value:"dotted",text:"Dotted"},{value:"dashed",text:"Dashed"}];function i(l){return l==null?"150px":typeof l=="number"?`${l}px`:String(l)}function s(l,c){const u={...n.value};c===void 0?delete u[l]:u[l]=c,n.value=u}const a=Ve(null);return un(()=>{var c;const l=(c=a.value)==null?void 0:c.$el;l&&(l.focus(),l.select())}),(l,c)=>{const u=_y,d=Mn,f=Ga,h=ea,g=Rs;return w(),R("div",Oce,[H(d,{label:"Text"},{default:te(()=>[H(u,{ref_key:"textRef",ref:a,"model-value":n.value.text,placeholder:"Annotation text",rows:"2","onUpdate:modelValue":c[0]||(c[0]=b=>s("text",b))},null,8,["model-value"])]),_:1}),H(d,{label:"Target"},{default:te(()=>[H(f,{"model-value":n.value.target,options:p(o),"onUpdate:modelValue":c[1]||(c[1]=b=>s("target",b))},null,8,["model-value","options"])]),_:1}),H(p(Pa),{id:"ann-point-text-color","model-value":n.value.textColor??"#000000",label:"Text color","onUpdate:modelValue":c[2]||(c[2]=b=>s("textColor",b))},null,8,["model-value"]),H(p(nn),{"model-value":n.value.textOutline??!0,label:"Text outline","onUpdate:modelValue":c[3]||(c[3]=b=>s("textOutline",b))},null,8,["model-value"]),H(p(Yh),{id:"ann-point-max-width","model-value":i(n.value.maxWidth),label:"Max width",min:"0",max:String(t.chartWidth??600),units:["px","%"],"onUpdate:modelValue":c[4]||(c[4]=b=>s("maxWidth",b))},null,8,["model-value","max"]),H(p(nn),{"model-value":n.value.showLine??!0,label:"Show line","onUpdate:modelValue":c[10]||(c[10]=b=>s("showLine",b))},bi({_:2},[n.value.showLine?{name:"section",fn:te(()=>[M("div",Bce,[H(p(Cn),{"model-value":n.value.lineStyle??"direct",label:"Line style",block:"","onUpdate:modelValue":c[5]||(c[5]=b=>s("lineStyle",b))},{default:te(()=>[H(p(oh),{value:"direct",text:"Direct","icon-left":p(q2)},null,8,["icon-left"]),H(p(oh),{value:"curve-left",text:"Curve left","icon-left":p(kce)},null,8,["icon-left"]),H(p(oh),{value:"curve-right",text:"Curve right","icon-left":p(Cce)},null,8,["icon-left"]),H(p(oh),{value:"elbow",text:"Elbow","icon-left":p(Mce)},null,8,["icon-left"])]),_:1},8,["model-value"]),H(d,{label:"Line weight"},{default:te(()=>[H(h,{"model-value":String(n.value.lineWeight??1),type:"number",min:"1",max:"10","onUpdate:modelValue":c[6]||(c[6]=b=>s("lineWeight",Number(b)))},null,8,["model-value"])]),_:1}),H(p(kA),{"model-value":n.value.anchorDirection??"N",label:"Anchor position","onUpdate:modelValue":c[7]||(c[7]=b=>s("anchorDirection",b))},null,8,["model-value"]),H(d,null,{default:te(()=>[H(g,{"model-value":n.value.showArrow??!0,switch:"","onUpdate:modelValue":c[8]||(c[8]=b=>s("showArrow",b))},{default:te(()=>[...c[14]||(c[14]=[Ye(" Show arrow ",-1)])]),_:1},8,["model-value"])]),_:1}),H(d,{label:"Line target distance"},{default:te(()=>[H(h,{"model-value":String(n.value.lineTargetDistance??0),type:"number","onUpdate:modelValue":c[9]||(c[9]=b=>s("lineTargetDistance",Number(b)))},null,8,["model-value"])]),_:1})])]),key:"0"}:void 0]),1032,["model-value"]),H(p(nn),{"model-value":n.value.showCircle??!1,label:"Show circle","onUpdate:modelValue":c[13]||(c[13]=b=>s("showCircle",b))},bi({_:2},[n.value.showCircle?{name:"section",fn:te(()=>[M("div",Lce,[H(d,{label:"Circle size"},{default:te(()=>[H(h,{"model-value":String(n.value.circleSize??4),type:"number",min:"1","onUpdate:modelValue":c[11]||(c[11]=b=>s("circleSize",Number(b)))},null,8,["model-value"])]),_:1}),H(d,{label:"Circle style"},{default:te(()=>[H(f,{"model-value":n.value.circleStyle??"solid",options:r,"onUpdate:modelValue":c[12]||(c[12]=b=>s("circleStyle",b))},null,8,["model-value"])]),_:1})])]),key:"0"}:void 0]),1032,["model-value"])])}}}),Dce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ece(t,e){return w(),R("svg",Dce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M247.31 124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57 61.26 162.88 48 128 48S61.43 61.26 36.34 86.35C17.51 105.18 9 124 8.69 124.76a8 8 0 0 0 0 6.5c.35.79 8.82 19.57 27.65 38.4C61.43 194.74 93.12 208 128 208s66.57-13.26 91.66-38.34c18.83-18.83 27.3-37.61 27.65-38.4a8 8 0 0 0 0-6.5M128 192c-30.78 0-57.67-11.19-79.93-33.25A133.5 133.5 0 0 1 25 128a133.3 133.3 0 0 1 23.07-30.75C70.33 75.19 97.22 64 128 64s57.67 11.19 79.93 33.25A133.5 133.5 0 0 1 231.05 128c-7.21 13.46-38.62 64-103.05 64m0-112a48 48 0 1 0 48 48a48.05 48.05 0 0 0-48-48m0 80a32 32 0 1 1 32-32a32 32 0 0 1-32 32"},null,-1)])])}const WT=Oe({name:"ph-eye",render:Ece}),Nce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ice(t,e){return w(),R("svg",Nce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M53.92 34.62a8 8 0 1 0-11.84 10.76l19.24 21.17C25 88.84 9.38 123.2 8.69 124.76a8 8 0 0 0 0 6.5c.35.79 8.82 19.57 27.65 38.4C61.43 194.74 93.12 208 128 208a127.1 127.1 0 0 0 52.07-10.83l22 24.21a8 8 0 1 0 11.84-10.76Zm47.33 75.84l41.67 45.85a32 32 0 0 1-41.67-45.85M128 192c-30.78 0-57.67-11.19-79.93-33.25A133.2 133.2 0 0 1 25 128c4.69-8.79 19.66-33.39 47.35-49.38l18 19.75a48 48 0 0 0 63.66 70l14.73 16.2A112 112 0 0 1 128 192m6-95.43a8 8 0 0 1 3-15.72a48.16 48.16 0 0 1 38.77 42.64a8 8 0 0 1-7.22 8.71a6 6 0 0 1-.75 0a8 8 0 0 1-8-7.26A32.09 32.09 0 0 0 134 96.57m113.28 34.69c-.42.94-10.55 23.37-33.36 43.8a8 8 0 1 1-10.67-11.92a132.8 132.8 0 0 0 27.8-35.14a133.2 133.2 0 0 0-23.12-30.77C185.67 75.19 158.78 64 128 64a118.4 118.4 0 0 0-19.36 1.57A8 8 0 1 1 106 49.79A134 134 0 0 1 128 48c34.88 0 66.57 13.26 91.66 38.35c18.83 18.83 27.3 37.62 27.65 38.41a8 8 0 0 1 0 6.5Z"},null,-1)])])}const cf=Oe({name:"ph-eye-slash",render:Ice}),Rce={class:"badge bg-secondary-subtle text-secondary-emphasis"},Fce=le({__name:"EditorAnnotationHeader",props:{kindLabel:{},summary:{},collapsed:{type:Boolean},hidden:{type:Boolean},canToggleVisibility:{type:Boolean}},emits:["duplicate","remove","toggleCollapse","toggleVisibility"],setup(t){return(e,n)=>(w(),J(p(WA),{label:t.summary,class:Me({"opacity-50":t.hidden}),onClick:n[3]||(n[3]=o=>e.$emit("toggleCollapse"))},{leading:te(()=>[M("span",Rce,ye(t.kindLabel),1)]),actions:te(()=>[t.canToggleVisibility?(w(),J(p(Vo),{key:0,variant:"link",size:"sm",class:"annotation-header__btn text-body-secondary",title:t.hidden?"Show in scene":"Hide in scene",onClick:n[0]||(n[0]=pn(o=>e.$emit("toggleVisibility"),["stop"]))},{default:te(()=>[H(p(Sf),{name:t.hidden?p(cf):p(WT)},null,8,["name"])]),_:1},8,["title"])):ie("",!0),H(p(jU),{onDuplicate:n[1]||(n[1]=o=>e.$emit("duplicate")),onRemove:n[2]||(n[2]=o=>e.$emit("remove"))})]),_:1},8,["label","class"]))}}),Vce=Be(Fce,[["__scopeId","data-v-acf3aff5"]]),zce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Hce(t,e){return w(),R("svg",zce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 64a40 40 0 1 0 40 40a40 40 0 0 0-40-40m0 64a24 24 0 1 1 24-24a24 24 0 0 1-24 24m0-112a88.1 88.1 0 0 0-88 88c0 31.4 14.51 64.68 42 96.25a254.2 254.2 0 0 0 41.45 38.3a8 8 0 0 0 9.18 0a254.2 254.2 0 0 0 41.37-38.3c27.45-31.57 42-64.85 42-96.25a88.1 88.1 0 0 0-88-88m0 206c-16.53-13-72-60.75-72-118a72 72 0 0 1 144 0c0 57.23-55.47 105-72 118"},null,-1)])])}const Wce=Oe({name:"ph-map-pin",render:Hce}),Uce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Gce(t,e){return w(),R("svg",Uce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M136 40v176a8 8 0 0 1-16 0V40a8 8 0 0 1 16 0m-40 80H35.31l18.35-18.34a8 8 0 0 0-11.32-11.32l-32 32a8 8 0 0 0 0 11.32l32 32a8 8 0 0 0 11.32-11.32L35.31 136H96a8 8 0 0 0 0-16m149.66 2.34l-32-32a8 8 0 0 0-11.32 11.32L220.69 120H160a8 8 0 0 0 0 16h60.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32"},null,-1)])])}const qce=Oe({name:"ph-arrows-out-line-horizontal",render:Gce}),Yce={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function jce(t,e){return w(),R("svg",Yce,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M88 96a8 8 0 0 1 8-8h64a8 8 0 0 1 0 16H96a8 8 0 0 1-8-8m8 40h64a8 8 0 0 0 0-16H96a8 8 0 0 0 0 16m32 16H96a8 8 0 0 0 0 16h32a8 8 0 0 0 0-16m96-104v108.69a15.86 15.86 0 0 1-4.69 11.31L168 219.31a15.86 15.86 0 0 1-11.31 4.69H48a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h160a16 16 0 0 1 16 16M48 208h104v-48a8 8 0 0 1 8-8h48V48H48Zm120-40v28.7l28.69-28.7Z"},null,-1)])])}const Xce=Oe({name:"ph-note",render:jce}),Kce={class:"d-flex flex-column gap-4"},Zce={class:"d-flex flex-column gap-2"},Qce={class:"d-flex flex-column gap-2"},Jce={class:"d-flex flex-column gap-2"},X6="abcdefghijklmnopqrstuvwxyz0123456789",eue=le({__name:"EditorAnnotations",props:it({labels:{},chartType:{},chartWidth:{},chartHeight:{},hiddenAnnotationIds:{},canToggleVisibility:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:it(["toggle-visibility"],["update:modelValue"]),setup(t,{expose:e,emit:n}){const o=t,r=n,i=dt(t,"modelValue"),s=A(()=>i.value);function a(){let S="";for(let L=0;L<5;L++)S+=X6[Math.floor(Math.random()*X6.length)];return S}const l=A(()=>o.chartType===Le.Pie||o.chartType===Le.Donut),c=Ve(null);function u(S){c.value=c.value===S?null:S}e({openIndex:c});const d=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Point)),f=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Range)),h=A(()=>s.value.map((S,L)=>({ann:S,index:L})).filter(({ann:S})=>S.kind===Dt.Free));function g(S){var L;return!!S.id&&!!((L=o.hiddenAnnotationIds)!=null&&L.has(S.id))}function b(S){S.id&&r("toggle-visibility",S.id,S.kind)}function m(S){return S.kind===Dt.Point?"Point":S.kind===Dt.Range?"Range":"Note"}function v(S){return S.kind===Dt.Point?S.text||S.target||"Empty":S.kind===Dt.Range?S.text||`${S.start} - ${S.end}`:S.text||"Empty"}function y(S,L){const D=s.value.map(I=>({...I}));D[S]=L,i.value=D}function x(){const S={kind:Dt.Point,id:a(),target:o.labels[0]??"",text:"Enter an annotation",showLine:!0,showArrow:!0},L=[...s.value,S];i.value=L,c.value=L.length-1}function _(){const S=o.labels.length>0,L={kind:Dt.Range,id:a(),start:S?o.labels[0]:0,end:S?o.labels[o.labels.length-1]:100},D=[...s.value,L];i.value=D,c.value=D.length-1}function k(){const S={kind:Dt.Free,id:a(),text:"Enter an annotation",x:0,y:0},L=[...s.value,S];i.value=L,c.value=L.length-1}function E(S){const L=[...s.value];L.splice(S+1,0,{...L[S],id:a()}),i.value=L}function B(S){const L=[...s.value];L.splice(S,1),i.value=L,c.value===S?c.value=null:c.value!==null&&c.value>S&&c.value--}return(S,L)=>{const D=Vce,I=Pce,C=xce,T=uce;return w(),R("div",Kce,[p(l)?ie("",!0):(w(),J(p(Fo),{key:0,title:"Points",icon:p(Wce)},{default:te(()=>[M("div",Zce,[(w(!0),R(He,null,ht(p(d),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(I,{key:0,annotation:P,labels:t.labels,"chart-width":t.chartWidth,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","labels","chart-width","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:x})]),_:1},8,["icon"])),p(l)?ie("",!0):(w(),J(p(Fo),{key:1,title:"Ranges",icon:p(qce)},{default:te(()=>[M("div",Qce,[(w(!0),R(He,null,ht(p(f),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(C,{key:0,annotation:P,labels:t.labels,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","labels","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:_})]),_:1},8,["icon"])),H(p(Fo),{title:"Notes",icon:p(Xce)},{default:te(()=>[M("div",Jce,[(w(!0),R(He,null,ht(p(h),({ann:P,index:$})=>(w(),J(p(Ad),{key:$},{header:te(()=>[H(D,{"kind-label":m(P),summary:v(P),collapsed:p(c)!==$,hidden:g(P),"can-toggle-visibility":t.canToggleVisibility,onDuplicate:F=>E($),onRemove:F=>B($),onToggleCollapse:F=>u($),onToggleVisibility:F=>b(P)},null,8,["kind-label","summary","collapsed","hidden","can-toggle-visibility","onDuplicate","onRemove","onToggleCollapse","onToggleVisibility"])]),default:te(()=>[p(c)===$?(w(),J(T,{key:0,annotation:P,"chart-width":t.chartWidth,"chart-height":t.chartHeight,"onUpdate:annotation":F=>y($,F)},null,8,["annotation","chart-width","chart-height","onUpdate:annotation"])):ie("",!0)]),_:2},1024))),128))]),H(p(Sl),{label:"Add",onClick:k})]),_:1},8,["icon"])])}}});function tue(t,e,n,o){let r=null,i=null;function s(){r!=null&&r.parentNode&&r.parentNode.removeChild(r),r=null,i&&(i(),i=null)}function a(){s();const l=t.value,c=n.value;if(!l||c===null)return;const u=e.value[c];if(!u||u.kind==="range")return;const d=l.querySelector("svg");if(!d)return;const f=u.id,h=f?d.querySelector(`g[data-annotation-id="${f}"]`):d.querySelector(`g[data-annotation-index="${c}"]`);if(!h)return;const g=h.querySelector(".bc-annotation-text");if(!g)return;const b=h.querySelector(".bc-annotation-circle"),m=h.querySelector(".bc-annotation-line");let v=null,y=null,x=0;if(b&&(v=parseFloat(b.getAttribute("cx")||"0"),y=parseFloat(b.getAttribute("cy")||"0"),x=parseFloat(b.getAttribute("r")||"0")),v===null&&m){const N=(m.getAttribute("d")||"").split(/[MLA]\s*/).filter(Boolean);if(N.length>=2){const G=N[N.length-1].trim().split(/[\s,]+/);G.length>=2&&(v=parseFloat(G[G.length-2]),y=parseFloat(G[G.length-1]))}}const _=v!==null&&y!==null,k=(u&&"lineStyle"in u?u.lineStyle:"direct")||"direct",E=x>0?x+((u&&"lineTargetDistance"in u?u.lineTargetDistance:5)||5):0,B=parseFloat(g.getAttribute("x")||"0"),S=parseFloat(g.getAttribute("y")||"0"),L=g.getBBox(),I=(g.getAttribute("transform")||"").match(/translate\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)/),C=I?parseFloat(I[1]):0,T=I?parseFloat(I[2]):0,P={x:L.x+C,y:L.y+T,width:L.width,height:L.height},$=4,F=u?u.maxWidth:void 0;let V=P.width;if(F!=null){const ve=parseFloat(d.getAttribute("width")||"0");if(typeof F=="number"&&F>0)V=F;else if(typeof F=="string")if(F.endsWith("%")&&ve>0)V=parseFloat(F)/100*ve;else{const N=parseFloat(F);N>0&&(V=N)}}const U=g.getAttribute("text-anchor")||"middle";let K;U==="middle"?K=B-V/2:U==="end"?K=B-V:K=B,r=document.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("x",String(K-$)),r.setAttribute("y",String(P.y-$)),r.setAttribute("width",String(V+$*2)),r.setAttribute("height",String(P.height+$*2)),r.setAttribute("fill","rgba(255,245,157,0.4)"),r.setAttribute("rx","3"),r.style.cursor="grab",r.style.pointerEvents="all",h.appendChild(r);let se=!1,he=0,ce=0,be=0,oe=0,de=0;function we(){return d.getScreenCTM()}function ee(){const ve=we();if(!ve)return;const N=(oe-he)/ve.a,G=(de-ce)/ve.d,Y=B+N,ue=S+G;g.setAttribute("x",String(Y)),g.setAttribute("y",String(ue));const ae=g.querySelectorAll("tspan");for(const Z of ae)Z.setAttribute("x",String(Y));const q=g.getBBox(),ne={x:q.x+C,y:q.y+T,width:q.width,height:q.height};let j;const X=g.getAttribute("text-anchor")||"middle";if(X==="middle"?j=Y-V/2:X==="end"?j=Y-V:j=Y,r.setAttribute("x",String(j-$)),r.setAttribute("y",String(ne.y-$)),r.setAttribute("width",String(V+$*2)),r.setAttribute("height",String(ne.height+$*2)),m&&_){const Z=bboxEdgeToward(ne,v,y),fe=E>0?shortenToward({x:v,y},Z,E):{x:v,y},pe=ne.x+ne.width/2,me=Math.abs(Z.x-pe)<1;m.setAttribute("d",buildPathD(Z,fe,k,me))}be=0}function ge(ve){ve.preventDefault(),ve.stopPropagation(),se=!0,he=ve.clientX,ce=ve.clientY,oe=ve.clientX,de=ve.clientY,r.style.cursor="grabbing",r.setPointerCapture(ve.pointerId)}function Q(ve){se&&(ve.preventDefault(),oe=ve.clientX,de=ve.clientY,be||(be=requestAnimationFrame(ee)))}function re(ve){if(!se)return;se=!1,r.style.cursor="grab",be&&(cancelAnimationFrame(be),be=0);const N=we();if(!N)return;const G=(ve.clientX-he)/N.a,Y=(ve.clientY-ce)/N.d;if(Math.abs(G)<1&&Math.abs(Y)<1){g.setAttribute("x",String(B)),g.setAttribute("y",String(S));const q=g.querySelectorAll("tspan");for(const ne of q)ne.setAttribute("x",String(B));return}const ue=e.value[c];if(!ue)return;const ae={...ue};if(ue.kind==="free"){const q=h.closest(".bc-annotations"),ne=parseFloat((q==null?void 0:q.getAttribute("data-ctx-width"))||"")||parseFloat(d.getAttribute("width")||"600"),j=parseFloat((q==null?void 0:q.getAttribute("data-ctx-height"))||"")||parseFloat(d.getAttribute("height")||"400"),X=ue.x,Z=ue.y;if(typeof X=="number")ae.x=+(X+G/ne*100).toFixed(1);else{const fe=String(X);fe.endsWith("px")?ae.x=`${Math.round(parseFloat(fe)+G)}px`:ae.x=+((parseFloat(fe)||0)+G/ne*100).toFixed(1)}if(typeof Z=="number")ae.y=+(Z+Y/j*100).toFixed(1);else{const fe=String(Z);fe.endsWith("px")?ae.y=`${Math.round(parseFloat(fe)+Y)}px`:ae.y=+((parseFloat(fe)||0)+Y/j*100).toFixed(1)}}else if(ue.kind==="point"){const q=ae.textOffsetX??-42,ne=ae.textOffsetY??-42;ae.textOffsetX=Math.round(q+G),ae.textOffsetY=Math.round(ne+Y)}o(c,ae)}r.addEventListener("pointerdown",ge),r.addEventListener("pointermove",Q),r.addEventListener("pointerup",re),i=()=>{be&&cancelAnimationFrame(be),r==null||r.removeEventListener("pointerdown",ge),r==null||r.removeEventListener("pointermove",Q),r==null||r.removeEventListener("pointerup",re)}}Ge(n,()=>{requestAnimationFrame(a)}),Ge(e,()=>{n.value!==null&&requestAnimationFrame(a)},{deep:!0}),Ta(s)}const nue={class:"d-flex flex-column gap-4"},oue=le({__name:"EditorAnnotateTab",setup(t){const e=dn(),{chartType:n,data:o,areaFills:r,seriesOverrides:i}=e,{currentOptions:s}=_n(),a=A(()=>s.value.interpolation??"linear"),{pendingAnnotationIndex:l}=Ct(cr()),{scenes:c,activeIndex:u,activeScene:d,update:f}=wn(),h=A(()=>u.value>=0),g=[Le.BarVertical,Le.BarHorizontal,Le.LineMulti,Le.AreaStacked],b=A(()=>g.includes(n.value)),m=A({get(){const $=e._base.annotations.value;if(u.value>=0){const F=Ra(c.value,u.value),V=(F==null?void 0:F.annotations)??[];return[...$,...V]}return $},set($){if(u.value>=0&&d.value){const F=new Set(e._base.annotations.value.map(K=>K.id).filter(Boolean)),V=$.filter(K=>K.id&&F.has(K.id)),U=$.filter(K=>!K.id||!F.has(K.id));e._base.annotations.value=V,f(u.value,{annotations:U.length>0?U:void 0});return}e._base.annotations.value=$}}),v=A(()=>{if(u.value<0)return;const $=Ra(c.value,u.value);return $==null?void 0:$.hiddenAnnotationIds});function y($,F){var se;if(u.value<0)return;const V=d.value;if(!V)return;const U=V.annotationVisibility??[];((se=v.value)==null?void 0:se.has($))?U.find(ce=>ce.id===$&&ce.action==="hide")?f(u.value,{annotationVisibility:U.filter(ce=>!(ce.id===$&&ce.action==="hide"))}):f(u.value,{annotationVisibility:[...U,{action:"show",kind:F,id:$}]}):U.find(ce=>ce.id===$&&ce.action==="show")?f(u.value,{annotationVisibility:U.filter(ce=>!(ce.id===$&&ce.action==="show"))}):f(u.value,{annotationVisibility:[...U,{action:"hide",kind:F,id:$}]})}const x=A(()=>n.value===Le.LineMulti),_=A(()=>fs(o.value)),k=A(()=>_.value.labels),E=A(()=>{var $;return(($=_.value.series)==null?void 0:$.map(F=>F.name))??[]}),B=Ve(null),S=A(()=>{var $;return(($=B.value)==null?void 0:$.openIndex)??null}),{containerRef:L}=HT(),D=Ie(600),I=Ie(400);function C(){var F;const $=(F=L.value)==null?void 0:F.querySelector("svg");$&&(D.value=parseFloat($.getAttribute("width")||"600")||600,I.value=parseFloat($.getAttribute("height")||"400")||400)}let T;un(()=>{C(),T=new ResizeObserver(C),L.value&&T.observe(L.value)}),Gs(()=>T==null?void 0:T.disconnect());function P($,F){const V=m.value.map(U=>({...U}));V[$]=F,m.value=V}return tue(L,m,S,P),Ge(l,async $=>{if($!==null&&(await xn(),B.value)){const F=typeof $=="string"?m.value.findIndex(V=>V.id===$):$;if(F<0){l.value=null;return}B.value.openIndex=B.value.openIndex===F?null:F,l.value=null}},{immediate:!0}),($,F)=>{const V=ece,U=Qle;return w(),R("div",nue,[p(b)?(w(),J(p(Fo),{key:0,title:"Highlight",icon:p(ace)},{default:te(()=>[H(V)]),_:1},8,["icon"])):ie("",!0),H(eue,{ref_key:"annotationsRef",ref:B,modelValue:p(m),"onUpdate:modelValue":F[0]||(F[0]=K=>Ze(m)?m.value=K:null),labels:p(k),"chart-type":p(n),"chart-width":p(D),"chart-height":p(I),"hidden-annotation-ids":p(v),"can-toggle-visibility":p(h),onToggleVisibility:y},null,8,["modelValue","labels","chart-type","chart-width","chart-height","hidden-annotation-ids","can-toggle-visibility"]),p(x)?(w(),J(p(Fo),{key:1,title:"Area Fills",icon:p(rce)},{default:te(()=>[H(U,{modelValue:p(r),"onUpdate:modelValue":F[1]||(F[1]=K=>Ze(r)?r.value=K:null),"series-names":p(E),"series-overrides":p(i),"global-interpolation":p(a)},null,8,["modelValue","series-names","series-overrides","global-interpolation"])]),_:1},8,["icon"])):ie("",!0)])}}}),rue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function iue(t,e){return w(),R("svg",rue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M243.31 136L144 36.69A15.86 15.86 0 0 0 132.69 32H40a8 8 0 0 0-8 8v92.69A15.86 15.86 0 0 0 36.69 144L136 243.31a16 16 0 0 0 22.63 0l84.68-84.68a16 16 0 0 0 0-22.63m-96 96L48 132.69V48h84.69L232 147.31ZM96 84a12 12 0 1 1-12-12a12 12 0 0 1 12 12"},null,-1)])])}const sue=Oe({name:"ph-tag",render:iue}),aue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function lue(t,e){return w(),R("svg",aue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M48 64a8 8 0 0 1 8-8h16V40a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16H88v16a8 8 0 0 1-16 0V72H56a8 8 0 0 1-8-8m136 128h-8v-8a8 8 0 0 0-16 0v8h-8a8 8 0 0 0 0 16h8v8a8 8 0 0 0 16 0v-8h8a8 8 0 0 0 0-16m56-48h-16v-16a8 8 0 0 0-16 0v16h-16a8 8 0 0 0 0 16h16v16a8 8 0 0 0 16 0v-16h16a8 8 0 0 0 0-16m-20.69-64L80 219.31a16 16 0 0 1-22.62 0l-20.7-20.68a16 16 0 0 1 0-22.63L176 36.69a16 16 0 0 1 22.63 0l20.68 20.68a16 16 0 0 1 0 22.63m-54.63 32L144 91.31l-96 96L68.68 208ZM208 68.69L187.31 48l-32 32L176 100.69Z"},null,-1)])])}const rb=Oe({name:"ph-magic-wand",render:lue}),cue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function uue(t,e){return w(),R("svg",cue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M205.66 138.34a8 8 0 0 1-11.32 11.32L136 91.31V224a8 8 0 0 1-16 0V91.31l-58.34 58.35a8 8 0 0 1-11.32-11.32l72-72a8 8 0 0 1 11.32 0ZM216 32H40a8 8 0 0 0 0 16h176a8 8 0 0 0 0-16"},null,-1)])])}const due=Oe({name:"ph-arrow-line-up",render:uue}),fue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function hue(t,e){return w(),R("svg",fue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M50.34 117.66a8 8 0 0 1 11.32-11.32L120 164.69V32a8 8 0 0 1 16 0v132.69l58.34-58.35a8 8 0 0 1 11.32 11.32l-72 72a8 8 0 0 1-11.32 0ZM216 208H40a8 8 0 0 0 0 16h176a8 8 0 0 0 0-16"},null,-1)])])}const pue=Oe({name:"ph-arrow-line-down",render:hue}),mue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function gue(t,e){return w(),R("svg",mue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 128a8 8 0 0 1-8 8H91.31l58.35 58.34a8 8 0 0 1-11.32 11.32l-72-72a8 8 0 0 1 0-11.32l72-72a8 8 0 0 1 11.32 11.32L91.31 120H224a8 8 0 0 1 8 8M40 32a8 8 0 0 0-8 8v176a8 8 0 0 0 16 0V40a8 8 0 0 0-8-8"},null,-1)])])}const vue=Oe({name:"ph-arrow-line-left",render:gue}),bue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function yue(t,e){return w(),R("svg",bue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M189.66 122.34a8 8 0 0 1 0 11.32l-72 72a8 8 0 0 1-11.32-11.32L164.69 136H32a8 8 0 0 1 0-16h132.69l-58.35-58.34a8 8 0 0 1 11.32-11.32ZM216 32a8 8 0 0 0-8 8v176a8 8 0 0 0 16 0V40a8 8 0 0 0-8-8"},null,-1)])])}const xue=Oe({name:"ph-arrow-line-right",render:yue}),wue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function _ue(t,e){return w(),R("svg",wue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 136v64a8 8 0 0 1-16 0v-44.68l-66.34 66.34a8 8 0 0 1-11.32-11.32L100.68 144H56a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8m80-104H80a16 16 0 0 0-16 16v48a8 8 0 0 0 16 0V48h128v128h-48a8 8 0 0 0 0 16h48a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16"},null,-1)])])}const ib=Oe({name:"ph-arrow-square-in",render:_ue}),kue={class:"d-flex flex-column gap-3"},Sue=le({__name:"EditorLegendSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("legend")),i=A(()=>n.value.includes("legendPosition")),s=A(()=>n.value.includes("legendAnchor")),a=A(()=>n.value.includes("directLabelling")),l=A(()=>a.value),c=A(()=>n.value.includes("directLabelAnchor")),u=A(()=>e.value.directLabelling?"direct":e.value.legend===!1?"none":"legend"),d=A(()=>{const v=[{value:"legend",text:"Legend",icon:ZA},{value:"none",text:"None",icon:cf}];return a.value&&v.splice(1,0,{value:"direct",text:"Direct labelling",icon:sue}),v});function f(v){v==="legend"?(o("legend",!0),o("directLabelling","")):v==="direct"?(o("legend",!1),o("directLabelling","auto")):(o("legend",!1),o("directLabelling",""))}const h=[{value:"auto",text:"Auto",icon:rb},{value:"outside",text:"Outside",icon:Fp},{value:"inside",text:"Inside",icon:ib}],g=[{value:"start",text:"Start",icon:af},{value:"middle",text:"Middle",icon:v0},{value:"end",text:"End",icon:lf}],b=[{value:"top",text:"Top",icon:due},{value:"bottom",text:"Bottom",icon:pue},{value:"left",text:"Left",icon:vue},{value:"right",text:"Right",icon:xue}],m=[{value:"start",text:"Start",icon:af},{value:"middle",text:"Middle",icon:v0},{value:"end",text:"End",icon:lf}];return(v,y)=>(w(),R("div",kue,[p(r)?(w(),J(p(Cn),{key:0,label:"Labels","model-value":p(u),options:p(d),block:"","onUpdate:modelValue":f},null,8,["model-value","options"])):ie("",!0),p(l)&&p(u)==="direct"?(w(),J(p(Cn),{key:1,label:"Direct label style","model-value":p(e).directLabelling||"auto",options:h,block:"","onUpdate:modelValue":y[0]||(y[0]=x=>p(o)("directLabelling",x))},null,8,["model-value"])):ie("",!0),p(c)&&p(u)==="direct"&&p(e).directLabelling==="inside"?(w(),J(p(Cn),{key:2,label:"Label anchor","model-value":p(e).directLabelAnchor||"middle",options:g,block:"","onUpdate:modelValue":y[1]||(y[1]=x=>p(o)("directLabelAnchor",x))},null,8,["model-value"])):ie("",!0),p(i)&&p(u)==="legend"?(w(),J(p(Cn),{key:3,label:"Legend position","model-value":p(e).legendPosition??"top",options:b,block:"","onUpdate:modelValue":y[2]||(y[2]=x=>p(o)("legendPosition",x))},null,8,["model-value"])):ie("",!0),p(s)&&p(u)==="legend"?(w(),J(p(Cn),{key:4,label:"Legend anchor","model-value":p(e).legendAnchor??"start",options:m,block:"","onUpdate:modelValue":y[3]||(y[3]=x=>p(o)("legendAnchor",x))},null,8,["model-value"])):ie("",!0)]))}}),Aue={class:"d-flex flex-column gap-3"},Cue={class:"pt-2"},$ue={class:"pt-2"},Tue={class:"pt-2"},Mue={class:"pt-2"},Oue=le({__name:"EditorLayoutSection",setup(t){const{layout:e}=dn(),n=A({get:()=>e.value.sizing,set:h=>{e.value.sizing=h}}),o=A({get:()=>e.value.heightMode,set:h=>{e.value.heightMode=h}}),r=A({get:()=>String(e.value.fixedWidth),set:h=>{e.value.fixedWidth=Number(h)||600}}),i=A({get:()=>String(e.value.fixedHeight),set:h=>{e.value.fixedHeight=Number(h)||400}}),s=A({get:()=>String(e.value.padding),set:h=>{e.value.padding=Number(h)||0}}),a=A({get:()=>e.value.aspectRatio,set:h=>{e.value.aspectRatio=h}}),l=A({get:()=>e.value.transparentBackground,set:h=>{e.value.transparentBackground=h}}),c=A({get:()=>String(e.value.maxWidth),set:h=>{e.value.maxWidth=Number(h)||660}}),u=[{value:"responsive",text:"Responsive"},{value:"max-width",text:"Max width"},{value:"fixed",text:"Fixed"}],d=[{value:"auto",text:"Auto"},{value:"fixed",text:"Fixed"},{value:"aspect-ratio",text:"Aspect ratio"}],f=[{value:"16:9",label:"16:9"},{value:"4:3",label:"4:3"},{value:"3:2",label:"3:2"},{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"9:16",label:"9:16"}];return(h,g)=>(w(),R("div",Aue,[H(p(Cn),{modelValue:p(n),"onUpdate:modelValue":g[2]||(g[2]=b=>Ze(n)?n.value=b:null),label:"Width",options:u,block:""},{"section:fixed":te(()=>[M("div",Cue,[H(p(xr),{id:"layout-fixed-width",modelValue:p(r),"onUpdate:modelValue":g[0]||(g[0]=b=>Ze(r)?r.value=b:null),label:"",min:"200",max:"1200",suffix:"px"},null,8,["modelValue"])])]),"section:max-width":te(()=>[M("div",$ue,[H(p(xr),{id:"layout-max-width",modelValue:p(c),"onUpdate:modelValue":g[1]||(g[1]=b=>Ze(c)?c.value=b:null),label:"",min:"200",max:"1200",suffix:"px"},null,8,["modelValue"])])]),_:1},8,["modelValue"]),H(p(Cn),{modelValue:p(o),"onUpdate:modelValue":g[5]||(g[5]=b=>Ze(o)?o.value=b:null),label:"Height",options:d,block:""},{"section:fixed":te(()=>[M("div",Tue,[H(p(xr),{id:"layout-fixed-height",modelValue:p(i),"onUpdate:modelValue":g[3]||(g[3]=b=>Ze(i)?i.value=b:null),label:"",min:"100",max:"800",suffix:"px"},null,8,["modelValue"])])]),"section:aspect-ratio":te(()=>[M("div",Mue,[H(p(En),{id:"layout-aspect-ratio",modelValue:p(a),"onUpdate:modelValue":g[4]||(g[4]=b=>Ze(a)?a.value=b:null),options:f,block:""},null,8,["modelValue"])])]),_:1},8,["modelValue"]),H(p(xr),{id:"layout-padding",modelValue:p(s),"onUpdate:modelValue":g[6]||(g[6]=b=>Ze(s)?s.value=b:null),label:"Padding",min:"0",max:"80",suffix:"px"},null,8,["modelValue"]),H(p(nn),{modelValue:p(l),"onUpdate:modelValue":g[7]||(g[7]=b=>Ze(l)?l.value=b:null),label:"Transparent background"},null,8,["modelValue"])]))}}),Bue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Lue(t,e){return w(),R("svg",Bue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M80 64a8 8 0 0 1 8-8h128a8 8 0 0 1 0 16H88a8 8 0 0 1-8-8m136 56H88a8 8 0 0 0 0 16h128a8 8 0 0 0 0-16m0 64H88a8 8 0 0 0 0 16h128a8 8 0 0 0 0-16M44 52a12 12 0 1 0 12 12a12 12 0 0 0-12-12m0 64a12 12 0 1 0 12 12a12 12 0 0 0-12-12m0 64a12 12 0 1 0 12 12a12 12 0 0 0-12-12"},null,-1)])])}const Pue=Oe({name:"ph-list-bullets",render:Lue}),Due={class:"d-flex flex-column gap-4"},Eue=le({__name:"EditorLayoutTab",setup(t){const{availableOptionKeys:e}=_n(),n=A(()=>e.value.includes("legend"));return(o,r)=>{const i=Oue,s=Sue;return w(),R("div",Due,[H(i),p(n)?(w(),J(p(Fo),{key:0,title:"Legend",icon:p(Pue)},{default:te(()=>[H(s)]),_:1},8,["icon"])):ie("",!0)])}}}),Nue={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Iue(t,e){return w(),R("svg",Nue,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M239.24 131.4c-22 46.8-41.4 68.6-61.2 68.6c-25.1 0-40.73-33.32-57.28-68.6C107.7 103.56 92.9 72 78 72c-16.4 0-36.31 37.21-46.72 59.4a8 8 0 0 1-14.48-6.8C38.71 77.8 58.16 56 78 56c25.1 0 40.73 33.32 57.28 68.6C148.3 152.44 163.1 184 178 184c16.4 0 36.31-37.21 46.72-59.4a8 8 0 0 1 14.48 6.8Z"},null,-1)])])}const Rue=Oe({name:"ph-wave-sine",render:Iue}),Fue={key:0,class:"d-flex flex-column gap-4"},Vue={class:"d-flex flex-column gap-2"},zue={key:1,class:"text-muted small"},Hue=le({__name:"EditorAxisOptions",setup(t){const e=A(()=>l.value.includes("valueLabels")),n=A(()=>l.value.includes("swapLabelValue")),o=[{value:"auto",text:"Auto",icon:rb},{value:"outside",text:"Outside",icon:Fp},{value:"inside",text:"Inside",icon:ib}],r=new Set(["showVerticalAxis","verticalAxisDirection","showVerticalTicks","verticalLabelPosition","verticalGridStyle","verticalNumberFormat","verticalScaleType","verticalRangeMin","verticalRangeMax"]),i=new Set(["showHorizontalAxis","showHorizontalTicks","horizontalLabelPosition","horizontalGridStyle","horizontalNumberFormat","horizontalScaleType","horizontalRangeMin","horizontalRangeMax"]),{currentOptions:s,optionDefs:a,availableOptionKeys:l,setOption:c}=_n();function u(T,P){c(T,P)}const{displayColumnTypes:d}=jo(),f=A(()=>d.value[0]??"string"),h=A(()=>d.value[1]??"number"),g=A(()=>a.value.some(T=>T.key==="verticalScaleType"));function b(T){return T.replace(/^(Show\s+)?(vertical|horizontal)\s+/i,(P,$)=>$??"").replace(/^./,P=>P.toUpperCase())}function m(T){return(T?!g.value:g.value)?h.value:f.value}function v(T,P){if(T.type!=="numberFormat")return T;const $=m(P);return $==="date"?{...T,type:"dateFormat",label:T.label.replace(/number\s+format/i,"Date format")}:$==="string"?{...T,type:"__hidden"}:T}const y=A(()=>a.value.filter(T=>r.has(T.key)).map(T=>v({...T,label:b(T.label)},!1)).filter(T=>T.type!=="__hidden")),x=A(()=>a.value.filter(T=>i.has(T.key)).map(T=>v({...T,label:b(T.label)},!0)).filter(T=>T.type!=="__hidden")),_={solid:q2,dashed:VT,dotted:zT,none:cf},k={auto:rb,inside:ib,outside:Fp,off:cf},E={left:af,right:lf},B={linear:rd,log:Rue},S={verticalGridStyle:_,horizontalGridStyle:_,verticalLabelPosition:k,horizontalLabelPosition:k,verticalAxisDirection:E,verticalScaleType:B,horizontalScaleType:B},L=(T,{emit:P})=>{const{def:$,value:F}=T;if($.type==="boolean")return Vt(nn,{label:$.label,modelValue:F??$.default??!1,"onUpdate:modelValue":V=>P("update",V)});if($.type==="select"&&$.choices){const V=S[$.key],U=$.choices.map(K=>({value:K.value,text:K.text,...V!=null&&V[K.value]?{icon:V[K.value]}:{}}));return Vt(Cn,{label:$.label,options:U,block:!0,modelValue:F??$.default??"","onUpdate:modelValue":K=>P("update",K)})}return $.type==="text"?Vt(wm,{label:$.label,id:`opt-${$.key}`,placeholder:$.placeholder??"",modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):$.type==="numberFormat"?Vt(FV,{label:$.label,id:`opt-${$.key}`,modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):$.type==="dateFormat"?Vt(TH,{label:$.label,id:`opt-${$.key}`,modelValue:F??"","onUpdate:modelValue":V=>P("update",V)}):null};L.props=["def","value"],L.emits=["update"];function D(T){return T.endsWith("RangeMin")}function I(T){return T.endsWith("RangeMax")}const C=(T,{emit:P})=>{const $=[],{defs:F,currentOptions:V}=T;let U=0;for(;U<F.length;){const K=F[U];if(D(K.key)&&U+1<F.length&&I(F[U+1].key)){const se=F[U+1];$.push(Vt("div",{class:"d-flex gap-2",key:K.key},[Vt("div",{class:"flex-fill",style:"min-width:0"},[Vt(L,{def:K,value:V[K.key],onUpdate:he=>P("update",K.key,he)})]),Vt("div",{class:"flex-fill",style:"min-width:0"},[Vt(L,{def:se,value:V[se.key],onUpdate:he=>P("update",se.key,he)})])])),U+=2}else $.push(Vt(L,{key:K.key,def:K,value:V[K.key],onUpdate:se=>P("update",K.key,se)})),U++}return Vt("div",{class:"d-flex flex-column gap-2"},$)};return C.props=["defs","currentOptions"],C.emits=["update"],(T,P)=>p(e)||p(y).length>0||p(x).length>0?(w(),R("div",Fue,[p(e)?(w(),J(p(Fo),{key:0,title:"Value Labels",icon:p(ET)},{default:te(()=>[M("div",Vue,[H(p(nn),{"model-value":p(s).valueLabels??!1,label:"Show value labels","onUpdate:modelValue":P[0]||(P[0]=$=>u("valueLabels",$))},null,8,["model-value"]),p(s).valueLabels?(w(),J(p(Cn),{key:0,label:"Position","model-value":p(s).valueLabelPosition??"auto",options:o,block:"","onUpdate:modelValue":P[1]||(P[1]=$=>u("valueLabelPosition",$))},null,8,["model-value"])):ie("",!0),p(s).valueLabels&&p(n)?(w(),J(p(nn),{key:1,"model-value":p(s).swapLabelValue??!1,label:"Swap labels and values","onUpdate:modelValue":P[2]||(P[2]=$=>u("swapLabelValue",$))},null,8,["model-value"])):ie("",!0)])]),_:1},8,["icon"])):ie("",!0),p(y).length>0?(w(),J(p(Fo),{key:1,title:"Vertical Axis",icon:p(RT)},{default:te(()=>[H(C,{defs:p(y),"current-options":p(s),onUpdate:u},null,8,["defs","current-options"])]),_:1},8,["icon"])):ie("",!0),p(x).length>0?(w(),J(p(Fo),{key:2,title:"Horizontal Axis",icon:p(FT)},{default:te(()=>[H(C,{defs:p(x),"current-options":p(s),onUpdate:u},null,8,["defs","current-options"])]),_:1},8,["icon"])):ie("",!0)])):(w(),R("p",zue," No axis options for this chart type. "))}}),Wue={class:"d-flex flex-column gap-3"},UT=le({__name:"EditorSymbolOptions",props:{shape:{},showOn:{},style:{},size:{},opacity:{},idPrefix:{default:"symbol"}},emits:["update:shape","update:showOn","update:style","update:size","update:opacity"],setup(t){const e=[{value:"circle",text:"Circle"},{value:"square",text:"Square"},{value:"diamond",text:"Diamond"},{value:"triangle",text:"Triangle Up"},{value:"triangleDown",text:"Triangle Down"},{value:"cross",text:"Cross"},{value:"star",text:"Star"}],n=[{value:"firstLast",text:"First & Last"},{value:"first",text:"First"},{value:"last",text:"Last"},{value:"all",text:"All"}],o=[{value:"filled",text:"Filled"},{value:"hollow",text:"Hollow"}];return(r,i)=>{const s=Ga,a=Mn;return w(),R("div",Wue,[H(a,{label:"Symbol","label-for":`${t.idPrefix}-shape`},{default:te(()=>[H(s,{id:`${t.idPrefix}-shape`,"model-value":t.shape,options:e,"onUpdate:modelValue":i[0]||(i[0]=l=>r.$emit("update:shape",l))},null,8,["id","model-value"])]),_:1},8,["label-for"]),H(p(Cn),{label:"Show on","model-value":t.showOn,options:n,"onUpdate:modelValue":i[1]||(i[1]=l=>r.$emit("update:showOn",l))},null,8,["model-value"]),H(p(Cn),{label:"Style","model-value":t.style,options:o,"onUpdate:modelValue":i[2]||(i[2]=l=>r.$emit("update:style",l))},null,8,["model-value"]),H(p(xr),{id:`${t.idPrefix}-size`,label:"Size","model-value":t.size,min:"0.5",max:"10",step:"0.5","onUpdate:modelValue":i[3]||(i[3]=l=>r.$emit("update:size",l))},null,8,["id","model-value"]),H(p(xr),{id:`${t.idPrefix}-opacity`,label:"Opacity","model-value":t.opacity,min:"0",max:"1",step:"0.1","onUpdate:modelValue":i[4]||(i[4]=l=>r.$emit("update:opacity",l))},null,8,["id","model-value"])])}}}),Uue={class:"d-flex flex-column gap-3"},Gue={class:"d-flex gap-2 justify-content-end"},que=le({__name:"EditorSeriesOptions",props:{selected:{},overrides:{},colors:{},chartType:{}},emits:["update:overrides"],setup(t,{emit:e}){const n=t,o=e;function r(C){return n.overrides.find(T=>T.name===C)}function i(){return n.selected.length>0?r(n.selected[0]):void 0}const s=A(()=>n.chartType==="bar-multi"),a=A(()=>n.chartType==="line-multi"),l=A(()=>{var C;return((C=i())==null?void 0:C.color)??"#4e79a7"}),c=A(()=>{var C;return String(((C=i())==null?void 0:C.opacity)??1)}),u=A(()=>{var C;return String(((C=i())==null?void 0:C.lineWidth)??2)}),d=A(()=>{var C;return((C=i())==null?void 0:C.dash)??"solid"}),f=A(()=>{var C;return((C=i())==null?void 0:C.interpolation)??"global"}),h=A(()=>{var C;return((C=i())==null?void 0:C.labelMode)??"global"}),g=A(()=>{var C;return((C=i())==null?void 0:C.valueLabels)??!1}),b=A(()=>{var C;return((C=i())==null?void 0:C.lineSymbols)??!1}),m=A(()=>{var C;return((C=i())==null?void 0:C.symbolShape)??"circle"}),v=A(()=>{var C;return((C=i())==null?void 0:C.symbolShowOn)??"firstLast"}),y=A(()=>{var C;return((C=i())==null?void 0:C.symbolStyle)??"filled"}),x=A(()=>{var C;return String(((C=i())==null?void 0:C.symbolSize)??3.5)}),_=A(()=>{var C;return String(((C=i())==null?void 0:C.symbolOpacity)??1)});function k(C,T){const P=n.overrides.map($=>({...$}));for(const $ of n.selected){let F=P.find(V=>V.name===$);F||(F={name:$},P.push(F)),F[C]=T}o("update:overrides",P)}function E(){if(n.selected.length<2)return;const C=r(n.selected[0]);if(!C)return;const T=n.overrides.map(P=>({...P}));for(let P=1;P<n.selected.length;P++){const $=n.selected[P];let F=T.find(V=>V.name===$);F||(F={name:$},T.push(F)),Object.assign(F,{...C,name:$})}o("update:overrides",T)}function B(){const C=new Set(n.selected),T=n.overrides.filter(P=>!C.has(P.name));o("update:overrides",T)}const S=[{value:"1",text:"1"},{value:"2",text:"2"},{value:"3",text:"3"},{value:"4",text:"4"},{value:"5",text:"5"}],L=[{value:"solid",text:"Solid"},{value:"dotted",text:"Dotted"},{value:"dashed",text:"Dashed"},{value:"dash-dot",text:"Dash-dot"}],D=[{value:"global",text:"Global"},{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}],I=[{value:"global",text:"Global"},{value:"legend",text:"Legend"},{value:"direct",text:"Direct"},{value:"none",text:"None"}];return(C,T)=>{const P=Ga,$=Mn,F=UT,V=Vo;return w(),R("div",Uue,[H(p(Pa),{id:"series-color",label:"Color","model-value":p(l),"onUpdate:modelValue":T[0]||(T[0]=U=>k("color",U))},null,8,["model-value"]),H(p(Cn),{label:"Label mode","model-value":p(h),options:I,block:"","onUpdate:modelValue":T[1]||(T[1]=U=>k("labelMode",U))},null,8,["model-value"]),H(p(nn),{"model-value":p(g),label:"Value labels","onUpdate:modelValue":T[2]||(T[2]=U=>k("valueLabels",U))},null,8,["model-value"]),p(s)?(w(),J(p(xr),{key:0,id:"series-opacity",label:"Opacity","model-value":p(c),min:"0",max:"1",step:"0.1","onUpdate:modelValue":T[3]||(T[3]=U=>k("opacity",Number(U)))},null,8,["model-value"])):ie("",!0),p(a)?(w(),R(He,{key:1},[H(p(Cn),{label:"Line width","model-value":p(u),options:S,"onUpdate:modelValue":T[4]||(T[4]=U=>k("lineWidth",Number(U)))},null,8,["model-value"]),H(p(Cn),{label:"Dash style","model-value":p(d),options:L,"onUpdate:modelValue":T[5]||(T[5]=U=>k("dash",U))},null,8,["model-value"]),H($,{label:"Interpolation","label-for":"series-interpolation"},{default:te(()=>[H(P,{id:"series-interpolation","model-value":p(f),options:D,"onUpdate:modelValue":T[6]||(T[6]=U=>k("interpolation",U))},null,8,["model-value"])]),_:1}),H(p(nn),{"model-value":p(b),label:"Line symbols","onUpdate:modelValue":T[7]||(T[7]=U=>k("lineSymbols",U))},null,8,["model-value"]),p(b)?(w(),J(F,{key:0,"id-prefix":"series-symbol",shape:p(m),"show-on":p(v),style:Et(p(y)),size:p(x),opacity:p(_),"onUpdate:shape":T[8]||(T[8]=U=>k("symbolShape",U)),"onUpdate:showOn":T[9]||(T[9]=U=>k("symbolShowOn",U)),"onUpdate:style":T[10]||(T[10]=U=>k("symbolStyle",U)),"onUpdate:size":T[11]||(T[11]=U=>k("symbolSize",Number(U))),"onUpdate:opacity":T[12]||(T[12]=U=>k("symbolOpacity",Number(U)))},null,8,["shape","show-on","style","size","opacity"])):ie("",!0)],64)):ie("",!0),M("div",Gue,[t.selected.length>1?(w(),J(V,{key:0,variant:"outline-secondary",size:"sm",onClick:E},{default:te(()=>[...T[13]||(T[13]=[Ye(" Copy from first ",-1)])]),_:1})):ie("",!0),H(V,{variant:"outline-danger",size:"sm",onClick:B},{default:te(()=>[...T[14]||(T[14]=[Ye(" Reset to default ",-1)])]),_:1})])])}}}),Yue=le({__name:"EditorSeriesList",props:{seriesNames:{},selected:{},colors:{},overrides:{}},emits:["update:selected","toggleVisibility"],setup(t){const e=t;function n(r,i){return an(r,i,e.colors,e.overrides)}function o(r){return Ja(r,e.overrides)}return(r,i)=>{const s=Rs;return w(),J(p(Vy),{items:t.seriesNames,selected:t.selected,"onUpdate:selected":i[1]||(i[1]=a=>r.$emit("update:selected",a))},{"item-leading":te(({item:a,index:l})=>[H(p(xm),{color:n(a,l)},null,8,["color"])]),"item-actions":te(({item:a})=>[H(s,{"model-value":!o(a),switch:"",size:"sm",onClick:i[0]||(i[0]=pn(()=>{},["stop"])),"onUpdate:modelValue":l=>r.$emit("toggleVisibility",a,!l)},null,8,["model-value","onUpdate:modelValue"])]),_:1},8,["items","selected"])}}}),jue={class:"d-flex flex-column gap-3"},Xue=le({__name:"EditorSeriesPanel",setup(t){const{chartType:e,data:n,seriesOverrides:o}=dn(),{currentOptions:r}=_n(),i=Ve([]),s=A(()=>{var u;return((u=fs(n.value).series)==null?void 0:u.map(d=>d.name))??[]}),a=A(()=>U$(r.value).colors??["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"]);function l(c,u){const d=o.value.map(h=>({...h}));let f=d.find(h=>h.name===c);f||(f={name:c},d.push(f)),f.hidden=u,o.value=d}return(c,u)=>{const d=Yue,f=que;return w(),R("div",jue,[u[2]||(u[2]=M("h6",{class:"fw-bold mb-0"}," Series ",-1)),H(d,{"series-names":p(s),selected:p(i),colors:p(a),overrides:p(o),"onUpdate:selected":u[0]||(u[0]=h=>i.value=h),onToggleVisibility:l},null,8,["series-names","selected","colors","overrides"]),p(i).length>0?(w(),J(p(Ad),{key:0,label:"Editing "+p(i).length+" "+(p(i).length===1?"series: "+p(i)[0]:"series")},{default:te(()=>[H(f,{selected:p(i),overrides:p(o),colors:p(a),"chart-type":p(e),"onUpdate:overrides":u[1]||(u[1]=h=>o.value=h)},null,8,["selected","overrides","colors","chart-type"])]),_:1},8,["label"])):ie("",!0)])}}}),Kue={class:"d-flex flex-column gap-3"},Zue={class:"bc-area-stack-options"},Que=le({__name:"EditorAreaSection",setup(t){const{currentOptions:e,setOption:n}=_n(),o=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}],r=[{value:"none",text:"Keep order"},{value:"ascending",text:"Smallest first"},{value:"descending",text:"Largest first"}];return(i,s)=>{const a=Ga,l=Mn,c=KD,u=Rs;return w(),R("div",Kue,[H(p(xr),{id:"opt-area-opacity","model-value":String(p(e).areaFillOpacity??"0.85"),label:"Opacity",min:"0",max:"1",step:"0.05","onUpdate:modelValue":s[0]||(s[0]=d=>p(n)("areaFillOpacity",d))},null,8,["model-value"]),H(l,{label:"Interpolation","label-for":"opt-area-interpolation"},{default:te(()=>[H(a,{id:"opt-area-interpolation","model-value":p(e).interpolation??"monotoneX",options:o,"onUpdate:modelValue":s[1]||(s[1]=d=>p(n)("interpolation",String(d)))},null,8,["model-value"])]),_:1}),H(l,{label:"Sort areas"},{default:te(()=>[H(c,{"model-value":p(e).areaSortMode??"none",options:r,stacked:"","onUpdate:modelValue":s[2]||(s[2]=d=>p(n)("areaSortMode",String(d)))},null,8,["model-value"])]),_:1}),H(p(nn),{"model-value":p(e).stacked!==!1,label:"Stack areas","onUpdate:modelValue":s[5]||(s[5]=d=>p(n)("stacked",d))},{section:te(()=>[M("div",Zue,[H(u,{"model-value":p(e).stackPercent??!1,"onUpdate:modelValue":s[3]||(s[3]=d=>p(n)("stackPercent",d))},{default:te(()=>[...s[6]||(s[6]=[Ye(" Stack to 100% ",-1)])]),_:1},8,["model-value"]),H(u,{"model-value":p(e).areaLines!==!1,"onUpdate:modelValue":s[4]||(s[4]=d=>p(n)("areaLines",d))},{default:te(()=>[...s[7]||(s[7]=[Ye(" Separate areas with lines ",-1)])]),_:1},8,["model-value"])])]),_:1},8,["model-value"])])}}}),Jue=Be(Que,[["__scopeId","data-v-3bf56010"]]),ede={class:"d-flex flex-column gap-3"},tde=le({__name:"EditorSliceSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n();function r(i){return n.value.includes(i)}return(i,s)=>{const a=ea,l=Mn;return w(),R("div",ede,[r("displayAsPercentage")?(w(),J(p(nn),{key:0,"model-value":p(e).displayAsPercentage??!1,label:"Display as percentage","onUpdate:modelValue":s[0]||(s[0]=c=>p(o)("displayAsPercentage",c))},null,8,["model-value"])):ie("",!0),r("showTotal")?(w(),J(p(nn),{key:1,"model-value":p(e).showTotal??!1,label:"Show total","onUpdate:modelValue":s[1]||(s[1]=c=>p(o)("showTotal",c))},null,8,["model-value"])):ie("",!0),r("showLabels")?(w(),J(p(nn),{key:2,"model-value":p(e).showLabels??!0,label:"Show labels","onUpdate:modelValue":s[2]||(s[2]=c=>p(o)("showLabels",c))},null,8,["model-value"])):ie("",!0),r("showValues")?(w(),J(p(nn),{key:3,"model-value":p(e).showValues??!0,label:"Show values","onUpdate:modelValue":s[3]||(s[3]=c=>p(o)("showValues",c))},null,8,["model-value"])):ie("",!0),r("sliceMax")?(w(),J(p(xr),{key:4,id:"opt-sliceMax",label:"Max slices","model-value":p(e).sliceMax??"6",min:"2",max:"20","onUpdate:modelValue":s[4]||(s[4]=c=>p(o)("sliceMax",String(c)))},null,8,["model-value"])):ie("",!0),r("sliceGroupLabel")?(w(),J(l,{key:5,label:"Group label","label-for":"opt-sliceGroupLabel"},{default:te(()=>[H(a,{id:"opt-sliceGroupLabel","model-value":p(e).sliceGroupLabel??"Others",placeholder:"Others","onUpdate:modelValue":s[5]||(s[5]=c=>p(o)("sliceGroupLabel",c))},null,8,["model-value"])]),_:1})):ie("",!0)])}}}),nde={class:"d-flex flex-column gap-3"},K6=.15,ode=le({__name:"EditorBarStyleSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("barBackground")),i=A(()=>n.value.includes("barSeparators")),s=A(()=>n.value.includes("barGap")),a=A(()=>n.value.includes("connectedColumns")),l=A(()=>n.value.includes("waterfall")),c=A(()=>n.value.includes("waterfallTotal")),u=A(()=>n.value.includes("categoryLabelLine"));function d(y){return Math.max(0,Math.min(100,y))}const f=A(()=>{const y=parseFloat(e.value.barGap??""),x=isNaN(y)?ef:y;return String(d(x))});function h(y){const x=parseFloat(y),_=isNaN(x)?ef:x;o("barGap",String(d(_)))}function g(y){const x=parseFloat(y??""),_=isNaN(x)?K6:x,k=Math.max(0,Math.min(1,_));return String(Math.round(k*100))}function b(y){const x=parseFloat(y);if(isNaN(x))return String(K6);const _=Math.max(0,Math.min(100,x));return String(_/100)}const m=A(()=>g(e.value.connectionsOpacity));function v(y){o("connectionsOpacity",b(y))}return(y,x)=>(w(),R("div",nde,[p(r)?(w(),J(p(nn),{key:0,"model-value":p(e).barBackground??!1,label:"Bar background","onUpdate:modelValue":x[0]||(x[0]=_=>p(o)("barBackground",_))},null,8,["model-value"])):ie("",!0),p(i)?(w(),J(p(nn),{key:1,"model-value":p(e).barSeparators??!1,label:"Bar separators","onUpdate:modelValue":x[1]||(x[1]=_=>p(o)("barSeparators",_))},null,8,["model-value"])):ie("",!0),p(s)?(w(),J(p(xr),{key:2,id:"opt-bar-gap","model-value":p(f),label:"Bar gap",min:"0",max:"100",step:"1",suffix:"%","onUpdate:modelValue":h},null,8,["model-value"])):ie("",!0),p(a)?(w(),J(p(nn),{key:3,"model-value":p(e).connectedColumns??!1,label:"Connected columns","onUpdate:modelValue":x[2]||(x[2]=_=>p(o)("connectedColumns",_))},null,8,["model-value"])):ie("",!0),p(a)&&p(e).connectedColumns?(w(),J(p(xr),{key:4,id:"opt-connections-opacity","model-value":p(m),label:"Opacity",min:"0",max:"100",step:"1",suffix:"%","onUpdate:modelValue":v},null,8,["model-value"])):ie("",!0),p(l)?(w(),J(p(nn),{key:5,"model-value":p(e).waterfall??!1,label:"Waterfall","onUpdate:modelValue":x[3]||(x[3]=_=>p(o)("waterfall",_))},null,8,["model-value"])):ie("",!0),p(c)&&p(e).waterfall?(w(),J(p(nn),{key:6,"model-value":p(e).waterfallTotal??!1,label:"Waterfall total","onUpdate:modelValue":x[4]||(x[4]=_=>p(o)("waterfallTotal",_))},null,8,["model-value"])):ie("",!0),p(u)?(w(),J(p(nn),{key:7,"model-value":p(e).categoryLabelLine??!1,label:"Labels on separate line","onUpdate:modelValue":x[5]||(x[5]=_=>p(o)("categoryLabelLine",_))},null,8,["model-value"])):ie("",!0)]))}}),rde={class:"d-flex flex-column gap-3"},ide=le({__name:"EditorLineSymbols",setup(t){const{currentOptions:e,setOption:n}=_n();return(o,r)=>{const i=UT;return w(),R("div",rde,[H(p(nn),{"model-value":p(e).lineSymbols??!1,label:"Show line symbols","onUpdate:modelValue":r[0]||(r[0]=s=>p(n)("lineSymbols",s))},null,8,["model-value"]),p(e).lineSymbols?(w(),J(i,{key:0,"id-prefix":"opt-line-symbol",shape:p(e).lineSymbolShape??"circle","show-on":p(e).lineSymbolShowOn??"firstLast",style:Et(p(e).lineSymbolStyle??"filled"),size:p(e).lineSymbolSize??"3.5",opacity:p(e).lineSymbolOpacity??"1","onUpdate:shape":r[1]||(r[1]=s=>p(n)("lineSymbolShape",s)),"onUpdate:showOn":r[2]||(r[2]=s=>p(n)("lineSymbolShowOn",s)),"onUpdate:style":r[3]||(r[3]=s=>p(n)("lineSymbolStyle",s)),"onUpdate:size":r[4]||(r[4]=s=>p(n)("lineSymbolSize",s)),"onUpdate:opacity":r[5]||(r[5]=s=>p(n)("lineSymbolOpacity",s))},null,8,["shape","show-on","style","size","opacity"])):ie("",!0)])}}}),sde={class:"d-flex flex-column gap-3"},ade=le({__name:"EditorLineSection",setup(t){const{currentOptions:e,availableOptionKeys:n,setOption:o}=_n(),r=A(()=>n.value.includes("interpolation")),i=A(()=>n.value.includes("edgePadding")),s=A(()=>n.value.includes("lineSymbols")),a=[{value:"linear",text:"Linear"},{value:"monotoneX",text:"Monotone"},{value:"step",text:"Step"},{value:"stepBefore",text:"Step (before)"},{value:"stepAfter",text:"Step (after)"},{value:"basis",text:"Basis"},{value:"cardinal",text:"Cardinal"},{value:"catmullRom",text:"Catmull-Rom"}];return(l,c)=>{const u=Ga,d=Mn,f=ide;return w(),R("div",sde,[p(r)?(w(),J(d,{key:0,label:"Line interpolation","label-for":"opt-interpolation"},{default:te(()=>[H(u,{id:"opt-interpolation","model-value":p(e).interpolation??"linear",options:a,"onUpdate:modelValue":c[0]||(c[0]=h=>p(o)("interpolation",h))},null,8,["model-value"])]),_:1})):ie("",!0),p(i)?(w(),J(p(nn),{key:1,"model-value":p(e).edgePadding??!1,label:"Edge padding","onUpdate:modelValue":c[1]||(c[1]=h=>p(o)("edgePadding",h))},null,8,["model-value"])):ie("",!0),p(s)?(w(),J(f,{key:2})):ie("",!0)])}}}),lde={class:"d-flex flex-column gap-3"},cde=le({__name:"EditorBarAppearance",props:{labels:{},colorizes:{},baseColor:{}},emits:["update:colorizes","update:baseColor"],setup(t,{emit:e}){const n=t,o=e,r=Ve([]),i=Ie(n.colorizes.length>0),s=A(()=>{const h=new Map;for(const g of n.colorizes)h.set(g.target,g.color);return h});function a(h){return s.value.get(h)??n.baseColor}const l=A(()=>r.value.length===0?n.baseColor:s.value.get(r.value[0])??n.baseColor);function c(h,g,b){b.ctrlKey||b.metaKey?r.value.indexOf(h)>=0?r.value=r.value.filter(v=>v!==h):r.value=[...r.value,h]:r.value.length===1&&r.value[0]===h?r.value=[]:r.value=[h]}function u(h){const g=new Map(n.colorizes.map(b=>[b.target,b]));for(const b of r.value)g.set(b,{target:b,color:h,label:""});o("update:colorizes",[...g.values()])}function d(){o("update:colorizes",[]),r.value=[]}function f(h){i.value=h,h||(o("update:colorizes",[]),r.value=[])}return(h,g)=>(w(),R("div",lde,[H(p(Pa),{id:"bar-base-color",label:"Base color","model-value":t.baseColor,"onUpdate:modelValue":g[0]||(g[0]=b=>h.$emit("update:baseColor",b))},null,8,["model-value"]),H(p(nn),{"model-value":p(i),label:"Customize colors","onUpdate:modelValue":f},null,8,["model-value"]),p(i)?(w(),R(He,{key:0},[H(p(Vy),{items:t.labels,selected:p(r),"on-item-click":c,"onUpdate:selected":g[1]||(g[1]=b=>r.value=b)},{"item-leading":te(({item:b})=>[H(p(xm),{color:a(b)},null,8,["color"])]),_:1},8,["items","selected"]),p(r).length>0?(w(),J(p(Ad),{key:0,label:"Editing "+p(r).length+" "+(p(r).length===1?"label":"labels")},{default:te(()=>[H(p(Pa),{id:"bar-highlight-color",label:"Color for selected","model-value":p(l),"onUpdate:modelValue":u},null,8,["model-value"]),t.colorizes.length>0?(w(),J(p(Vo),{key:0,variant:"outline-danger",size:"sm",onClick:d},{default:te(()=>[...g[2]||(g[2]=[Ye(" Reset all changes ",-1)])]),_:1})):ie("",!0)]),_:1},8,["label"])):ie("",!0)],64)):ie("",!0)]))}}),ude=Oo("cvdMode",()=>({cvdMode:Ie("")}));function GT(){const t=ude(),{cvdMode:e}=Ct(t);return{cvdMode:e}}const dde="#ffffff",fde="#1a1a1a",hde={protanopia:"Protan",deuteranopia:"Deutan",tritanopia:"Tritan"};function Z6(t,e,n){const r=(n?o$(t,e):t).map(s=>mte(s,e)),i=Math.min(...r);return{level:gte(i),ratio:`${i.toFixed(1)}:1`}}function pde(t,e,n){const o=A(()=>{const s=gt(t);return s.length===0?null:Z6(s,dde,gt(e))}),r=A(()=>{const s=gt(t);return s.length===0||!gt(n)?null:Z6(s,fde,gt(e))}),i=A(()=>{const s=gt(t);if(s.length===0)return null;const a=s.length>=2?ioe(s):[];return a.length===0?{safe:!0,issues:[]}:{safe:!1,issues:a.map(l=>({type:l.type,shortLabel:hde[l.type],tooltip:`${l.label}: ${l.pairs.length} color ${l.pairs.length===1?"pair":"pairs"} may be hard to distinguish.`}))}});return{lightContrastInfo:o,darkContrastInfo:r,cvdInfo:i}}const mde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#2563A0" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#D4A63A" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#C94044" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},gde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#4767a2" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#baa62a" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#655e43" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},vde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#345b9f" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#c5b23f" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#887c40" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},bde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="5.30" y="9.00" width="11.22" height="25.00" fill="#00717a" rx="0.5"/><rect x="17.77" y="14.00" width="11.22" height="20.00" fill="#e69790" rx="0.5"/><rect x="30.23" y="4.00" width="11.22" height="30.00" fill="#dc1a43" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},yde={class:"d-flex flex-column gap-3"},xde={key:4,class:"d-flex align-items-center gap-2"},wde={key:5,class:"d-flex align-items-center gap-2"},_de={key:6,class:"d-flex align-items-center gap-2"},kde=le({__name:"EditorColorSection",setup(t){const{chartType:e,data:n,colorizes:o}=dn(),{currentOptions:r,availableOptionKeys:i,setOption:s}=_n(),{cvdMode:a}=Ct(GT()),l=A(()=>[Le.BarVertical,Le.BarHorizontal,Le.VerticalBar,Le.HorizontalBar].includes(e.value)),c=A(()=>i.value.includes("colors")),u=A(()=>i.value.includes("colorPalette")),d=A(()=>fs(n.value)),f=A(()=>d.value.labels),h=A(()=>{const L=r.value.colorPalette;return L?QC(L)??[]:r.value.colors??[]}),g=A(()=>h.value[0]??"#4e79a7");function b(L){r.value.colorPalette&&s("colorPalette",""),s("colors",[L])}const m=A(()=>{if(l.value){const L=o.value.map(I=>I.color),D=g.value;return L.length>0?[D,...L]:[D]}return h.value}),{lightContrastInfo:v,darkContrastInfo:y,cvdInfo:x}=pde(m,()=>!!r.value.autoContrast,()=>r.value.allowDarkMode??!0),_=ft("cvdSafeBadgeRef"),k=ft("cvdBadgeRefs");function E(L){var I;const D=((I=x.value)==null?void 0:I.issues.findIndex(C=>C.type===L))??-1;return D>=0?k.value[D]:void 0}const B=[{value:"",text:"None",description:"Normal color vision",visual:Oe(mde)},{value:"protanopia",text:"Protanopia",description:"No red cones (1% of males)",visual:Oe(gde)},{value:"deuteranopia",text:"Deuteranopia",description:"No green cones (1% of males)",visual:Oe(vde)},{value:"tritanopia",text:"Tritanopia",description:"No blue cones (very rare)",visual:Oe(bde)}],S=[{value:"",label:"Custom",colors:[]},...JC().map(L=>({value:L.name,label:L.label,colors:[...L.colors]}))];return(L,D)=>{const I=cde;return w(),R("div",yde,[p(l)?(w(),J(I,{key:0,labels:p(f),colorizes:p(o),"base-color":p(g),"onUpdate:colorizes":D[0]||(D[0]=C=>o.value=C),"onUpdate:baseColor":b},null,8,["labels","colorizes","base-color"])):(w(),R(He,{key:1},[p(u)?(w(),J(p(uV),{key:0,id:"opt-palette",label:"Color palette","model-value":p(r).colorPalette??"",palettes:S,"onUpdate:modelValue":D[1]||(D[1]=C=>p(s)("colorPalette",C))},null,8,["model-value"])):ie("",!0),p(c)&&!p(r).colorPalette?(w(),J(p(EF),{key:1,id:"opt-colors",label:"Colors","model-value":p(r).colors??[],"onUpdate:modelValue":D[2]||(D[2]=C=>p(s)("colors",C))},null,8,["model-value"])):ie("",!0)],64)),p(u)||p(c)?(w(),J(p(nn),{key:2,id:"opt-allow-dark-mode",label:"Allow dark mode","model-value":p(r).allowDarkMode??!0,"onUpdate:modelValue":D[3]||(D[3]=C=>p(s)("allowDarkMode",C))},null,8,["model-value"])):ie("",!0),p(u)||p(c)?(w(),J(p(nn),{key:3,id:"opt-auto-contrast",label:"Auto-adjust contrast","model-value":p(r).autoContrast??!1,"onUpdate:modelValue":D[4]||(D[4]=C=>p(s)("autoContrast",C))},null,8,["model-value"])):ie("",!0),p(v)?(w(),R("div",xde,[D[6]||(D[6]=M("span",{class:"form-label mb-0"},"Light contrast",-1)),H(p(o8),{level:p(v).level,ratio:p(v).ratio},null,8,["level","ratio"])])):ie("",!0),p(y)?(w(),R("div",wde,[D[7]||(D[7]=M("span",{class:"form-label mb-0"},"Dark contrast",-1)),H(p(o8),{level:p(y).level,ratio:p(y).ratio},null,8,["level","ratio"])])):ie("",!0),p(x)?(w(),R("div",_de,[D[9]||(D[9]=M("span",{class:"form-label mb-0"},"Colorblind",-1)),p(x).safe?(w(),R("span",{key:0,ref_key:"cvdSafeBadgeRef",ref:_,class:"editor-color-section__cvd-badge editor-color-section__cvd-badge--safe"},[H(p(My)),D[8]||(D[8]=Ye(" Safe ",-1)),H(p($1),{class:"editor-color-section__cvd-badge__info"}),H(p(Ud),{"teleport-to":"body",target:p(_),title:"All colors remain distinguishable under protanopia, deuteranopia, and tritanopia simulations.",placement:"top"},null,8,["target"])],512)):(w(!0),R(He,{key:1},ht(p(x).issues,C=>(w(),R("span",{key:C.type,ref_for:!0,ref_key:"cvdBadgeRefs",ref:k,class:"editor-color-section__cvd-badge editor-color-section__cvd-badge--warn"},[H(p(WT)),Ye(" "+ye(C.shortLabel)+" ",1),H(p($1),{class:"editor-color-section__cvd-badge__info"}),H(p(Ud),{"teleport-to":"body",target:()=>E(C.type),title:C.tooltip,placement:"top"},null,8,["target","title"])]))),128))])):ie("",!0),H(p(Cn),{modelValue:p(a),"onUpdate:modelValue":D[5]||(D[5]=C=>Ze(a)?a.value=C:null),label:"Colorblind simulation",options:B,block:""},null,8,["modelValue"])])}}}),Sde=Be(kde,[["__scopeId","data-v-bbe9fd0a"]]),Ade=le({__name:"EditorThemeSection",setup(t){const{chartTheme:e,availableThemes:n}=rT();return(o,r)=>(w(),J(p(En),{modelValue:p(e),"onUpdate:modelValue":r[0]||(r[0]=i=>Ze(e)?e.value=i:null),label:"Chart Theme",options:p(n),block:""},null,8,["modelValue","options"]))}}),Cde={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function $de(t,e){return w(),R("svg",Cde,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M238.64 33.36a32 32 0 0 0-45.26 0a32 32 0 0 0 0 45.26c.29.29.6.57.9.85l-26.63 49.46a32.2 32.2 0 0 0-23.9 3.5l-20.18-20.18a32 32 0 0 0-50.2-38.89a32 32 0 0 0 0 45.26c.29.29.59.57.89.85l-26.63 49.47a32 32 0 0 0-30.27 8.44a32 32 0 1 0 45.26 0c-.29-.29-.6-.57-.9-.85l26.63-49.46A32.4 32.4 0 0 0 96 128a32 32 0 0 0 16.25-4.41l20.18 20.18a32 32 0 1 0 50.2-6.38c-.29-.29-.59-.57-.89-.85l26.63-49.46A32.3 32.3 0 0 0 216 88a32 32 0 0 0 22.63-54.62ZM51.3 211.33a16 16 0 0 1-22.63-22.64a16 16 0 1 1 22.63 22.64m33.38-104a16 16 0 0 1 0-22.63a16 16 0 1 1 0 22.63m86.64 64a16 16 0 0 1-22.63-22.63a16 16 0 0 1 22.63 22.63m56-104a16 16 0 1 1-22.62-22.66a16 16 0 0 1 22.63 22.64Z"},null,-1)])])}const Tde=Oe({name:"ph-line-segments",render:$de}),Mde={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ode(t,e){return w(),R("svg",Mde,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 32a8 8 0 0 0-8-8c-44.08 0-89.31 49.71-114.43 82.63A60 60 0 0 0 32 164c0 30.88-19.54 44.73-20.47 45.37A8 8 0 0 0 16 224h76a60 60 0 0 0 57.37-77.57C182.3 121.31 232 76.08 232 32M92 208H34.63C41.38 198.41 48 183.92 48 164a44 44 0 1 1 44 44m32.42-94.45q5.14-6.66 10.09-12.55A76.2 76.2 0 0 1 155 121.49q-5.9 4.94-12.55 10.09a60.5 60.5 0 0 0-18.03-18.03m42.7-2.68a92.6 92.6 0 0 0-22-22c31.78-34.53 55.75-45 69.9-47.91c-2.85 14.16-13.37 38.13-47.9 69.91"},null,-1)])])}const Bde=Oe({name:"ph-paint-brush",render:Ode}),Lde={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Pde(t,e){return w(),R("svg",Lde,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M232 208a8 8 0 0 1-8 8H32a8 8 0 0 1-8-8V48a8 8 0 0 1 16 0v94.37L90.73 98a8 8 0 0 1 10.07-.38l58.81 44.11L218.73 90a8 8 0 1 1 10.54 12l-64 56a8 8 0 0 1-10.07.38l-58.81-44.09L40 163.63V200h184a8 8 0 0 1 8 8"},null,-1)])])}const Dde=Oe({name:"ph-chart-line",render:Pde}),Ede={class:"d-flex flex-column gap-4"},Nde=le({__name:"EditorAppearanceTab",setup(t){const{chartType:e}=dn(),{availableOptionKeys:n}=_n(),o=A(()=>e.value.includes("horizontal")||e.value===Le.BarStacked||e.value===Le.BarSplit||e.value===Le.BarGrouped?od:Ls),r=A(()=>n.value.includes("stacked")),i=A(()=>n.value.includes("interpolation")||n.value.includes("lineSymbols")),s=A(()=>!r.value&&i.value),a=A(()=>n.value.includes("barBackground")||n.value.includes("barSeparators")||n.value.includes("barGap")||n.value.includes("connectedColumns")||n.value.includes("categoryLabelLine")),l=A(()=>n.value.includes("displayAsPercentage"));return(c,u)=>{const d=Ade,f=Sde,h=ade,g=ode,b=tde,m=Jue;return w(),R("div",Ede,[H(p(Fo),{title:"Theme",icon:p(Bde)},{default:te(()=>[H(d)]),_:1},8,["icon"]),H(p(Fo),{title:"Colors",icon:p(NT)},{default:te(()=>[H(f)]),_:1},8,["icon"]),p(s)?(w(),J(p(Fo),{key:0,title:"Line Style",icon:p(Tde)},{default:te(()=>[H(h)]),_:1},8,["icon"])):ie("",!0),p(a)?(w(),J(p(Fo),{key:1,title:"Bar Style",icon:p(o)},{default:te(()=>[H(g)]),_:1},8,["icon"])):ie("",!0),p(l)?(w(),J(p(Fo),{key:2,title:"Slices",icon:p(IA)},{default:te(()=>[H(b)]),_:1},8,["icon"])):ie("",!0),p(r)?(w(),J(p(Fo),{key:3,title:"Areas",icon:p(Dde)},{default:te(()=>[H(m)]),_:1},8,["icon"])):ie("",!0)])}}}),Ide={class:"d-flex flex-column gap-3"},Rde=le({__name:"EditorPropertyForm",setup(t){const{title:e,description:n,byline:o,note:r,source:i,sourceUrl:s}=dn();return(a,l)=>{const c=ea,u=Mn,d=_y;return w(),R("div",Ide,[H(u,{label:"Title","label-for":"prop-title"},{default:te(()=>[H(c,{id:"prop-title",modelValue:p(e),"onUpdate:modelValue":l[0]||(l[0]=f=>Ze(e)?e.value=f:null),placeholder:"Chart title"},null,8,["modelValue"])]),_:1}),H(u,{label:"Description","label-for":"prop-description"},{default:te(()=>[H(d,{id:"prop-description",modelValue:p(n),"onUpdate:modelValue":l[1]||(l[1]=f=>Ze(n)?n.value=f:null),placeholder:"Short description",rows:"2","max-rows":"5"},null,8,["modelValue"])]),_:1}),H(u,{label:"Byline","label-for":"prop-byline"},{default:te(()=>[H(c,{id:"prop-byline",modelValue:p(o),"onUpdate:modelValue":l[2]||(l[2]=f=>Ze(o)?o.value=f:null),placeholder:"Author or byline"},null,8,["modelValue"])]),_:1}),H(u,{label:"Note","label-for":"prop-note"},{default:te(()=>[H(d,{id:"prop-note",modelValue:p(r),"onUpdate:modelValue":l[3]||(l[3]=f=>Ze(r)?r.value=f:null),placeholder:"Additional note or caveat",rows:"2","max-rows":"4"},null,8,["modelValue"])]),_:1}),H(u,{label:"Source","label-for":"prop-source"},{default:te(()=>[H(c,{id:"prop-source",modelValue:p(i),"onUpdate:modelValue":l[4]||(l[4]=f=>Ze(i)?i.value=f:null),placeholder:"Data source"},null,8,["modelValue"])]),_:1}),H(u,{label:"Source URL","label-for":"prop-source-url"},{default:te(()=>[H(c,{id:"prop-source-url",modelValue:p(s),"onUpdate:modelValue":l[5]||(l[5]=f=>Ze(s)?s.value=f:null),type:"url",placeholder:"https://..."},null,8,["modelValue"])]),_:1})])}}}),qT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.466666666666666" y="20.666666666666668" width="11.733333333333334" height="13.333333333333332" fill="#2563A0" rx="0.5"/><rect x="18.13333333333333" y="4" width="11.733333333333334" height="30" fill="#2563A0" rx="0.5"/><rect x="32.8" y="14" width="11.733333333333334" height="20" fill="#2563A0" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},YT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2.8" width="26.727272727272727" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="10.8" width="42" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="18.8" width="17.181818181818183" height="6.4" fill="#2563A0" rx="0.5"/><rect x="2" y="26.8" width="34.36363636363637" height="6.4" fill="#2563A0" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},jT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.65" y="17.64" width="5.61" height="16.36" fill="#2563A0" rx="0.5"/><rect x="9.88" y="23.09" width="5.61" height="10.91" fill="#D4A63A" rx="0.5"/><rect x="16.12" y="13.55" width="5.61" height="20.45" fill="#C94044" rx="0.5"/><rect x="25.65" y="9.45" width="5.61" height="24.55" fill="#2563A0" rx="0.5"/><rect x="31.88" y="4.00" width="5.61" height="30.00" fill="#D4A63A" rx="0.5"/><rect x="38.12" y="20.36" width="5.61" height="13.64" fill="#C94044" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},XT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><polyline points="2.00,32.00 10.80,21.50 19.60,26.75 28.40,11.00 37.20,16.25 46.00,4.00" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},KT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><polyline points="2.00,32.00 13.00,20.00 24.00,26.00 35.00,8.00 46.00,14.00" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="2.00,12.00 13.00,18.00 24.00,4.00 35.00,22.00 46.00,8.00" fill="none" stroke="#D4A63A" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="2.00,24.00 13.00,16.00 24.00,20.00 35.00,10.00 46.00,4.00" fill="none" stroke="#C94044" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},Fde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><path d="M 2.00,22.67 L 13.00,10.22 L 24.00,16.44 L 35.00,4.00 L 46.00,13.33 L 46.00,34 L 2.00,34 Z" fill="#2563A0" opacity="0.3"/><polyline points="2.00,22.67 13.00,10.22 24.00,16.44 35.00,4.00 46.00,13.33" fill="none" stroke="#2563A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',style:"width:100%;height:100%"})}},Vde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><path d="M 2.00,16.92 L 13.00,8.31 L 24.00,12.62 L 35.00,4.00 L 46.00,12.62 L 46.00,23.38 L 35.00,16.92 L 24.00,21.23 L 13.00,19.08 L 2.00,23.38 Z" fill="#D4A63A" opacity="0.7"/><path d="M 2.00,23.38 L 13.00,19.08 L 24.00,21.23 L 35.00,16.92 L 46.00,23.38 L 46.00,34 L 35.00,34 L 24.00,34 L 13.00,34 L 2.00,34 Z" fill="#2563A0" opacity="0.7"/></svg>',style:"width:100%;height:100%"})}},zde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="3.10" y="24.77" width="8.80" height="9.23" fill="#2563A0" rx="0.5"/><rect x="3.10" y="17.85" width="8.80" height="6.92" fill="#D4A63A" rx="0.5"/><rect x="14.10" y="20.15" width="8.80" height="13.85" fill="#2563A0" rx="0.5"/><rect x="14.10" y="8.62" width="8.80" height="11.54" fill="#D4A63A" rx="0.5"/><rect x="25.10" y="22.46" width="8.80" height="11.54" fill="#2563A0" rx="0.5"/><rect x="25.10" y="13.23" width="8.80" height="9.23" fill="#D4A63A" rx="0.5"/><rect x="36.10" y="17.85" width="8.80" height="16.15" fill="#2563A0" rx="0.5"/><rect x="36.10" y="4.00" width="8.80" height="13.85" fill="#D4A63A" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},Hde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2.00" y="2.80" width="12.92" height="6.40" fill="#2563A0" rx="0.5"/><rect x="14.92" y="2.80" width="9.69" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="10.80" width="19.38" height="6.40" fill="#2563A0" rx="0.5"/><rect x="21.38" y="10.80" width="16.15" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="18.80" width="16.15" height="6.40" fill="#2563A0" rx="0.5"/><rect x="18.15" y="18.80" width="12.92" height="6.40" fill="#D4A63A" rx="0.5"/><rect x="2.00" y="26.80" width="22.62" height="6.40" fill="#2563A0" rx="0.5"/><rect x="24.62" y="26.80" width="19.38" height="6.40" fill="#D4A63A" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},Wde={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2.00" y="2.80" width="12.08" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="10.80" width="9.17" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="18.80" width="5.83" height="6.40" fill="#6878E8" rx="0.5"/><rect x="2.00" y="26.80" width="4.17" height="6.40" fill="#6878E8" rx="0.5"/><rect x="17.33" y="2.80" width="13.33" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="10.80" width="10.42" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="18.80" width="6.67" height="6.40" fill="#E07B38" rx="0.5"/><rect x="17.33" y="26.80" width="5.00" height="6.40" fill="#E07B38" rx="0.5"/><rect x="32.67" y="2.80" width="11.25" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="10.80" width="8.33" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="18.80" width="5.00" height="6.40" fill="#B83B5E" rx="0.5"/><rect x="32.67" y="26.80" width="3.33" height="6.40" fill="#B83B5E" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},Ude={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 48 36" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2.60" width="38.06" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="4.87" width="28.88" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="7.13" width="18.38" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="10.60" width="42.00" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="12.87" width="32.81" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="15.13" width="21.00" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="18.60" width="35.44" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="20.87" width="26.25" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="23.13" width="15.75" height="2.04" fill="#B83B5E" rx="0.5"/><rect x="2" y="26.60" width="15.75" height="2.04" fill="#6878E8" rx="0.5"/><rect x="2" y="28.87" width="10.50" height="2.04" fill="#E07B38" rx="0.5"/><rect x="2" y="31.13" width="6.56" height="2.04" fill="#B83B5E" rx="0.5"/></svg>',style:"width:100%;height:100%"})}},ZT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M 20.000 2.000 A 18 18 0 0 1 34.562 30.580 L 28.737 26.348 A 10.799999999999999 10.799999999999999 0 0 0 20.000 9.200 Z" fill="#2563A0"/><path d="M 34.562 30.580 A 18 18 0 0 1 9.420 34.562 L 13.652 28.737 A 10.799999999999999 10.799999999999999 0 0 0 28.737 26.348 Z" fill="#D4A63A"/><path d="M 9.420 34.562 A 18 18 0 0 1 3.713 12.336 L 10.228 15.402 A 10.799999999999999 10.799999999999999 0 0 0 13.652 28.737 Z" fill="#C94044"/><path d="M 3.713 12.336 A 18 18 0 0 1 20.000 2.000 L 20.000 9.200 A 10.799999999999999 10.799999999999999 0 0 0 10.228 15.402 Z" fill="#2D8659"/></svg>',style:"width:100%;height:100%"})}},QT={render(){return Vt("div",{innerHTML:'<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M 20 20 L 20.000 2.000 A 18 18 0 0 1 34.562 30.580 Z" fill="#2563A0"/><path d="M 20 20 L 34.562 30.580 A 18 18 0 0 1 9.420 34.562 Z" fill="#D4A63A"/><path d="M 20 20 L 9.420 34.562 A 18 18 0 0 1 3.713 12.336 Z" fill="#C94044"/><path d="M 20 20 L 3.713 12.336 A 18 18 0 0 1 20.000 2.000 Z" fill="#2D8659"/></svg>',style:"width:100%;height:100%"})}},Gde=le({__name:"EditorChartTypePicker",setup(t){const{chartType:e,selectedColumn:n}=dn(),{currentOptions:o,availableOptionKeys:r,setOption:i}=_n(),s=jo(),a=A(()=>r.value.includes("stackMode")),l=[{value:"normal",text:"Normal"},{value:"percent",text:"Percentage (100%)"}],c=[{value:Le.BarVertical,label:"Columns",description:"Compare values across categories",visual:Oe(qT)},{value:Le.BarHorizontal,label:"Bars",description:"Compare values with long labels",visual:Oe(YT)},{value:Le.BarMulti,label:"Grouped Columns",description:"Compare multiple series side by side",visual:Oe(jT)},{value:Le.ColumnStacked,label:"Stacked Columns",description:"Compare stacked totals",visual:Oe(zde)},{value:Le.BarStacked,label:"Stacked Bars",description:"Compare stacked totals horizontally",visual:Oe(Hde)},{value:Le.BarSplit,label:"Split Bars",description:"Compare multiple metrics in separate bar panels",visual:Oe(Wde)},{value:Le.BarGrouped,label:"Grouped Bars",description:"Compare multiple series side by side horizontally",visual:Oe(Ude)},{value:Le.Line,label:"Line",description:"Show trends over time",visual:Oe(XT)},{value:Le.LineMulti,label:"Lines",description:"Compare trends across series",visual:Oe(KT)},{value:Le.Area,label:"Area",description:"Show magnitude over time",visual:Oe(Fde)},{value:Le.AreaStacked,label:"Areas",description:"Compare and stack multiple area series",visual:Oe(Vde)},{value:Le.Donut,label:"Donut",description:"Show proportions with a center space",visual:Oe(ZT)},{value:Le.Pie,label:"Pie",description:"Show parts of a whole",visual:Oe(QT)}],u=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.Area,Le.VerticalBar,Le.HorizontalBar],d=A(()=>u.includes(e.value)&&s.columns.value.length>2),f=A(()=>s.columns.value.slice(1).map(h=>({value:h,text:h})));return Ge([e,()=>s.columns.value],()=>{d.value&&!n.value&&s.columns.value.length>2&&(n.value=s.columns.value[1])},{immediate:!0}),(h,g)=>{const b=Mn,m=Ga;return w(),R(He,null,[H(b,{label:"Chart type","label-for":"chart-type-select"},{default:te(()=>[H(p(En),{id:"chart-type-select",modelValue:p(e),"onUpdate:modelValue":g[0]||(g[0]=v=>Ze(e)?e.value=v:null),block:"",options:c},null,8,["modelValue"])]),_:1}),p(d)?(w(),J(b,{key:0,label:"Data column","label-for":"column-select",class:"mt-3"},{default:te(()=>[H(m,{id:"column-select",modelValue:p(n),"onUpdate:modelValue":g[1]||(g[1]=v=>Ze(n)?n.value=v:null),options:p(f)},null,8,["modelValue","options"])]),_:1})):ie("",!0),p(a)?(w(),J(b,{key:1,label:"Stack mode","label-for":"opt-stack-mode",class:"mt-3"},{default:te(()=>[H(m,{id:"opt-stack-mode","model-value":p(o).stackMode??"normal",options:l,"onUpdate:modelValue":g[2]||(g[2]=v=>p(i)("stackMode",v))},null,8,["model-value"])]),_:1})):ie("",!0)],64)}}}),qde=100,Yde=Oo("chartHistory",()=>{const t=new Map,e=Ie(!1),n=Ie(!1);let o="",r=!1,i=!1;function s(d){let f=t.get(d);return f||(f={undoStack:[],redoStack:[],currentState:""},t.set(d,f)),f}function a(d,f){const h={config:{chartType:d.chartType,title:d.title,description:d.description,byline:d.byline,note:d.note,source:d.source,sourceUrl:d.sourceUrl,sort:d.sort,data:d.data,selectedColumn:d.selectedColumn,colorizes:JSON.parse(JSON.stringify(d.colorizes)),highlights:JSON.parse(JSON.stringify(d.highlights)),areaFills:JSON.parse(JSON.stringify(d.areaFills)),annotations:JSON.parse(JSON.stringify(d.annotations)),seriesOverrides:JSON.parse(JSON.stringify(d.seriesOverrides??[])),layout:JSON.parse(JSON.stringify(d.layout??rf))},typeOptions:JSON.parse(JSON.stringify(f))};return JSON.stringify(h)}function l(){const d=t.get(o);e.value=d?d.undoStack.length>0:!1,n.value=d?d.redoStack.length>0:!1}function c(d){const f=s(o);d!==f.currentState&&(f.undoStack.push(f.currentState),f.undoStack.length>qde&&f.undoStack.shift(),f.redoStack.length=0,f.currentState=d,l())}function u(){const d=dn(),{store:f,hydrate:h}=_n(),{sessionId:g}=js();function b(){return a({chartType:d.chartType.value,title:d.title.value,description:d.description.value,byline:d.byline.value,note:d.note.value,source:d.source.value,sourceUrl:d.sourceUrl.value,sort:d.sort.value,data:d.data.value,selectedColumn:d.selectedColumn.value,colorizes:d.colorizes.value,highlights:d.highlights.value,areaFills:d.areaFills.value,annotations:d.annotations.value,seriesOverrides:d.seriesOverrides.value,layout:d.layout.value},f)}i||(i=!0,U0(!0).run(()=>{Ge(g,_=>{if(r=!0,o=_,_){const k=s(_);k.currentState||(k.currentState=b())}l(),xn(()=>{r=!1})},{immediate:!0,flush:"sync"}),Ge([d.chartType,d.title,d.description,d.byline,d.note,d.source,d.sourceUrl,d.sort,d.data,d.selectedColumn,d.colorizes,d.highlights,d.areaFills,d.annotations,d.layout,()=>JSON.stringify(f)],()=>{r||!o||c(b())},{deep:!0})}));function m(x){r=!0;const _=JSON.parse(x);d.hydrate(_.config),h(_.typeOptions),xn(()=>{r=!1})}function v(){const x=t.get(o);!x||x.undoStack.length===0||(x.redoStack.push(x.currentState),x.currentState=x.undoStack.pop(),l(),m(x.currentState))}function y(){const x=t.get(o);!x||x.redoStack.length===0||(x.undoStack.push(x.currentState),x.currentState=x.redoStack.pop(),l(),m(x.currentState))}return{undo:v,redo:y}}return{canUndo:A(()=>e.value),canRedo:A(()=>n.value),init:u}});function jde(){const t=Yde(),{canUndo:e,canRedo:n}=Ct(t),{undo:o,redo:r}=t.init();return{canUndo:e,canRedo:n,undo:o,redo:r}}const Xde={class:"chart-edit-toolbar"},Kde=le({__name:"ChartEditToolbar",setup(t){const e=cr(),{viewMode:n}=Ct(e),{setViewMode:o}=e,{canUndo:r,canRedo:i,undo:s,redo:a}=jde(),l=A({get:()=>n.value,set:u=>o(u)}),c=[{value:"preview",text:"Preview"},{value:"dsl",text:"DSL"}];return(u,d)=>(w(),R("div",Xde,[H(p(CW),{disabled:!p(r),onClick:p(s)},null,8,["disabled","onClick"]),H(p(_W),{disabled:!p(i),onClick:p(a)},null,8,["disabled","onClick"]),H(p(tU),{modelValue:p(l),"onUpdate:modelValue":d[0]||(d[0]=f=>Ze(l)?l.value=f:null),options:c,size:"sm"},null,8,["modelValue"])]))}}),Zde=Be(Kde,[["__scopeId","data-v-de044834"]]);let sb=[],JT=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?JT:sb).push(n=n+t[e])})();function Qde(t){if(t<768)return!1;for(let e=0,n=sb.length;;){let o=e+n>>1;if(t<sb[o])n=o;else if(t>=JT[o])e=o+1;else return!0;if(e==n)return!1}}function Q6(t){return t>=127462&&t<=127487}const J6=8205;function Jde(t,e,n=!0,o=!0){return(n?eM:efe)(t,e,o)}function eM(t,e,n){if(e==t.length)return e;e&&tM(t.charCodeAt(e))&&nM(t.charCodeAt(e-1))&&e--;let o=Mv(t,e);for(e+=ek(o);e<t.length;){let r=Mv(t,e);if(o==J6||r==J6||n&&Qde(r))e+=ek(r),o=r;else if(Q6(r)){let i=0,s=e-2;for(;s>=0&&Q6(Mv(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function efe(t,e,n){for(;e>0;){let o=eM(t,e-2,n);if(o<e)return o;e--}return 0}function Mv(t,e){let n=t.charCodeAt(e);if(!nM(n)||e+1==t.length)return n;let o=t.charCodeAt(e+1);return tM(o)?(n-55296<<10)+(o-56320)+65536:n}function tM(t){return t>=56320&&t<57344}function nM(t){return t>=55296&&t<56320}function ek(t){return t<65536?1:2}class Ut{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,o){[e,n]=lu(this,e,n);let r=[];return this.decompose(0,e,r,2),o.length&&o.decompose(0,o.length,r,3),this.decompose(n,this.length,r,1),Ui.from(r,this.length-(n-e)+o.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=lu(this,e,n);let o=[];return this.decompose(e,n,o,0),Ui.from(o,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),o=this.length-this.scanIdentical(e,-1),r=new Md(this),i=new Md(e);for(let s=n,a=n;;){if(r.next(s),i.next(s),s=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=o)return!0}}iter(e=1){return new Md(this,e)}iterRange(e,n=this.length){return new oM(this,e,n)}iterLines(e,n){let o;if(e==null)o=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;o=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new rM(o)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Ut.empty:e.length<=32?new An(e):Ui.from(An.split(e,[]))}}class An extends Ut{constructor(e,n=tfe(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,o,r){for(let i=0;;i++){let s=this.text[i],a=r+s.length;if((n?o:a)>=e)return new nfe(r,a,o,s);r=a+1,o++}}decompose(e,n,o,r){let i=e<=0&&n>=this.length?this:new An(tk(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let s=o.pop(),a=ip(i.text,s.text.slice(),0,i.length);if(a.length<=32)o.push(new An(a,s.length+i.length));else{let l=a.length>>1;o.push(new An(a.slice(0,l)),new An(a.slice(l)))}}else o.push(i)}replace(e,n,o){if(!(o instanceof An))return super.replace(e,n,o);[e,n]=lu(this,e,n);let r=ip(this.text,ip(o.text,tk(this.text,0,e)),n),i=this.length+o.length-(n-e);return r.length<=32?new An(r,i):Ui.from(An.split(r,[]),i)}sliceString(e,n=this.length,o=`
|
|
850
850
|
`){[e,n]=lu(this,e,n);let r="";for(let i=0,s=0;i<=n&&s<this.text.length;s++){let a=this.text[s],l=i+a.length;i>e&&s&&(r+=o),e<l&&n>i&&(r+=a.slice(Math.max(0,e-i),n-i)),i=l+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let o=[],r=-1;for(let i of e)o.push(i),r+=i.length+1,o.length==32&&(n.push(new An(o,r)),o=[],r=-1);return r>-1&&n.push(new An(o,r)),n}}class Ui extends Ut{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let o of e)this.lines+=o.lines}lineInner(e,n,o,r){for(let i=0;;i++){let s=this.children[i],a=r+s.length,l=o+s.lines-1;if((n?l:a)>=e)return s.lineInner(e,n,o,r);r=a+1,o=l+1}}decompose(e,n,o,r){for(let i=0,s=0;s<=n&&i<this.children.length;i++){let a=this.children[i],l=s+a.length;if(e<=l&&n>=s){let c=r&((s<=e?1:0)|(l>=n?2:0));s>=e&&l<=n&&!c?o.push(a):a.decompose(e-s,n-s,o,c)}s=l+1}}replace(e,n,o){if([e,n]=lu(this,e,n),o.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let s=this.children[r],a=i+s.length;if(e>=i&&n<=a){let l=s.replace(e-i,n-i,o),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[r]=l,new Ui(u,this.length-(n-e)+o.length)}return super.replace(i,a,l)}i=a+1}return super.replace(e,n,o)}sliceString(e,n=this.length,o=`
|
|
851
|
-
`){[e,n]=lu(this,e,n);let r="";for(let i=0,s=0;i<this.children.length&&s<=n;i++){let a=this.children[i],l=s+a.length;s>e&&i&&(r+=o),e<l&&n>s&&(r+=a.sliceString(e-s,n-s,o)),s=l+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ui))return 0;let o=0,[r,i,s,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,i+=n){if(r==s||i==a)return o;let l=this.children[r],c=e.children[i];if(l!=c)return o+l.scanIdentical(c,n);o+=l.length+1}}static from(e,n=e.reduce((o,r)=>o+r.length+1,-1)){let o=0;for(let h of e)o+=h.lines;if(o<32){let h=[];for(let g of e)g.flatten(h);return new An(h,n)}let r=Math.max(32,o>>5),i=r<<1,s=r>>1,a=[],l=0,c=-1,u=[];function d(h){let g;if(h.lines>i&&h instanceof Ui)for(let b of h.children)d(b);else h.lines>s&&(l>s||!l)?(f(),a.push(h)):h instanceof An&&l&&(g=u[u.length-1])instanceof An&&h.lines+g.lines<=32?(l+=h.lines,c+=h.length+1,u[u.length-1]=new An(g.text.concat(h.text),g.length+1+h.length)):(l+h.lines>r&&f(),l+=h.lines,c+=h.length+1,u.push(h))}function f(){l!=0&&(a.push(u.length==1?u[0]:Ui.from(u,c)),c=-1,l=u.length=0)}for(let h of e)d(h);return f(),a.length==1?a[0]:new Ui(a,n)}}Ut.empty=new An([""],0);function
|
|
852
|
-
`,this;e--}else if(r instanceof An){let l=r.text[s+(n<0?-1:0)];if(this.offsets[o]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[s+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[o]+=n):(n<0&&this.offsets[o]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof An?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class oM{constructor(e,n,o){this.value="",this.done=!1,this.cursor=new Md(e,n>o?-1:1),this.pos=n>o?e.length:0,this.from=Math.min(n,o),this.to=Math.max(n,o)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let o=n<0?this.pos-this.from:this.to-this.pos;e>o&&(e=o),o-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=o?r:n<0?r.slice(r.length-o):r.slice(0,o),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class rM{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:o,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):o?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this.iter()},Md.prototype[Symbol.iterator]=oM.prototype[Symbol.iterator]=rM.prototype[Symbol.iterator]=function(){return this});class efe{constructor(e,n,o,r){this.from=e,this.to=n,this.number=o,this.text=r}get length(){return this.to-this.from}}function lu(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function To(t,e,n=!0,o=!0){return Zde(t,e,n,o)}function tfe(t){return t>=56320&&t<57344}function nfe(t){return t>=55296&&t<56320}function ofe(t,e){let n=t.charCodeAt(e);if(!nfe(n)||e+1==t.length)return n;let o=t.charCodeAt(e+1);return tfe(o)?(n-55296<<10)+(o-56320)+65536:n}function rfe(t){return t<65536?1:2}const ab=/\r\n?|\n/;var br=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(br||(br={}));class os{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let o=this.sections[n+1];e+=o<0?this.sections[n]:o}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,o=0,r=0;n<this.sections.length;){let i=this.sections[n++],s=this.sections[n++];s<0?(e(o,r,i),r+=i):r+=s,o+=i}}iterChangedRanges(e,n=!1){lb(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let o=this.sections[n++],r=this.sections[n++];r<0?e.push(o,r):e.push(r,o)}return new os(e)}composeDesc(e){return this.empty?e:e.empty?this:iM(this,e)}mapDesc(e,n=!1){return e.empty?this:cb(this,e,n)}mapPos(e,n=-1,o=br.Simple){let r=0,i=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=r+a;if(l<0){if(c>e)return i+(e-r);i+=a}else{if(o!=br.Simple&&c>=e&&(o==br.TrackDel&&r<e&&c>e||o==br.TrackBefore&&r<e||o==br.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!a)return e==r||n<0?i:i+l;i+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,n=e){for(let o=0,r=0;o<this.sections.length&&r<=n;){let i=this.sections[o++],s=this.sections[o++],a=r+i;if(s>=0&&r<=n&&a>=e)return r<e&&a>n?"cover":!0;r=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let o=this.sections[n++],r=this.sections[n++];e+=(e?" ":"")+o+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new os(e)}static create(e){return new os(e)}}class zn extends os{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return lb(this,(n,o,r,i,s)=>e=e.replace(r,r+(o-n),s),!1),e}mapDesc(e,n=!1){return cb(this,e,n,!0)}invert(e){let n=this.sections.slice(),o=[];for(let r=0,i=0;r<n.length;r+=2){let s=n[r],a=n[r+1];if(a>=0){n[r]=a,n[r+1]=s;let l=r>>1;for(;o.length<l;)o.push(Ut.empty);o.push(s?e.slice(i,i+s):Ut.empty)}i+=s}return new zn(n,o)}compose(e){return this.empty?e:e.empty?this:iM(this,e,!0)}map(e,n=!1){return e.empty?this:cb(this,e,n,!0)}iterChanges(e,n=!1){lb(this,e,n)}get desc(){return os.create(this.sections)}filter(e){let n=[],o=[],r=[],i=new uf(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,l-a);vo(r,u,-1);let d=i.ins==-1?-1:i.off==0?i.ins:0;vo(n,u,d),d>0&&ka(o,n,i.text),i.forward(u),a+=u}let c=e[s++];for(;a<c;){if(i.done)break e;let u=Math.min(i.len,c-a);vo(n,u,-1),vo(r,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),a+=u}}return{changes:new zn(n,o),filtered:os.create(r)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let o=this.sections[n],r=this.sections[n+1];r<0?e.push(o):r==0?e.push([o]):e.push([o].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,o){let r=[],i=[],s=0,a=null;function l(u=!1){if(!u&&!r.length)return;s<n&&vo(r,n-s,-1);let d=new zn(r,i);a=a?a.compose(d.map(a)):d,r=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof zn){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:f=d,insert:h}=u;if(d>f||d<0||f>n)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${n})`);let g=h?typeof h=="string"?Ut.of(h.split(o||ab)):h:Ut.empty,b=g.length;if(d==f&&b==0)return;d<s&&l(),d>s&&vo(r,d-s,-1),vo(r,f-d,b),ka(i,r,g),s=f}}return c(e),l(!a),a}static empty(e){return new zn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],o=[];for(let r=0;r<e.length;r++){let i=e[r];if(typeof i=="number")n.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)n.push(i[0],0);else{for(;o.length<r;)o.push(Ut.empty);o[r]=Ut.of(i.slice(1)),n.push(i[0],o[r].length)}}}return new zn(n,o)}static createSet(e,n){return new zn(e,n)}}function vo(t,e,n,o=!1){if(e==0&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:o?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function ka(t,e,n){if(n.length==0)return;let o=e.length-2>>1;if(o<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<o;)t.push(Ut.empty);t.push(n)}}function lb(t,e,n){let o=t.inserted;for(let r=0,i=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)r+=a,i+=a;else{let c=r,u=i,d=Ut.empty;for(;c+=a,u+=l,l&&o&&(d=d.append(o[s-2>>1])),!(n||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(r,c,i,u,d),r=c,i=u}}}function cb(t,e,n,o=!1){let r=[],i=o?[]:null,s=new uf(t),a=new uf(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);vo(r,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!n))){let c=a.len;for(vo(r,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(vo(r,0,s.ins),i&&ka(i,r,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;vo(r,c,l<s.i?s.ins:0),i&&l<s.i&&ka(i,r,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return i?zn.createSet(r,i):os.create(r);throw new Error("Mismatched change set lengths")}}}function iM(t,e,n=!1){let o=[],r=n?[]:null,i=new uf(t),s=new uf(e);for(let a=!1;;){if(i.done&&s.done)return r?zn.createSet(o,r):os.create(o);if(i.ins==0)vo(o,i.len,0,a),i.next();else if(s.len==0&&!s.done)vo(o,0,s.ins,a),r&&ka(r,o,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(i.len2,s.len),c=o.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;vo(o,l,u,a),r&&u&&ka(r,o,s.text)}else s.ins==-1?(vo(o,i.off?0:i.len,l,a),r&&ka(r,o,i.textBit(l))):(vo(o,i.off?0:i.len,s.off?0:s.ins,a),r&&!s.off&&ka(r,o,s.text));a=(i.ins>l||s.ins>=0&&s.len>l)&&(a||o.length>c),i.forward2(l),s.forward(l)}}}}class uf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?Ut.empty:e[n]}textBit(e){let{inserted:n}=this.set,o=this.i-2>>1;return o>=n.length&&!e?Ut.empty:n[o].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class xl{constructor(e,n,o){this.from=e,this.to=n,this.flags=o}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let o,r;return this.empty?o=r=e.mapPos(this.from,n):(o=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),o==this.from&&r==this.to?this:new xl(o,r,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ze.range(e,n);let o=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ze.range(this.anchor,o)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ze.range(e.anchor,e.head)}static create(e,n,o){return new xl(e,n,o)}}class ze{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ze.create(this.ranges.map(o=>o.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let o=0;o<this.ranges.length;o++)if(!this.ranges[o].eq(e.ranges[o],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ze([this.main],0)}addRange(e,n=!0){return ze.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let o=this.ranges.slice();return o[n]=e,ze.create(o,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ze(e.ranges.map(n=>xl.fromJSON(n)),e.main)}static single(e,n=e){return new ze([ze.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let o=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=o:i.from<o)return ze.normalized(e.slice(),n);o=i.to}return new ze(e,n)}static cursor(e,n=0,o,r){return xl.create(e,e,(n==0?0:n<0?8:16)|(o==null?7:Math.min(6,o))|(r??16777215)<<6)}static range(e,n,o,r){let i=(o??16777215)<<6|(r==null?7:Math.min(6,r));return n<e?xl.create(n,e,48|i):xl.create(e,n,(n>e?8:0)|i)}static normalized(e,n=0){let o=e[n];e.sort((r,i)=>r.from-i.from),n=e.indexOf(o);for(let r=1;r<e.length;r++){let i=e[r],s=e[r-1];if(i.empty?i.from<=s.to:i.from<s.to){let a=s.from,l=Math.max(i.to,s.to);r<=n&&n--,e.splice(--r,2,i.anchor>i.head?ze.range(l,a):ze.range(a,l))}}return new ze(e,n)}}function sM(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Y2=0;class pt{constructor(e,n,o,r,i){this.combine=e,this.compareInput=n,this.compare=o,this.isStatic=r,this.id=Y2++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}get reader(){return this}static define(e={}){return new pt(e.combine||(n=>n),e.compareInput||((n,o)=>n===o),e.compare||(e.combine?(n,o)=>n===o:j2),!!e.static,e.enables)}of(e){return new sp([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new sp(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new sp(e,this,2,n)}from(e,n){return n||(n=o=>o),this.compute([e],o=>n(o.field(e)))}}function j2(t,e){return t==e||t.length==e.length&&t.every((n,o)=>n===e[o])}class sp{constructor(e,n,o,r){this.dependencies=e,this.facet=n,this.type=o,this.value=r,this.id=Y2++}dynamicSlot(e){var n;let o=this.value,r=this.facet.compareInput,i=this.id,s=e[i]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=e[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[s]=o(d),1},update(d,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||ub(d,u)){let h=o(d);if(a?!nk(h,d.values[s],r):!r(h,d.values[s]))return d.values[s]=h,1}return 0},reconfigure:(d,f)=>{let h,g=f.config.address[i];if(g!=null){let b=y0(f,g);if(this.dependencies.every(m=>m instanceof pt?f.facet(m)===d.facet(m):m instanceof el?f.field(m,!1)==d.field(m,!1):!0)||(a?nk(h=o(d),b,r):r(h=o(d),b)))return d.values[s]=b,0}else h=o(d);return d.values[s]=h,1}}}}function nk(t,e,n){if(t.length!=e.length)return!1;for(let o=0;o<t.length;o++)if(!n(t[o],e[o]))return!1;return!0}function ub(t,e){let n=!1;for(let o of e)Od(t,o)&1&&(n=!0);return n}function ife(t,e,n){let o=n.map(l=>t[l.id]),r=n.map(l=>l.type),i=o.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<o.length;u++){let d=y0(l,o[u]);if(r[u]==2)for(let f of d)c.push(f);else c.push(d)}return e.combine(c)}return{create(l){for(let c of o)Od(l,c);return l.values[s]=a(l),1},update(l,c){if(!ub(l,i))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=ub(l,o),d=c.config.facets[e.id],f=c.facet(e);if(d&&!u&&j2(n,d))return l.values[s]=f,0;let h=a(l);return e.compare(h,f)?(l.values[s]=f,0):(l.values[s]=h,1)}}}const Sh=pt.define({static:!0});class el{constructor(e,n,o,r,i){this.id=e,this.createF=n,this.updateF=o,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let n=new el(Y2++,e.create,e.update,e.compare||((o,r)=>o===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Sh).find(o=>o.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:o=>(o.values[n]=this.create(o),1),update:(o,r)=>{let i=o.values[n],s=this.updateF(i,r);return this.compareF(i,s)?0:(o.values[n]=s,1)},reconfigure:(o,r)=>{let i=o.facet(Sh),s=r.facet(Sh),a;return(a=i.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(o.values[n]=a.create(o),1):r.config.address[this.id]!=null?(o.values[n]=r.field(this),0):(o.values[n]=this.create(o),1)}}}init(e){return[this,Sh.of({field:this,create:e})]}get extension(){return this}}const vl={lowest:4,low:3,default:2,high:1,highest:0};function Ku(t){return e=>new aM(e,t)}const X2={highest:Ku(vl.highest),high:Ku(vl.high),default:Ku(vl.default),low:Ku(vl.low),lowest:Ku(vl.lowest)};class aM{constructor(e,n){this.inner=e,this.prec=n}}class fg{of(e){return new db(this,e)}reconfigure(e){return fg.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class db{constructor(e,n){this.compartment=e,this.inner=n}}class b0{constructor(e,n,o,r,i,s){for(this.base=e,this.compartments=n,this.dynamicSlots=o,this.address=r,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<o.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,o){let r=[],i=Object.create(null),s=new Map;for(let f of sfe(e,n,s))f instanceof el?r.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of r)a[f.id]=c.length<<1,c.push(h=>f.slot(h));let u=o==null?void 0:o.config.facets;for(let f in i){let h=i[f],g=h[0].facet,b=u&&u[f]||[];if(h.every(m=>m.type==0))if(a[g.id]=l.length<<1|1,j2(b,h))l.push(o.facet(g));else{let m=g.combine(h.map(v=>v.value));l.push(o&&g.compare(m,o.facet(g))?o.facet(g):m)}else{for(let m of h)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(v=>m.dynamicSlot(v)));a[g.id]=c.length<<1,c.push(m=>ife(m,g,h))}}let d=c.map(f=>f(a));return new b0(e,s,d,a,l,i)}}function sfe(t,e,n){let o=[[],[],[],[],[]],r=new Map;function i(s,a){let l=r.get(s);if(l!=null){if(l<=a)return;let c=o[l].indexOf(s);c>-1&&o[l].splice(c,1),s instanceof db&&n.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let c of s)i(c,a);else if(s instanceof db){if(n.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;n.set(s.compartment,c),i(c,a)}else if(s instanceof aM)i(s.inner,s.prec);else if(s instanceof el)o[a].push(s),s.provides&&i(s.provides,a);else if(s instanceof sp)o[a].push(s),s.facet.extensions&&i(s.facet.extensions,vl.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,a)}}return i(t,vl.default),o.reduce((s,a)=>s.concat(a))}function Od(t,e){if(e&1)return 2;let n=e>>1,o=t.status[n];if(o==4)throw new Error("Cyclic dependency between fields and/or facets");if(o&2)return o;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function y0(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const lM=pt.define(),fb=pt.define({combine:t=>t.some(e=>e),static:!0}),cM=pt.define({combine:t=>t.length?t[0]:void 0,static:!0}),uM=pt.define(),dM=pt.define(),fM=pt.define(),hM=pt.define({combine:t=>t.length?t[0]:!1});class tl{constructor(e,n){this.type=e,this.value=n}static define(){return new afe}}class afe{of(e){return new tl(this,e)}}class lfe{constructor(e){this.map=e}of(e){return new $n(this,e)}}class $n{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new $n(this.type,n)}is(e){return this.type==e}static define(e={}){return new lfe(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let o=[];for(let r of e){let i=r.map(n);i&&o.push(i)}return o}}$n.reconfigure=$n.define();$n.appendConfig=$n.define();class Wn{constructor(e,n,o,r,i,s){this.startState=e,this.changes=n,this.selection=o,this.effects=r,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,o&&sM(o,n.newLength),i.some(a=>a.type==Wn.time)||(this.annotations=i.concat(Wn.time.of(Date.now())))}static create(e,n,o,r,i,s){return new Wn(e,n,o,r,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Wn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Wn.time=tl.define();Wn.userEvent=tl.define();Wn.addToHistory=tl.define();Wn.remote=tl.define();function cfe(t,e){let n=[];for(let o=0,r=0;;){let i,s;if(o<t.length&&(r==e.length||e[r]>=t[o]))i=t[o++],s=t[o++];else if(r<e.length)i=e[r++],s=e[r++];else return n;!n.length||n[n.length-1]<i?n.push(i,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function pM(t,e,n){var o;let r,i,s;return n?(r=e.changes,i=zn.empty(e.changes.length),s=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),i=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(r)),{changes:s,selection:e.selection?e.selection.map(i):(o=t.selection)===null||o===void 0?void 0:o.map(r),effects:$n.mapEffects(t.effects,r).concat($n.mapEffects(e.effects,i)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function hb(t,e,n){let o=e.selection,r=Rc(e.annotations);return e.userEvent&&(r=r.concat(Wn.userEvent.of(e.userEvent))),{changes:e.changes instanceof zn?e.changes:zn.of(e.changes||[],n,t.facet(cM)),selection:o&&(o instanceof ze?o:ze.single(o.anchor,o.head)),effects:Rc(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function mM(t,e,n){let o=hb(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(n=!1);let s=!!e[i].sequential;o=pM(o,hb(t,e[i],s?o.changes.newLength:t.doc.length),s)}let r=Wn.create(t,o.changes,o.selection,o.effects,o.annotations,o.scrollIntoView);return dfe(n?ufe(r):r)}function ufe(t){let e=t.startState,n=!0;for(let r of e.facet(uM)){let i=r(t);if(i===!1){n=!1;break}Array.isArray(i)&&(n=n===!0?i:cfe(n,i))}if(n!==!0){let r,i;if(n===!1)i=t.changes.invertedDesc,r=zn.empty(e.doc.length);else{let s=t.changes.filter(n);r=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}t=Wn.create(e,r,t.selection&&t.selection.map(i),$n.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let o=e.facet(dM);for(let r=o.length-1;r>=0;r--){let i=o[r](t);i instanceof Wn?t=i:Array.isArray(i)&&i.length==1&&i[0]instanceof Wn?t=i[0]:t=mM(e,Rc(i),!1)}return t}function dfe(t){let e=t.startState,n=e.facet(fM),o=t;for(let r=n.length-1;r>=0;r--){let i=n[r](t);i&&Object.keys(i).length&&(o=pM(o,hb(e,i,t.changes.newLength),!0))}return o==t?t:Wn.create(e,t.changes,t.selection,o.effects,o.annotations,o.scrollIntoView)}const ffe=[];function Rc(t){return t==null?ffe:Array.isArray(t)?t:[t]}var Es=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(Es||(Es={}));const hfe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let pb;try{pb=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function pfe(t){if(pb)return pb.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||hfe.test(n)))return!0}return!1}function mfe(t){return e=>{if(!/\S/.test(e))return Es.Space;if(pfe(e))return Es.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Es.Word;return Es.Other}}class Kt{constructor(e,n,o,r,i,s){this.config=e,this.doc=n,this.selection=o,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Od(this,a<<1);this.computeSlot=null}field(e,n=!0){let o=this.config.address[e.id];if(o==null){if(n)throw new RangeError("Field is not present in this state");return}return Od(this,o),y0(this,o)}update(...e){return mM(this,e,!0)}applyTransaction(e){let n=this.config,{base:o,compartments:r}=n;for(let a of e.effects)a.is(fg.reconfigure)?(n&&(r=new Map,n.compartments.forEach((l,c)=>r.set(c,l)),n=null),r.set(a.value.compartment,a.value.extension)):a.is($n.reconfigure)?(n=null,o=a.value):a.is($n.appendConfig)&&(n=null,o=Rc(o).concat(a.value));let i;n?i=e.startState.values.slice():(n=b0.resolve(o,r,this),i=new Kt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(fb)?e.newSelection:e.newSelection.asSingle();new Kt(n,e.newDoc,s,i,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ze.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,o=e(n.ranges[0]),r=this.changes(o.changes),i=[o.range],s=Rc(o.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),c=this.changes(l.changes),u=c.map(r);for(let f=0;f<a;f++)i[f]=i[f].map(u);let d=r.mapDesc(c,!0);i.push(l.range.map(d)),r=r.compose(u),s=$n.mapEffects(s,u).concat($n.mapEffects(Rc(l.effects),d))}return{changes:r,selection:ze.create(i,n.mainIndex),effects:s}}changes(e=[]){return e instanceof zn?e:zn.of(e,this.doc.length,this.facet(Kt.lineSeparator))}toText(e){return Ut.of(e.split(this.facet(Kt.lineSeparator)||ab))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Od(this,n),y0(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let o in e){let r=e[o];r instanceof el&&this.config.address[r.id]!=null&&(n[o]=r.spec.toJSON(this.field(e[o]),this))}return n}static fromJSON(e,n={},o){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(o){for(let i in o)if(Object.prototype.hasOwnProperty.call(e,i)){let s=o[i],a=e[i];r.push(s.init(l=>s.spec.fromJSON(a,l)))}}return Kt.create({doc:e.doc,selection:ze.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=b0.resolve(e.extensions||[],new Map),o=e.doc instanceof Ut?e.doc:Ut.of((e.doc||"").split(n.staticFacet(Kt.lineSeparator)||ab)),r=e.selection?e.selection instanceof ze?e.selection:ze.single(e.selection.anchor,e.selection.head):ze.single(0);return sM(r,o.length),n.staticFacet(fb)||(r=r.asSingle()),new Kt(n,o,r,n.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Kt.tabSize)}get lineBreak(){return this.facet(Kt.lineSeparator)||`
|
|
853
|
-
`}get readOnly(){return this.facet(hM)}phrase(e,...n){for(let o of this.facet(Kt.phrases))if(Object.prototype.hasOwnProperty.call(o,e)){e=o[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(o,r)=>{if(r=="$")return"$";let i=+(r||1);return!i||i>n.length?o:n[i-1]})),e}languageDataAt(e,n,o=-1){let r=[];for(let i of this.facet(lM))for(let s of i(this,n,o))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return mfe(n.length?n[0]:"")}wordAt(e){let{text:n,from:o,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-o,a=e-o;for(;s>0;){let l=To(n,s,!1);if(i(n.slice(l,s))!=Es.Word)break;s=l}for(;a<r;){let l=To(n,a);if(i(n.slice(a,l))!=Es.Word)break;a=l}return s==a?null:ze.range(s+o,a+o)}}Kt.allowMultipleSelections=fb;Kt.tabSize=pt.define({combine:t=>t.length?t[0]:4});Kt.lineSeparator=cM;Kt.readOnly=hM;Kt.phrases=pt.define({compare(t,e){let n=Object.keys(t),o=Object.keys(e);return n.length==o.length&&n.every(r=>t[r]==e[r])}});Kt.languageData=lM;Kt.changeFilter=uM;Kt.transactionFilter=dM;Kt.transactionExtender=fM;fg.reconfigure=$n.define();function gfe(t,e,n={}){let o={};for(let r of t)for(let i of Object.keys(r)){let s=r[i],a=o[i];if(a===void 0)o[i]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(n,i))o[i]=n[i](a,s);else throw new Error("Config merge conflict for field "+i)}for(let r in e)o[r]===void 0&&(o[r]=e[r]);return o}class Vl{eq(e){return this==e}range(e,n=e){return mb.create(e,n,this)}}Vl.prototype.startSide=Vl.prototype.endSide=0;Vl.prototype.point=!1;Vl.prototype.mapMode=br.TrackDel;function K2(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let mb=class gM{constructor(e,n,o){this.from=e,this.to=n,this.value=o}static create(e,n,o){return new gM(e,n,o)}};function gb(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Z2{constructor(e,n,o,r){this.from=e,this.to=n,this.value=o,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,n,o,r=0){let i=o?this.to:this.from;for(let s=r,a=i.length;;){if(s==a)return s;let l=s+a>>1,c=i[l]-e||(o?this.value[l].endSide:this.value[l].startSide)-n;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,n,o,r){for(let i=this.findIndex(n,-1e9,!0),s=this.findIndex(o,1e9,!1,i);i<s;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,n){let o=[],r=[],i=[],s=-1,a=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],u=this.from[l]+e,d=this.to[l]+e,f,h;if(u==d){let g=n.mapPos(u,c.startSide,c.mapMode);if(g==null||(f=h=g,c.startSide!=c.endSide&&(h=n.mapPos(u,c.endSide),h<f)))continue}else if(f=n.mapPos(u,c.startSide),h=n.mapPos(d,c.endSide),f>h||f==h&&c.startSide>0&&c.endSide<=0)continue;(h-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(a=Math.max(a,h-f)),o.push(c),r.push(f-s),i.push(h-s))}return{mapped:o.length?new Z2(r,i,o,a):null,pos:s}}}class tn{constructor(e,n,o,r){this.chunkPos=e,this.chunk=n,this.nextLayer=o,this.maxPoint=r}static create(e,n,o,r){return new tn(e,n,o,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:o=!1,filterFrom:r=0,filterTo:i=this.length}=e,s=e.filter;if(n.length==0&&!s)return this;if(o&&(n=n.slice().sort(gb)),this.isEmpty)return n.length?tn.of(n):this;let a=new vM(this,null,-1).goto(0),l=0,c=[],u=new df;for(;a.value||l<n.length;)if(l<n.length&&(a.from-n[l].from||a.startSide-n[l].value.startSide)>=0){let d=n[l++];u.addInner(d.from,d.to,d.value)||c.push(d)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==n.length||this.chunkEnd(a.chunkIndex)<n[l].from)&&(!s||r>this.chunkEnd(a.chunkIndex)||i<this.chunkPos[a.chunkIndex])&&u.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!s||r>a.to||i<a.from||s(a.from,a.to,a.value))&&(u.addInner(a.from,a.to,a.value)||c.push(mb.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?tn.empty:this.nextLayer.update({add:c,filter:s,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let n=[],o=[],r=-1;for(let s=0;s<this.chunk.length;s++){let a=this.chunkPos[s],l=this.chunk[s],c=e.touchesRange(a,a+l.length);if(c===!1)r=Math.max(r,l.maxPoint),n.push(l),o.push(e.mapPos(a));else if(c===!0){let{mapped:u,pos:d}=l.map(a,e);u&&(r=Math.max(r,u.maxPoint),n.push(u),o.push(d))}}let i=this.nextLayer.map(e);return n.length==0?i:new tn(o,n,i||tn.empty,r)}between(e,n,o){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],s=this.chunk[r];if(n>=i&&e<=i+s.length&&s.between(i,e-i,n-i,o)===!1)return}this.nextLayer.between(e,n,o)}}iter(e=0){return ff.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return ff.from(e).goto(n)}static compare(e,n,o,r,i=-1){let s=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),a=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),l=ok(s,a,o),c=new Zu(s,l,i),u=new Zu(a,l,i);o.iterGaps((d,f,h)=>rk(c,d,u,f,h,r)),o.empty&&o.length==0&&rk(c,0,u,0,0,r)}static eq(e,n,o=0,r){r==null&&(r=999999999);let i=e.filter(u=>!u.isEmpty&&n.indexOf(u)<0),s=n.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(i.length!=s.length)return!1;if(!i.length)return!0;let a=ok(i,s),l=new Zu(i,a,0).goto(o),c=new Zu(s,a,0).goto(o);for(;;){if(l.to!=c.to||!vb(l.active,c.active)||l.point&&(!c.point||!K2(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,n,o,r,i=-1){let s=new Zu(e,null,i).goto(n),a=n,l=s.openStart;for(;;){let c=Math.min(s.to,o);if(s.point){let u=s.activeForPoint(s.to),d=s.pointFrom<n?u.length+1:s.point.startSide<0?u.length:Math.min(u.length,l);r.point(a,c,s.point,u,d,s.pointRank),l=Math.min(s.openEnd(c),u.length)}else c>a&&(r.span(a,c,s.active,l),l=s.openEnd(c));if(s.to>o)return l+(s.point&&s.to>o?1:0);a=s.to,s.next()}}static of(e,n=!1){let o=new df;for(let r of e instanceof mb?[e]:n?vfe(e):e)o.add(r.from,r.to,r.value);return o.finish()}static join(e){if(!e.length)return tn.empty;let n=e[e.length-1];for(let o=e.length-2;o>=0;o--)for(let r=e[o];r!=tn.empty;r=r.nextLayer)n=new tn(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}tn.empty=new tn([],[],null,-1);function vfe(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let o=t[n];if(gb(e,o)>0)return t.slice().sort(gb);e=o}return t}tn.empty.nextLayer=tn.empty;class df{finishChunk(e){this.chunks.push(new Z2(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,o){this.addInner(e,n,o)||(this.nextLayer||(this.nextLayer=new df)).add(e,n,o)}addInner(e,n,o){let r=e-this.lastTo||o.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||o.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=o,this.lastFrom=e,this.lastTo=n,this.value.push(o),o.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let o=n.value.length-1;return this.last=n.value[o],this.lastFrom=n.from[o]+e,this.lastTo=n.to[o]+e,!0}finish(){return this.finishInner(tn.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=tn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ok(t,e,n){let o=new Map;for(let i of t)for(let s=0;s<i.chunk.length;s++)i.chunk[s].maxPoint<=0&&o.set(i.chunk[s],i.chunkPos[s]);let r=new Set;for(let i of e)for(let s=0;s<i.chunk.length;s++){let a=o.get(i.chunk[s]);a!=null&&(n?n.mapPos(a):a)==i.chunkPos[s]&&!(n!=null&&n.touchesRange(a,a+i.chunk[s].length))&&r.add(i.chunk[s])}return r}class vM{constructor(e,n,o,r=0){this.layer=e,this.skip=n,this.minPoint=o,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,n=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,n,!1),this}gotoInner(e,n,o){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,o=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],n,!0);(!o||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,n){(this.to-e||this.endSide-n)<0&&this.gotoInner(e,n,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],n=this.layer.chunk[this.chunkIndex],o=e+n.from[this.rangeIndex];if(this.from=o,this.to=e+n.to[this.rangeIndex],this.value=n.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class ff{constructor(e){this.heap=e}static from(e,n=null,o=-1){let r=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=o&&r.push(new vM(s,n,o,i));return r.length==1?r[0]:new ff(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let o of this.heap)o.goto(e,n);for(let o=this.heap.length>>1;o>=0;o--)Ov(this.heap,o);return this.next(),this}forward(e,n){for(let o of this.heap)o.forward(e,n);for(let o=this.heap.length>>1;o>=0;o--)Ov(this.heap,o);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Ov(this.heap,0)}}}function Ov(t,e){for(let n=t[e];;){let o=(e<<1)+1;if(o>=t.length)break;let r=t[o];if(o+1<t.length&&r.compare(t[o+1])>=0&&(r=t[o+1],o++),n.compare(r)<0)break;t[o]=n,t[e]=r,e=o}}class Zu{constructor(e,n,o){this.minPoint=o,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ff.from(e,n,o)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Ah(this.active,e),Ah(this.activeTo,e),Ah(this.activeRank,e),this.minActive=ik(this.active,this.activeTo)}addActive(e){let n=0,{value:o,to:r,rank:i}=this.cursor;for(;n<this.activeRank.length&&(i-this.activeRank[n]||r-this.activeTo[n])>0;)n++;Ch(this.active,n,o),Ch(this.activeTo,n,r),Ch(this.activeRank,n,i),e&&Ch(e,n,this.cursor.from),this.minActive=ik(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let o=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),o&&Ah(o,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(o),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(o){this.openStart=0;for(let r=o.length-1;r>=0&&o[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let n=[];for(let o=this.active.length-1;o>=0&&!(this.activeRank[o]<this.pointRank);o--)(this.activeTo[o]>e||this.activeTo[o]==e&&this.active[o].endSide>=this.point.endSide)&&n.push(this.active[o]);return n.reverse()}openEnd(e){let n=0;for(let o=this.activeTo.length-1;o>=0&&this.activeTo[o]>e;o--)n++;return n}}function rk(t,e,n,o,r,i){t.goto(e),n.goto(o);let s=o+r,a=o,l=o-e,c=!!i.boundChange;for(let u=!1;;){let d=t.to+l-n.to,f=d||t.endSide-n.endSide,h=f<0?t.to+l:n.to,g=Math.min(h,s);if(t.point||n.point?(t.point&&n.point&&K2(t.point,n.point)&&vb(t.activeForPoint(t.to),n.activeForPoint(n.to))||i.comparePoint(a,g,t.point,n.point),u=!1):(u&&i.boundChange(a),g>a&&!vb(t.active,n.active)&&i.compareRange(a,g,t.active,n.active),c&&g<s&&(d||t.openEnd(h)!=n.openEnd(h))&&(u=!0)),h>s)break;a=h,f<=0&&t.next(),f>=0&&n.next()}}function vb(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!K2(t[n],e[n]))return!1;return!0}function Ah(t,e){for(let n=e,o=t.length-1;n<o;n++)t[n]=t[n+1];t.pop()}function Ch(t,e,n){for(let o=t.length-1;o>=e;o--)t[o+1]=t[o];t[e]=n}function ik(t,e){let n=-1,o=1e9;for(let r=0;r<e.length;r++)(e[r]-o||t[r].endSide-t[n].endSide)<0&&(n=r,o=e[r]);return n}function hg(t,e,n=t.length){let o=0;for(let r=0;r<n&&r<t.length;)t.charCodeAt(r)==9?(o+=e-o%e,r++):(o++,r=To(t,r));return o}function bfe(t,e,n,o){for(let r=0,i=0;;){if(i>=e)return r;if(r==t.length)break;i+=t.charCodeAt(r)==9?n-i%n:1,r=To(t,r)}return t.length}const bb="ͼ",sk=typeof Symbol>"u"?"__"+bb:Symbol.for(bb),yb=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ak=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Fa{constructor(e,n){this.rules=[];let{finish:o}=n||{};function r(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,a,l,c){let u=[],d=/^@(\w+)\b/.exec(s[0]),f=d&&d[1]=="keyframes";if(d&&a==null)return l.push(s[0]+";");for(let h in a){let g=a[h];if(/&/.test(h))i(h.split(/,\s*/).map(b=>s.map(m=>b.replace(/&/,m))).reduce((b,m)=>b.concat(m)),g,l);else if(g&&typeof g=="object"){if(!d)throw new RangeError("The value of a property ("+h+") should be a primitive value.");i(r(h),g,u,f)}else g!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+g+";")}(u.length||f)&&l.push((o&&!d&&!c?s.map(o):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)i(r(s),e[s],this.rules)}getRules(){return this.rules.join(`
|
|
854
|
-
`)}static newName(){let e=ak[sk]||1;return ak[sk]=e+1,bb+e.toString(36)}static mount(e,n,o){let r=e[yb],i=o&&o.nonce;r?i&&r.setNonce(i):r=new
|
|
855
|
-
`;this.styleTag.textContent=s;let a=n.head||n;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Va={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xfe=typeof navigator<"u"&&/Mac/.test(navigator.platform),wfe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var oo=0;oo<10;oo++)Va[48+oo]=Va[96+oo]=String(oo);for(var oo=1;oo<=24;oo++)Va[oo+111]="F"+oo;for(var oo=65;oo<=90;oo++)Va[oo]=String.fromCharCode(oo+32),hf[oo]=String.fromCharCode(oo);for(var Bv in Va)hf.hasOwnProperty(Bv)||(hf[Bv]=Va[Bv]);function _fe(t){var e=xfe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||wfe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hf:Va)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Io=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},xb=typeof document<"u"?document:{documentElement:{style:{}}};const wb=/Edge\/(\d+)/.exec(Io.userAgent),bM=/MSIE \d/.test(Io.userAgent),_b=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Io.userAgent),pg=!!(bM||_b||wb),ck=!pg&&/gecko\/(\d+)/i.test(Io.userAgent),Lv=!pg&&/Chrome\/(\d+)/.exec(Io.userAgent),kfe="webkitFontSmoothing"in xb.documentElement.style,kb=!pg&&/Apple Computer/.test(Io.vendor),uk=kb&&(/Mobile\/\w+/.test(Io.userAgent)||Io.maxTouchPoints>2);var ot={mac:uk||/Mac/.test(Io.platform),windows:/Win/.test(Io.platform),linux:/Linux|X11/.test(Io.platform),ie:pg,ie_version:bM?xb.documentMode||6:_b?+_b[1]:wb?+wb[1]:0,gecko:ck,gecko_version:ck?+(/Firefox\/(\d+)/.exec(Io.userAgent)||[0,0])[1]:0,chrome:!!Lv,chrome_version:Lv?+Lv[1]:0,ios:uk,android:/Android\b/.test(Io.userAgent),webkit_version:kfe?+(/\bAppleWebKit\/(\d+)/.exec(Io.userAgent)||[0,0])[1]:0,safari:kb,safari_version:kb?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Io.userAgent)||[0,0])[1]:0,tabSize:xb.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Q2(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const x0=Object.create(null);function J2(t,e,n){if(t==e)return!0;t||(t=x0),e||(e=x0);let o=Object.keys(t),r=Object.keys(e);if(o.length-0!=r.length-0)return!1;for(let i of o)if(i!=n&&(r.indexOf(i)==-1||t[i]!==e[i]))return!1;return!0}function Sfe(t,e){for(let n=t.attributes.length-1;n>=0;n--){let o=t.attributes[n].name;e[o]==null&&t.removeAttribute(o)}for(let n in e){let o=e[n];n=="style"?t.style.cssText=o:t.getAttribute(n)!=o&&t.setAttribute(n,o)}}function dk(t,e,n){let o=!1;if(e)for(let r in e)n&&r in n||(o=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(o=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return o}function Afe(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let o=t.attributes[n];e[o.name]=o.value}return e}class mg{eq(e){return!1}updateDOM(e,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,o){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var zr=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})(zr||(zr={}));class Xn extends Vl{constructor(e,n,o,r){super(),this.startSide=e,this.endSide=n,this.widget=o,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Rf(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),o=!!e.block;return n+=o&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new zl(e,n,n,o,e.widget||null,!1)}static replace(e){let n=!!e.block,o,r;if(e.isBlockGap)o=-5e8,r=4e8;else{let{start:i,end:s}=yM(e,n);o=(i?n?-3e8:-1:5e8)-1,r=(s?n?2e8:1:-6e8)+1}return new zl(e,o,r,n,e.widget||null,!0)}static line(e){return new Ff(e)}static set(e,n=!1){return tn.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Xn.none=tn.empty;class Rf extends Xn{constructor(e){let{start:n,end:o}=yM(e);super(n?-1:5e8,o?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Q2(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||x0}eq(e){return this==e||e instanceof Rf&&this.tagName==e.tagName&&J2(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Rf.prototype.point=!1;class Ff extends Xn{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ff&&this.spec.class==e.spec.class&&J2(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ff.prototype.mapMode=br.TrackBefore;Ff.prototype.point=!0;class zl extends Xn{constructor(e,n,o,r,i,s){super(n,o,i,e),this.block=r,this.isReplace=s,this.mapMode=r?n<=0?br.TrackBefore:br.TrackAfter:br.TrackDel}get type(){return this.startSide!=this.endSide?zr.WidgetRange:this.startSide<=0?zr.WidgetBefore:zr.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof zl&&Cfe(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}zl.prototype.point=!0;function yM(t,e=!1){let{inclusiveStart:n,inclusiveEnd:o}=t;return n==null&&(n=t.inclusive),o==null&&(o=t.inclusive),{start:n??e,end:o??e}}function Cfe(t,e){return t==e||!!(t&&e&&t.compare(e))}function Fc(t,e,n,o=0){let r=n.length-1;r>=0&&n[r]+o>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class pf extends Vl{constructor(e,n){super(),this.tagName=e,this.attributes=n}eq(e){return e==this||e instanceof pf&&this.tagName==e.tagName&&J2(this.attributes,e.attributes)}static create(e){return new pf(e.tagName,e.attributes||x0)}static set(e,n=!1){return tn.of(e,n)}}pf.prototype.startSide=pf.prototype.endSide=-1;function mf(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Sb(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Bd(t,e){if(!e.anchorNode)return!1;try{return Sb(t,e.anchorNode)}catch{return!1}}function ap(t){return t.nodeType==3?gf(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Ld(t,e,n,o){return n?fk(t,e,n,o,-1)||fk(t,e,n,o,1):!1}function za(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function w0(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function fk(t,e,n,o,r){for(;;){if(t==n&&e==o)return!0;if(e==(r<0?0:Xs(t))){if(t.nodeName=="DIV")return!1;let i=t.parentNode;if(!i||i.nodeType!=1)return!1;e=za(t)+(r<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?Xs(t):0}else return!1}}function Xs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _0(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function $fe(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function xM(t,e){let n=e.width/t.offsetWidth,o=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(e.height-t.offsetHeight)<1)&&(o=1),{scaleX:n,scaleY:o}}function Tfe(t,e,n,o,r,i,s,a){let l=t.ownerDocument,c=l.defaultView||window;for(let u=t,d=!1;u&&!d;)if(u.nodeType==1){let f,h=u==l.body,g=1,b=1;if(h)f=$fe(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let y=u.getBoundingClientRect();({scaleX:g,scaleY:b}=xM(u,y)),f={left:y.left,right:y.left+u.clientWidth*g,top:y.top,bottom:y.top+u.clientHeight*b}}let m=0,v=0;if(r=="nearest")e.top<f.top?(v=e.top-(f.top+s),n>0&&e.bottom>f.bottom+v&&(v=e.bottom-f.bottom+s)):e.bottom>f.bottom&&(v=e.bottom-f.bottom+s,n<0&&e.top-v<f.top&&(v=e.top-(f.top+s)));else{let y=e.bottom-e.top,x=f.bottom-f.top;v=(r=="center"&&y<=x?e.top+y/2-x/2:r=="start"||r=="center"&&n<0?e.top-s:e.bottom-x+s)-f.top}if(o=="nearest"?e.left<f.left?(m=e.left-(f.left+i),n>0&&e.right>f.right+m&&(m=e.right-f.right+i)):e.right>f.right&&(m=e.right-f.right+i,n<0&&e.left<f.left+m&&(m=e.left-(f.left+i))):m=(o=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:o=="start"==a?e.left-i:e.right-(f.right-f.left)+i)-f.left,m||v)if(h)c.scrollBy(m,v);else{let y=0,x=0;if(v){let _=u.scrollTop;u.scrollTop+=v/b,x=(u.scrollTop-_)*b}if(m){let _=u.scrollLeft;u.scrollLeft+=m/g,y=(u.scrollLeft-_)*g}e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x},y&&Math.abs(y-m)<1&&(o="nearest"),x&&Math.abs(x-v)<1&&(r="nearest")}if(h)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Mfe(t){let e=t.ownerDocument,n,o;for(let r=t.parentNode;r&&!(r==e.body||n&&o);)if(r.nodeType==1)!o&&r.scrollHeight>r.clientHeight&&(o=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:n,y:o}}class Ofe{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:o}=e;this.set(n,Math.min(e.anchorOffset,n?Xs(n):0),o,Math.min(e.focusOffset,o?Xs(o):0))}set(e,n,o,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=o,this.focusOffset=r}}let pl=null;ot.safari&&ot.safari_version>=26&&(pl=!1);function wM(t){if(t.setActive)return t.setActive();if(pl)return t.focus(pl);let e=[];for(let n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(pl==null?{get preventScroll(){return pl={preventScroll:!0},!0}}:void 0),!pl){pl=!1;for(let n=0;n<e.length;){let o=e[n++],r=e[n++],i=e[n++];o.scrollTop!=r&&(o.scrollTop=r),o.scrollLeft!=i&&(o.scrollLeft=i)}}}let hk;function gf(t,e,n=e){let o=hk||(hk=document.createRange());return o.setEnd(t,n),o.setStart(t,e),o}function Vc(t,e,n,o){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};o&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=o);let i=new KeyboardEvent("keydown",r);i.synthetic=!0,t.dispatchEvent(i);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,t.dispatchEvent(s),i.defaultPrevented||s.defaultPrevented}function Bfe(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Lfe(t,e){let n=e.focusNode,o=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=o)return!1;for(o=Math.min(o,Xs(n));;)if(o){if(n.nodeType!=1)return!1;let r=n.childNodes[o-1];r.contentEditable=="false"?o--:(n=r,o=Xs(n))}else{if(n==t)return!0;o=za(n),n=n.parentNode}}function _M(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function kM(t,e){for(let n=t,o=e;;){if(n.nodeType==3&&o>0)return{node:n,offset:o};if(n.nodeType==1&&o>0){if(n.contentEditable=="false")return null;n=n.childNodes[o-1],o=Xs(n)}else if(n.parentNode&&!w0(n))o=za(n),n=n.parentNode;else return null}}function SM(t,e){for(let n=t,o=e;;){if(n.nodeType==3&&o<n.nodeValue.length)return{node:n,offset:o};if(n.nodeType==1&&o<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[o],o=0}else if(n.parentNode&&!w0(n))o=za(n)+1,n=n.parentNode;else return null}}class ci{constructor(e,n,o=!0){this.node=e,this.offset=n,this.precise=o}static before(e,n){return new ci(e.parentNode,za(e),n)}static after(e,n){return new ci(e.parentNode,za(e)+1,n)}}var Dn=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(Dn||(Dn={}));const Hl=Dn.LTR,ex=Dn.RTL;function AM(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const Pfe=AM("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Dfe=AM("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ab=Object.create(null),Ii=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);Ab[e]=n,Ab[n]=-e}function CM(t){return t<=247?Pfe[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Dfe[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Efe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Yi{get dir(){return this.level%2?ex:Hl}constructor(e,n,o){this.from=e,this.to=n,this.level=o}side(e,n){return this.dir==n==e?this.to:this.from}forward(e,n){return e==(this.dir==n)}static find(e,n,o,r){let i=-1;for(let s=0;s<e.length;s++){let a=e[s];if(a.from<=n&&a.to>=n){if(a.level==o)return s;(i<0||(r!=0?r<0?a.from<n:a.to>n:e[i].level>a.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}}function $M(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let o=t[n],r=e[n];if(o.from!=r.from||o.to!=r.to||o.direction!=r.direction||!$M(o.inner,r.inner))return!1}return!0}const sn=[];function Nfe(t,e,n,o,r){for(let i=0;i<=o.length;i++){let s=i?o[i-1].to:e,a=i<o.length?o[i].from:n,l=i?256:r;for(let c=s,u=l,d=l;c<a;c++){let f=CM(t.charCodeAt(c));f==512?f=u:f==8&&d==4&&(f=16),sn[c]=f==4?2:f,f&7&&(d=f),u=f}for(let c=s,u=l,d=l;c<a;c++){let f=sn[c];if(f==128)c<a-1&&u==sn[c+1]&&u&24?f=sn[c]=u:sn[c]=256;else if(f==64){let h=c+1;for(;h<a&&sn[h]==64;)h++;let g=c&&u==8||h<n&&sn[h]==8?d==1?1:8:256;for(let b=c;b<h;b++)sn[b]=g;c=h-1}else f==8&&d==1&&(sn[c]=1);u=f,f&7&&(d=f)}}}function Ife(t,e,n,o,r){let i=r==1?2:1;for(let s=0,a=0,l=0;s<=o.length;s++){let c=s?o[s-1].to:e,u=s<o.length?o[s].from:n;for(let d=c,f,h,g;d<u;d++)if(h=Ab[f=t.charCodeAt(d)])if(h<0){for(let b=a-3;b>=0;b-=3)if(Ii[b+1]==-h){let m=Ii[b+2],v=m&2?r:m&4?m&1?i:r:0;v&&(sn[d]=sn[Ii[b]]=v),a=b;break}}else{if(Ii.length==189)break;Ii[a++]=d,Ii[a++]=f,Ii[a++]=l}else if((g=sn[d])==2||g==1){let b=g==r;l=b?0:1;for(let m=a-3;m>=0;m-=3){let v=Ii[m+2];if(v&2)break;if(b)Ii[m+2]|=2;else{if(v&4)break;Ii[m+2]|=4}}}}}function Rfe(t,e,n,o){for(let r=0,i=o;r<=n.length;r++){let s=r?n[r-1].to:t,a=r<n.length?n[r].from:e;for(let l=s;l<a;){let c=sn[l];if(c==256){let u=l+1;for(;;)if(u==a){if(r==n.length)break;u=n[r++].to,a=r<n.length?n[r].from:e}else if(sn[u]==256)u++;else break;let d=i==1,f=(u<e?sn[u]:o)==1,h=d==f?d?1:2:o;for(let g=u,b=r,m=b?n[b-1].to:t;g>l;)g==m&&(g=n[--b].from,m=b?n[b-1].to:t),sn[--g]=h;l=u}else i=c,l++}}}function Cb(t,e,n,o,r,i,s){let a=o%2?2:1;if(o%2==r%2)for(let l=e,c=0;l<n;){let u=!0,d=!1;if(c==i.length||l<i[c].from){let b=sn[l];b!=a&&(u=!1,d=b==16)}let f=!u&&a==1?[]:null,h=u?o:o+1,g=l;e:for(;;)if(c<i.length&&g==i[c].from){if(d)break e;let b=i[c];if(!u)for(let m=b.to,v=c+1;;){if(m==n)break e;if(v<i.length&&i[v].from==m)m=i[v++].to;else{if(sn[m]==a)break e;break}}if(c++,f)f.push(b);else{b.from>l&&s.push(new Yi(l,b.from,h));let m=b.direction==Hl!=!(h%2);$b(t,m?o+1:o,r,b.inner,b.from,b.to,s),l=b.to}g=b.to}else{if(g==n||(u?sn[g]!=a:sn[g]==a))break;g++}f?Cb(t,l,g,o+1,r,f,s):l<g&&s.push(new Yi(l,g,h)),l=g}else for(let l=n,c=i.length;l>e;){let u=!0,d=!1;if(!c||l>i[c-1].to){let b=sn[l-1];b!=a&&(u=!1,d=b==16)}let f=!u&&a==1?[]:null,h=u?o:o+1,g=l;e:for(;;)if(c&&g==i[c-1].to){if(d)break e;let b=i[--c];if(!u)for(let m=b.from,v=c;;){if(m==e)break e;if(v&&i[v-1].to==m)m=i[--v].from;else{if(sn[m-1]==a)break e;break}}if(f)f.push(b);else{b.to<l&&s.push(new Yi(b.to,l,h));let m=b.direction==Hl!=!(h%2);$b(t,m?o+1:o,r,b.inner,b.from,b.to,s),l=b.from}g=b.from}else{if(g==e||(u?sn[g-1]!=a:sn[g-1]==a))break;g--}f?Cb(t,g,l,o+1,r,f,s):g<l&&s.push(new Yi(g,l,h)),l=g}}function $b(t,e,n,o,r,i,s){let a=e%2?2:1;Nfe(t,r,i,o,a),Ife(t,r,i,o,a),Rfe(r,i,o,a),Cb(t,r,i,e,n,o,s)}function Ffe(t,e,n){if(!t)return[new Yi(0,0,e==ex?1:0)];if(e==Hl&&!n.length&&!Efe.test(t))return TM(t.length);if(n.length)for(;t.length>sn.length;)sn[sn.length]=256;let o=[],r=e==Hl?0:1;return $b(t,r,r,n,0,t.length,o),o}function TM(t){return[new Yi(0,t,0)]}let MM="";function Vfe(t,e,n,o,r){var i;let s=o.head-t.from,a=Yi.find(e,s,(i=o.bidiLevel)!==null&&i!==void 0?i:-1,o.assoc),l=e[a],c=l.side(r,n);if(s==c){let f=a+=r?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],s=l.side(!r,n),c=l.side(r,n)}let u=To(t.text,s,l.forward(r,n));(u<l.from||u>l.to)&&(u=c),MM=t.text.slice(Math.min(s,u),Math.max(s,u));let d=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return d&&u==c&&d.level+(r?0:1)<l.level?ze.cursor(d.side(!r,n)+t.from,d.forward(r,n)?1:-1,d.level):ze.cursor(u+t.from,l.forward(r,n)?-1:1,l.level)}function zfe(t,e,n){for(let o=e;o<n;o++){let r=CM(t.charCodeAt(o));if(r==1)return Hl;if(r==2||r==4)return ex}return Hl}const OM=pt.define(),BM=pt.define(),LM=pt.define(),PM=pt.define(),Tb=pt.define(),DM=pt.define(),EM=pt.define(),tx=pt.define(),nx=pt.define(),NM=pt.define({combine:t=>t.some(e=>e)}),Hfe=pt.define({combine:t=>t.some(e=>e)}),IM=pt.define();class zc{constructor(e,n="nearest",o="nearest",r=5,i=5,s=!1){this.range=e,this.y=n,this.x=o,this.yMargin=r,this.xMargin=i,this.isSnapshot=s}map(e){return e.empty?this:new zc(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new zc(ze.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const $h=$n.define({map:(t,e)=>t.map(e)}),RM=$n.define();function ji(t,e,n){let o=t.facet(PM);o.length?o[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Bs=pt.define({combine:t=>t.length?t[0]:!0});let Wfe=0;const Ac=pt.define({combine(t){return t.filter((e,n)=>{for(let o=0;o<n;o++)if(t[o].plugin==e.plugin)return!1;return!0})}});class Wl{constructor(e,n,o,r,i){this.id=e,this.create=n,this.domEventHandlers=o,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ac.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ac.of({plugin:this,arg:e}))}static define(e,n){const{eventHandlers:o,eventObservers:r,provide:i,decorations:s}=n||{};return new Wl(Wfe++,e,o,r,a=>{let l=[];return s&&l.push(gg.of(c=>{let u=c.plugin(a);return u?s(u):Xn.none})),i&&l.push(i(a)),l})}static fromClass(e,n){return Wl.define((o,r)=>new e(o,r),n)}}class Pv{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(o){if(ji(n.state,o,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){ji(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(o){ji(e.state,o,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const FM=pt.define(),ox=pt.define(),gg=pt.define(),VM=pt.define(),rx=pt.define(),Vf=pt.define(),zM=pt.define();function pk(t,e){let n=t.state.facet(zM);if(!n.length)return n;let o=n.map(i=>i instanceof Function?i(t):i),r=[];return tn.spans(o,e.from,e.to,{point(){},span(i,s,a,l){let c=i-e.from,u=s-e.from,d=r;for(let f=a.length-1;f>=0;f--,l--){let h=a[f].spec.bidiIsolate,g;if(h==null&&(h=zfe(e.text,c,u)),l>0&&d.length&&(g=d[d.length-1]).to==c&&g.direction==h)g.to=u,d=g.inner;else{let b={from:c,to:u,direction:h,inner:[]};d.push(b),d=b.inner}}}}),r}const HM=pt.define();function WM(t){let e=0,n=0,o=0,r=0;for(let i of t.state.facet(HM)){let s=i(t);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(n=Math.max(n,s.right)),s.top!=null&&(o=Math.max(o,s.top)),s.bottom!=null&&(r=Math.max(r,s.bottom)))}return{left:e,right:n,top:o,bottom:r}}const ud=pt.define();class Nr{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}join(e){return new Nr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,o=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>o.toA)){if(r.toA<o.fromA)break;o=o.join(r),e.splice(n-1,1)}}return e.splice(n,0,o),e}static extendWithRanges(e,n){if(n.length==0)return e;let o=[];for(let r=0,i=0,s=0;;){let a=r<e.length?e[r].fromB:1e9,l=i<n.length?n[i]:1e9,c=Math.min(a,l);if(c==1e9)break;let u=c+s,d=c,f=u;for(;;)if(i<n.length&&n[i]<=d){let h=n[i+1];i+=2,d=Math.max(d,h);for(let g=r;g<e.length&&e[g].fromB<=d;g++)s=e[g].toA-e[g].toB;f=Math.max(f,h+s)}else if(r<e.length&&e[r].fromB<=d){let h=e[r++];d=Math.max(d,h.toB),f=Math.max(f,h.toA),s=h.toA-h.toB}else break;o.push(new Nr(u,f,c,d))}return o}}class k0{constructor(e,n,o){this.view=e,this.state=n,this.transactions=o,this.flags=0,this.startState=e.state,this.changes=zn.empty(this.startState.doc.length);for(let i of o)this.changes=this.changes.compose(i.changes);let r=[];this.changes.iterChangedRanges((i,s,a,l)=>r.push(new Nr(i,s,a,l))),this.changedRanges=r}static create(e,n,o){return new k0(e,n,o)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Ufe=[];class Nn{constructor(e,n,o=0){this.dom=e,this.length=n,this.flags=o,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Ufe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&Sfe(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let o=n;for(let r of this.children){if(r==e)return o;o+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n){return null}domPosFor(e,n){let o=za(this.dom),r=this.length?e>0:n>0;return new ci(this.parent.dom,o+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof bg)return e;return null}static get(e){return e.cmTile}}class vg extends Nn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,o=null,r,i=(e==null?void 0:e.node)==n?e:null,s=0;for(let a of this.children){if(a.sync(e),s+=a.length+a.breakAfter,r=o?o.nextSibling:n.firstChild,i&&r!=a.dom&&(i.written=!0),a.dom.parentNode==n)for(;r&&r!=a.dom;)r=mk(r);else n.insertBefore(a.dom,r);o=a.dom}for(r=o?o.nextSibling:n.firstChild,i&&r&&(i.written=!0);r;)r=mk(r);this.length=s}}function mk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class bg extends vg{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Nn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],o=this,r=0,i=0;;)if(r==o.children.length){if(!n.length)return;o=o.parent,o.breakAfter&&i++,r=n.pop()}else{let s=o.children[r++];if(s instanceof zs)n.push(r),o=s,r=0;else{let a=i+s.length,l=e(s,i);if(l!==void 0)return l;i=a+s.breakAfter}}}resolveBlock(e,n){let o,r=-1,i,s=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&n>=-1&&n<=1){if(a.flags&32)return!0;a.flags&16&&(o=void 0)}(l<e||e==c&&(n<-1?a.length:a.covers(1)))&&(!o||!a.isWidget()&&o.isWidget())&&(o=a,r=e-l),(c>e||e==l&&(n>1?a.length:a.covers(-1)))&&(!i||!a.isWidget()&&i.isWidget())&&(i=a,s=e-l)}}),!o&&!i)throw new Error("No tile at position "+e);return o&&n<0||!i?{tile:o,offset:r}:{tile:i,offset:s}}}class zs extends vg{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let o=new zs(n||document.createElement(e.tagName),e);return n||(o.flags|=4),o}}class cu extends vg{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,o){let r=new cu(n||document.createElement("div"),e);return(!n||!o)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,o){let r=null,i=-1,s=null,a=-1;function l(u,d){for(let f=0,h=0;f<u.children.length&&h<=d;f++){let g=u.children[f],b=h+g.length;b>=d&&(g.isComposite()?l(g,d-h):(!s||s.isHidden&&(n>0||o&&qfe(s,g)))&&(b>d||g.flags&32)?(s=g,a=d-h):(h<d||g.flags&16&&!g.isHidden)&&(r=g,i=d-h)),h=b}}l(this,e);let c=(n<0?r:s)||r||s;return c?{tile:c,offset:c==r?i:a}:null}coordsIn(e,n){let o=this.resolveInline(e,n,!0);return o?o.tile.coordsIn(Math.max(0,o.offset),n):Gfe(this)}domIn(e,n){let o=this.resolveInline(e,n);if(o){let{tile:r,offset:i}=o;if(this.dom.contains(r.dom))return r.isText()?new ci(r.dom,Math.min(r.dom.nodeValue.length,i)):r.domPosFor(i,r.flags&16?1:r.flags&32?-1:n);let s=o.tile.parent,a=!1;for(let l of s.children){if(a)return new ci(l.dom,0);l==o.tile&&(a=!0)}}return new ci(this.dom,0)}}function Gfe(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ap(e);return n[n.length-1]||null}function qfe(t,e){let n=t.coordsIn(0,1),o=e.coordsIn(0,1);return n&&o&&o.top<n.bottom}class Jo extends vg{constructor(e,n){super(e),this.mark=n}get domAttrs(){return this.mark.attrs}static of(e,n){let o=new Jo(n||document.createElement(e.tagName),e);return n||(o.flags|=4),o}}class wl extends Nn{constructor(e,n){super(e,n.length),this.text=n}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,n){let o=this.dom.nodeValue.length;e>o&&(e=o);let r=e,i=e,s=0;e==0&&n<0||e==o&&n>=0?ot.chrome||ot.gecko||(e?(r--,s=1):i<o&&(i++,s=-1)):n<0?r--:i<o&&i++;let a=gf(this.dom,r,i).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];return ot.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?_0(l,s<0):l||null}static of(e,n){let o=new wl(n||document.createTextNode(e),e);return n||(o.flags|=2),o}}class Ul extends Nn{constructor(e,n,o,r){super(e,n,r),this.widget=o}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,o){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(o)return _0(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let i=this.dom.getClientRects(),s=null;if(!i.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?i.length-1:0;s=i[l],!(e>0?l==0:l==i.length-1||s.top<s.bottom);l+=a?-1:1);return _0(s,!a)}}get overrideDOMText(){if(!this.length)return Ut.empty;let{root:e}=this;if(!e)return Ut.empty;let n=this.posAtStart;return e.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,n,o,r,i){return i||(i=e.toDOM(n),e.editable||(i.contentEditable="false")),new Ul(i,o,e,r)}}class S0 extends Nn{constructor(e){let n=document.createElement("img");n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),super(n,0,e)}get isHidden(){return!0}get overrideDOMText(){return Ut.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Yfe{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,o){let{tile:r,index:i,beforeBreak:s,parents:a}=this;for(;e||n>0;)if(r.isComposite())if(s){if(!e)break;o&&o.break(),e--,s=!1}else if(i==r.children.length){if(!e&&!a.length)break;o&&o.leave(r),s=!!r.breakAfter,{tile:r,index:i}=a.pop(),i++}else{let l=r.children[i],c=l.breakAfter;(n>0?l.length<=e:l.length<e)&&(!o||o.skip(l,0,l.length)!==!1||!l.isComposite)?(s=!!c,i++,e-=l.length):(a.push({tile:r,index:i}),r=l,i=0,o&&l.isComposite()&&o.enter(l))}else if(i==r.length)s=!!r.breakAfter,{tile:r,index:i}=a.pop(),i++;else if(e){let l=Math.min(e,r.length-i);o&&o.skip(r,i,i+l),e-=l,i+=l}else break;return this.tile=r,this.index=i,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class jfe{constructor(e,n,o,r){this.from=e,this.to=n,this.wrapper=o,this.rank=r}}class Xfe{constructor(e,n,o){this.cache=e,this.root=n,this.blockWrappers=o,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,n,o,r){var i;this.flushBuffer();let s=this.ensureMarks(n,o),a=s.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let l=s.children[s.children.length-1]=new wl(a.dom,a.text+e);l.parent=s}else s.append(r||wl.of(e,(i=this.cache.find(wl))===null||i===void 0?void 0:i.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,n){let o=this.curLine;o.dom!=n.line.dom&&(o.setDOM(this.cache.reused.has(n.line)?Dv(n.line.dom):n.line.dom),this.cache.reused.set(n.line,2));let r=o;for(let a=n.marks.length-1;a>=0;a--){let l=n.marks[a],c=r.lastChild;if(c instanceof Jo&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Dv(l.dom)),r=c;else{if(this.cache.reused.get(l)){let d=Nn.get(l.dom);d&&d.setDOM(Dv(l.dom))}let u=Jo.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let i=Nn.get(e.text);i&&this.cache.reused.set(i,2);let s=new wl(e.text,e.text.nodeValue);s.flags|=8,r.append(s)}addInlineWidget(e,n,o){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(n,o);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,o){this.flushBuffer(),this.ensureMarks(n,o).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var o;e||(e=UM);let r=cu.start(e,n||((o=this.cache.find(cu))===null||o===void 0?void 0:o.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var o;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let s=e[i],a;if(n>0&&(a=r.lastChild)&&a instanceof Jo&&a.mark.eq(s))r=a,n--;else{let l=Jo.of(s,(o=this.cache.find(Jo,c=>c.mark.eq(s)))===null||o===void 0?void 0:o.dom);r.append(l),r=l,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!gk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(ot.ios&&gk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ev,0,32)||new Ul(Ev.toDOM(),0,Ev,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let n=new jfe(e.from,e.to,e.value,e.rank),o=this.wrappers.length;for(;o>0&&(this.wrappers[o-1].rank-n.rank||this.wrappers[o-1].to-n.to)<0;)o--;this.wrappers.splice(o,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let o of this.wrappers){let r=n.lastChild;if(o.from<this.pos&&r instanceof zs&&r.wrapper.eq(o.wrapper))n=r;else{let i=zs.of(o.wrapper,(e=this.cache.find(zs,s=>s.wrapper.eq(o.wrapper)))===null||e===void 0?void 0:e.dom);n.append(i),n=i}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),o=this.cache.find(S0,void 0,1);return o&&(o.flags=n),o||new S0(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Kfe{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:i,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=r;let a=this.textOff=Math.min(e,r.length);return i?null:r.slice(0,a)}let n=Math.min(this.text.length,this.textOff+e),o=this.text.slice(this.textOff,n);return this.textOff=n,o}}const A0=[Ul,cu,wl,Jo,S0,zs,bg];for(let t=0;t<A0.length;t++)A0[t].bucket=t;class Zfe{constructor(e){this.view=e,this.buckets=A0.map(()=>[]),this.index=A0.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,o=this.buckets[n];o.length<6?o.push(e):o[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,o=2){let r=e.bucket,i=this.buckets[r],s=this.index[r];for(let a=i.length-1;a>=0;a--){let l=(a+s)%i.length,c=i[l];if((!n||n(c))&&!this.reused.has(c))return i.splice(l,1),l<s&&this.index[r]--,this.reused.set(c,o),c}return null}findWidget(e,n,o){let r=this.buckets[0];if(r.length)for(let i=0,s=0;;i++){if(i==r.length){if(s)return null;s=1,i=0}let a=r[i];if(!this.reused.has(a)&&(s==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,a.widget==e&&a.length==n&&(a.flags&497)==o?(this.reused.set(a,1),a):(this.reused.set(a,2),new Ul(a.dom,n,e,a.flags&-498|o))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,n=2){if(!this.reused.has(e))return this.reused.set(e,n),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Qfe{constructor(e,n,o,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Zfe(e),this.text=new Kfe(e.state.doc),this.builder=new Xfe(this.cache,new bg(e,e.contentDOM),tn.iter(o)),this.cache.reused.set(n,2),this.old=new Yfe(n),this.reuseWalker={skip:(s,a,l)=>{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(e,n){let o=n&&this.getCompositionContext(n.text);for(let r=0,i=0,s=0;;){let a=s<e.length?e[s++]:null,l=a?a.fromA:this.old.root.length;if(l>r){let c=l-r;this.preserve(c,!s,!a),r=l,i+=c}if(!a)break;n&&a.fromA<=n.range.fromA&&a.toA>=n.range.toA?(this.forward(a.fromA,n.range.fromA,n.range.fromA<n.range.toA?1:-1),this.emit(i,n.range.fromB),this.cache.clear(),this.builder.addComposition(n,o),this.text.skip(n.range.toB-n.range.fromB),this.forward(n.range.fromA,a.toA),this.emit(n.range.toB,a.toB)):(this.forward(a.fromA,a.toA),this.emit(i,a.toB)),i=a.toB,r=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,n,o){let r=the(this.old),i=this.openMarks;this.old.advance(e,o?1:-1,{skip:(s,a,l)=>{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a<s.length?Ul.of(s.widget,this.view,l-a,s.flags&496,this.cache.maybeReuse(s)):this.cache.reuse(s);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,i),i=r.length)}else if(s.isText())this.builder.ensureLine(null),!a&&l==s.length?this.builder.addText(s.text,r,i,this.cache.reuse(s)):(this.cache.add(s),this.builder.addText(s.text.slice(a,l),r,i)),i=r.length;else if(s.isLine())s.flags&=-2,this.cache.reused.set(s,1),this.builder.addLine(s);else if(s instanceof S0)this.cache.add(s);else if(s instanceof Jo)this.builder.ensureLine(null),this.builder.addMark(s,r,i),this.cache.reused.set(s,1),i=r.length;else return!1;this.openWidget=!1},enter:s=>{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof Jo&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=i=0):s instanceof Jo&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let o=null,r=this.builder,i=0,s=tn.spans(this.decorations,e,n,{point:(a,l,c,u,d,f)=>{if(c instanceof zl){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=u.length,d>u.length)r.continueWidget(l-a);else{let h=c.widget||(c.block?uu.block:uu.inline),g=Jfe(c),b=this.cache.findWidget(h,l-a,g)||Ul.of(h,this.view,l-a,g);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(o),r.addBlockWidget(b)):(r.ensureLine(o),r.addInlineWidget(b,u,d))}o=null}else o=ehe(o,c);l>a&&this.text.skip(l-a)},span:(a,l,c,u)=>{for(let d=a;d<l;){let f=this.text.next(Math.min(512,l-d));f==null?(r.addLineStartIfNotCovered(o),r.addBreak(),d++):(r.ensureLine(o),r.addText(f,c,d==a?u:c.length),d+=f.length),o=null}}});r.addLineStartIfNotCovered(o),this.openWidget=s>i,this.openMarks=s}forward(e,n,o=1){n-e<=10?this.old.advance(n-e,o,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,o,this.reuseWalker))}getCompositionContext(e){let n=[],o=null;for(let r=e.parentNode;;r=r.parentNode){let i=Nn.get(r);if(r==this.view.contentDOM)break;i instanceof Jo?n.push(i):i!=null&&i.isLine()?o=i:i instanceof zs||(r.nodeName=="DIV"&&!o&&r!=this.view.contentDOM?o=new cu(r,UM):o||n.push(Jo.of(new Rf({tagName:r.nodeName.toLowerCase(),attributes:Afe(r)}),r)))}return{line:o,marks:n}}}function gk(t,e){let n=o=>{for(let r of o.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function Jfe(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const UM={class:"cm-line"};function ehe(t,e){let n=e.spec.attributes,o=e.spec.class;return!n&&!o||(t||(t={class:"cm-line"}),n&&Q2(n,t),o&&(t.class+=" "+o)),t}function the(t){let e=[];for(let n=t.parents.length;n>1;n--){let o=n==t.parents.length?t.tile:t.parents[n].tile;o instanceof Jo&&e.push(o.mark)}return e}function Dv(t){let e=Nn.get(t);return e&&e.setDOM(t.cloneNode()),t}class uu extends mg{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}uu.inline=new uu("span");uu.block=new uu("div");const Ev=new class extends mg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class vk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Xn.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new bg(e,e.contentDOM),this.updateInner([new Nr(0,0,0,e.state.doc.length)],null)}update(e){var n;let o=e.changedRanges;this.minWidth>0&&o.length&&(o.every(({fromA:u,toA:d})=>d<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!uhe(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?ohe(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:d}=this.hasComposition;o=new Nr(u,d,e.changes.mapPos(u,-1),e.changes.mapPos(d,1)).addToSet(o.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(ot.ie||ot.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,a=this.blockWrappers;this.updateDeco();let l=she(s,this.decorations,e.changes);l.length&&(o=Nr.extendWithRanges(o,l));let c=lhe(a,this.blockWrappers,e.changes);return c.length&&(o=Nr.extendWithRanges(o,c)),i&&!o.some(u=>u.fromA<=i.range.fromA&&u.toA>=i.range.toA)&&(o=i.range.addToSet(o.slice())),this.tile.flags&2&&o.length==0?!1:(this.updateInner(o,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:o}=this.view;o.ignore(()=>{if(n||e.length){let s=this.tile,a=new Qfe(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=a.run(e,n),Mb(s,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=ot.chrome||ot.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),i&&(i.written||o.selectionRange.focusNode!=i.node||!this.tile.dom.contains(i.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let i of this.tile.children)i.isWidget()&&i.widget instanceof Nv&&r.push(i.dom);o.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let o of n.effects)o.is(RM)&&(this.editContextFormatting=o.value)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:o}=this.tile,r=this.view.root.activeElement,i=r==o,s=!i&&!(this.view.state.facet(Bs)||o.tabIndex>-1)&&Bd(o,this.view.observer.selectionRange)&&!(r&&o.contains(r));if(!(i||n||s))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,u;if(l.empty?u=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(u=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),ot.gecko&&l.empty&&!this.hasComposition&&nhe(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=u=new ci(f,0),a=!0}let d=this.view.observer.selectionRange;(a||!d.focusNode||(!Ld(c.node,c.offset,d.anchorNode,d.anchorOffset)||!Ld(u.node,u.offset,d.focusNode,d.focusOffset))&&!this.suppressWidgetCursorChange(d,l))&&(this.view.observer.ignore(()=>{ot.android&&ot.chrome&&o.contains(d.focusNode)&&che(d.focusNode,o)&&(o.blur(),o.focus({preventScroll:!0}));let f=mf(this.view.root);if(f)if(l.empty){if(ot.gecko){let h=rhe(c.node,c.offset);if(h&&h!=3){let g=(h==1?kM:SM)(c.node,c.offset);g&&(c=new ci(g.node,g.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(u.node,u.offset)}catch{}}else{let h=document.createRange();l.anchor>l.head&&([c,u]=[u,c]),h.setEnd(u.node,u.offset),h.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(h)}s&&this.view.root.activeElement==o&&(o.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new ci(d.anchorNode,d.anchorOffset),this.impreciseHead=u.precise?null:new ci(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Ld(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,o=mf(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!o||!n.empty||!n.assoc||!o.modify)return;let s=this.lineAt(n.head,n.assoc);if(!s)return;let a=s.posAtStart;if(n.head==a||n.head==a+s.length)return;let l=this.coordsAt(n.head,-1),c=this.coordsAt(n.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(n.head+n.assoc,n.assoc);o.collapse(u.node,u.offset),o.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=n.from&&o.collapse(r,i)}posFromDOM(e,n){let o=this.tile.nearest(e);if(!o)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=o.posAtStart;if(o.isComposite()){let i;if(e==o.dom)i=o.dom.childNodes[n];else{let s=Xs(e)==0?0:n==0?-1:1;for(;;){let a=e.parentNode;if(a==o.dom)break;s==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?s=-1:s=1),e=a}s<0?i=e:i=e.nextSibling}if(i==o.dom.firstChild)return r;for(;i&&!Nn.get(i);)i=i.nextSibling;if(!i)return r+o.length;for(let s=0,a=r;;s++){let l=o.children[s];if(l.dom==i)return a;a+=l.length+l.breakAfter}}else return o.isText()?e==o.dom?r+n:r+(n?o.length:0):r}domAtPos(e,n){let{tile:o,offset:r}=this.tile.resolveBlock(e,n);return o.isWidget()?o.domPosFor(e,n):o.domIn(r,n)}inlineDOMNearPos(e,n){let o,r=-1,i=!1,s,a=-1,l=!1;return this.tile.blockTiles((c,u)=>{if(c.isWidget()){if(c.flags&32&&u>=e)return!0;c.flags&16&&(i=!0)}else{let d=u+c.length;if(u<=e&&(o=c,r=e-u,i=d<e),d>=e&&!s&&(s=c,a=e-u,l=u>e),u>e&&s)return!0}}),!o&&!s?this.domAtPos(e,n):(i&&s?o=null:l&&o&&(s=null),o&&n<0||!s?o.domIn(r,n):s.domIn(a,n))}coordsAt(e,n){let{tile:o,offset:r}=this.tile.resolveBlock(e,n);return o.isWidget()?o.widget instanceof Nv?null:o.coordsInWidget(r,n,!0):o.coordsIn(r,n)}lineAt(e,n){let{tile:o}=this.tile.resolveBlock(e,n);return o.isLine()?o:null}coordsForChar(e){let{tile:n,offset:o}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(i,s){if(i.isComposite())for(let a of i.children){if(a.length>=s){let l=r(a,s);if(l)return l}if(s-=a.length,s<0)break}else if(i.isText()&&s<i.length){let a=To(i.text,s);if(a==s)return null;let l=gf(i.dom,s,a).getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(c==l.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}return r(n,o)}measureVisibleLineHeights(e){let n=[],{from:o,to:r}=e,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Dn.LTR,c=0,u=(d,f,h)=>{for(let g=0;g<d.children.length&&!(f>r);g++){let b=d.children[g],m=f+b.length,v=b.dom.getBoundingClientRect(),{height:y}=v;if(h&&!g&&(c+=v.top-h.top),b instanceof zs)m>o&&u(b,f,v);else if(f>=o&&(c>0&&n.push(-c),n.push(y+c),c=0,s)){let x=b.dom.lastChild,_=x?ap(x):[];if(_.length){let k=_[_.length-1],E=l?k.right-v.left:v.right-k.left;E>a&&(a=E,this.minWidth=i,this.minWidthFrom=f,this.minWidthTo=m)}}h&&g==d.children.length-1&&(c+=h.bottom-v.bottom),f=m+b.breakAfter}};return u(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Dn.RTL:Dn.LTR}measureTextSize(){let e=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let a=0,l;for(let c of s.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let u=ap(c.dom);if(u.length!=1)return;a+=u[0].width,l=u[0].height}if(a)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:a/s.length,textHeight:l}}});if(e)return e;let n=document.createElement("div"),o,r,i;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let s=ap(n.firstChild)[0];o=n.getBoundingClientRect().height,r=s&&s.width?s.width/27:7,i=s&&s.height?s.height:o,n.remove()}),{lineHeight:o,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let o=0,r=0;;r++){let i=r==n.viewports.length?null:n.viewports[r],s=i?i.from-1:this.view.state.doc.length;if(s>o){let a=(n.lineBlockAt(s).bottom-n.lineBlockAt(o).top)/this.view.scaleY;e.push(Xn.replace({widget:new Nv(a),block:!0,inclusive:!0,isBlockGap:!0}).range(o,s))}if(!i)break;o=i.to+1}return Xn.set(e)}updateDeco(){let e=1,n=this.view.state.facet(gg).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),o=!1,r=this.view.state.facet(rx).map((i,s)=>{let a=typeof i=="function";return a&&(o=!0),a?i(this.view):i});for(r.length&&(this.dynamicDecorationMap[e++]=o,n.push(tn.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(VM).map(i=>typeof i=="function"?i(this.view):i)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(IM))try{if(c(this.view,e.range,e))return!0}catch(u){ji(this.view.state,u,"scroll handler")}let{range:n}=e,o=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1),r;if(!o)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(o={left:Math.min(o.left,r.left),top:Math.min(o.top,r.top),right:Math.max(o.right,r.right),bottom:Math.max(o.bottom,r.bottom)});let i=WM(this.view),s={left:o.left-i.left,top:o.top-i.top,right:o.right+i.right,bottom:o.bottom+i.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(Tfe(this.view.scrollDOM,s,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Dn.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(o.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||o.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(n.head,1);c&&c.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let n=o=>o.isWidget()||o.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){Mb(this.tile)}}function Mb(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let o of t.children)Mb(o,e)}}function nhe(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function GM(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let o=kM(n.focusNode,n.focusOffset),r=SM(n.focusNode,n.focusOffset),i=o||r;if(r&&o&&r.node!=o.node){let a=Nn.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)i=r;else if(t.docView.lastCompositionAfterCursor){let l=Nn.get(o.node);!l||l.isText()&&l.text!=o.node.nodeValue||(i=r)}}if(t.docView.lastCompositionAfterCursor=i!=o,!i)return null;let s=e-i.offset;return{from:s,to:s+i.node.nodeValue.length,node:i.node}}function ohe(t,e,n){let o=GM(t,n);if(!o)return null;let{node:r,from:i,to:s}=o,a=r.nodeValue;if(/[\n\r]/.test(a)||t.state.doc.sliceString(o.from,o.to)!=a)return null;let l=e.invertedDesc;return{range:new Nr(l.mapPos(i),l.mapPos(s),i,s),text:r}}function rhe(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let ihe=class{constructor(){this.changes=[]}compareRange(e,n){Fc(e,n,this.changes)}comparePoint(e,n){Fc(e,n,this.changes)}boundChange(e){Fc(e,e,this.changes)}};function she(t,e,n){let o=new ihe;return tn.compare(t,e,n,o),o.changes}class ahe{constructor(){this.changes=[]}compareRange(e,n){Fc(e,n,this.changes)}comparePoint(){}boundChange(e){Fc(e,e,this.changes)}}function lhe(t,e,n){let o=new ahe;return tn.compare(t,e,n,o),o.changes}function che(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function uhe(t,e){let n=!1;return e&&t.iterChangedRanges((o,r)=>{o<e.to&&r>e.from&&(n=!0)}),n}class Nv extends mg{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function dhe(t,e,n=1){let o=t.charCategorizer(e),r=t.doc.lineAt(e),i=e-r.from;if(r.length==0)return ze.cursor(e);i==0?n=1:i==r.length&&(n=-1);let s=i,a=i;n<0?s=To(r.text,i,!1):a=To(r.text,i);let l=o(r.text.slice(s,a));for(;s>0;){let c=To(r.text,s,!1);if(o(r.text.slice(c,s))!=l)break;s=c}for(;a<r.length;){let c=To(r.text,a);if(o(r.text.slice(a,c))!=l)break;a=c}return ze.range(s+r.from,a+r.from)}function fhe(t,e,n,o,r){let i=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>t.defaultLineHeight*1.5){let a=t.viewState.heightOracle.textHeight,l=Math.floor((r-n.top-(t.defaultLineHeight-a)*.5)/a);i+=l*t.viewState.heightOracle.lineLength}let s=t.state.sliceDoc(n.from,n.to);return n.from+bfe(s,i,t.state.tabSize)}function hhe(t,e,n){let o=t.lineBlockAt(e);if(Array.isArray(o.type)){let r;for(let i of o.type){if(i.from>e)break;if(!(i.to<e)){if(i.from<e&&i.to>e)return i;(!r||i.type==zr.Text&&(r.type!=i.type||(n<0?i.from<e:i.to>e)))&&(r=i)}}return r||o}return o}function phe(t,e,n,o){let r=hhe(t,e.head,e.assoc||-1),i=!o||r.type!=zr.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(i){let s=t.dom.getBoundingClientRect(),a=t.textDirectionAt(r.from),l=t.posAtCoords({x:n==(a==Dn.LTR)?s.right-1:s.left+1,y:(i.top+i.bottom)/2});if(l!=null)return ze.cursor(l,n?-1:1)}return ze.cursor(n?r.to:r.from,n?-1:1)}function bk(t,e,n,o){let r=t.state.doc.lineAt(e.head),i=t.bidiSpans(r),s=t.textDirectionAt(r.from);for(let a=e,l=null;;){let c=Vfe(r,i,s,a,n),u=MM;if(!c){if(r.number==(n?t.state.doc.lines:1))return a;u=`
|
|
856
|
-
`,r=t.state.doc.line(r.number+(n?1:-1)),i=t.bidiSpans(r),c=t.visualLineSide(r,!n)}if(l){if(!l(u))return a}else{if(!o)return c;l=o(u)}a=c}}function
|
|
857
|
-
`&&t.lineWrapping&&(o&&(o=ze.single(o.main.anchor-1,o.main.head-1)),n={from:r.from,to:r.to,insert:Ut.of([" "])}),n)return ix(t,n,o,i);if(o&&!C0(o,r)){let s=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(s=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(o=qM(t.state.facet(Vf).map(l=>l(t)),o))),t.dispatch({selection:o,scrollIntoView:s,userEvent:a}),!0}else return!1}function ix(t,e,n,o=-1){if(ot.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(ot.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Vc(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||o==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Vc(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Vc(t.contentDOM,"Delete",46)))return!0;let i=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let s,a=()=>s||(s=_he(t,e,n));return t.state.facet(DM).some(l=>l(t,e.from,e.to,i,a))||t.dispatch(a()),!0}function _he(t,e,n){let o,r=t.state,i=r.selection.main,s=-1;if(e.from==e.to&&e.from<i.from||e.from>i.to){let l=e.from<i.from?-1:1,c=l<0?i.from:i.to,u=Pd(r.facet(Vf).map(d=>d(t)),c,l);e.from==u&&(s=u)}if(s>-1)o={changes:e,selection:ze.cursor(e.from+e.insert.length,-1)};else if(e.from>=i.from&&e.to<=i.to&&e.to-e.from>=(i.to-i.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let l=i.from<e.from?r.sliceDoc(i.from,e.from):"",c=i.to>e.to?r.sliceDoc(e.to,i.to):"";o=r.replaceSelection(t.state.toText(l+e.insert.sliceString(0,void 0,t.state.lineBreak)+c))}else{let l=r.changes(e),c=n&&n.main.to<=l.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=i.to+10&&e.to>=i.to-10){let u=t.state.sliceDoc(e.from,e.to),d,f=n&&GM(t,n.main.head);if(f){let g=e.insert.length-(e.to-e.from);d={from:f.from,to:f.to-g}}else d=t.state.doc.lineAt(i.head);let h=i.to-e.to;o=r.changeByRange(g=>{if(g.from==i.from&&g.to==i.to)return{changes:l,range:c||g.map(l)};let b=g.to-h,m=b-u.length;if(t.state.sliceDoc(m,b)!=u||b>=d.from&&m<=d.to)return{range:g};let v=r.changes({from:m,to:b,insert:e.insert}),y=g.to-i.to;return{changes:v,range:c?ze.range(Math.max(0,c.anchor+y),Math.max(0,c.head+y)):g.map(v)}})}else o={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1)),r.update(o,{userEvent:a,scrollIntoView:!0})}function XM(t,e,n,o){let r=Math.min(t.length,e.length),i=0;for(;i<r&&t.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==r&&t.length==e.length)return null;let s=t.length,a=e.length;for(;s>0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(o=="end"){let l=Math.max(0,i-Math.min(s,a));n-=s+l-i}if(s<i&&t.length<e.length){let l=n<=i&&n>=s?i-n:0;i-=l,a=i+(a-s),s=i}else if(a<i){let l=n<=i&&n>=a?i-n:0;i-=l,s=i+(s-a),a=i}return{from:i,toA:s,toB:a}}function khe(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}=t.observer.selectionRange;return n&&(e.push(new yk(n,o)),(r!=n||i!=o)&&e.push(new yk(r,i))),e}function She(t,e){if(t.length==0)return null;let n=t[0].pos,o=t.length==2?t[1].pos:n;return n>-1&&o>-1?ze.single(n+e,o+e):null}function C0(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class Ahe{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ot.safari&&e.contentDOM.addEventListener("input",()=>null),ot.gecko&&Vhe(e.contentDOM.ownerDocument)}handleEvent(e){!Phe(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let o=this.handlers[e];if(o){for(let r of o.observers)r(this.view,n);for(let r of o.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=Che(e),o=this.handlers,r=this.view.contentDOM;for(let i in n)if(i!="scroll"){let s=!n[i].handlers.length,a=o[i];a&&s!=!a.handlers.length&&(r.removeEventListener(i,this.handleEvent),a=null),a||r.addEventListener(i,this.handleEvent,{passive:s})}for(let i in o)i!="scroll"&&!n[i]&&r.removeEventListener(i,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ZM.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ot.android&&ot.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return ot.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=KM.find(o=>o.keyCode==e.keyCode))&&!e.ctrlKey||$he.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Vc(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:ot.safari&&!ot.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function xk(t,e){return(n,o)=>{try{return e.call(t,o,n)}catch(r){ji(n.state,r)}}}function Che(t){let e=Object.create(null);function n(o){return e[o]||(e[o]={observers:[],handlers:[]})}for(let o of t){let r=o.spec,i=r&&r.plugin.domEventHandlers,s=r&&r.plugin.domEventObservers;if(i)for(let a in i){let l=i[a];l&&n(a).handlers.push(xk(o.value,l))}if(s)for(let a in s){let l=s[a];l&&n(a).observers.push(xk(o.value,l))}}for(let o in $i)n(o).handlers.push($i[o]);for(let o in Gr)n(o).observers.push(Gr[o]);return e}const KM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],$he="dthko",ZM=[16,17,18,20,91,92,224,225],Th=6;function Mh(t){return Math.max(0,t)*.7+8}function The(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Mhe{constructor(e,n,o,r){this.view=e,this.startEvent=n,this.style=o,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=Mfe(e.contentDOM),this.atoms=e.state.facet(Vf).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Kt.allowMultipleSelections)&&Ohe(e,n),this.dragging=Lhe(e,n)&&eO(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&The(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,r=0,i=0,s=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=WM(this.view);e.clientX-l.left<=r+Th?n=-Mh(r-e.clientX):e.clientX+l.right>=s-Th&&(n=Mh(e.clientX-s)),e.clientY-l.top<=i+Th?o=-Mh(i-e.clientY):e.clientY+l.bottom>=a-Th&&(o=Mh(e.clientY-a)),this.setScrollSpeed(n,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,o=qM(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!o.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:o,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Ohe(t,e){let n=t.state.facet(OM);return n.length?n[0](e):ot.mac?e.metaKey:e.ctrlKey}function Bhe(t,e){let n=t.state.facet(BM);return n.length?n[0](e):ot.mac?!e.altKey:!e.ctrlKey}function Lhe(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let o=mf(t.root);if(!o||o.rangeCount==0)return!0;let r=o.getRangeAt(0).getClientRects();for(let i=0;i<r.length;i++){let s=r[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function Phe(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,o;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(o=Nn.get(n))&&o.isWidget()&&!o.isHidden&&o.widget.ignoreEvent(e))return!1;return!0}const $i=Object.create(null),Gr=Object.create(null),QM=ot.ie&&ot.ie_version<15||ot.ios&&ot.webkit_version<604;function Dhe(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),JM(t,n.value)},50)}function yg(t,e,n){for(let o of t.facet(e))n=o(n,t);return n}function JM(t,e){e=yg(t.state,tx,e);let{state:n}=t,o,r=1,i=n.toText(e),s=i.lines==n.selection.ranges.length;if(Bb!=null&&n.selection.ranges.every(l=>l.empty)&&Bb==i.toString()){let l=-1;o=n.changeByRange(c=>{let u=n.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let d=n.toText((s?i.line(r++).text:e)+n.lineBreak);return{changes:{from:u.from,insert:d},range:ze.cursor(c.from+d.length)}})}else s?o=n.changeByRange(l=>{let c=i.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:ze.cursor(l.from+c.length)}}):o=n.replaceSelection(i);t.dispatch(o,{userEvent:"input.paste",scrollIntoView:!0})}Gr.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};$i.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Gr.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};Gr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};$i.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let o of t.state.facet(LM))if(n=o(t,e),n)break;if(!n&&e.button==0&&(n=Nhe(t,e)),n){let o=!t.hasFocus;t.inputState.startMouseSelection(new Mhe(t,e,n,o)),o&&t.observer.ignore(()=>{wM(t.contentDOM);let i=t.root.activeElement;i&&!i.contains(t.contentDOM)&&i.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function wk(t,e,n,o){if(o==1)return ze.cursor(e,n);if(o==2)return dhe(t.state,e,n);{let r=t.docView.lineAt(e,n),i=t.state.doc.lineAt(r?r.posAtEnd:e),s=r?r.posAtStart:i.from,a=r?r.posAtEnd:i.to;return a<t.state.doc.length&&a==i.to&&a++,ze.range(s,a)}}const Ehe=ot.ie&&ot.ie_version<=11;let _k=null,kk=0,Sk=0;function eO(t){if(!Ehe)return t.detail;let e=_k,n=Sk;return _k=t,Sk=Date.now(),kk=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(kk+1)%3:1}function Nhe(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),o=eO(e),r=t.state.selection;return{update(i){i.docChanged&&(n.pos=i.changes.mapPos(n.pos),r=r.map(i.changes))},get(i,s,a){let l=t.posAndSideAtCoords({x:i.clientX,y:i.clientY},!1),c,u=wk(t,l.pos,l.assoc,o);if(n.pos!=l.pos&&!s){let d=wk(t,n.pos,n.assoc,o),f=Math.min(d.from,u.from),h=Math.max(d.to,u.to);u=f<u.from?ze.range(f,h):ze.range(h,f)}return s?r.replaceRange(r.main.extend(u.from,u.to)):a&&o==1&&r.ranges.length>1&&(c=Ihe(r,l.pos))?c:a?r.addRange(u):ze.create([u])}}}function Ihe(t,e){for(let n=0;n<t.ranges.length;n++){let{from:o,to:r}=t.ranges[n];if(o<=e&&r>=e)return ze.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}$i.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let i=r.posAtStart,s=i+r.length;(i>=n.to||s<=n.from)&&(n=ze.range(i,s))}}let{inputState:o}=t;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",yg(t.state,nx,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};$i.dragend=t=>(t.inputState.draggedContent=null,!1);function Ak(t,e,n,o){if(n=yg(t.state,tx,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:i}=t.inputState,s=o&&i&&Bhe(t,e)?{from:i.from,to:i.to}:null,a={from:r,insert:n},l=t.state.changes(s?[s,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),t.inputState.draggedContent=null}$i.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let o=Array(n.length),r=0,i=()=>{++r==n.length&&Ak(t,e,o.filter(s=>s!=null).join(t.state.lineBreak),!1)};for(let s=0;s<n.length;s++){let a=new FileReader;a.onerror=i,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(o[s]=a.result),i()},a.readAsText(n[s])}return!0}else{let o=e.dataTransfer.getData("Text");if(o)return Ak(t,e,o,!0),!0}return!1};$i.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=QM?null:e.clipboardData;return n?(JM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Dhe(t),!1)};function Rhe(t,e){let n=t.dom.parentNode;if(!n)return;let o=n.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout(()=>{o.remove(),t.focus()},50)}function Fhe(t){let e=[],n=[],o=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:i}of t.selection.ranges){let s=t.doc.lineAt(i);s.number>r&&(e.push(s.text),n.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}o=!0}return{text:yg(t,nx,e.join(t.lineBreak)),ranges:n,linewise:o}}let Bb=null;$i.copy=$i.cut=(t,e)=>{if(!Bd(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:o,linewise:r}=Fhe(t.state);if(!n&&!r)return!1;Bb=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"});let i=QM?null:e.clipboardData;return i?(i.clearData(),i.setData("text/plain",n),!0):(Rhe(t,n),!1)};const tO=tl.define();function nO(t,e){let n=[];for(let o of t.facet(EM)){let r=o(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:tO.of(!0)}):null}function oO(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=nO(t.state,e);n?t.dispatch(n):t.update([])}},10)}Gr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),oO(t)};Gr.blur=t=>{t.observer.clearSelectionRange(),oO(t)};Gr.compositionstart=Gr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Gr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,ot.chrome&&ot.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Gr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};$i.beforeinput=(t,e)=>{var n,o;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let i=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),s=e.getTargetRanges();if(i&&s.length){let a=s[0],l=t.posAtDOM(a.startContainer,a.startOffset),c=t.posAtDOM(a.endContainer,a.endOffset);return ix(t,{from:l,to:c,insert:t.state.toText(i)},null),!0}}let r;if(ot.chrome&&ot.android&&(r=KM.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let i=((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return ot.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),ot.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Gr.compositionend(t,e),20),!1};const Ck=new Set;function Vhe(t){Ck.has(t)||(Ck.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const $k=["pre-wrap","normal","pre-line","break-spaces"];let du=!1;function Tk(){du=!1}class zhe{constructor(e){this.lineWrapping=e,this.doc=Ut.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let o=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(o+=Math.max(0,Math.ceil((n-e-o*this.lineLength*.5)/this.lineLength))),this.lineHeight*o}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return $k.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let o=0;o<e.length;o++){let r=e[o];r<0?o++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,o,r,i,s){let a=$k.indexOf(e)>-1,l=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=a||Math.abs(o-this.charWidth)>.1;if(this.lineWrapping=a,this.lineHeight=n,this.charWidth=o,this.textHeight=r,this.lineLength=i,l){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class Hhe{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class ii{constructor(e,n,o,r,i){this.from=e,this.length=n,this.top=o,this.height=r,this._content=i}get type(){return typeof this._content=="number"?zr.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zl?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ii(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var cn=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(cn||(cn={}));const lp=.001;class Ho{constructor(e,n,o=2){this.length=e,this.height=n,this.flags=o}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>lp&&(du=!0),this.height=e)}replace(e,n,o){return Ho.of(o)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,o,r){let i=this,s=o.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:d}=r[a],f=i.lineAt(l,cn.ByPosNoHeight,o.setDoc(n),0,0),h=f.to>=c?f:i.lineAt(c,cn.ByPosNoHeight,o,0,0);for(d+=h.to-c,c=h.to;a>0&&f.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,l<f.from&&(f=i.lineAt(l,cn.ByPosNoHeight,o,0,0));u+=f.from-l,l=f.from;let g=sx.build(o.setDoc(s),e,u,d);i=$0(i,i.replace(l,c,g))}return i.updateHeight(o,0)}static empty(){return new gr(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,o=e.length,r=0,i=0;for(;;)if(n==o)if(r>i*2){let a=e[n-1];a.break?e.splice(--n,1,a.left,null,a.right):e.splice(--n,1,a.left,a.right),o+=1+a.break,r-=a.size}else if(i>r*2){let a=e[o];a.break?e.splice(o,1,a.left,null,a.right):e.splice(o,1,a.left,a.right),o+=2+a.break,i-=a.size}else break;else if(r<i){let a=e[n++];a&&(r+=a.size)}else{let a=e[--o];a&&(i+=a.size)}let s=0;return e[n-1]==null?(s=1,n--):e[n]==null&&(s=1,o++),new Uhe(Ho.of(e.slice(0,n)),s,Ho.of(e.slice(o)))}}function $0(t,e){return t==e?t:(t.constructor!=e.constructor&&(du=!0),e)}Ho.prototype.size=1;const Whe=Xn.replace({});class rO extends Ho{constructor(e,n,o){super(e,n),this.deco=o,this.spaceAbove=0}mainBlock(e,n){return new ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,o,r){return this.spaceAbove&&e<o+this.spaceAbove?new ii(r,0,o,this.spaceAbove,Whe):this.mainBlock(o,r)}lineAt(e,n,o,r,i){let s=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,o,r,i).join(s):s}forEachLine(e,n,o,r,i,s){e<=i+this.length&&n>=i&&s(this.lineAt(0,cn.ByPos,o,r,i))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,o=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class gr extends rO{constructor(e,n,o){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=o}mainBlock(e,n){return new ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,o){let r=o[0];return o.length==1&&(r instanceof gr||r instanceof to&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof to?r=new gr(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ho.of(o)}updateHeight(e,n=0,o=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(o||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class to extends Ho{constructor(e){super(e,0)}heightMetrics(e,n){let o=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,i=r-o+1,s,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*i);s=l/i,this.length>i+1&&(a=(this.height-l)/(this.length-i-1))}else s=this.height/i;return{firstLine:o,lastLine:r,perLine:s,perChar:a}}blockAt(e,n,o,r){let{firstLine:i,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);if(n.lineWrapping){let c=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-o)/this.height))*this.length)),u=n.doc.lineAt(c),d=a+u.length*l,f=Math.max(o,e-d/2);return new ii(u.from,u.length,f,d,0)}else{let c=Math.max(0,Math.min(s-i,Math.floor((e-o)/a))),{from:u,length:d}=n.doc.line(i+c);return new ii(u,d,o+a*c,a,0)}}lineAt(e,n,o,r,i){if(n==cn.ByHeight)return this.blockAt(e,o,r,i);if(n==cn.ByPosNoHeight){let{from:h,to:g}=o.doc.lineAt(e);return new ii(h,g-h,0,0,0)}let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(o,i),c=o.doc.lineAt(e),u=a+c.length*l,d=c.number-s,f=r+a*d+l*(c.from-i-d);return new ii(c.from,c.length,Math.max(r,Math.min(f,r+this.height-u)),u,0)}forEachLine(e,n,o,r,i,s){e=Math.max(e,i),n=Math.min(n,i+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(o,i);for(let u=e,d=r;u<=n;){let f=o.doc.lineAt(u);if(u==e){let g=f.number-a;d+=l*g+c*(e-i-g)}let h=l+c*f.length;s(new ii(f.from,f.length,d,h,0)),d+=h,u=f.to+1}}replace(e,n,o){let r=this.length-n;if(r>0){let i=o[o.length-1];i instanceof to?o[o.length-1]=new to(i.length+r):o.push(null,new to(r-1))}if(e>0){let i=o[0];i instanceof to?o[0]=new to(e+i.length):o.unshift(new to(e-1),null)}return Ho.of(o)}decomposeLeft(e,n){n.push(new to(e-1),null)}decomposeRight(e,n){n.push(null,new to(this.length-e-1))}updateHeight(e,n=0,o=!1,r){let i=n+this.length;if(r&&r.from<=n+this.length&&r.more){let s=[],a=Math.max(n,r.from),l=-1;for(r.from>n&&s.push(new to(r.from-n-1).updateHeight(e,n));a<=i&&r.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let d=r.heights[r.index++],f=0;d<0&&(f=-d,d=r.heights[r.index++]),l==-1?l=d:Math.abs(d-l)>=lp&&(l=-2);let h=new gr(u,d,f);h.outdated=!1,s.push(h),a+=u+1}a<=i&&s.push(null,new to(i-a).updateHeight(e,a));let c=Ho.of(s);return(l<0||Math.abs(c.height-this.height)>=lp||Math.abs(l-this.heightMetrics(e,n).perLine)>=lp)&&(du=!0),$0(this,c)}else(o||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Uhe extends Ho{constructor(e,n,o){super(e.length+n+o.length,e.height+o.height,n|(e.outdated||o.outdated?2:0)),this.left=e,this.right=o,this.size=e.size+o.size}get break(){return this.flags&1}blockAt(e,n,o,r){let i=o+this.left.height;return e<i?this.left.blockAt(e,n,o,r):this.right.blockAt(e,n,i,r+this.left.length+this.break)}lineAt(e,n,o,r,i){let s=r+this.left.height,a=i+this.left.length+this.break,l=n==cn.ByHeight?e<s:e<a,c=l?this.left.lineAt(e,n,o,r,i):this.right.lineAt(e,n,o,s,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=n==cn.ByPosNoHeight?cn.ByPosNoHeight:cn.ByPos;return l?c.join(this.right.lineAt(a,u,o,s,a)):this.left.lineAt(a,u,o,r,i).join(c)}forEachLine(e,n,o,r,i,s){let a=r+this.left.height,l=i+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,n,o,r,i,s),n>=l&&this.right.forEachLine(e,n,o,a,l,s);else{let c=this.lineAt(l,cn.ByPos,o,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,o,r,i,s),c.to>=e&&c.from<=n&&s(c),n>c.to&&this.right.forEachLine(c.to+1,n,o,a,l,s)}}replace(e,n,o){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,o),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,o));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let a of o)i.push(a);if(e>0&&Mk(i,s-1),n<this.length){let a=i.length;this.decomposeRight(n,i),Mk(i,a)}return Ho.of(i)}decomposeLeft(e,n){let o=this.left.length;if(e<=o)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(o++,e>=o&&n.push(null)),e>o&&this.right.decomposeLeft(e-o,n)}decomposeRight(e,n){let o=this.left.length,r=o+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<o&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Ho.of(this.break?[e,null,n]:[e,n]):(this.left=$0(this.left,e),this.right=$0(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,o=!1,r){let{left:i,right:s}=this,a=n+i.length+this.break,l=null;return r&&r.from<=n+i.length&&r.more?l=i=i.updateHeight(e,n,o,r):i.updateHeight(e,n,o),r&&r.from<=a+s.length&&r.more?l=s=s.updateHeight(e,a,o,r):s.updateHeight(e,a,o),l?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Mk(t,e){let n,o;t[e]==null&&(n=t[e-1])instanceof to&&(o=t[e+1])instanceof to&&t.splice(e-1,3,new to(n.length+1+o.length))}const Ghe=5;class sx{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let o=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof gr?r.length+=o-this.pos:(o>this.pos||!this.isCovered)&&this.nodes.push(new gr(o-this.pos,-1,0)),this.writtenTo=o,n>o&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,o){if(e<n||o.heightRelevant){let r=o.widget?o.widget.estimatedHeight:0,i=o.widget?o.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let s=n-e;o.block?this.addBlock(new rO(s,r,o)):(s||i||r>=Ghe)&&this.addLineDeco(r,i,s)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new gr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let o=new to(n-e);return this.oracle.doc.lineAt(e).to==n&&(o.flags|=4),o}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof gr)return e;let n=new gr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,o){let r=this.ensureLine();r.length+=o,r.collapsed+=o,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+o}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof gr)&&!this.isCovered?this.nodes.push(new gr(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let o=e;for(let r of this.nodes)r instanceof gr&&r.updateHeight(this.oracle,o),o+=r?r.length:1;return this.nodes}static build(e,n,o,r){let i=new sx(o,e);return tn.spans(n,o,r,i,0),i.finish(o)}}function qhe(t,e,n){let o=new Yhe;return tn.compare(t,e,n,o,0),o.changes}class Yhe{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,o,r){(e<n||o&&o.heightRelevant||r&&r.heightRelevant)&&Fc(e,n,this.changes,5)}}function jhe(t,e){let n=t.getBoundingClientRect(),o=t.ownerDocument,r=o.defaultView||window,i=Math.max(0,n.left),s=Math.min(r.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let c=t.parentNode;c&&c!=o.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let f=u.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),a=Math.max(a,f.top),l=Math.min(c==t.parentNode?r.innerHeight:l,f.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-n.left,right:Math.max(i,s)-n.left,top:a-(n.top+e),bottom:Math.max(a,l)-(n.top+e)}}function Xhe(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function Khe(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Rv{constructor(e,n,o,r){this.from=e,this.to=n,this.size=o,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],i=n[o];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,n){return Xn.replace({widget:new Zhe(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Zhe extends mg{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Ok{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Bk,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Dn.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(ox).some(o=>typeof o!="function"&&o.class=="cm-lineWrapping");this.heightOracle=new zhe(n),this.stateDeco=Lk(e),this.heightMap=Ho.empty().applyChanges(this.stateDeco,Ut.empty,this.heightOracle.setDoc(e.doc),[new Nr(0,0,0,e.doc.length)]);for(let o=0;o<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());o++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Xn.set(this.lineGaps.map(o=>o.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let o=0;o<=1;o++){let r=o?n.head:n.anchor;if(!e.some(({from:i,to:s})=>r>=i&&r<=s)){let{from:i,to:s}=this.lineBlockAt(r);e.push(new Oh(i,s))}}return this.viewports=e.sort((o,r)=>o.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Bk:new ax(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(fd(e,this.scaler))})}update(e,n=null){this.state=e.state;let o=this.stateDeco;this.stateDeco=Lk(this.state);let r=e.changedRanges,i=Nr.extendWithRanges(r,qhe(o,this.stateDeco,e?e.changes:zn.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Tk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=s||du)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<l.from||n.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,n));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Hfe)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,o=window.getComputedStyle(n),r=this.heightOracle,i=o.whiteSpace;this.defaultTextDirection=o.direction=="rtl"?Dn.RTL:Dn.LTR;let s=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent==="refresh",a=n.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:_,scaleY:k}=xM(n,a);(_>.005&&Math.abs(this.scaleX-_)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=_,this.scaleY=k,c|=16,s=l=!0)}let d=(parseInt(o.paddingTop)||0)*this.scaleY,f=(parseInt(o.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let h=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=h&&(this.scrollAnchorHeight=-1,this.scrollTop=h),this.scrolledToBottom=_M(e.scrollDOM);let g=(this.printing?Khe:jhe)(n,this.paddingTop),b=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget&&!Xhe(e.dom))return 0;let y=a.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let _=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(_)&&(s=!0),s||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:E,textHeight:B}=e.docView.measureTextSize();s=k>0&&r.refresh(i,k,E,B,Math.max(5,y/E),_),s&&(e.docView.minWidth=0,c|=16)}b>0&&m>0?u=Math.max(b,m):b<0&&m<0&&(u=Math.min(b,m)),Tk();for(let k of this.viewports){let E=k.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(k);this.heightMap=(s?Ho.empty().applyChanges(this.stateDeco,Ut.empty,this.heightOracle,[new Nr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new Hhe(k.from,E))}du&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let o=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:s,visibleBottom:a}=this,l=new Oh(r.lineAt(s-o*1e3,cn.ByHeight,i,0,0).from,r.lineAt(a+(1-o)*1e3,cn.ByHeight,i,0,0).to);if(n){let{head:c}=n.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=r.lineAt(c,cn.ByPos,i,0,0),f;n.y=="center"?f=(d.top+d.bottom)/2-u/2:n.y=="start"||n.y=="nearest"&&c<l.from?f=d.top:f=d.bottom-u,l=new Oh(r.lineAt(f-1e3/2,cn.ByHeight,i,0,0).from,r.lineAt(f+u+1e3/2,cn.ByHeight,i,0,0).to)}}return l}mapViewport(e,n){let o=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new Oh(this.heightMap.lineAt(o,cn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,cn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},o=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,cn.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(n,cn.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:a}=this;return(e==0||r<=s-Math.max(10,Math.min(-o,250)))&&(n==this.state.doc.length||i>=a+Math.max(10,Math.min(o,250)))&&r>s-2*1e3&&i<a+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let o=[];for(let r of e)n.touchesRange(r.from,r.to)||o.push(new Rv(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return o}ensureLineGaps(e,n){let o=this.heightOracle.lineWrapping,r=o?1e4:2e3,i=r>>1,s=r<<1;if(this.defaultTextDirection!=Dn.LTR&&!o)return[];let a=[],l=(u,d,f,h)=>{if(d-u<i)return;let g=this.state.selection.main,b=[g.from];g.empty||b.push(g.to);for(let v of b)if(v>u&&v<d){l(u,v-10,f,h),l(v+10,d,f,h);return}let m=Jhe(e,v=>v.from>=f.from&&v.to<=f.to&&Math.abs(v.from-u)<i&&Math.abs(v.to-d)<i&&!b.some(y=>v.from<y&&v.to>y));if(!m){if(d<f.to&&n&&o&&n.visibleRanges.some(x=>x.from<=d&&x.to>=d)){let x=n.moveToLineBoundary(ze.cursor(d),!1,!0).head;x>u&&(d=x)}let v=this.gapSize(f,u,d,h),y=o||v<2e6?v:2e6;m=new Rv(u,d,v,y)}a.push(m)},c=u=>{if(u.length<s||u.type!=zr.Text)return;let d=Qhe(u.from,u.to,this.stateDeco);if(d.total<s)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,h,g;if(o){let b=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,v;if(f!=null){let y=Lh(d,f),x=((this.visibleBottom-this.visibleTop)/2+b)/u.height;m=y-x,v=y+x}else m=(this.visibleTop-u.top-b)/u.height,v=(this.visibleBottom-u.top+b)/u.height;h=Bh(d,m),g=Bh(d,v)}else{let b=d.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,v=0;if(b>2e6)for(let E of e)E.from>=u.from&&E.from<u.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+v<this.pixelViewport.left&&(v=E.size-E.displaySize);let y=this.pixelViewport.left+v,x=this.pixelViewport.right+v,_,k;if(f!=null){let E=Lh(d,f),B=((x-y)/2+m)/b;_=E-B,k=E+B}else _=(y-m)/b,k=(x+m)/b;h=Bh(d,_),g=Bh(d,k)}h>u.from&&l(u.from,h,u,d),g<u.to&&l(g,u.to,u,d)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,n,o,r){let i=Lh(r,o)-Lh(r,n);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Rv.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Xn.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let o=[];tn.spans(n,this.viewport.from,this.viewport.to,{span(i,s){o.push({from:i,to:s})},point(){}},20);let r=0;if(o.length!=this.visibleRanges.length)r=12;else for(let i=0;i<o.length&&!(r&8);i++){let s=this.visibleRanges[i],a=o[i];(s.from!=a.from||s.to!=a.to)&&(r|=4,e&&e.mapPos(s.from,-1)==a.from&&e.mapPos(s.to,1)==a.to||(r|=8))}return this.visibleRanges=o,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||fd(this.heightMap.lineAt(e,cn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||fd(this.heightMap.lineAt(this.scaler.fromDOM(e),cn.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return fd(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Oh{constructor(e,n){this.from=e,this.to=n}}function Qhe(t,e,n){let o=[],r=t,i=0;return tn.spans(n,t,e,{span(){},point(s,a){s>r&&(o.push({from:r,to:s}),i+=s-r),r=a}},20),r<e&&(o.push({from:r,to:e}),i+=e-r),{total:i,ranges:o}}function Bh({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let o=Math.floor(t*n);for(let r=0;;r++){let{from:i,to:s}=e[r],a=s-i;if(o<=a)return i+o;o-=a}}function Lh(t,e){let n=0;for(let{from:o,to:r}of t.ranges){if(e<=r){n+=e-o;break}n+=r-o}return n/t.total}function Jhe(t,e){for(let n of t)if(e(n))return n}const Bk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Lk(t){let e=t.facet(gg).filter(o=>typeof o!="function"),n=t.facet(rx).filter(o=>typeof o!="function");return n.length&&e.push(tn.join(n)),e}class ax{constructor(e,n,o){let r=0,i=0,s=0;this.viewports=o.map(({from:a,to:l})=>{let c=n.lineAt(a,cn.ByPos,e,0,0).top,u=n.lineAt(l,cn.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let a of this.viewports)a.domTop=s+(a.top-i)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),i=a.bottom}toDOM(e){for(let n=0,o=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.top)return r+(e-o)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);o=i.bottom,r=i.domBottom}}fromDOM(e){for(let n=0,o=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.domTop)return o+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);o=i.bottom,r=i.domBottom}}eq(e){return e instanceof ax?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,o)=>n.from==e.viewports[o].from&&n.to==e.viewports[o].to):!1}}function fd(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),o=e.toDOM(t.bottom);return new ii(t.from,t.length,n,o-n,Array.isArray(t._content)?t._content.map(r=>fd(r,e)):t._content)}const Ph=pt.define({combine:t=>t.join(" ")}),Lb=pt.define({combine:t=>t.indexOf(!0)>-1}),Pb=Fa.newName(),iO=Fa.newName(),sO=Fa.newName(),aO={"&light":"."+iO,"&dark":"."+sO};function Db(t,e,n){return new Fa(e,{finish(o){return/&/.test(o)?o.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+o}})}const epe=Db("."+Pb,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},aO),tpe={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fv=ot.ie&&ot.ie_version<=11;class npe{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Ofe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let o of n)this.queue.push(o);(ot.ie&&ot.ie_version<=11||ot.ios&&e.composing)&&n.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&ot.android&&e.constructor.EDIT_CONTEXT!==!1&&!(ot.chrome&&ot.chrome_version<126)&&(this.editContext=new rpe(e),e.state.facet(Bs)&&(e.contentDOM.editContext=this.editContext.editContext)),Fv&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,o)=>n!=e[o]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:o}=this,r=this.selectionRange;if(o.state.facet(Bs)?o.root.activeElement!=this.dom:!Bd(this.dom,r))return;let i=r.anchorNode&&o.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(ot.ie&&ot.ie_version<=11||ot.android&&ot.chrome)&&!o.state.selection.main.empty&&r.focusNode&&Ld(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=mf(e.root);if(!n)return!1;let o=ot.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&ope(this.view,n)||n;if(!o||this.selectionRange.eq(o))return!1;let r=Bd(this.dom,o);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Lfe(this.dom,o)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(o),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let o=this.dom;o;)if(o.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==o?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let o of this.scrollTargets)o.removeEventListener("scroll",this.onScroll);for(let o of this.scrollTargets=n)o.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,tpe),Fv&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fv&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var o;if(!this.delayedAndroidKey){let r=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Vc(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((o=this.delayedAndroidKey)===null||o===void 0)&&o.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,o=-1,r=!1;for(let i of e){let s=this.readMutation(i);s&&(s.typeOver&&(r=!0),n==-1?{from:n,to:o}=s:(n=Math.min(s.from,n),o=Math.max(s.to,o)))}return{from:n,to:o,typeOver:r}}readChange(){let{from:e,to:n,typeOver:o}=this.processRecords(),r=this.selectionChanged&&Bd(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new whe(this.view,e,n,o);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let o=this.view.state,r=jM(this.view,n);return this.view.state==o&&(n.domChanged||n.newSel&&!C0(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let o=Pk(n,e.previousSibling||e.target.previousSibling,-1),r=Pk(n,e.nextSibling||e.target.nextSibling,1);return{from:o?n.posAfter(o):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Bs)!=e.state.facet(Bs)&&(e.view.contentDOM.editContext=e.state.facet(Bs)?this.editContext.editContext:null))}destroy(){var e,n,o;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(o=this.resizeScroll)===null||o===void 0||o.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Pk(t,e,n){for(;e;){let o=Nn.get(e);if(o&&o.parent==t)return o;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function Dk(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.docView.domAtPos(t.state.selection.main.anchor,1);return Ld(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function ope(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Dk(t,r)}let n=null;function o(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",o,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",o,!0),n?Dk(t,n):null}class rpe{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=o=>{let r=e.state.selection.main,{anchor:i,head:s}=r,a=this.toEditorPos(o.updateRangeStart),l=this.toEditorPos(o.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:o.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>o.text.length;a==this.from&&i<this.from?a=i:l==this.to&&i>this.to&&(l=i);let u=XM(e.state.sliceDoc(a,l),o.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let f=ze.single(this.toEditorPos(o.selectionStart),this.toEditorPos(o.selectionEnd));C0(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let d={from:u.from+a,to:u.toA+a,insert:Ut.of(o.text.slice(u.from,u.toB).split(`
|
|
858
|
-
`))};if((ot.mac||ot.android)&&d.from==s-1&&/^\. ?$/.test(o.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(d={from:a,to:l,insert:Ut.of([o.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let f=this.to-this.from+(d.to-d.from+d.insert.length);ix(e,d,ze.single(this.toEditorPos(o.selectionStart,f),this.toEditorPos(o.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from<d.to&&!d.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,o.updateRangeStart-1),Math.min(n.text.length,o.updateRangeStart+1)))&&this.handlers.compositionend(o)},this.handlers.characterboundsupdate=o=>{let r=[],i=null;for(let s=this.toEditorPos(o.rangeStart),a=this.toEditorPos(o.rangeEnd);s<a;s++){let l=e.coordsForChar(s);i=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||i||new DOMRect,r.push(i)}n.updateCharacterBounds(o.rangeStart,r)},this.handlers.textformatupdate=o=>{let r=[];for(let i of o.getTextFormats()){let s=i.underlineStyle,a=i.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(a)){let l=this.toEditorPos(i.rangeStart),c=this.toEditorPos(i.rangeEnd);if(l<c){let u=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;r.push(Xn.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:RM.of(Xn.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:o}=this.composing;this.composing=null,o&&this.reset(e.state)}};for(let o in this.handlers)n.addEventListener(o,this.handlers[o]);this.measureReq={read:o=>{this.editContext.updateControlBounds(o.contentDOM.getBoundingClientRect());let r=mf(o.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,o=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,s,a,l,c)=>{if(o)return;let u=c.length-(s-i);if(r&&s>=r.to)if(r.from==i&&r.to==s&&r.insert.eq(c)){r=this.pendingContextChange=null,n+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(i+=n,s+=n,s<=this.from)this.from+=u,this.to+=u;else if(i<this.to){if(i<this.from||s>this.to||this.to-this.from+c.length>3e4){o=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(s),c.toString()),this.to+=u}n+=u}),r&&!o&&this.revertPending(e.state),!o}update(e){let n=this.pendingContextChange,o=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(o.from,o.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,o=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=o||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(o,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let o=this.composing;return o&&o.drifted?o.editorBase+(e-o.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class _t{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:o}=e;this.dispatchTransactions=e.dispatchTransactions||o&&(r=>r.forEach(i=>o(i,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Bfe(e.parent)||document,this.viewState=new Ok(e.state||Kt.create(e)),e.scrollTo&&e.scrollTo.is($h)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ac).map(r=>new Pv(r));for(let r of this.plugins)r.update(this);this.observer=new npe(this),this.inputState=new Ahe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new vk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Wn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,o=!1,r,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let s=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(tO))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=nO(i,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Kt.phrases)!=this.state.facet(Kt.phrases))return this.setState(i);r=k0.create(this,i,e),r.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:h}=f.state.selection;d=new zc(h.empty?h:ze.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of f.effects)h.is($h)&&(d=h.value.clip(this.state))}this.viewState.update(r,d),this.bidiCache=T0.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(ud)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Ph)!=r.state.facet(Ph)&&(this.viewState.mustMeasureContent=!0),(n||o||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Tb))try{f(r)}catch(h){ji(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!jM(this,u)&&c.force&&Vc(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let o of this.plugins)o.destroy(this);this.viewState=new Ok(e),this.plugins=e.facet(Ac).map(o=>new Pv(o)),this.pluginMap.clear();for(let o of this.plugins)o.update(this);this.docView.destroy(),this.docView=new vk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Ac),o=e.state.facet(Ac);if(n!=o){let r=[];for(let i of o){let s=n.indexOf(i);if(s<0)r.push(new Pv(i));else{let a=this.plugins[s];a.mustUpdate=e,r.push(a)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=o&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(o){ji(this.state,o,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,o=this.scrollDOM,r=o.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:s}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(_M(o))i=-1,s=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(r);i=h.from,s=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(g){return ji(this.state,g),Ek}}),d=k0.create(this,this.state,[]),f=!1;d.flags|=l,n?n.flags|=l:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d),f&&this.docViewUpdate());for(let h=0;h<c.length;h++)if(u[h]!=Ek)try{let g=c[h];g.write&&g.write(u[h],this)}catch(g){ji(this.state,g)}if(f&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let g=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-s;if(g>1||g<-1){r=r+g,o.scrollTop=r/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(Tb))a(n)}get themeClasses(){return Pb+" "+(this.state.facet(Lb)?sO:iO)+" "+this.state.facet(Ph)}updateAttrs(){let e=Nk(this,FM,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Bs)?"true":"false",class:"cm-content",style:`${ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Nk(this,ox,n);let o=this.observer.ignore(()=>{let r=dk(this.contentDOM,this.contentAttrs,n),i=dk(this.dom,this.editorAttrs,e);return r||i});return this.editorAttrs=e,this.contentAttrs=n,o}showAnnouncements(e){let n=!0;for(let o of e)for(let r of o.effects)if(r.is(_t.announce)){n&&(this.announceDOM.textContent=""),n=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(ud);let e=this.state.facet(_t.cspNonce);Fa.mount(this.root,this.styleModules.concat(epe).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(o=>o.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,o){return Iv(this,e,bk(this,e,n,o))}moveByGroup(e,n){return Iv(this,e,bk(this,e,n,o=>mhe(this,e.head,o)))}visualLineSide(e,n){let o=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=o[n?o.length-1:0];return ze.cursor(i.side(n,r)+e.from,i.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,o=!0){return phe(this,e,n,o)}moveVertically(e,n,o){return Iv(this,e,ghe(this,e,n,o))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let o=Ob(this,e,n);return o&&o.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Ob(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let o=this.docView.coordsAt(e,n);if(!o||o.left==o.right)return o;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Yi.find(i,e-r.from,-1,n)];return _0(o,s.dir==Dn.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(NM)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ipe)return TM(e.length);let n=this.textDirectionAt(e.from),o;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||$M(i.isolates,o=pk(this,e))))return i.order;o||(o=pk(this,e));let r=Ffe(e.text,n,o);return this.bidiCache.push(new T0(e.from,e.to,n,o,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ot.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{wM(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return $h.of(new zc(typeof e=="number"?ze.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,o=this.viewState.scrollAnchorAt(e);return $h.of(new zc(ze.cursor(o.from),"start","start",o.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Wl.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Wl.define(()=>({}),{eventObservers:e})}static theme(e,n){let o=Fa.newName(),r=[Ph.of(o),ud.of(Db(`.${o}`,e))];return n&&n.dark&&r.push(Lb.of(!0)),r}static baseTheme(e){return X2.lowest(ud.of(Db("."+Pb,e,aO)))}static findFromDOM(e){var n;let o=e.querySelector(".cm-content"),r=o&&Nn.get(o)||Nn.get(e);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}_t.styleModule=ud;_t.inputHandler=DM;_t.clipboardInputFilter=tx;_t.clipboardOutputFilter=nx;_t.scrollHandler=IM;_t.focusChangeEffect=EM;_t.perLineTextDirection=NM;_t.exceptionSink=PM;_t.updateListener=Tb;_t.editable=Bs;_t.mouseSelectionStyle=LM;_t.dragMovesSelection=BM;_t.clickAddsSelectionRange=OM;_t.decorations=gg;_t.blockWrappers=VM;_t.outerDecorations=rx;_t.atomicRanges=Vf;_t.bidiIsolatedRanges=zM;_t.scrollMargins=HM;_t.darkTheme=Lb;_t.cspNonce=pt.define({combine:t=>t.length?t[0]:""});_t.contentAttributes=ox;_t.editorAttributes=FM;_t.lineWrapping=_t.contentAttributes.of({class:"cm-lineWrapping"});_t.announce=$n.define();const ipe=4096,Ek={};class T0{constructor(e,n,o,r,i,s){this.from=e,this.to=n,this.dir=o,this.isolates=r,this.fresh=i,this.order=s}static update(e,n){if(n.empty&&!e.some(i=>i.fresh))return e;let o=[],r=e.length?e[e.length-1].dir:Dn.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let s=e[i];s.dir==r&&!n.touchesRange(s.from,s.to)&&o.push(new T0(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return o}}function Nk(t,e,n){for(let o=t.state.facet(e),r=o.length-1;r>=0;r--){let i=o[r],s=typeof i=="function"?i(t):i;s&&Q2(s,n)}return n}const spe=ot.mac?"mac":ot.windows?"win":ot.linux?"linux":"key";function ape(t,e){const n=t.split(/-(?!$)/);let o=n[n.length-1];o=="Space"&&(o=" ");let r,i,s,a;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(o="Alt-"+o),i&&(o="Ctrl-"+o),a&&(o="Meta-"+o),s&&(o="Shift-"+o),o}function Dh(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const lpe=X2.default(_t.domEventHandlers({keydown(t,e){return fpe(cpe(e.state),t,e,"editor")}})),lO=pt.define({enables:lpe}),Ik=new WeakMap;function cpe(t){let e=t.facet(lO),n=Ik.get(e);return n||Ik.set(e,n=dpe(e.reduce((o,r)=>o.concat(r),[]))),n}let ya=null;const upe=4e3;function dpe(t,e=spe){let n=Object.create(null),o=Object.create(null),r=(s,a)=>{let l=o[s];if(l==null)o[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},i=(s,a,l,c,u)=>{var d,f;let h=n[s]||(n[s]=Object.create(null)),g=a.split(/ (?!$)/).map(v=>ape(v,e));for(let v=1;v<g.length;v++){let y=g.slice(0,v).join(" ");r(y,!0),h[y]||(h[y]={preventDefault:!0,stopPropagation:!1,run:[x=>{let _=ya={view:x,prefix:y,scope:s};return setTimeout(()=>{ya==_&&(ya=null)},upe),!0}]})}let b=g.join(" ");r(b,!1);let m=h[b]||(h[b]={preventDefault:!1,stopPropagation:!1,run:((f=(d=h._any)===null||d===void 0?void 0:d.run)===null||f===void 0?void 0:f.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let s of t){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=s;for(let f in u)u[f].run.push(h=>d(h,Eb))}let l=s[e]||s.key;if(l)for(let c of a)i(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&i(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return n}let Eb=null;function fpe(t,e,n,o){Eb=e;let r=_fe(e),i=ofe(r,0),s=rfe(i)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;ya&&ya.view==n&&ya.scope==o&&(a=ya.prefix+" ",ZM.indexOf(e.keyCode)<0&&(c=!0,ya=null));let d=new Set,f=m=>{if(m){for(let v of m.run)if(!d.has(v)&&(d.add(v),v(n)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},h=t[o],g,b;return h&&(f(h[a+Dh(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ot.windows&&e.ctrlKey&&e.altKey)&&!(ot.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(g=Va[e.keyCode])&&g!=r?(f(h[a+Dh(g,e,!0)])||e.shiftKey&&(b=hf[e.keyCode])!=r&&b!=g&&f(h[a+Dh(b,e,!1)]))&&(l=!0):s&&e.shiftKey&&f(h[a+Dh(r,e,!0)])&&(l=!0),!l&&f(h._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),Eb=null,l}class fu extends Vl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}fu.prototype.elementClass="";fu.prototype.toDOM=void 0;fu.prototype.mapMode=br.TrackBefore;fu.prototype.startSide=fu.prototype.endSide=-1;fu.prototype.point=!0;const cO=1024;let hpe=0;class Vv{constructor(e,n){this.from=e,this.to=n}}class Nt{constructor(e={}){this.id=hpe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=lr.match(e)),n=>{let o=e(n);return o===void 0?null:[this,o]}}}Nt.closedBy=new Nt({deserialize:t=>t.split(" ")});Nt.openedBy=new Nt({deserialize:t=>t.split(" ")});Nt.group=new Nt({deserialize:t=>t.split(" ")});Nt.isolate=new Nt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Nt.contextHash=new Nt({perNode:!0});Nt.lookAhead=new Nt({perNode:!0});Nt.mounted=new Nt({perNode:!0});class Dd{constructor(e,n,o,r=!1){this.tree=e,this.overlay=n,this.parser=o,this.bracketed=r}static get(e){return e&&e.props&&e.props[Nt.mounted.id]}}const ppe=Object.create(null);class lr{constructor(e,n,o,r=0){this.name=e,this.props=n,this.id=o,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):ppe,o=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new lr(e.name||"",n,e.id,o);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Nt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let o in e)for(let r of o.split(" "))n[r]=e[o];return o=>{for(let r=o.prop(Nt.group),i=-1;i<(r?r.length:0);i++){let s=n[i<0?o.name:r[i]];if(s)return s}}}}lr.none=new lr("",Object.create(null),0,8);class lx{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let o of this.types){let r=null;for(let i of e){let s=i(o);if(s){r||(r=Object.assign({},o.props));let a=s[1],l=s[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}n.push(r?new lr(o.name,r,o.id,o.flags):o)}return new lx(n)}}const Eh=new WeakMap,Rk=new WeakMap;var yn;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(yn||(yn={}));class Tn{constructor(e,n,o,r,i){if(this.type=e,this.children=n,this.positions=o,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=Dd.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let o of this.children){let r=o.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Ib(this.topNode,e)}cursorAt(e,n=0,o=0){let r=Eh.get(this)||this.topNode,i=new Ib(r);return i.moveTo(e,n),Eh.set(this,i._tree),i}get topNode(){return new Hr(this,0,0,null)}resolve(e,n=0){let o=vf(Eh.get(this)||this.topNode,e,n,!1);return Eh.set(this,o),o}resolveInner(e,n=0){let o=vf(Rk.get(this)||this.topNode,e,n,!0);return Rk.set(this,o),o}resolveStack(e,n=0){return vpe(this,e,n)}iterate(e){let{enter:n,leave:o,from:r=0,to:i=this.length}=e,s=e.mode||0,a=(s&yn.IncludeAnonymous)>0;for(let l=this.cursor(s|yn.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=r&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&o&&(a||!l.type.isAnonymous)&&o(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:dx(lr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,o,r)=>new Tn(this.type,n,o,r,this.propValues),e.makeTree||((n,o,r)=>new Tn(lr.none,n,o,r)))}static build(e){return bpe(e)}}Tn.empty=new Tn(lr.none,[],[],0);class cx{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new cx(this.buffer,this.index)}}class Ha{constructor(e,n,o){this.buffer=e,this.length=n,this.set=o}get type(){return lr.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],o=this.buffer[e+3],r=this.set.types[n],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,o==e)return i;let s=[];for(;e<o;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,o,r,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(uO(i,r,s[l+1],s[l+2])&&(a=l,o>0));l=s[l+3]);return a}slice(e,n,o){let r=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=r[a++],i[l++]=r[a++]-o;let c=i[l++]=r[a++]-o;i[l++]=r[a++]-e,s=Math.max(s,c)}return new Ha(i,s,this.set)}}function uO(t,e,n,o){switch(t){case-2:return n<e;case-1:return o>=e&&n<e;case 0:return n<e&&o>e;case 1:return n<=e&&o>e;case 2:return o>e;case 4:return!0}}function vf(t,e,n,o){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!o&&t instanceof Hr&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=o?0:yn.IgnoreOverlays;if(o)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Hr&&s.index<0&&((r=a.enter(e,n,i))===null||r===void 0?void 0:r.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class dO{cursor(e=0){return new Ib(this,e)}getChild(e,n=null,o=null){let r=Fk(this,e,n,o);return r.length?r[0]:null}getChildren(e,n=null,o=null){return Fk(this,e,n,o)}resolve(e,n=0){return vf(this,e,n,!1)}resolveInner(e,n=0){return vf(this,e,n,!0)}matchContext(e){return Nb(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),o=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(o=n,n=r.prevSibling):n=r}return o}get node(){return this}get next(){return this.parent}}class Hr extends dO{constructor(e,n,o,r){super(),this._tree=e,this.from=n,this.index=o,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,o,r,i=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=n>0?a.length:-1;e!=c;e+=n){let u=a[e],d=l[e]+s.from,f;if(!(!(i&yn.EnterBracketed&&u instanceof Tn&&(f=Dd.get(u))&&!f.overlay&&f.bracketed&&o>=d&&o<=d+u.length)&&!uO(r,o,d,d+u.length))){if(u instanceof Ha){if(i&yn.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,o-d,r);if(h>-1)return new Sa(new mpe(s,u,e,d),null,h)}else if(i&yn.IncludeAnonymous||!u.type.isAnonymous||ux(u)){let h;if(!(i&yn.IgnoreMounts)&&(h=Dd.get(u))&&!h.overlay)return new Hr(h.tree,d,e,s);let g=new Hr(u,d,e,s);return i&yn.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?u.children.length-1:0,n,o,r,i)}}}if(i&yn.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+n:e=n<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,o=0){let r;if(!(o&yn.IgnoreOverlays)&&(r=Dd.get(this._tree))&&r.overlay){let i=e-this.from,s=o&yn.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Hr(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,o)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Fk(t,e,n,o){let r=t.cursor(),i=[];if(!r.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=r.type.is(n),!r.nextSibling())return i}for(;;){if(o!=null&&r.type.is(o))return i;if(r.type.is(e)&&i.push(r.node),!r.nextSibling())return o==null?i:[]}}function Nb(t,e,n=e.length-1){for(let o=t;n>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}class mpe{constructor(e,n,o,r){this.parent=e,this.buffer=n,this.index=o,this.start=r}}class Sa extends dO{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,o){super(),this.context=e,this._parent=n,this.index=o,this.type=e.buffer.set.types[e.buffer.buffer[o]]}child(e,n,o){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,o);return i<0?null:new Sa(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,o=0){if(o&yn.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new Sa(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Sa(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Sa(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:o}=this.context,r=this.index+4,i=o.buffer[this.index+3];if(i>r){let s=o.buffer[this.index+1];e.push(o.slice(r,i,s)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function fO(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let o=n instanceof Hr&&n.index<0?null:n.parent,r=t.slice();return o?r[e]=o:r.splice(e,1),new gpe(r,n)}class gpe{constructor(e,n){this.heads=e,this.node=n}get next(){return fO(this.heads)}}function vpe(t,e,n){let o=t.resolveInner(e,n),r=null;for(let i=o instanceof Hr?o:o.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(r||(r=[o])).push(s.resolve(e,n)),i=s}else{let s=Dd.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Hr(s.tree,s.overlay[0].from+i.from,-1,i);(r||(r=[o])).push(vf(a,e,n,!1))}}return r?fO(r):o}class Ib{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~yn.EnterBracketed,e instanceof Hr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let o=e._parent;o;o=o._parent)this.stack.unshift(o.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:o,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=o+r.buffer[e+1],this.to=o+r.buffer[e+2],!0}yield(e){return e?e instanceof Hr?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,o){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,o,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,o);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,o=this.mode){return this.buffer?o&yn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,o))}parent(){if(!this.buffer)return this.yieldNode(this.mode&yn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&yn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,o=this.stack.length-1;if(e<0){let r=o<0?0:this.stack[o]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(o<0?n.buffer.length:n.buffer[this.stack[o]+3]))return this.yieldBuf(r)}return o<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,o,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:o}=r)}else({index:n,_parent:o}=this._tree);for(;o;{index:n,_parent:o}=o)if(n>-1)for(let i=n+e,s=e<0?-1:o._tree.children.length;i!=s;i+=e){let a=o._tree.children[i];if(this.mode&yn.IncludeAnonymous||a instanceof Ha||!a.type.isAnonymous||ux(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,o=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;n=s,o=i+1;break e}r=this.stack[--i]}for(let r=o;r<this.stack.length;r++)n=new Sa(this.buffer,n,this.stack[r]);return this.bufferNode=new Sa(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let o=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){o++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!o)return;if(this.nextSibling())break;this.parent(),o--,r=!0}}}matchContext(e){if(!this.buffer)return Nb(this.node.parent,e);let{buffer:n}=this.buffer,{types:o}=n.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return Nb(this._tree,e,r);let s=o[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}}function ux(t){return t.children.some(e=>e instanceof Ha||!e.type.isAnonymous||ux(e))}function bpe(t){var e;let{buffer:n,nodeSet:o,maxBufferLength:r=cO,reused:i=[],minRepeatType:s=o.types.length}=t,a=Array.isArray(n)?new cx(n,n.length):n,l=o.types,c=0,u=0;function d(k,E,B,S,L,D){let{id:I,start:C,end:T,size:P}=a,$=u,F=c;if(P<0)if(a.next(),P==-1){let he=i[I];B.push(he),S.push(C-k);return}else if(P==-3){c=I;return}else if(P==-4){u=I;return}else throw new RangeError(`Unrecognized record size: ${P}`);let V=l[I],U,K,se=C-k;if(T-C<=r&&(K=m(a.pos-E,L))){let he=new Uint16Array(K.size-K.skip),ce=a.pos-K.size,be=he.length;for(;a.pos>ce;)be=v(K.start,he,be);U=new Ha(he,T-K.start,o),se=K.start-k}else{let he=a.pos-P;a.next();let ce=[],be=[],oe=I>=s?I:-1,de=0,we=T;for(;a.pos>he;)oe>=0&&a.id==oe&&a.size>=0?(a.end<=we-r&&(g(ce,be,C,de,a.end,we,oe,$,F),de=ce.length,we=a.end),a.next()):D>2500?f(C,he,ce,be):d(C,he,ce,be,oe,D+1);if(oe>=0&&de>0&&de<ce.length&&g(ce,be,C,de,C,we,oe,$,F),ce.reverse(),be.reverse(),oe>-1&&de>0){let ee=h(V,F);U=dx(V,ce,be,0,ce.length,0,T-C,ee,ee)}else U=b(V,ce,be,T-C,$-T,F)}B.push(U),S.push(se)}function f(k,E,B,S){let L=[],D=0,I=-1;for(;a.pos>E;){let{id:C,start:T,end:P,size:$}=a;if($>4)a.next();else{if(I>-1&&T<I)break;I<0&&(I=P-r),L.push(C,T,P),D++,a.next()}}if(D){let C=new Uint16Array(D*4),T=L[L.length-2];for(let P=L.length-3,$=0;P>=0;P-=3)C[$++]=L[P],C[$++]=L[P+1]-T,C[$++]=L[P+2]-T,C[$++]=$;B.push(new Ha(C,L[2]-T,o)),S.push(T-k)}}function h(k,E){return(B,S,L)=>{let D=0,I=B.length-1,C,T;if(I>=0&&(C=B[I])instanceof Tn){if(!I&&C.type==k&&C.length==L)return C;(T=C.prop(Nt.lookAhead))&&(D=S[I]+C.length+T)}return b(k,B,S,L,D,E)}}function g(k,E,B,S,L,D,I,C,T){let P=[],$=[];for(;k.length>S;)P.push(k.pop()),$.push(E.pop()+B-L);k.push(b(o.types[I],P,$,D-L,C-D,T)),E.push(L-B)}function b(k,E,B,S,L,D,I){if(D){let C=[Nt.contextHash,D];I=I?[C].concat(I):[C]}if(L>25){let C=[Nt.lookAhead,L];I=I?[C].concat(I):[C]}return new Tn(k,E,B,S,I)}function m(k,E){let B=a.fork(),S=0,L=0,D=0,I=B.end-r,C={size:0,start:0,skip:0};e:for(let T=B.pos-k;B.pos>T;){let P=B.size;if(B.id==E&&P>=0){C.size=S,C.start=L,C.skip=D,D+=4,S+=4,B.next();continue}let $=B.pos-P;if(P<0||$<T||B.start<I)break;let F=B.id>=s?4:0,V=B.start;for(B.next();B.pos>$;){if(B.size<0)if(B.size==-3||B.size==-4)F+=4;else break e;else B.id>=s&&(F+=4);B.next()}L=V,S+=P,D+=F}return(E<0||S==k)&&(C.size=S,C.start=L,C.skip=D),C.size>4?C:void 0}function v(k,E,B){let{id:S,start:L,end:D,size:I}=a;if(a.next(),I>=0&&S<s){let C=B;if(I>4){let T=a.pos-(I-4);for(;a.pos>T;)B=v(k,E,B)}E[--B]=C,E[--B]=D-k,E[--B]=L-k,E[--B]=S}else I==-3?c=S:I==-4&&(u=S);return B}let y=[],x=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,y,x,-1,0);let _=(e=t.length)!==null&&e!==void 0?e:y.length?x[0]+y[0].length:0;return new Tn(l[t.topID],y.reverse(),x.reverse(),_)}const Vk=new WeakMap;function cp(t,e){if(!t.isAnonymous||e instanceof Ha||e.type!=t)return 1;let n=Vk.get(e);if(n==null){n=1;for(let o of e.children){if(o.type!=t||!(o instanceof Tn)){n=1;break}n+=cp(t,o)}Vk.set(e,n)}return n}function dx(t,e,n,o,r,i,s,a,l){let c=0;for(let g=o;g<r;g++)c+=cp(t,e[g]);let u=Math.ceil(c*1.5/8),d=[],f=[];function h(g,b,m,v,y){for(let x=m;x<v;){let _=x,k=b[x],E=cp(t,g[x]);for(x++;x<v;x++){let B=cp(t,g[x]);if(E+B>=u)break;E+=B}if(x==_+1){if(E>u){let B=g[_];h(B.children,B.positions,0,B.children.length,b[_]+y);continue}d.push(g[_])}else{let B=b[x-1]+g[x-1].length-k;d.push(dx(t,g,b,_,x,k,B,null,l))}f.push(k+y-i)}}return h(e,n,o,r,0),(a||l)(d,f,s)}class Ml{constructor(e,n,o,r,i=!1,s=!1){this.from=e,this.to=n,this.tree=o,this.offset=r,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],o=!1){let r=[new Ml(0,e.length,e,0,!1,o)];for(let i of n)i.to>e.length&&r.push(i);return r}static applyChanges(e,n,o=128){if(!n.length)return e;let r=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=o)for(;s&&s.from<d;){let f=s;if(l>=f.from||d<=f.to||c){let h=Math.max(f.from,l)-c,g=Math.min(f.to,d)-c;f=h>=g?null:new Ml(h,g,f.tree,f.offset+c,a>0,!!u)}if(f&&r.push(f),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return r}}class hO{startParse(e,n,o){return typeof e=="string"&&(e=new ype(e)),o=o?o.length?o.map(r=>new Vv(r.from,r.to)):[new Vv(0,0)]:[new Vv(0,e.length)],this.createParse(e,n||[],o)}parse(e,n,o){let r=this.startParse(e,n,o);for(;;){let i=r.advance();if(i)return i}}}class ype{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Nt({perNode:!0});let xpe=0;class Dr{constructor(e,n,o,r){this.name=e,this.set=n,this.base=o,this.modified=r,this.id=xpe++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let o=typeof e=="string"?e:"?";if(e instanceof Dr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new Dr(o,[],null,[]);if(r.set.push(r),n)for(let i of n.set)r.set.push(i);return r}static defineModifier(e){let n=new M0(e);return o=>o.modified.indexOf(n)>-1?o:M0.get(o.base||o,o.modified.concat(n).sort((r,i)=>r.id-i.id))}}let wpe=0;class M0{constructor(e){this.name=e,this.instances=[],this.id=wpe++}static get(e,n){if(!n.length)return e;let o=n[0].instances.find(a=>a.base==e&&_pe(n,a.modified));if(o)return o;let r=[],i=new Dr(e.name,r,e,n);for(let a of n)a.instances.push(i);let s=kpe(n);for(let a of e.set)if(!a.modified.length)for(let l of s)r.push(M0.get(a,l));return i}}function _pe(t,e){return t.length==e.length&&t.every((n,o)=>n==e[o])}function kpe(t){let e=[[]];for(let n=0;n<t.length;n++)for(let o=0,r=e.length;o<r;o++)e.push(e[o].concat(t[n]));return e.sort((n,o)=>o.length-n.length)}function pO(t){let e=Object.create(null);for(let n in t){let o=t[n];Array.isArray(o)||(o=[o]);for(let r of n.split(" "))if(r){let i=[],s=2,a=r;for(let d=0;;){if(a=="..."&&d>0&&d+3==r.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+r);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==r.length)break;let h=r[d++];if(d==r.length&&h=="!"){s=0;break}if(h!="/")throw new RangeError("Invalid path: "+r);a=r.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new bf(o,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return mO.add(e)}const mO=new Nt({combine(t,e){let n,o,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let i=new bf(r.tags,r.mode,r.context);n?n.next=i:o=i,n=i}return o}});class bf{constructor(e,n,o,r){this.tags=e,this.mode=n,this.context=o,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}bf.empty=new bf([],2,null);function gO(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:o,all:r=null}=e||{};return{style:i=>{let s=r;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:o}}function Spe(t,e){let n=null;for(let o of t){let r=o.style(e);r&&(n=n?n+" "+r:r)}return n}function vO(t,e,n,o=0,r=t.length){let i=new Ape(o,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),o,r,"",i.highlighters),i.flush(r)}class Ape{constructor(e,n,o){this.at=e,this.highlighters=n,this.span=o,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,o,r,i){let{type:s,from:a,to:l}=e;if(a>=o||l<=n)return;s.isTop&&(i=this.highlighters.filter(h=>!h.scope||h.scope(s)));let c=r,u=Cpe(e)||bf.empty,d=Spe(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let f=e.tree&&e.tree.prop(Nt.mounted);if(f&&f.overlay){let h=e.node.enter(f.overlay[0].from+a,1),g=this.highlighters.filter(m=>!m.scope||m.scope(f.tree.type)),b=e.firstChild();for(let m=0,v=a;;m++){let y=m<f.overlay.length?f.overlay[m]:null,x=y?y.from+a:l,_=Math.max(n,v),k=Math.min(o,x);if(_<k&&b)for(;e.from<k&&(this.highlightRange(e,_,k,r,i),this.startSpan(Math.min(k,e.to),c),!(e.to>=x||!e.nextSibling())););if(!y||x>o)break;v=y.to+a,v>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+a),Math.min(o,v),"",g),this.startSpan(Math.min(o,v),c))}b&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=n)){if(e.from>=o)break;this.highlightRange(e,n,o,r,i),this.startSpan(Math.min(o,e.to),c)}while(e.nextSibling());e.parent()}}}function Cpe(t){let e=t.type.prop(mO);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Ke=Dr.define,Nh=Ke(),ga=Ke(),zk=Ke(ga),Hk=Ke(ga),va=Ke(),Ih=Ke(va),zv=Ke(va),Vi=Ke(),cl=Ke(Vi),Ri=Ke(),Fi=Ke(),Rb=Ke(),Qu=Ke(Rb),Rh=Ke(),at={comment:Nh,lineComment:Ke(Nh),blockComment:Ke(Nh),docComment:Ke(Nh),name:ga,variableName:Ke(ga),typeName:zk,tagName:Ke(zk),propertyName:Hk,attributeName:Ke(Hk),className:Ke(ga),labelName:Ke(ga),namespace:Ke(ga),macroName:Ke(ga),literal:va,string:Ih,docString:Ke(Ih),character:Ke(Ih),attributeValue:Ke(Ih),number:zv,integer:Ke(zv),float:Ke(zv),bool:Ke(va),regexp:Ke(va),escape:Ke(va),color:Ke(va),url:Ke(va),keyword:Ri,self:Ke(Ri),null:Ke(Ri),atom:Ke(Ri),unit:Ke(Ri),modifier:Ke(Ri),operatorKeyword:Ke(Ri),controlKeyword:Ke(Ri),definitionKeyword:Ke(Ri),moduleKeyword:Ke(Ri),operator:Fi,derefOperator:Ke(Fi),arithmeticOperator:Ke(Fi),logicOperator:Ke(Fi),bitwiseOperator:Ke(Fi),compareOperator:Ke(Fi),updateOperator:Ke(Fi),definitionOperator:Ke(Fi),typeOperator:Ke(Fi),controlOperator:Ke(Fi),punctuation:Rb,separator:Ke(Rb),bracket:Qu,angleBracket:Ke(Qu),squareBracket:Ke(Qu),paren:Ke(Qu),brace:Ke(Qu),content:Vi,heading:cl,heading1:Ke(cl),heading2:Ke(cl),heading3:Ke(cl),heading4:Ke(cl),heading5:Ke(cl),heading6:Ke(cl),contentSeparator:Ke(Vi),list:Ke(Vi),quote:Ke(Vi),emphasis:Ke(Vi),strong:Ke(Vi),link:Ke(Vi),monospace:Ke(Vi),strikethrough:Ke(Vi),inserted:Ke(),deleted:Ke(),changed:Ke(),invalid:Ke(),meta:Rh,documentMeta:Ke(Rh),annotation:Ke(Rh),processingInstruction:Ke(Rh),definition:Dr.defineModifier("definition"),constant:Dr.defineModifier("constant"),function:Dr.defineModifier("function"),standard:Dr.defineModifier("standard"),local:Dr.defineModifier("local"),special:Dr.defineModifier("special")};for(let t in at){let e=at[t];e instanceof Dr&&(e.name=t)}const bO=gO([{tag:at.link,class:"tok-link"},{tag:at.heading,class:"tok-heading"},{tag:at.emphasis,class:"tok-emphasis"},{tag:at.strong,class:"tok-strong"},{tag:at.keyword,class:"tok-keyword"},{tag:at.atom,class:"tok-atom"},{tag:at.bool,class:"tok-bool"},{tag:at.url,class:"tok-url"},{tag:at.labelName,class:"tok-labelName"},{tag:at.inserted,class:"tok-inserted"},{tag:at.deleted,class:"tok-deleted"},{tag:at.literal,class:"tok-literal"},{tag:at.string,class:"tok-string"},{tag:at.number,class:"tok-number"},{tag:[at.regexp,at.escape,at.special(at.string)],class:"tok-string2"},{tag:at.variableName,class:"tok-variableName"},{tag:at.local(at.variableName),class:"tok-variableName tok-local"},{tag:at.definition(at.variableName),class:"tok-variableName tok-definition"},{tag:at.special(at.variableName),class:"tok-variableName2"},{tag:at.definition(at.propertyName),class:"tok-propertyName tok-definition"},{tag:at.typeName,class:"tok-typeName"},{tag:at.namespace,class:"tok-namespace"},{tag:at.className,class:"tok-className"},{tag:at.macroName,class:"tok-macroName"},{tag:at.propertyName,class:"tok-propertyName"},{tag:at.operator,class:"tok-operator"},{tag:at.comment,class:"tok-comment"},{tag:at.meta,class:"tok-meta"},{tag:at.invalid,class:"tok-invalid"},{tag:at.punctuation,class:"tok-punctuation"}]);var Hv;const Cc=new Nt;function $pe(t){return pt.define({combine:t?e=>e.concat(t):void 0})}const Tpe=new Nt;class ui{constructor(e,n,o=[],r=""){this.data=e,this.name=r,Kt.prototype.hasOwnProperty("tree")||Object.defineProperty(Kt.prototype,"tree",{get(){return as(this)}}),this.parser=n,this.extension=[pu.of(this),Kt.languageData.of((i,s,a)=>{let l=Wk(i,s,a),c=l.type.prop(Cc);if(!c)return[];let u=i.facet(c),d=l.type.prop(Tpe);if(d){let f=l.resolve(s-l.from,a);for(let h of d)if(h.test(f,i)){let g=i.facet(h.facet);return h.type=="replace"?g:g.concat(u)}}return u})].concat(o)}isActiveAt(e,n,o=-1){return Wk(e,n,o).type.prop(Cc)==this.data}findRegions(e){let n=e.facet(pu);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let o=[],r=(i,s)=>{if(i.prop(Cc)==this.data){o.push({from:s,to:s+i.length});return}let a=i.prop(Nt.mounted);if(a){if(a.tree.prop(Cc)==this.data){if(a.overlay)for(let l of a.overlay)o.push({from:l.from+s,to:l.to+s});else o.push({from:s,to:s+i.length});return}else if(a.overlay){let l=o.length;if(r(a.tree,a.overlay[0].from+s),o.length>l)return}}for(let l=0;l<i.children.length;l++){let c=i.children[l];c instanceof Tn&&r(c,i.positions[l]+s)}};return r(as(e),0),o}get allowsNesting(){return!0}}ui.setState=$n.define();function Wk(t,e,n){let o=t.facet(pu),r=as(t).topNode;if(!o||o.allowsNesting)for(let i=r;i;i=i.enter(e,n,yn.ExcludeBuffers|yn.EnterBracketed))i.type.isTop&&(r=i);return r}class O0 extends ui{constructor(e,n,o){super(e,n,[],o),this.parser=n}static define(e){let n=$pe(e.languageData);return new O0(n,e.parser.configure({props:[Cc.add(o=>o.isTop?n:void 0)]}),e.name)}configure(e,n){return new O0(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function as(t){let e=t.field(ui.state,!1);return e?e.tree:Tn.empty}class Mpe{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let o=this.cursorPos-this.string.length;return e<o||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-o,n-o)}}let Ju=null;class B0{constructor(e,n,o=[],r,i,s,a,l){this.parser=e,this.state=n,this.fragments=o,this.tree=r,this.treeLen=i,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,o){return new B0(e,n,[],Tn.empty,0,o,[],null)}startParse(){return this.parser.startParse(new Mpe(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var o;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Ml.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(o=this.parse.stoppedAt)!==null&&o!==void 0?o:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Ml.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ju;Ju=this;try{return e()}finally{Ju=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Uk(e,n.from,n.to);return e}changes(e,n){let{fragments:o,tree:r,treeLen:i,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,d,f)=>l.push({fromA:c,toA:u,fromB:d,toB:f})),o=Ml.applyChanges(o,l),r=Tn.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&a.push({from:u,to:d})}}}return new B0(this.parser,n,o,r,i,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let o=0;o<this.skipped.length;o++){let{from:r,to:i}=this.skipped[o];r<e.to&&i>e.from&&(this.fragments=Uk(this.fragments,r,i),this.skipped.splice(o--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends hO{createParse(n,o,r){let i=r[0].from,s=r[r.length-1].to;return{parsedPos:i,advance(){let l=Ju;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new Tn(lr.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ju}}function Uk(t,e,n){return Ml.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class hu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),o=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,o)||n.takeTree(),new hu(n)}static init(e){let n=Math.min(3e3,e.doc.length),o=B0.create(e.facet(pu).parser,e,{from:0,to:n});return o.work(20,n)||o.takeTree(),new hu(o)}}ui.state=el.define({create:hu.init,update(t,e){for(let n of e.effects)if(n.is(ui.setState))return n.value;return e.startState.facet(pu)!=e.state.facet(pu)?hu.init(e.state):t.apply(e)}});let yO=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(yO=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Wv=typeof navigator<"u"&&(!((Hv=navigator.scheduling)===null||Hv===void 0)&&Hv.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ope=Wl.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(ui.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ui.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=yO(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:o,viewport:{to:r}}=this.view,i=o.field(ui.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Wv?Math.max(25,e.timeRemaining()-5):1e9),a=i.context.treeLen<r&&o.doc.length>r+1e3,l=i.context.work(()=>Wv&&Wv()||Date.now()>s,r+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:ui.setState.of(new hu(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>ji(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),pu=pt.define({combine(t){return t.length?t[0]:null},enables:t=>[ui.state,Ope,_t.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Bpe{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Lpe=pt.define(),fx=pt.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function L0(t){let e=t.facet(fx);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function P0(t,e){let n="",o=t.tabSize,r=t.facet(fx)[0];if(r==" "){for(;e>=o;)n+=" ",e-=o;r=" "}for(let i=0;i<e;i++)n+=r;return n}function xO(t,e){t instanceof Kt&&(t=new xg(t));for(let o of t.state.facet(Lpe)){let r=o(t,e);if(r!==void 0)return r}let n=as(t.state);return n.length>=e?Dpe(t,n,e):null}class xg{constructor(e,n={}){this.state=e,this.options=n,this.unit=L0(e)}lineAt(e,n=1){let o=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=o.from&&r<=o.to?i&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:o.text.slice(r-o.from),from:r}:{text:o.text.slice(0,r-o.from),from:o.from}:o}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:o,from:r}=this.lineAt(e,n);return o.slice(e-r,Math.min(o.length,e+100-r))}column(e,n=1){let{text:o,from:r}=this.lineAt(e,n),i=this.countColumn(o,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(i+=s-this.countColumn(o,o.search(/\S|$/))),i}countColumn(e,n=e.length){return hg(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:o,from:r}=this.lineAt(e,n),i=this.options.overrideIndentation;if(i){let s=i(r);if(s>-1)return s}return this.countColumn(o,o.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ppe=new Nt;function Dpe(t,e,n){let o=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=o.node){let i=[];for(let s=r;s&&!(s.from<o.node.from||s.to>o.node.to||s.from==o.node.from&&s.type==o.node.type);s=s.parent)i.push(s);for(let s=i.length-1;s>=0;s--)o={node:i[s],next:o}}return wO(o,t,n)}function wO(t,e,n){for(let o=t;o;o=o.next){let r=Npe(o.node);if(r)return r(hx.create(e,n,o))}return 0}function Epe(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Npe(t){let e=t.type.prop(Ppe);if(e)return e;let n=t.firstChild,o;if(n&&(o=n.type.prop(Nt.closedBy))){let r=t.lastChild,i=r&&o.indexOf(r.name)>-1;return s=>Vpe(s,!0,1,void 0,i&&!Epe(s)?r.from:void 0)}return t.parent==null?Ipe:null}function Ipe(){return 0}class hx extends xg{constructor(e,n,o){super(e.state,e.options),this.base=e,this.pos=n,this.context=o}get node(){return this.context.node}static create(e,n,o){return new hx(e,n,o)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let o=e.resolve(n.from);for(;o.parent&&o.parent.from==o.from;)o=o.parent;if(Rpe(o,e))break;n=this.state.doc.lineAt(o.from)}return this.lineIndent(n.from)}continue(){return wO(this.context.next,this.base,this.pos)}}function Rpe(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function Fpe(t){let e=t.node,n=e.childAfter(e.from),o=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,i=t.state.doc.lineAt(n.from),s=r==null||r<=i.from?i.to:Math.min(i.to,r);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==o)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function Vpe(t,e,n,o,r){let i=t.textAfter,s=i.match(/^\s*/)[0].length,a=o&&i.slice(s,s+o.length)==o||r==t.pos+s,l=Fpe(t);return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}class px{constructor(e,n){this.specs=e;let o;function r(a){let l=Fa.newName();return(o||(o=Object.create(null)))["."+l]=a,l}const i=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,s=n.scope;this.scope=s instanceof ui?a=>a.prop(Cc)==s.data:s?a=>a==s:void 0,this.style=gO(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=o?new Fa(o):null,this.themeType=n.themeType}static define(e,n){return new px(e,n||{})}}const Fb=pt.define(),zpe=pt.define({combine(t){return t.length?[t[0]]:null}});function Uv(t){let e=t.facet(Fb);return e.length?e:t.facet(zpe)}function Hpe(t,e){let n=[Upe],o;return t instanceof px&&(t.module&&n.push(_t.styleModule.of(t.module)),o=t.themeType),o?n.push(Fb.computeN([_t.darkTheme],r=>r.facet(_t.darkTheme)==(o=="dark")?[t]:[])):n.push(Fb.of(t)),n}class Wpe{constructor(e){this.markCache=Object.create(null),this.tree=as(e.state),this.decorations=this.buildDeco(e,Uv(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=as(e.state),o=Uv(e.state),r=o!=Uv(e.startState),{viewport:i}=e.view,s=e.changes.mapPos(this.decoratedTo,1);n.length<i.to&&!r&&n.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,o),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return Xn.none;let o=new df;for(let{from:r,to:i}of e.visibleRanges)vO(this.tree,n,(s,a,l)=>{o.add(s,a,this.markCache[l]||(this.markCache[l]=Xn.mark({class:l})))},r,i);return o.finish()}}const Upe=X2.high(Wl.fromClass(Wpe,{decorations:t=>t.decorations})),Gpe=1e4,qpe="()[]{}",Ype=new Nt;function Vb(t,e,n){let o=t.prop(e<0?Nt.openedBy:Nt.closedBy);if(o)return o;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function zb(t){let e=t.type.prop(Ype);return e?e(t.node):t}function $c(t,e,n,o={}){let r=o.maxScanDistance||Gpe,i=o.brackets||qpe,s=as(t),a=s.resolveInner(e,n);for(let l=a;l;l=l.parent){let c=Vb(l.type,n,i);if(c&&l.from<l.to){let u=zb(l);if(u&&(n>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return jpe(t,e,n,l,u,c,i)}}return Xpe(t,e,n,s,a.type,r,i)}function jpe(t,e,n,o,r,i,s){let a=o.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(n<0?u.childBefore(o.from):u.childAfter(o.to)))do if(n<0?u.to<=o.from:u.from>=o.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let d=zb(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(Vb(u.type,n,s))c++;else if(Vb(u.type,-n,s)){if(c==0){let d=zb(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function Xpe(t,e,n,o,r,i,s){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?e-1:e,to:n>0?e+1:e},u=t.doc.iterRange(e,n>0?t.doc.length:0),d=0;for(let f=0;!u.next().done&&f<=i;){let h=u.value;n<0&&(f+=h.length);let g=e+f*n;for(let b=n>0?0:h.length-1,m=n>0?h.length:-1;b!=m;b+=n){let v=s.indexOf(h[b]);if(!(v<0||o.resolveInner(g+b,1).type!=r))if(v%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:g+b,to:g+b+1},matched:v>>1==l>>1};d--}}n>0&&(f+=h.length)}return u.done?{start:c,matched:!1}:null}const Kpe=Object.create(null),Gk=[lr.none],qk=[],Yk=Object.create(null),Zpe=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Zpe[t]=Qpe(Kpe,e);function Gv(t,e){qk.indexOf(t)>-1||(qk.push(t),console.warn(e))}function Qpe(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=t[c]||at[c];u?typeof u=="function"?l.length?l=l.map(u):Gv(c,`Modifier ${c} used at start of tag`):l.length?Gv(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Gv(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let o=e.replace(/ /g,"_"),r=o+" "+n.map(a=>a.id),i=Yk[r];if(i)return i.id;let s=Yk[r]=lr.define({id:Gk.length,name:o,props:[pO({[o]:n})]});return Gk.push(s),s.id}Dn.RTL,Dn.LTR;const Jpe=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),o=gx(t.state,n.from);return o.line?e0e(t):o.block?n0e(t):!1};function mx(t,e){return({state:n,dispatch:o})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(o(n.update(r)),!0):!1}}const e0e=mx(i0e,0),t0e=mx(_O,0),n0e=mx((t,e)=>_O(t,e,r0e(e)),0);function gx(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const ed=50;function o0e(t,{open:e,close:n},o,r){let i=t.sliceDoc(o-ed,o),s=t.sliceDoc(r,r+ed),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(s)[0].length,c=i.length-a;if(i.slice(c-e.length,c)==e&&s.slice(l,l+n.length)==n)return{open:{pos:o-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,d;r-o<=2*ed?u=d=t.sliceDoc(o,r):(u=t.sliceDoc(o,o+ed),d=t.sliceDoc(r-ed,r));let f=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(d)[0].length,g=d.length-h-n.length;return u.slice(f,f+e.length)==e&&d.slice(g,g+n.length)==n?{open:{pos:o+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:r-h-n.length,margin:/\s/.test(d.charAt(g-1))?1:0}}:null}function r0e(t){let e=[];for(let n of t.selection.ranges){let o=t.doc.lineAt(n.from),r=n.to<=o.to?o:t.doc.lineAt(n.to);r.from>o.from&&r.from==n.to&&(r=n.to==o.to+1?o:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>o.from?e[i].to=r.to:e.push({from:o.from+/^\s*/.exec(o.text)[0].length,to:r.to})}return e}function _O(t,e,n=e.selection.ranges){let o=n.map(i=>gx(e,i.from).block);if(!o.every(i=>i))return null;let r=n.map((i,s)=>o0e(e,o[s],i.from,i.to));if(t!=2&&!r.every(i=>i))return{changes:e.changes(n.map((i,s)=>r[s]?[]:[{from:i.from,insert:o[s].open+" "},{from:i.to,insert:" "+o[s].close}]))};if(t!=1&&r.some(i=>i)){let i=[];for(let s=0,a;s<r.length;s++)if(a=r[s]){let l=o[s],{open:c,close:u}=a;i.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:i}}return null}function i0e(t,e,n=e.selection.ranges){let o=[],r=-1;e:for(let{from:i,to:s}of n){let a=o.length,l=1e9,c;for(let u=i;u<=s;){let d=e.doc.lineAt(u);if(c==null&&(c=gx(e,d.from).line,!c))continue e;if(d.from>r&&(i==s||s>d.from)){r=d.from;let f=/^\s*/.exec(d.text)[0].length,h=f==d.length,g=d.text.slice(f,f+c.length)==c?f:-1;f<d.text.length&&f<l&&(l=f),o.push({line:d,comment:g,token:c,indent:f,empty:h,single:!1})}u=d.to+1}if(l<1e9)for(let u=a;u<o.length;u++)o[u].indent<o[u].line.text.length&&(o[u].indent=l);o.length==a+1&&(o[a].single=!0)}if(t!=2&&o.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:c,empty:u,single:d}of o)(d||!u)&&i.push({from:a.from+c,insert:l+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&o.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:a,token:l}of o)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}const Hb=tl.define(),s0e=tl.define(),a0e=pt.define(),kO=pt.define({combine(t){return gfe(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(o,r)=>e(o,r)||n(o,r)})}}),SO=el.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(kO),o=e.annotation(Hb);if(o){let l=or.fromTransaction(e,o.selection),c=o.side,u=c==0?t.undone:t.done;return l?u=D0(u,u.length,n.minDepth,l):u=$O(u,e.startState.selection),new Xi(c==0?o.rest:u,c==0?u:o.rest)}let r=e.annotation(s0e);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Wn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=or.fromTransaction(e),s=e.annotation(Wn.time),a=e.annotation(Wn.userEvent);return i?t=t.addChanges(i,s,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(or.fromJSON),t.undone.map(or.fromJSON))}});function l0e(t={}){return[SO,kO.of(t),_t.domEventHandlers({beforeinput(e,n){let o=e.inputType=="historyUndo"?AO:e.inputType=="historyRedo"?Wb:null;return o?(e.preventDefault(),o(n)):!1}})]}function wg(t,e){return function({state:n,dispatch:o}){if(!e&&n.readOnly)return!1;let r=n.field(SO,!1);if(!r)return!1;let i=r.pop(t,n,e);return i?(o(i),!0):!1}}const AO=wg(0,!1),Wb=wg(1,!1),c0e=wg(0,!0),u0e=wg(1,!0);class or{constructor(e,n,o,r,i){this.changes=e,this.effects=n,this.mapped=o,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new or(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,o;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(o=this.startSelection)===null||o===void 0?void 0:o.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new or(e.changes&&zn.fromJSON(e.changes),[],e.mapped&&os.fromJSON(e.mapped),e.startSelection&&ze.fromJSON(e.startSelection),e.selectionsAfter.map(ze.fromJSON))}static fromTransaction(e,n){let o=Ir;for(let r of e.startState.facet(a0e)){let i=r(e);i.length&&(o=o.concat(i))}return!o.length&&e.changes.empty?null:new or(e.changes.invert(e.startState.doc),o,void 0,n||e.startState.selection,Ir)}static selection(e){return new or(void 0,Ir,void 0,void 0,e)}}function D0(t,e,n,o){let r=e+1>n+20?e-n-1:0,i=t.slice(r,e);return i.push(o),i}function d0e(t,e){let n=[],o=!1;return t.iterChangedRanges((r,i)=>n.push(r,i)),e.iterChangedRanges((r,i,s,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&s<=u&&(o=!0)}}),o}function f0e(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,o)=>n.empty!=e.ranges[o].empty).length===0}function CO(t,e){return t.length?e.length?t.concat(e):t:e}const Ir=[],h0e=200;function $O(t,e){if(t.length){let n=t[t.length-1],o=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-h0e));return o.length&&o[o.length-1].eq(e)?t:(o.push(e),D0(t,t.length-1,1e9,n.setSelAfter(o)))}else return[or.selection([e])]}function p0e(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function qv(t,e){if(!t.length)return t;let n=t.length,o=Ir;for(;n;){let r=m0e(t[n-1],e,o);if(r.changes&&!r.changes.empty||r.effects.length){let i=t.slice(0,n);return i[n-1]=r,i}else e=r.mapped,n--,o=r.selectionsAfter}return o.length?[or.selection(o)]:Ir}function m0e(t,e,n){let o=CO(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Ir,n);if(!t.changes)return or.selection(o);let r=t.changes.map(e),i=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(i):i;return new or(r,$n.mapEffects(t.effects,e),s,t.startSelection.map(i),o)}const g0e=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,o=0,r=void 0){this.done=e,this.undone=n,this.prevTime=o,this.prevUserEvent=r}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,o,r,i){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!o||g0e.test(o))&&(!a.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,d0e(a.changes,e.changes))||o=="input.type.compose")?s=D0(s,s.length-1,r.minDepth,new or(e.changes.compose(a.changes),CO($n.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Ir)):s=D0(s,s.length,r.minDepth,e),new Xi(s,Ir,n,o)}addSelection(e,n,o,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Ir;return i.length>0&&n-this.prevTime<r&&o==this.prevUserEvent&&o&&/^select($|\.)/.test(o)&&f0e(i[i.length-1],e)?this:new Xi($O(this.done,e),this.undone,n,o)}addMapping(e){return new Xi(qv(this.done,e),qv(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,o){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(o&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Hb.of({side:e,rest:p0e(r),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=r.length==1?Ir:r.slice(0,r.length-1);return i.mapped&&(a=qv(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Hb.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Xi.empty=new Xi(Ir,Ir);const v0e=[{key:"Mod-z",run:AO,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Wb,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Wb,preventDefault:!0},{key:"Mod-u",run:c0e,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:u0e,preventDefault:!0}];function Lu(t,e){return ze.create(t.ranges.map(e),t.mainIndex)}function Li(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Pi({state:t,dispatch:e},n){let o=Lu(t.selection,n);return o.eq(t.selection,!0)?!1:(e(Li(t,o)),!0)}function _g(t,e){return ze.cursor(e?t.to:t.from)}function TO(t,e){return Pi(t,n=>n.empty?t.moveByChar(n,e):_g(n,e))}function Bo(t){return t.textDirectionAt(t.state.selection.main.head)==Dn.LTR}const MO=t=>TO(t,!Bo(t)),OO=t=>TO(t,Bo(t));function BO(t,e){return Pi(t,n=>n.empty?t.moveByGroup(n,e):_g(n,e))}const b0e=t=>BO(t,!Bo(t)),y0e=t=>BO(t,Bo(t));function x0e(t,e,n){if(e.type.prop(n))return!0;let o=e.to-e.from;return o&&(o>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function kg(t,e,n){let o=as(t).resolveInner(e.head),r=n?Nt.closedBy:Nt.openedBy;for(let l=e.head;;){let c=n?o.childAfter(l):o.childBefore(l);if(!c)break;x0e(t,c,r)?o=c:l=n?c.to:c.from}let i=o.type.prop(r),s,a;return i&&(s=n?$c(t,o.from,1):$c(t,o.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?o.to:o.from,ze.cursor(a,n?-1:1)}const w0e=t=>Pi(t,e=>kg(t.state,e,!Bo(t))),_0e=t=>Pi(t,e=>kg(t.state,e,Bo(t)));function LO(t,e){return Pi(t,n=>{if(!n.empty)return _g(n,e);let o=t.moveVertically(n,e);return o.head!=n.head?o:t.moveToLineBoundary(n,e)})}const PO=t=>LO(t,!1),DO=t=>LO(t,!0);function EO(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,o=0,r;if(e){for(let i of t.state.facet(_t.scrollMargins)){let s=i(t);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(o=Math.max(s==null?void 0:s.bottom,o))}r=t.scrollDOM.clientHeight-n-o}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:o,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function NO(t,e){let n=EO(t),{state:o}=t,r=Lu(o.selection,s=>s.empty?t.moveVertically(s,e,n.height):_g(s,e));if(r.eq(o.selection))return!1;let i;if(n.selfScroll){let s=t.coordsAtPos(o.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<c&&(i=_t.scrollIntoView(r.main.head,{y:"start",yMargin:s.top-l}))}return t.dispatch(Li(o,r),{effects:i}),!0}const jk=t=>NO(t,!1),Ub=t=>NO(t,!0);function nl(t,e,n){let o=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?o.to:o.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==o.from&&o.length){let i=/^\s*/.exec(t.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;i&&e.head!=o.from+i&&(r=ze.cursor(o.from+i))}return r}const k0e=t=>Pi(t,e=>nl(t,e,!0)),S0e=t=>Pi(t,e=>nl(t,e,!1)),A0e=t=>Pi(t,e=>nl(t,e,!Bo(t))),C0e=t=>Pi(t,e=>nl(t,e,Bo(t))),$0e=t=>Pi(t,e=>ze.cursor(t.lineBlockAt(e.head).from,1)),T0e=t=>Pi(t,e=>ze.cursor(t.lineBlockAt(e.head).to,-1));function M0e(t,e,n){let o=!1,r=Lu(t.selection,i=>{let s=$c(t,i.head,-1)||$c(t,i.head,1)||i.head>0&&$c(t,i.head-1,1)||i.head<t.doc.length&&$c(t,i.head+1,-1);if(!s||!s.end)return i;o=!0;let a=s.start.from==i.head?s.end.to:s.end.from;return ze.cursor(a)});return o?(e(Li(t,r)),!0):!1}const O0e=({state:t,dispatch:e})=>M0e(t,e);function Zr(t,e){let n=Lu(t.state.selection,o=>{let r=e(o);return ze.range(o.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(Li(t.state,n)),!0)}function IO(t,e){return Zr(t,n=>t.moveByChar(n,e))}const RO=t=>IO(t,!Bo(t)),FO=t=>IO(t,Bo(t));function VO(t,e){return Zr(t,n=>t.moveByGroup(n,e))}const B0e=t=>VO(t,!Bo(t)),L0e=t=>VO(t,Bo(t)),P0e=t=>Zr(t,e=>kg(t.state,e,!Bo(t))),D0e=t=>Zr(t,e=>kg(t.state,e,Bo(t)));function zO(t,e){return Zr(t,n=>t.moveVertically(n,e))}const HO=t=>zO(t,!1),WO=t=>zO(t,!0);function UO(t,e){return Zr(t,n=>t.moveVertically(n,e,EO(t).height))}const Xk=t=>UO(t,!1),Kk=t=>UO(t,!0),E0e=t=>Zr(t,e=>nl(t,e,!0)),N0e=t=>Zr(t,e=>nl(t,e,!1)),I0e=t=>Zr(t,e=>nl(t,e,!Bo(t))),R0e=t=>Zr(t,e=>nl(t,e,Bo(t))),F0e=t=>Zr(t,e=>ze.cursor(t.lineBlockAt(e.head).from)),V0e=t=>Zr(t,e=>ze.cursor(t.lineBlockAt(e.head).to)),Zk=({state:t,dispatch:e})=>(e(Li(t,{anchor:0})),!0),Qk=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.doc.length})),!0),Jk=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.selection.main.anchor,head:0})),!0),eS=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),z0e=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),H0e=({state:t,dispatch:e})=>{let n=Sg(t).map(({from:o,to:r})=>ze.range(o,Math.min(r+1,t.doc.length)));return e(t.update({selection:ze.create(n),userEvent:"select"})),!0},W0e=({state:t,dispatch:e})=>{let n=Lu(t.selection,o=>{let r=as(t),i=r.resolveStack(o.from,1);if(o.empty){let s=r.resolveStack(o.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:a}=s;if((a.from<o.from&&a.to>=o.to||a.to>o.to&&a.from<=o.from)&&s.next)return ze.range(a.to,a.from)}return o});return n.eq(t.selection)?!1:(e(Li(t,n)),!0)};function GO(t,e){let{state:n}=t,o=n.selection,r=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=i;;){let l=t.moveVertically(a,e);if(l.head<s.from||l.head>s.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==o.ranges.length?!1:(t.dispatch(Li(n,ze.create(r,r.length-1))),!0)}const U0e=t=>GO(t,!1),G0e=t=>GO(t,!0),q0e=({state:t,dispatch:e})=>{let n=t.selection,o=null;return n.ranges.length>1?o=ze.create([n.main]):n.main.empty||(o=ze.create([ze.cursor(n.main.head)])),o?(e(Li(t,o)),!0):!1};function zf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:o}=t,r=o.changeByRange(i=>{let{from:s,to:a}=i;if(s==a){let l=e(i);l<s?(n="delete.backward",l=Fh(t,l,!1)):l>s&&(n="delete.forward",l=Fh(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Fh(t,s,!1),a=Fh(t,a,!0);return s==a?{range:i}:{changes:{from:s,to:a},range:ze.cursor(s,s<i.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(o.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?_t.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function Fh(t,e,n){if(t instanceof _t)for(let o of t.state.facet(_t.atomicRanges).map(r=>r(t)))o.between(e,e,(r,i)=>{r<e&&i>e&&(e=n?i:r)});return e}const qO=(t,e,n)=>zf(t,o=>{let r=o.from,{state:i}=t,s=i.doc.lineAt(r),a,l;if(n&&!e&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,r-s.from))){if(a[a.length-1]==" ")return r-1;let c=hg(a,i.tabSize),u=c%L0(i)||L0(i);for(let d=0;d<u&&a[a.length-1-d]==" ";d++)r--;l=r}else l=To(s.text,r-s.from,e,e)+s.from,l==r&&s.number!=(e?i.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,r-s.from))&&(l=To(s.text,l-s.from,!1,!1)+s.from);return l}),Gb=t=>qO(t,!1,!0),YO=t=>qO(t,!0,!1),jO=(t,e)=>zf(t,n=>{let o=n.head,{state:r}=t,i=r.doc.lineAt(o),s=r.charCategorizer(o);for(let a=null;;){if(o==(e?i.to:i.from)){o==n.head&&i.number!=(e?r.doc.lines:1)&&(o+=e?1:-1);break}let l=To(i.text,o-i.from,e)+i.from,c=i.text.slice(Math.min(o,l)-i.from,Math.max(o,l)-i.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||o!=n.head)&&(a=u),o=l}return o}),XO=t=>jO(t,!1),Y0e=t=>jO(t,!0),j0e=t=>zf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),X0e=t=>zf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),K0e=t=>zf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Z0e=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(o=>({changes:{from:o.from,to:o.to,insert:Ut.of(["",""])},range:ze.cursor(o.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Q0e=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(o=>{if(!o.empty||o.from==0||o.from==t.doc.length)return{range:o};let r=o.from,i=t.doc.lineAt(r),s=r==i.from?r-1:To(i.text,r-i.from,!1)+i.from,a=r==i.to?r+1:To(i.text,r-i.from,!0)+i.from;return{changes:{from:s,to:a,insert:t.doc.slice(r,a).append(t.doc.slice(s,r))},range:ze.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sg(t){let e=[],n=-1;for(let o of t.selection.ranges){let r=t.doc.lineAt(o.from),i=t.doc.lineAt(o.to);if(!o.empty&&o.to==i.from&&(i=t.doc.lineAt(o.to-1)),n>=r.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(o)}else e.push({from:r.from,to:i.to,ranges:[o]});n=i.number+1}return e}function KO(t,e,n){if(t.readOnly)return!1;let o=[],r=[];for(let i of Sg(t)){if(n?i.to==t.doc.length:i.from==0)continue;let s=t.doc.lineAt(n?i.to+1:i.from-1),a=s.length+1;if(n){o.push({from:i.to,to:s.to},{from:i.from,insert:s.text+t.lineBreak});for(let l of i.ranges)r.push(ze.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{o.push({from:s.from,to:i.from},{from:i.to,insert:t.lineBreak+s.text});for(let l of i.ranges)r.push(ze.range(l.anchor-a,l.head-a))}}return o.length?(e(t.update({changes:o,scrollIntoView:!0,selection:ze.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const J0e=({state:t,dispatch:e})=>KO(t,e,!1),eme=({state:t,dispatch:e})=>KO(t,e,!0);function ZO(t,e,n){if(t.readOnly)return!1;let o=[];for(let i of Sg(t))n?o.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):o.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let r=t.changes(o);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const tme=({state:t,dispatch:e})=>ZO(t,e,!1),nme=({state:t,dispatch:e})=>ZO(t,e,!0),ome=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Sg(e).map(({from:r,to:i})=>(r>0?r--:i<e.doc.length&&i++,{from:r,to:i}))),o=Lu(e.selection,r=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(r.head),a=t.coordsAtPos(r.head,r.assoc||1);a&&(i=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,i)}).map(n);return t.dispatch({changes:n,selection:o,scrollIntoView:!0,userEvent:"delete.line"}),!0};function rme(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=as(t).resolveInner(e),o=n.childBefore(e),r=n.childAfter(e),i;return o&&r&&o.to<=e&&r.from>=e&&(i=o.type.prop(Nt.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(o.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(o.to,r.from))?{from:o.to,to:r.from}:null}const tS=QO(!1),ime=QO(!0);function QO(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let o=e.changeByRange(r=>{let{from:i,to:s}=r,a=e.doc.lineAt(i),l=!t&&i==s&&rme(e,i);t&&(i=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new xg(e,{simulateBreak:i,simulateDoubleBreak:!!l}),u=xO(c,i);for(u==null&&(u=hg(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:i,to:s}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let d=["",P0(e,u)];return l&&d.push(P0(e,c.lineIndent(a.from,-1))),{changes:{from:i,to:s,insert:Ut.of(d)},range:ze.cursor(i+1+d[1].length)}});return n(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0}}function vx(t,e){let n=-1;return t.changeByRange(o=>{let r=[];for(let s=o.from;s<=o.to;){let a=t.doc.lineAt(s);a.number>n&&(o.empty||o.to>a.from)&&(e(a,r,o),n=a.number),s=a.to+1}let i=t.changes(r);return{changes:r,range:ze.range(i.mapPos(o.anchor,1),i.mapPos(o.head,1))}})}const sme=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),o=new xg(t,{overrideIndentation:i=>{let s=n[i];return s??-1}}),r=vx(t,(i,s,a)=>{let l=xO(o,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let c=/^\s*/.exec(i.text)[0],u=P0(t,l);(c!=u||a.from<i.from+c.length)&&(n[i.from]=l,s.push({from:i.from,to:i.from+c.length,insert:u}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},ame=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(vx(t,(n,o)=>{o.push({from:n.from,insert:t.facet(fx)})}),{userEvent:"input.indent"})),!0),lme=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(vx(t,(n,o)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let i=hg(r,t.tabSize),s=0,a=P0(t,Math.max(0,i-L0(t)));for(;s<r.length&&s<a.length&&r.charCodeAt(s)==a.charCodeAt(s);)s++;o.push({from:n.from+s,to:n.from+r.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),cme=t=>(t.setTabFocusMode(),!0),ume=[{key:"Ctrl-b",run:MO,shift:RO,preventDefault:!0},{key:"Ctrl-f",run:OO,shift:FO},{key:"Ctrl-p",run:PO,shift:HO},{key:"Ctrl-n",run:DO,shift:WO},{key:"Ctrl-a",run:$0e,shift:F0e},{key:"Ctrl-e",run:T0e,shift:V0e},{key:"Ctrl-d",run:YO},{key:"Ctrl-h",run:Gb},{key:"Ctrl-k",run:j0e},{key:"Ctrl-Alt-h",run:XO},{key:"Ctrl-o",run:Z0e},{key:"Ctrl-t",run:Q0e},{key:"Ctrl-v",run:Ub}],dme=[{key:"ArrowLeft",run:MO,shift:RO,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:b0e,shift:B0e,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:A0e,shift:I0e,preventDefault:!0},{key:"ArrowRight",run:OO,shift:FO,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:y0e,shift:L0e,preventDefault:!0},{mac:"Cmd-ArrowRight",run:C0e,shift:R0e,preventDefault:!0},{key:"ArrowUp",run:PO,shift:HO,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Zk,shift:Jk},{mac:"Ctrl-ArrowUp",run:jk,shift:Xk},{key:"ArrowDown",run:DO,shift:WO,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Qk,shift:eS},{mac:"Ctrl-ArrowDown",run:Ub,shift:Kk},{key:"PageUp",run:jk,shift:Xk},{key:"PageDown",run:Ub,shift:Kk},{key:"Home",run:S0e,shift:N0e,preventDefault:!0},{key:"Mod-Home",run:Zk,shift:Jk},{key:"End",run:k0e,shift:E0e,preventDefault:!0},{key:"Mod-End",run:Qk,shift:eS},{key:"Enter",run:tS,shift:tS},{key:"Mod-a",run:z0e},{key:"Backspace",run:Gb,shift:Gb,preventDefault:!0},{key:"Delete",run:YO,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:XO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Y0e,preventDefault:!0},{mac:"Mod-Backspace",run:X0e,preventDefault:!0},{mac:"Mod-Delete",run:K0e,preventDefault:!0}].concat(ume.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),fme=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:w0e,shift:P0e},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:_0e,shift:D0e},{key:"Alt-ArrowUp",run:J0e},{key:"Shift-Alt-ArrowUp",run:tme},{key:"Alt-ArrowDown",run:eme},{key:"Shift-Alt-ArrowDown",run:nme},{key:"Mod-Alt-ArrowUp",run:U0e},{key:"Mod-Alt-ArrowDown",run:G0e},{key:"Escape",run:q0e},{key:"Mod-Enter",run:ime},{key:"Alt-l",mac:"Ctrl-l",run:H0e},{key:"Mod-i",run:W0e,preventDefault:!0},{key:"Mod-[",run:lme},{key:"Mod-]",run:ame},{key:"Mod-Alt-\\",run:sme},{key:"Shift-Mod-k",run:ome},{key:"Shift-Mod-\\",run:O0e},{key:"Mod-/",run:Jpe},{key:"Alt-A",run:t0e},{key:"Ctrl-m",mac:"Shift-Alt-m",run:cme}].concat(dme);var nS={};class E0{constructor(e,n,o,r,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=o,this.reducePos=r,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,o=0){let r=e.parser.context;return new E0(e,[],n,o,o,0,[],0,r?new oS(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let o=e>>19,r=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(r);if(a&&(this.score+=a),o==0){this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(o-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-d;if(r<i.minRepeatTerm||e&131072){let h=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,h,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let h=this.stack[l-3];this.state=i.getGoto(h,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,n,o,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==o)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=o;return}}}if(!i||this.pos==o)this.buffer.push(e,n,o,r);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>o;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>o;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,r>4&&(r-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=o,this.buffer[s+3]=r}}shift(e,n,o,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=r;let a=s.stateFlag(i,1);!a&&(r>o||n<=s.maxNode)&&(this.reducePos=r),this.pushState(i,a?o:Math.min(o,this.reducePos)),this.shiftContext(n,o),n<=s.maxNode&&this.buffer.push(n,o,r,4)}else this.pos=r,this.shiftContext(n,o),n<=this.p.parser.maxNode&&this.buffer.push(n,o,r,4)}apply(e,n,o,r){e&65536?this.reduce(e):this.shift(e,n,o,r)}useNode(e,n){let o=this.p.reused.length-1;(o<0||this.p.reused[o]!=e)&&(this.p.reused.push(e),o++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(o,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let o=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new E0(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,o,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let o=e<=this.p.parser.maxNode;o&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,o?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new hme(this);;){let o=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(o==0)return!1;if((o&65536)==0)return!0;n.reduce(o)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&r.push(n[i],s);if(this.stack.length<120)for(let i=0;r.length<8&&i<n.length;i+=2){let s=n[i+1];r.some((a,l)=>l&1&&a==s)||r.push(n[i],s)}n=r}let o=[];for(let r=0;r<n.length&&o.length<4;r+=2){let i=n[r+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[r],this.pos),s.reducePos=this.pos,s.score-=200,o.push(s)}return o}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let o=n>>19,r=n&65535,i=this.stack.length-o*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],o=(r,i)=>{if(!n.includes(r))return n.push(r),e.allActions(r,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=o(s,i+1);if(a!=null)return a}})};return o(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new oS(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class oS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class hme{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,o=e>>19;o==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(o-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class N0{constructor(e,n,o){this.stack=e,this.pos=n,this.index=o,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new N0(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new N0(this.stack,this.pos,this.index)}}function Vh(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let o=0,r=0;o<t.length;){let i=0;for(;;){let s=t.charCodeAt(o++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[r++]=i:n=new e(i)}return n}class up{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const rS=new up;class pme{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=rS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let o=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<o.from;){if(!r)return null;let s=this.ranges[--r];i-=o.from-s.to,o=s}for(;n<0?i>o.to:i>=o.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];i+=s.from-o.to,o=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,o,r;if(n>=0&&n<this.chunk.length)o=this.pos+e,r=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(o=i,o>=this.chunk2Pos&&o<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(o-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=o;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=o),o+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-o)),r=this.chunk2.charCodeAt(0)}}return o>=this.token.lookAhead&&(this.token.lookAhead=o+1),r}acceptToken(e,n=0){let o=n?this.resolveOffset(n,-1):this.pos;if(o==null||o<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=o}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=rS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let o="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(o+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return o}}class Hc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:o}=n.p;mme(this.data,e,n,this.id,o.data,o.tokenPrecTable)}}Hc.prototype.contextual=Hc.prototype.fallback=Hc.prototype.extend=!1;Hc.prototype.fallback=Hc.prototype.extend=!1;function mme(t,e,n,o,r,i){let s=0,a=1<<o,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let h=s+3;h<c;h+=2)if((t[h+1]&a)>0){let g=t[h];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||gme(g,e.token.value,r,i))){e.acceptToken(g);break}}let u=e.next,d=0,f=t[s+2];if(e.next<0&&f>d&&t[c+f*3-3]==65535){s=t[c+f*3-1];continue e}for(;d<f;){let h=d+f>>1,g=c+h+(h<<1),b=t[g],m=t[g+1]||65536;if(u<b)f=h;else if(u>=m)d=h+1;else{s=t[g+2],e.advance();continue e}}break}}function iS(t,e,n){for(let o=e,r;(r=t[o])!=65535;o++)if(r==n)return o-e;return-1}function gme(t,e,n,o){let r=iS(n,o,e);return r<0||iS(n,o,t)<r}const hr=typeof process<"u"&&nS&&/\bparse\b/.test(nS.LOG);let Yv=null;function sS(t,e,n){let o=t.cursor(yn.IncludeAnonymous);for(o.moveTo(e);;)if(!(n<0?o.childBefore(e):o.childAfter(e)))for(;;){if((n<0?o.to<e:o.from>e)&&!o.type.isError)return n<0?Math.max(0,Math.min(o.to-1,e-25)):Math.min(t.length,Math.max(o.from+1,e+25));if(n<0?o.prevSibling():o.nextSibling())break;if(!o.parent())return n<0?0:t.length}}class vme{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?sS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?sS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let o=this.trees[n],r=this.index[n];if(r==o.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=o.children[r],s=this.start[n]+o.positions[r];if(s>e)return this.nextStart=s,null;if(i instanceof Tn){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Nt.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class bme{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(o=>new up)}getActions(e){let n=0,o=null,{parser:r}=e.p,{tokenizers:i}=r,s=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(o&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let f=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(o=d,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!o&&e.pos==this.stream.end&&(o=new up,o.value=e.p.parser.eofTerm,o.start=o.end=e.pos,n=this.addActions(e,o.value,o.end,n)),this.mainToken=o,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new up,{pos:o,p:r}=e;return n.start=o,n.end=Math.min(o+1,r.stream.end),n.value=o==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,o){let r=this.stream.clipPos(o.pos);if(n.token(this.stream.reset(r,e),o),e.value>-1){let{parser:i}=o.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),o);if(a>=0&&o.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,o,r){for(let i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=o,r}addActions(e,n,o,r){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=$s(a,c+2);else{r==0&&a[c+1]==2&&(r=this.putAction($s(a,c+2),n,o,r));break}a[c]==n&&(r=this.putAction($s(a,c+1),n,o,r))}return r}}class yme{constructor(e,n,o,r){this.parser=e,this.input=n,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new pme(n,r),this.tokens=new bme(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[E0.start(this,e.top[0],i)],this.fragments=o.length&&this.stream.end-i>e.bufferLength*4?new vme(o,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,o=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)o.push(a);else{if(this.advanceStack(a,o,e))continue;{r||(r=[],i=[]),r.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!o.length){let s=r&&wme(r);if(s)return hr&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw hr&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,o);if(s)return hr&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(o.length>s)for(o.sort((a,l)=>l.score-a.score);o.length>s;)o.pop();o.some(a=>a.reducePos>n)&&this.recovering--}else if(o.length>1){e:for(let s=0;s<o.length-1;s++){let a=o[s];for(let l=s+1;l<o.length;l++){let c=o[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)o.splice(l--,1);else{o.splice(s--,1);continue e}}}o.length>12&&(o.sort((s,a)=>a.score-s.score),o.splice(12,o.length-12))}this.minStackPos=o[0].pos;for(let s=1;s<o.length;s++)o[s].pos<this.minStackPos&&(this.minStackPos=o[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,o){let r=e.pos,{parser:i}=this,s=hr?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(r);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(Nt.contextHash)||0)==u))return e.useNode(d,f),hr&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof Tn)||d.children.length==0||d.positions[0]>0)break;let h=d.children[0];if(h instanceof Tn&&d.positions[0]==0)d=h;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),hr&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],f=l[c++],h=c==l.length||!o,g=h?e:e.split(),b=this.tokens.mainToken;if(g.apply(u,d,b?b.start:g.pos,f),hr&&console.log(s+this.stackID(g)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${r}${g==e?"":", split"})`),h)return!0;g.pos>r?n.push(g):o.push(g)}return!1}advanceFully(e,n){let o=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>o)return aS(e,n),!0}}runRecovery(e,n,o){let r=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=hr?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),hr&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,o))))continue;let d=a.split(),f=u;for(let h=0;h<10&&d.forceReduce()&&(hr&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,o));h++)hr&&(f=this.stackID(d)+" -> ");for(let h of a.recoverByInsert(l))hr&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,o);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),hr&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),aS(a,o)):(!r||r.score<d.score)&&(r=d)}return r}stackToTree(e){return e.close(),Tn.build({buffer:N0.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Yv||(Yv=new WeakMap)).get(e);return n||Yv.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function aS(t,e){for(let n=0;n<e.length;n++){let o=e[n];if(o.pos==t.pos&&o.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class xme{constructor(e,n,o){this.source=e,this.flags=n,this.disabled=o}allows(e){return!this.disabled||this.disabled[e]==0}}class I0 extends hO{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let o=Object.keys(e.topRules).map(a=>e.topRules[a][1]),r=[];for(let a=0;a<n.length;a++)r.push([]);function i(a,l,c){r[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Nt[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let f=-u;f>0;f--)i(a[c++],l,d);c++}}}this.nodeSet=new lx(n.map((a,l)=>lr.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:o.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=cO;let s=Vh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(lS),this.states=Vh(e.states,Uint32Array),this.data=Vh(e.stateData),this.goto=Vh(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Hc(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,o){let r=new yme(this,e,n,o);for(let i of this.wrappers)r=i(r,e,n,o);return r}getGoto(e,n,o=!1){let r=this.goto;if(n>=r[0])return-1;for(let i=r[n+1];;){let s=r[i++],a=s&1,l=r[i++];if(a&&o)return l;for(let c=i+(s>>1);i<c;i++)if(r[i]==e)return l;if(a)return-1}}hasAction(e,n){let o=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),s;;i+=3){if((s=o[i])==65535)if(o[i+1]==1)s=o[i=$s(o,i+2)];else{if(o[i+1]==2)return $s(o,i+2);break}if(s==n||s==0)return $s(o,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,o=>o==n?!0:null)}allActions(e,n){let o=this.stateSlot(e,4),r=o?n(o):void 0;for(let i=this.stateSlot(e,1);r==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$s(this.data,i+2);else break;r=n($s(this.data,i+1))}return r}nextStates(e){let n=[];for(let o=this.stateSlot(e,1);;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=$s(this.data,o+2);else break;if((this.data[o+2]&1)==0){let r=this.data[o+1];n.some((i,s)=>s&1&&i==r)||n.push(this.data[o],r)}}return n}configure(e){let n=Object.assign(Object.create(I0.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let o=this.topRules[e.top];if(!o)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=o}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(o=>{let r=e.tokenizers.find(i=>i.from==o);return r?r.to:o})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((o,r)=>{let i=e.specializers.find(a=>a.from==o.external);if(!i)return o;let s=Object.assign(Object.assign({},o),{external:i.to});return n.specializers[r]=lS(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),o=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(o[s]=!0)}let r=null;for(let i=0;i<n.length;i++)if(!o[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new xme(e,o,r)}static deserialize(e){return new I0(e)}}function $s(t,e){return t[e]|t[e+1]<<16}function wme(t){let e=null;for(let n of t){let o=n.p.stoppedAt;(n.pos==n.p.stream.end||o!=null&&n.pos>o)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function lS(t){if(t.external){let e=t.extend?1:0;return(n,o)=>t.external(n,o)<<1|e}return t.get}const _me={__proto__:null,chart:10,data:16,colorize:38,highlight:40,areafill:44,range:48,note:52,annotation:56,series:60,scene:64,step:66,transform:72},kme=I0.deserialize({version:14,states:",`OYQPOOQOQPOOO_QPO'#C_OdQPO,58yO!dQPO1G.eOOQO'#Cf'#CfO!kQPO'#CmOOQO'#Cb'#CbOOQO'#DR'#DRO!pQPO7+$PO!wQPO'#CcO!|QPO'#CnO#RQPO'#CqO#WQPO'#CsO#]QPO'#CuO#bQPO'#CwO#gQPO'#CyO#lQPO'#DPO#qQPO'#C{OOQO7+$P7+$PO#yQPO,59XOOQO-E7P-E7POOQO<<Gk<<GkO$XQPO,58}O$dQPO,59YO$iQPO,59]O$nQPO,59_O$yQPO,59aO%UQPO,59cO%ZQPO,59eO%`QPO,59kO&YQPO,59gO&aQPO,59gOOQO'#Cj'#CjOOQO1G.s1G.sO&fQPO'#CmOOQO'#Ce'#CeOOQO'#DS'#DSO&kQPO1G.iOOQO1G.i1G.iO&vQPO1G.tO'RQPO1G.wOOQO'#DU'#DUO'WQPO1G.yOOQO1G.y1G.yO'cQPO1G.{OOQO1G.{1G.{O'nQPO1G.}O'yQPO1G/PO(UQPO1G/VOOQO'#DO'#DOOOQO'#DV'#DVO(aQPO1G/ROOQO1G/R1G/RO(aQPO1G/RO#yQPO,59XOOQO-E7Q-E7QOOQO7+$T7+$TO(hQPO7+$`OOQO7+$`7+$`O(sQPO7+$cOOQO-E7S-E7SOOQO7+$e7+$eOOQO7+$g7+$gO)OQPO7+$iOOQO7+$i7+$iO)ZQPO7+$kOOQO7+$k7+$kO)fQPO7+$qOOQO7+$q7+$qOOQO-E7T-E7TOOQO7+$m7+$mO)qQPO7+$mO)xQPO1G.sOOQO1G.k1G.kOOQO<<Gz<<GzO*WQPO<<G}OOQO<<G}<<G}OOQO<<HT<<HTOOQO<<HV<<HVOOQO<<H]<<H]OOQO<<HX<<HXO#yQPO'#DTO*cQPO,59TOOQOAN=iAN=iOOQO,59o,59oOOQO-E7R-E7R",stateData:"*w~O|OSPOS~OTQO~OSRO~O}SO~OSTOWYOZTOcZOdZOf[Oh]Oj^Ol_On`OpbOqbOtaO~O!PcO~PiO[dO~O!PfO~PiO}gO~OZhO~OZiO~O}jO~O}kO~OZlO~OZmO~OSnO~OZpO}oO~OSqOZqO_qO`qO~OSTOZTO!PwO~O}xO~OZyO~OSTOZTO!P|O~OSTOZTO!P!OO~O}!PO~O}!QO~O}!RO~OSTOWYOZTOcZOdZOf[Oh]Oj^Ol_On`OtaO~O!P!VO~P%eO}!WO~O[!XO~OSTOZTO!P!ZO~OSTOZTO!P!]O~O}!^O~OSTOZTO!P!`O~OSTOZTO!P!aO~OSTOZTO!P!cO~OSTOZTO!P!eO~OSTOZTO!P!gO~O!P!iO~P%eOSTOZTO!P!mO~OSTOZTO!P!oO~OSTOZTO!P!pO~OSTOZTO!P!qO~OSTOZTO!P!rO~O!P!sO~P%eO!O!tOSaiZai!Pai~OSTOZTO!P!vO~O!O!tOS]aZ]a!P]a~O_`PSP~",goto:"%`zPPP{PP!O!SP!^!bPP!|#PPP#Y!SPP!SP!SP!SP!SP!SP#xPP#|!SP$S$Y$`$f%URPOTWSXSVSXX!So!U!W!jTugvxUSXjkox{}!P!Q!R!U!W![!^!b!d!f!j!nTsgvR!l!XQrdQ!k!XR!w!tSVSXStgvlzjkx{}!P!Q!R![!^!b!d!f!nX!So!U!W!jTVSXX!To!U!W!jQXSReXQvgR!YvQ!u!kR!x!uQ{jQ}kQ![x^!_{}![!b!d!f!nQ!b!PQ!d!QQ!f!RR!n!^Q!UoS!h!U!jR!j!W",nodeNames:"⚠ LineComment Chart ChartDecl Identifier chart ChartMember DataBlock data DataEntry PropertyKey String Equals ValueList PropertyValue Percentage Number Property Colorize colorize highlight AreaFill areafill RangeAnnotation range NoteAnnotation note Annotation annotation Series series Scene scene step SceneMember Transform transform",maxTerm:47,skippedNodes:[0,1],repeatNodeCount:5,tokenData:"']~RfX^!gpq!grs#[st$u|}%^}!O%c!P!Q&_!Q![%i!_!`&|!c!}$u#R#S$u#T#o$u#o#p'R#q#r'W#y#z!g$f$g!g#BY#BZ!g$IS$I_!g$I|$JO!g$JT$JU!g$KV$KW!g&FU&FV!g~!lY|~X^!gpq!g#y#z!g$f$g!g#BY#BZ!g$IS$I_!g$I|$JO!g$JT$JU!g$KV$KW!g&FU&FV!g~#_VOr#[rs#ts#O#[#O#P#y#P;'S#[;'S;=`$o<%lO#[~#yOZ~~#|ZOr#[rs#[s#O#[#O#P#[#P#b#[#b#c#[#c#h#[#h#i#[#i;'S#[;'S;=`$o<%lO#[~$rP;=`<%l#[~$zUS~st$u}!O$u!Q![$u!c!}$u#R#S$u#T#o$u~%cO!O~~%fP!Q![%i~%nR`~uv%w!O!P%|!Q![%i~%|O_~~&PP!Q![&S~&XQ`~uv%w!Q![&S~&bP!P!Q&e~&jSP~OY&eZ;'S&e;'S;=`&v<%lO&e~&yP;=`<%l&e~'RO[~~'WO}~~']O!P~",tokenizers:[0],topRules:{Chart:[0,2]},specialized:[{term:4,get:t=>_me[t]||-1}],tokenPrec:447}),JO=kme.configure({props:[pO({chart:at.keyword,data:at.keyword,colorize:at.keyword,highlight:at.keyword,areafill:at.keyword,annotation:at.keyword,range:at.keyword,note:at.keyword,series:at.keyword,scene:at.keyword,step:at.keyword,transform:at.keyword,Identifier:at.variableName,String:at.string,Number:at.number,Percentage:at.number,Equals:at.operator,LineComment:at.lineComment,"{ }":at.brace})]}),Sme=O0.define({parser:JO,languageData:{commentTokens:{line:"//"}}}),Ame=Hpe(bO);function Cme(){return new Bpe(Sme)}function jv(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function vbe(t){const e=JO.parse(t);let n=0,o="";return vO(e,bO,(r,i,s)=>{r>n&&(o+=jv(t.slice(n,r))),o+=`<span class="${s}">${jv(t.slice(r,i))}</span>`,n=i}),n<t.length&&(o+=jv(t.slice(n))),o}const $me={class:"d-flex flex-column h-100"},Tme={key:0,class:"text-danger small mt-1"},Mme=le({__name:"ChartEditDsl",setup(t){const{dsl:e}=Nf(),{applyDsl:n}=Ic(),o=ft("editorEl"),r=Ve();let i,s=!1;function a(l){if(!l.docChanged||s)return;const c=l.state.doc.toString(),u=n(c);u.success?r.value=void 0:r.value=u.error}return un(()=>{const l=Kt.create({doc:e.value,extensions:[lO.of([...fme,...v0e]),l0e(),Cme(),Ame,_t.updateListener.of(a),_t.theme({"&":{height:"100%",backgroundColor:"var(--bc-tile-bg-elevated)"},".cm-scroller":{overflow:"auto"},".cm-content":{fontFamily:"var(--bs-font-monospace)"},".cm-gutters":{backgroundColor:"var(--bc-tile-bg-elevated)",color:"var(--bs-secondary-color)",borderRight:"1px solid var(--bs-border-color)"}})]});i=new _t({state:l,parent:o.value})}),Ge(e,l=>{!i||i.state.doc.toString()===l||(s=!0,i.dispatch({changes:{from:0,to:i.state.doc.length,insert:l}}),s=!1)}),Qs(()=>{i==null||i.destroy(),i=void 0}),(l,c)=>(w(),R("div",$me,[M("div",{ref_key:"editorEl",ref:o,class:"flex-grow-1 overflow-auto"},null,512),p(r)?(w(),R("div",Tme,ye(p(r)),1)):ie("",!0)]))}}),Ome={key:1,class:"position-absolute",width:"0",height:"0","aria-hidden":"true"},Bme=le({__name:"PreviewChart",setup(t){const e=ft("containerRef");G2(e);const{containerRef:n}=HT();Ge(e,D=>{n.value=D},{immediate:!0});const{selectAnnotation:o}=cr();function r(D){var $;const C=D.target.closest("g[data-annotation-index]");if(!C)return;D.preventDefault(),($=window.getSelection())==null||$.removeAllRanges();const T=C.getAttribute("data-annotation-id");if(T){o(T);return}const P=parseInt(C.getAttribute("data-annotation-index")||"",10);isNaN(P)||o(P)}un(()=>{var D;(D=e.value)==null||D.addEventListener("dblclick",r)}),Gs(()=>{var D;(D=e.value)==null||D.removeEventListener("dblclick",r)});const{cvdMode:i}=Ct(GT()),s=ft("cvdDefsRef");Ge([i,s],([D,I])=>{if(I){for(;I.firstChild;)I.removeChild(I.firstChild);D&&I.appendChild(Jne(D))}},{immediate:!0});const a=A(()=>{if(i.value)return{filter:`url(#${Y$(i.value)})`}}),{layout:l}=dn(),{scenes:c,activeIndex:u,playing:d,setActive:f,nextScene:h,previousScene:g,startPlayback:b,stopPlayback:m}=wn(),v=Ve(null),y={buttons:T1,"progress-bar":YA,"dot-stepper":jA,"minimal-arrows":XA},x=A(()=>y[l.value.playerType]),_=A(()=>c.value.length+1),k=A(()=>u.value+2),E=A(()=>c.value.length>=1&&l.value.playerType!=="none");function B(D){f(D-2)}let S=null;function L(){const D=e.value;return D?D.querySelector(".bc-frame-footer"):null}return Ge(e,D=>{if(S&&(S.disconnect(),S=null),!D){v.value=null;return}v.value=L(),S=new MutationObserver(()=>{v.value=L()}),S.observe(D,{childList:!0,subtree:!0})},{immediate:!0}),Gs(()=>{S&&(S.disconnect(),S=null)}),(D,I)=>(w(),R(He,null,[M("div",{ref_key:"containerRef",ref:e,class:"w-100 h-100",style:Et(p(a))},null,4),p(v)&&p(E)?(w(),J(ty,{key:0,to:p(v)},[(w(),J(Gt(p(x)),{total:p(_),current:p(k),playing:p(d),position:p(l).playerPosition,"onUpdate:current":B,onPrevious:p(g),onNext:p(h),onPlay:p(b),onPause:p(m)},null,40,["total","current","playing","position","onPrevious","onNext","onPlay","onPause"]))],8,["to"])):ie("",!0),p(i)?(w(),R("svg",Ome,[M("defs",{ref_key:"cvdDefsRef",ref:s},null,512)])):ie("",!0)],64))}}),Lme=le({__name:"ChartEditPanel",setup(t){const e=cr(),{viewMode:n,activeTab:o,canvasMode:r,showDimensions:i}=Ct(e),{selectTab:s,setLastNarrowEditTab:a}=e,{mode:l}=rc(),{isNarrow:c}=Ji(),{layout:u}=dn(),{cardClass:d,cardStyle:f}=U2(u,"chart-edit-panel__canvas__card"),{sections:h}=IT(),g=A({get:()=>!!o.value,set:I=>{I||s("")}});Ge(l,I=>{I==="drawer"&&o.value&&(a(o.value),s(""))},{immediate:!0});function b(I){a(I),s(I)}const m=A(()=>h.value.map(I=>({key:I.key,label:I.label,icon:I.icon}))),v=A(()=>({"chart-edit-panel--narrow":c.value})),y=A(()=>({[`chart-edit-panel__canvas--${r.value}`]:r.value!=="blueprint","chart-edit-panel__canvas--dsl":n.value!=="preview"})),x={type:"Chart Type",text:"Text",style:"Style",layout:"Layout",series:"Series",axes:"Axes",annotate:"Annotate",interactions:"Interactions"},_=A(()=>x[o.value]??"Panel"),k=ft("canvasRef"),E=ft("cardRef"),B=Ie(0),S=Ie(0);function L(){const I=E.value;I&&(B.value=I.offsetLeft,S.value=I.offsetTop)}is(k,L),is(E,L);const D=A(()=>({"--grid-offset-x":`${B.value}px`,"--grid-offset-y":`${S.value}px`}));return(I,C)=>{const T=Bme,P=Mme,$=DT,F=PT,V=W2,U=Xde,K=Wde,se=Nde,he=Dde,ce=Yue,be=Vue,oe=Pue,de=tue,we=zle,ee=H2,ge=ug,Q=_le;return w(),R("div",{class:Me(["chart-edit-panel",p(v)])},[M("div",{ref_key:"canvasRef",ref:k,class:Me(["chart-edit-panel__canvas",p(y)]),style:Et(p(D))},[p(n)==="preview"?(w(),R("div",{key:0,ref_key:"cardRef",ref:E,class:Me(["chart-edit-panel__canvas__card",p(d)]),style:Et(p(f))},[H(T)],6)):(w(),J(P,{key:1,class:"chart-edit-panel__canvas__dsl"})),p(n)==="preview"&&p(i)?(w(),J($,{key:2,"card-ref":p(E),"canvas-ref":p(k),layout:p(u)},null,8,["card-ref","canvas-ref","layout"])):ie("",!0),p(n)==="preview"?(w(),J(F,{key:3})):ie("",!0)],6),H(ge,{"drawer-open":p(g),"onUpdate:drawerOpen":C[0]||(C[0]=re=>Ze(g)?g.value=re:null),title:p(_),"container-ref":p(k),onClose:C[1]||(C[1]=re=>p(s)(""))},bi({default:te(()=>[p(o)==="type"?(w(),J(K,{key:0})):p(o)==="text"?(w(),J(se,{key:1})):p(o)==="style"?(w(),J(he,{key:2})):p(o)==="series"?(w(),J(ce,{key:3})):p(o)==="axes"?(w(),J(be,{key:4})):p(o)==="layout"?(w(),J(oe,{key:5})):p(o)==="annotate"?(w(),J(de,{key:6})):p(o)==="interactions"?(w(),J(we,{key:7})):ie("",!0)]),_:2},[p(l)==="drawer"?{name:"tabs",fn:te(()=>[H(V,{tabs:p(m),"model-value":p(o),sticky:"","onUpdate:modelValue":b},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(l)!=="drawer"?{name:"header",fn:te(()=>[H(U)]),key:"1"}:void 0,p(l)!=="drawer"?{name:"footer",fn:te(()=>[H(ee)]),key:"2"}:void 0]),1032,["drawer-open","title","container-ref"]),p(c)?ie("",!0):(w(),J(Q,{key:0}))],2)}}}),Pme=Be(Lme,[["__scopeId","data-v-70b3f6b1"]]),Dme={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Eme(t,e){return w(),R("svg",Dme,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M104 32H64a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176H64V48h40Zm88-176h-40a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176h-40V48h40Z"},null,-1)])])}const Nme=Oe({name:"ph-columns",render:Eme}),Ime={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Rme(t,e){return w(),R("svg",Ime,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m245.66 74.34l-32-32a8 8 0 0 0-11.32 11.32L220.69 72H208c-49.33 0-61.05 28.12-71.38 52.92c-9.38 22.51-16.92 40.59-49.48 42.84a40 40 0 1 0 .1 16c43.26-2.65 54.34-29.15 64.14-52.69C161.41 107 169.33 88 208 88h12.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32M48 200a24 24 0 1 1 24-24a24 24 0 0 1-24 24"},null,-1)])])}const Fme=Oe({name:"ph-flow-arrow",render:Rme}),Vme={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function zme(t,e){return w(),R("svg",Vme,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M176 232a8 8 0 0 1-8 8H88a8 8 0 0 1 0-16h80a8 8 0 0 1 8 8m40-128a87.55 87.55 0 0 1-33.64 69.21A16.24 16.24 0 0 0 176 186v6a16 16 0 0 1-16 16H96a16 16 0 0 1-16-16v-6a16 16 0 0 0-6.23-12.66A87.59 87.59 0 0 1 40 104.49C39.74 56.83 78.26 17.14 125.88 16A88 88 0 0 1 216 104m-16 0a72 72 0 0 0-73.74-72c-39 .92-70.47 33.39-70.26 72.39a71.65 71.65 0 0 0 27.64 56.3A32 32 0 0 1 96 186v6h64v-6a32.15 32.15 0 0 1 12.47-25.35A71.65 71.65 0 0 0 200 104m-16.11-9.34a57.6 57.6 0 0 0-46.56-46.55a8 8 0 0 0-2.66 15.78c16.57 2.79 30.63 16.85 33.44 33.45A8 8 0 0 0 176 104a9 9 0 0 0 1.35-.11a8 8 0 0 0 6.54-9.23"},null,-1)])])}const Hme=Oe({name:"ph-lightbulb",render:zme});function eB(){return{sections:[{key:"column",label:"Columns",icon:Nme},{key:"transforms",label:"Transforms",icon:Fme},{key:"parsing",label:"Parsing",icon:BT},{key:"reco",label:"Recommendations",icon:Hme}]}}const Wme=le({__name:"DataSideIconRail",props:{disabledTabs:{default:()=>[]}},setup(t){const e=t,n=cr(),{dataPanelTab:o}=Ct(n),{openDataPanel:r}=n,{mode:i,toggleMode:s}=rc(),{sections:a}=eB(),l=A(()=>a.filter(d=>!e.disabledTabs.includes(d.key)).map(d=>({value:d.key,icon:d.icon,tooltip:d.tooltip??d.label})));function c(d){r(d)}function u(){i.value==="closed"&&r(o.value||"column"),s()}return(d,f)=>{const h=V2;return w(),J(h,{"active-tab":p(o),items:p(l),onSelect:c,onToggleMode:u},null,8,["active-tab","items"])}}}),Ume={class:"reco-card__preview"},Gme={class:"reco-card__body"},qme={class:"reco-card__body__title"},Yme={class:"reco-card__body__reason"},jme=le({__name:"DataRecommendationCard",props:{chartType:{},label:{},fitness:{},reason:{}},emits:["select"],setup(t){const e={[Le.BarVertical]:Oe(qT),[Le.BarHorizontal]:Oe(YT),[Le.BarMulti]:Oe(jT),[Le.Line]:Oe(XT),[Le.LineMulti]:Oe(KT),[Le.Donut]:Oe(ZT),[Le.Pie]:Oe(QT)},n=t,o=A(()=>e[n.chartType]),r=A(()=>n.fitness==="best"?"reco-card__body__title__badge--best":n.fitness==="good"?"reco-card__body__title__badge--good":"reco-card__body__title__badge--alt"),i=A(()=>n.fitness==="best"?"Best match":n.fitness==="good"?"Good fit":"Alternative");return(s,a)=>(w(),R("button",{class:Me(["reco-card",{"reco-card--best":t.fitness==="best"}]),onClick:a[0]||(a[0]=l=>s.$emit("select",t.chartType))},[M("div",Ume,[p(o)?(w(),J(Gt(p(o)),{key:0,class:"reco-card__preview__thumb-svg"})):ie("",!0)]),M("div",Gme,[M("div",qme,[Ye(ye(t.label)+" ",1),M("span",{class:Me(["reco-card__body__title__badge",p(r)])},ye(p(i)),3)]),M("div",Yme,ye(t.reason),1)])],2))}}),Xme=Be(jme,[["__scopeId","data-v-0e22d5d1"]]),Kme={[Le.BarVertical]:"Vertical Bar Chart",[Le.BarHorizontal]:"Horizontal Bar Chart",[Le.BarMulti]:"Grouped Bar Chart",[Le.Line]:"Line Chart",[Le.LineMulti]:"Multi-Line Chart",[Le.Pie]:"Pie Chart",[Le.Donut]:"Donut Chart"};function Zme(){const{displayRows:t,displayColumnTypes:e}=jo(),n=A(()=>{const r=e.value,i=r.filter(c=>c==="string").length,s=r.filter(c=>c==="number").length,a=r.filter(c=>c==="date").length,l=[];return i>0&&l.push(`${i} categorical`),a>0&&l.push(`${a} date`),s>0&&l.push(`${s} numeric`),l.length>0?`${l.join(" + ")} column${r.length!==1?"s":""}`:"No data"});return{recommendations:A(()=>{const r=e.value;if(r.length===0)return[];const i=r.filter(d=>d==="string").length,s=r.filter(d=>d==="number").length,a=r.filter(d=>d==="date").length,l=t.value.length,c=[];function u(d,f,h){c.push({chartType:d,label:Kme[d]??d,fitness:f,reason:h})}return a===1&&s>=1?s===1?(u(Le.Line,"best","1 date + 1 numeric column — ideal for trend"),u(Le.BarVertical,"alternative","Can also show as bars")):(u(Le.LineMulti,"best",`1 date + ${s} numeric columns — compare trends`),u(Le.BarMulti,"alternative","Can also show as grouped bars")):i===1&&s===1?(u(Le.BarVertical,"best","1 categorical + 1 numeric — classic bar chart"),u(Le.BarHorizontal,"good","Horizontal bars work well for long labels"),l<=8&&(u(Le.Donut,"good",`${l} items — suitable for part-of-whole`),u(Le.Pie,"alternative","Pie chart for part-of-whole"))):i===1&&s>1?(u(Le.BarMulti,"best",`1 categorical + ${s} numeric columns — compare groups`),u(Le.LineMulti,"good","Can also show as multi-line chart")):s>=1&&(i>=1||a>=1)&&u(Le.BarVertical,"good","Default bar chart recommendation"),c}),dataSummary:n}}const Qme={class:"data-recommendations"},Jme={class:"data-recommendations__summary"},ege={key:0,class:"text-muted text-center py-3"},tge=le({__name:"DataRecommendations",setup(t){const{recommendations:e,dataSummary:n}=Zme(),o=dn();function r(i){o.chartType.value=i}return(i,s)=>{const a=Xme;return w(),R("div",Qme,[M("p",Jme," Based on your data: "+ye(p(n)),1),p(e).length===0?(w(),R("div",ege," Load data to see recommendations ")):ie("",!0),(w(!0),R(He,null,ht(p(e),l=>(w(),J(a,{key:l.chartType,"chart-type":l.chartType,label:l.label,fitness:l.fitness,reason:l.reason,onSelect:r},null,8,["chart-type","label","fitness","reason"]))),128))])}}}),nge=Be(tge,[["__scopeId","data-v-47bbaf64"]]),cS={firstRowIsHeader:!0,delimiter:"auto",decimalSeparator:".",treatEmptyAsNull:!0,trimWhitespace:!0},oge=Oo("parseOptions",()=>{const t=ir({...cS});function e(o,r){t[o]=r}function n(){Object.assign(t,{...cS})}return{...K0(t),setOption:e,reset:n}});function tB(){const t=oge(),{firstRowIsHeader:e,delimiter:n,decimalSeparator:o,treatEmptyAsNull:r,trimWhitespace:i}=Ct(t);return{firstRowIsHeader:e,delimiter:n,decimalSeparator:o,treatEmptyAsNull:r,trimWhitespace:i,setOption:t.setOption,reset:t.reset}}const rge={class:"data-parse-settings"},ige={class:"data-parse-settings__field"},sge={class:"data-parse-settings__field"},age=le({__name:"DataParseSettings",setup(t){const e=tB(),{firstRowIsHeader:n,delimiter:o,decimalSeparator:r,treatEmptyAsNull:i,trimWhitespace:s}=Ct(e),{setOption:a}=e,{sourceFormat:l}=jo(),c=A(()=>l.value!=="delimited"),u=A({get:()=>n.value,set:v=>a("firstRowIsHeader",v)}),d=A({get:()=>o.value,set:v=>a("delimiter",v)}),f=A({get:()=>r.value,set:v=>a("decimalSeparator",v)}),h=A({get:()=>i.value,set:v=>a("treatEmptyAsNull",v)}),g=A({get:()=>s.value,set:v=>a("trimWhitespace",v)}),b=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma (,)"},{value:" ",label:"Tab"},{value:";",label:"Semicolon (;)"},{value:"|",label:"Pipe (|)"}],m=[{value:".",label:"Period (.)"},{value:",",label:"Comma (,)"}];return(v,y)=>(w(),R("div",rge,[H(p(Rs),{modelValue:p(u),"onUpdate:modelValue":y[0]||(y[0]=x=>Ze(u)?u.value=x:null),switch:""},{default:te(()=>[...y[5]||(y[5]=[Ye(" First row is header ",-1)])]),_:1},8,["modelValue"]),M("div",ige,[y[6]||(y[6]=M("div",{class:"data-parse-settings__field__label"}," Delimiter ",-1)),H(p(En),{modelValue:p(d),"onUpdate:modelValue":y[1]||(y[1]=x=>Ze(d)?d.value=x:null),label:"",options:b,disabled:p(c),block:""},null,8,["modelValue","disabled"])]),M("div",sge,[y[7]||(y[7]=M("div",{class:"data-parse-settings__field__label"}," Decimal Separator ",-1)),H(p(En),{modelValue:p(f),"onUpdate:modelValue":y[2]||(y[2]=x=>Ze(f)?f.value=x:null),label:"",options:m,block:""},null,8,["modelValue"])]),H(p(Rs),{modelValue:p(h),"onUpdate:modelValue":y[3]||(y[3]=x=>Ze(h)?h.value=x:null),switch:""},{default:te(()=>[...y[8]||(y[8]=[Ye(" Treat empty as null ",-1)])]),_:1},8,["modelValue"]),H(p(Rs),{modelValue:p(g),"onUpdate:modelValue":y[4]||(y[4]=x=>Ze(g)?g.value=x:null),switch:""},{default:te(()=>[...y[9]||(y[9]=[Ye(" Trim whitespace ",-1)])]),_:1},8,["modelValue"])]))}}),lge=Be(age,[["__scopeId","data-v-872473d2"]]),cge={class:"output-block"},uge={class:"output-block__meta"},dge=le({__name:"DataTransformOutputBlock",props:{columns:{},rows:{}},setup(t){return(e,n)=>(w(),R("div",cge,[n[0]||(n[0]=M("span",{class:"output-block__icon"},[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",width:"14",height:"14"},[M("path",{d:"M20 6L9 17l-5-5"})])],-1)),n[1]||(n[1]=M("span",null,"Output",-1)),M("span",uge,ye(t.columns)+" cols · "+ye(t.rows)+" rows",1)]))}}),fge=Be(dge,[["__scopeId","data-v-b1080d62"]]),hge={class:"add-wrap"},pge={key:0,class:"add-wrap__dropdown"},mge=["disabled","onClick"],gge={class:"add-wrap__dropdown__item__text"},vge={class:"add-wrap__dropdown__item__text__name"},bge={class:"add-wrap__dropdown__item__text__desc"},yge=le({__name:"DataTransformAddButton",emits:["add"],setup(t,{emit:e}){const n=e,o=Ie(!1),r=[{value:Je.Sort,label:"Sort",desc:"Reorder rows by column values",disabled:!1},{value:Je.Filter,label:"Filter",desc:"Keep or exclude rows by condition",disabled:!1},{value:Je.HideColumns,label:"Hide Columns",desc:"Remove columns from output",disabled:!1},{value:Je.Transpose,label:"Transpose",desc:"Swap rows and columns",disabled:!1},{value:Je.Parse,label:"Parse",desc:"Transform column values",disabled:!1},{value:Je.Rename,label:"Rename Column",desc:"Change a column name",disabled:!1},{value:Je.GroupBy,label:"Group By",desc:"Aggregate rows by column values",disabled:!1},{value:Je.Computed,label:"Computed Column",desc:"Derive new column (coming soon)",disabled:!0}];function i(l){return{[Je.Sort]:"add-wrap__dropdown__item__icon--sort",[Je.Filter]:"add-wrap__dropdown__item__icon--filter",[Je.HideColumns]:"add-wrap__dropdown__item__icon--hide-columns",[Je.Transpose]:"add-wrap__dropdown__item__icon--transpose",[Je.Parse]:"add-wrap__dropdown__item__icon--parse",[Je.Rename]:"add-wrap__dropdown__item__icon--rename",[Je.GroupBy]:"add-wrap__dropdown__item__icon--group",[Je.Computed]:"add-wrap__dropdown__item__icon--computed"}[l]??""}function s(l){return{[Je.Sort]:"S",[Je.Filter]:"F",[Je.HideColumns]:"H",[Je.Transpose]:"T",[Je.Parse]:"P",[Je.Rename]:"R",[Je.GroupBy]:"G",[Je.Computed]:"C"}[l]??"?"}function a(l){n("add",l),o.value=!1}return(l,c)=>(w(),R("div",hge,[H(p(Sl),{label:"Add",onClick:c[0]||(c[0]=u=>o.value=!p(o))}),p(o)?(w(),R("div",pge,[(w(),R(He,null,ht(r,u=>M("button",{key:u.value,class:"add-wrap__dropdown__item",disabled:u.disabled,onClick:d=>a(u.value)},[M("span",{class:Me(["add-wrap__dropdown__item__icon",i(u.value)])},ye(s(u.value)),3),M("div",gge,[M("div",vge,ye(u.label),1),M("div",bge,ye(u.desc),1)])],8,mge)),64))])):ie("",!0)]))}}),xge=Be(yge,[["__scopeId","data-v-ac055819"]]),wge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function _ge(t,e){return w(),R("svg",wge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 128a8 8 0 0 1-8 8H48a8 8 0 0 1 0-16h72a8 8 0 0 1 8 8M48 72h136a8 8 0 0 0 0-16H48a8 8 0 0 0 0 16m56 112H48a8 8 0 0 0 0 16h56a8 8 0 0 0 0-16m125.66-21.66a8 8 0 0 0-11.32 0L192 188.69V112a8 8 0 0 0-16 0v76.69l-26.34-26.35a8 8 0 0 0-11.32 11.32l40 40a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0 0-11.32"},null,-1)])])}const kge=Oe({name:"ph-sort-ascending",render:_ge}),Sge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Age(t,e){return w(),R("svg",Sge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M230.6 49.53A15.81 15.81 0 0 0 216 40H40a16 16 0 0 0-11.81 26.76l.08.09L96 139.17V216a16 16 0 0 0 24.87 13.32l32-21.34a16 16 0 0 0 7.13-13.32v-55.49l67.74-72.32l.08-.09a15.8 15.8 0 0 0 2.78-17.23m-84.42 81.05A8 8 0 0 0 144 136v58.66L112 216v-80a8 8 0 0 0-2.16-5.47L40 56h176Z"},null,-1)])])}const Cge=Oe({name:"ph-funnel",render:Age}),$ge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Tge(t,e){return w(),R("svg",$ge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 48v48a8 8 0 0 1-8 8h-48a8 8 0 0 1 0-16h28.69l-14.63-14.63a79.56 79.56 0 0 0-56.13-23.43h-.45a79.52 79.52 0 0 0-55.89 22.77a8 8 0 0 1-11.18-11.44a96 96 0 0 1 135 .79L208 76.69V48a8 8 0 0 1 16 0m-37.59 135.29a80 80 0 0 1-112.47-.66L59.31 168H88a8 8 0 0 0 0-16H40a8 8 0 0 0-8 8v48a8 8 0 0 0 16 0v-28.69l14.63 14.63A95.43 95.43 0 0 0 130 222.06h.53a95.36 95.36 0 0 0 67.07-27.33a8 8 0 0 0-11.18-11.44Z"},null,-1)])])}const nB=Oe({name:"ph-arrows-clockwise",render:Tge}),Mge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Oge(t,e){return w(),R("svg",Mge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M226.76 69a8 8 0 0 0-12.84-2.88l-40.3 37.19l-17.23-3.7l-3.7-17.23l37.19-40.3A8 8 0 0 0 187 29.24A72 72 0 0 0 88 96a72.3 72.3 0 0 0 6 28.94L33.79 177c-.15.12-.29.26-.43.39a32 32 0 0 0 45.26 45.26c.13-.13.27-.28.39-.42L131.06 162A72 72 0 0 0 232 96a71.6 71.6 0 0 0-5.24-27M160 152a56.14 56.14 0 0 1-27.07-7a8 8 0 0 0-9.92 1.77l-55.9 64.74a16 16 0 0 1-22.62-22.62L109.18 133a8 8 0 0 0 1.77-9.93a56 56 0 0 1 58.36-82.31l-31.2 33.81a8 8 0 0 0-1.94 7.1l5.66 26.33a8 8 0 0 0 6.14 6.14l26.35 5.66a8 8 0 0 0 7.1-1.94l33.81-31.2A56.06 56.06 0 0 1 160 152"},null,-1)])])}const Bge=Oe({name:"ph-wrench",render:Oge}),Lge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Pge(t,e){return w(),R("svg",Lge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M230.91 172a8 8 0 0 1-2.91 10.91l-96 56a8 8 0 0 1-8.06 0l-96-56A8 8 0 0 1 36 169.09l92 53.65l92-53.65a8 8 0 0 1 10.91 2.91M220 121.09l-92 53.65l-92-53.65a8 8 0 0 0-8 13.82l96 56a8 8 0 0 0 8.06 0l96-56a8 8 0 1 0-8.06-13.82M24 80a8 8 0 0 1 4-6.91l96-56a8 8 0 0 1 8.06 0l96 56a8 8 0 0 1 0 13.82l-96 56a8 8 0 0 1-8.06 0l-96-56A8 8 0 0 1 24 80m23.88 0L128 126.74L208.12 80L128 33.26Z"},null,-1)])])}const Dge=Oe({name:"ph-stack",render:Pge}),Ege={[Je.Sort]:{iconClass:"step-card__body__icon--sort",iconComponent:kge,fallback:"S",label:"Sort"},[Je.Filter]:{iconClass:"step-card__body__icon--filter",iconComponent:Cge,fallback:"F",label:"Filter"},[Je.HideColumns]:{iconClass:"step-card__body__icon--hide-columns",iconComponent:cf,fallback:"H",label:"Hide Columns"},[Je.Transpose]:{iconClass:"step-card__body__icon--transpose",iconComponent:nB,fallback:"T",label:"Transpose"},[Je.Parse]:{iconClass:"step-card__body__icon--parse",iconComponent:Bge,fallback:"P",label:"Parse"},[Je.Rename]:{iconClass:"step-card__body__icon--rename",iconComponent:F2,fallback:"R",label:"Rename"},[Je.GroupBy]:{iconClass:"step-card__body__icon--group",iconComponent:Dge,fallback:"G",label:"Group By"},[Je.Computed]:{iconClass:"step-card__body__icon--computed",fallback:"C",label:"Computed"}},Nge={class:"step-card__number"},Ige={class:"step-card__body"},Rge={key:1},Fge={class:"step-card__body__text"},Vge={class:"step-card__body__text__name"},zge={class:"step-card__actions"},Hge=le({__name:"DataTransformStepCard",props:{step:{},index:{},active:{type:Boolean},error:{}},emits:["select","delete"],setup(t){const e=t,n=A(()=>Ege[e.step.type]),o=A(()=>n.value.iconClass),r=A(()=>n.value.iconComponent??null),i=A(()=>n.value.fallback),s=A(()=>n.value.label),a=A(()=>{const{step:l}=e;if(l.type===Je.Sort&&l.config.column)return`${l.config.column} ${l.config.direction??Zt.Ascending}`;if(l.type===Je.Filter&&l.config.column)return`${l.config.column} ${l.config.condition??go.Equals} ${l.config.value??""}`;if(l.type===Je.HideColumns){const c=l.config.columns?l.config.columns.split(",").map(u=>u.trim()).filter(Boolean):[];return c.length>0?`Hiding ${c.join(", ")}`:"Configure..."}if(l.type===Je.Transpose)return"Swap rows ↔ columns";if(l.type===Je.Parse&&l.config.column&&l.config.operation)return`${l.config.column} → ${l.config.operation}`;if(l.type===Je.Rename&&l.config.column&&l.config.newName)return`${l.config.column} → ${l.config.newName}`;if(l.type===Je.GroupBy&&l.config.groupColumns&&l.config.aggregates){const c=l.config.groupColumns.split(",").map(d=>d.trim()).filter(Boolean).join(", "),u=l.config.aggregates.split(",").map(d=>{const f=d.lastIndexOf(":");return f<0?d.trim():`${d.slice(f+1).trim()}(${d.slice(0,f).trim()})`}).join(", ");return`Group by ${c} — ${u}`}return"Configure..."});return(l,c)=>(w(),R("div",{class:Me(["step-card",{"step-card--active":t.active,"step-card--error":t.error}]),onClick:c[2]||(c[2]=u=>l.$emit("select"))},[M("div",Nge,ye(t.index+1),1),M("div",Ige,[M("span",{class:Me(["step-card__body__icon",p(o)])},[p(r)?(w(),J(Gt(p(r)),{key:0})):(w(),R("span",Rge,ye(p(i)),1))],2),M("div",Fge,[M("div",Vge,ye(p(s)),1),M("div",{class:Me(["step-card__body__text__desc",{"step-card__body__text__desc--error":t.error}])},ye(t.error||p(a)),3)])]),M("div",zge,[M("button",{class:"step-card__actions__btn","aria-label":"Remove step",onClick:c[0]||(c[0]=pn(u=>l.$emit("delete"),["stop"]))},[...c[3]||(c[3]=[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("path",{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]),t.active&&l.$slots.default?(w(),R("div",{key:0,class:"step-card__config",onClick:c[1]||(c[1]=pn(()=>{},["stop"]))},[Ce(l.$slots,"default",{},void 0,!0)])):ie("",!0)],2))}}),Wge=Be(Hge,[["__scopeId","data-v-4ba65e45"]]),Uge={class:"group-by-step"},Gge={class:"group-by-step__field"},qge={class:"group-by-step__field__columns"},Yge=["checked","onChange"],jge={key:0,class:"group-by-step__field"},Xge={class:"group-by-step__field__agg-list"},Kge={class:"group-by-step__field__agg-list__row"},Zge={class:"group-by-step__field__agg-list__row__check"},Qge=["checked"],Jge={class:"group-by-step__field__agg-list__row__check"},eve=["checked","onChange"],tve=["value","onChange"],nve=le({__name:"DataTransformStepGroupBy",props:{step:{},columns:{},columnTypes:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.groupColumns?e.step.config.groupColumns.split(",").map(b=>b.trim()).filter(Boolean):[]),r=A(()=>e.columns.filter(b=>!o.value.includes(b))),i=A(()=>e.step.config.aggregates?e.step.config.aggregates.split(",").map(b=>b.trim()).filter(Boolean).map(b=>{const m=b.lastIndexOf(":");return m<0?null:{col:b.slice(0,m),fn:b.slice(m+1)}}).filter(b=>b!==null):[]),s=A(()=>i.value.some(b=>b.fn==="count"));function a(b){return i.value.some(m=>m.col===b&&m.fn!=="count")}function l(b){const m=i.value.find(v=>v.col===b&&v.fn!=="count");return(m==null?void 0:m.fn)??"sum"}function c(b){return b.map(m=>`${m.col}:${m.fn}`).join(",")}function u(b,m){const v={...e.step.config};b.length>0?v.groupColumns=b.join(","):delete v.groupColumns,m.length>0?v.aggregates=c(m):delete v.aggregates,n(e.step.id,v)}function d(b){const m=[...o.value],v=m.indexOf(b);v>=0?m.splice(v,1):m.push(b);const y=i.value.filter(x=>x.fn==="count"||!m.includes(x.col));u(m,y)}function f(){const b=[...i.value],m=b.findIndex(v=>v.fn==="count");m>=0?b.splice(m,1):b.push({col:"rows",fn:"count"}),u(o.value,b)}function h(b){const m=[...i.value],v=m.findIndex(y=>y.col===b&&y.fn!=="count");v>=0?m.splice(v,1):m.push({col:b,fn:"sum"}),u(o.value,m)}function g(b,m){const v=i.value.map(y=>y.col===b&&y.fn!=="count"?{...y,fn:m}:y);u(o.value,v)}return(b,m)=>(w(),R("div",Uge,[M("div",Gge,[m[0]||(m[0]=M("label",{class:"group-by-step__field__label"},"Group by",-1)),M("div",qge,[(w(!0),R(He,null,ht(t.columns,v=>(w(),R("label",{key:v,class:"group-by-step__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(v),onChange:y=>d(v)},null,40,Yge),Ye(" "+ye(v),1)]))),128))])]),p(r).length>0||p(o).length>0?(w(),R("div",jge,[m[4]||(m[4]=M("label",{class:"group-by-step__field__label"},"Aggregates",-1)),M("div",Xge,[M("div",Kge,[M("label",Zge,[M("input",{type:"checkbox",checked:p(s),onChange:f},null,40,Qge),m[1]||(m[1]=Ye(" Row count ",-1))]),m[2]||(m[2]=M("span",{class:"group-by-step__field__agg-list__row__fn-label"},"count",-1))]),(w(!0),R(He,null,ht(p(r),v=>(w(),R("div",{key:v,class:"group-by-step__field__agg-list__row"},[M("label",Jge,[M("input",{type:"checkbox",checked:a(v),onChange:y=>h(v)},null,40,eve),Ye(" "+ye(v),1)]),a(v)?(w(),R("select",{key:0,class:"group-by-step__field__agg-list__row__fn",value:l(v),onChange:y=>g(v,y.target.value)},[...m[3]||(m[3]=[M("option",{value:"sum"}," Sum ",-1),M("option",{value:"avg"}," Average ",-1),M("option",{value:"min"}," Min ",-1),M("option",{value:"max"}," Max ",-1)])],40,tve)):ie("",!0)]))),128))])])):ie("",!0)]))}}),ove=Be(nve,[["__scopeId","data-v-c53de076"]]),rve={class:"data-transform-step-rename"},ive=le({__name:"DataTransformStepRename",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(i=>({value:i,label:i})));function r(i,s){n(e.step.id,{...e.step.config,[i]:s})}return(i,s)=>(w(),R("div",rve,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":s[0]||(s[0]=a=>r("column",a))},null,8,["model-value","options"]),H(p(wm),{id:"rename-new-name","model-value":t.step.config.newName??"",label:"New Name",placeholder:"Enter new column name","onUpdate:modelValue":s[1]||(s[1]=a=>r("newName",a))},null,8,["model-value"])]))}}),sve=Be(ive,[["__scopeId","data-v-5f4cb34e"]]),ave={class:"data-transform-step-parse"},lve=le({__name:"DataTransformStepParse",props:{step:{},columns:{}},setup(t){var b;const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(m=>({value:m,label:m}))),r=[{value:"type",label:"Type Conversions"},{value:"string",label:"String"},{value:"numeric",label:"Numeric"},{value:"date",label:"Date/Time"}],i=A(()=>op.find(m=>m.id===e.step.config.operation)),s=Ie(((b=i.value)==null?void 0:b.category)??"type");Ge(()=>e.step.config.operation,m=>{if(m){const v=op.find(y=>y.id===m);v&&(s.value=v.category)}});const a=A(()=>op.filter(m=>m.category===s.value).map(m=>({value:m.id,label:m.label,description:m.description}))),l=A(()=>{var m;return((m=i.value)==null?void 0:m.params)??[]}),c={decimals:"Decimal places",pattern:"Regex pattern",replacement:"Replacement",start:"Start index",end:"End index",length:"Length",char:"Pad character",separator:"Separator",limit:"Limit",min:"Minimum",max:"Maximum",size:"Bucket size",key:"JSON key",amount:"Amount",unit:"Unit",period:"Period",reference:"Reference date"},u={decimals:"0",pattern:"\\d+",replacement:"",start:"0",end:"",length:"10",char:" ",separator:",",limit:"",min:"0",max:"100",size:"10",key:"",amount:"1",unit:"days",period:"month",reference:"YYYY-MM-DD"};function d(m){return c[m]??m}function f(m){return u[m]??""}function h(m){s.value=m;const v={...e.step.config};delete v.operation,n(e.step.id,v)}function g(m,v){n(e.step.id,{...e.step.config,[m]:v})}return(m,v)=>(w(),R("div",ave,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":v[0]||(v[0]=y=>g("column",y))},null,8,["model-value","options"]),H(p(En),{"model-value":p(s),label:"Category",options:r,block:"","onUpdate:modelValue":h},null,8,["model-value"]),H(p(En),{"model-value":t.step.config.operation??"",label:"Operation",placeholder:"Select an operation",options:p(a),block:"","onUpdate:modelValue":v[1]||(v[1]=y=>g("operation",y))},null,8,["model-value","options"]),p(l).length>0?(w(!0),R(He,{key:0},ht(p(l),y=>(w(),J(p(wm),{id:`parse-${y}`,key:y,"model-value":t.step.config[y]??"",label:d(y),placeholder:f(y),"onUpdate:modelValue":x=>g(y,x)},null,8,["id","model-value","label","placeholder","onUpdate:modelValue"]))),128)):ie("",!0)]))}}),cve=Be(lve,[["__scopeId","data-v-37e3f025"]]),uve={class:"data-transform-step-hide-columns"},dve={class:"data-transform-step-hide-columns__field"},fve={class:"data-transform-step-hide-columns__field__columns"},hve=["checked","onChange"],pve=le({__name:"DataTransformStepHideColumns",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.columns?e.step.config.columns.split(",").map(i=>i.trim()).filter(Boolean):e.step.config.column?[e.step.config.column]:[]);function r(i){const s=[...o.value],a=s.indexOf(i);a>=0?s.splice(a,1):s.push(i);const l={...e.step.config};delete l.column,s.length===0?delete l.columns:l.columns=s.join(","),n(e.step.id,l)}return(i,s)=>(w(),R("div",uve,[M("div",dve,[s[0]||(s[0]=M("label",{class:"data-transform-step-hide-columns__field__label"},"Hide columns",-1)),M("div",fve,[(w(!0),R(He,null,ht(t.columns,a=>(w(),R("label",{key:a,class:"data-transform-step-hide-columns__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(a),onChange:l=>r(a)},null,40,hve),Ye(" "+ye(a),1)]))),128))])])]))}}),mve=Be(pve,[["__scopeId","data-v-a74ff0f2"]]),gve={class:"data-transform-step-filter"},vve=le({__name:"DataTransformStepFilter",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(s=>({value:s,label:s}))),r=[{value:go.Equals,label:"Equals"},{value:go.NotEquals,label:"Not equals"},{value:go.Contains,label:"Contains"},{value:go.GreaterThan,label:"Greater than"},{value:go.LessThan,label:"Less than"}];function i(s,a){n(e.step.id,{...e.step.config,[s]:a})}return(s,a)=>(w(),R("div",gve,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":a[0]||(a[0]=l=>i("column",l))},null,8,["model-value","options"]),H(p(En),{"model-value":t.step.config.condition??p(go).Equals,label:"Condition",options:r,block:"","onUpdate:modelValue":a[1]||(a[1]=l=>i("condition",l))},null,8,["model-value"]),H(p(wm),{id:"filter-value","model-value":t.step.config.value??"",label:"Value",placeholder:"Filter value","onUpdate:modelValue":a[2]||(a[2]=l=>i("value",l))},null,8,["model-value"])]))}}),bve=Be(vve,[["__scopeId","data-v-65704d71"]]),yve={class:"data-transform-step-sort"},xve={class:"data-transform-step-sort__field"},wve={class:"data-transform-step-sort__field__columns"},_ve=["checked","onChange"],kve=le({__name:"DataTransformStepSort",props:{step:{},columns:{},columnTypes:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.columns?e.step.config.columns.split(",").map(c=>c.trim()).filter(Boolean):e.step.config.column?[e.step.config.column]:[]),r=A(()=>o.value.every(c=>{const u=e.columns.indexOf(c);return u>=0&&e.columnTypes[u]==="number"}));function i(c){const u=[...o.value],d=u.indexOf(c);d>=0?u.splice(d,1):u.push(c);const f={...e.step.config};delete f.column,u.length===0?delete f.columns:f.columns=u.join(",");const h=u.every(g=>{const b=e.columns.indexOf(g);return b>=0&&e.columnTypes[b]==="number"});(u.length<=1||!h)&&delete f.operation,n(e.step.id,f)}const s=[{value:"",text:"None"},{value:"sum",text:"Sum"},{value:"avg",text:"Avg"}],a=[{value:Zt.Ascending,text:"Ascending"},{value:Zt.Descending,text:"Descending"}];function l(c,u){n(e.step.id,{...e.step.config,[c]:u})}return(c,u)=>(w(),R("div",yve,[M("div",xve,[u[2]||(u[2]=M("label",{class:"data-transform-step-sort__field__label"},"Sort by",-1)),M("div",wve,[(w(!0),R(He,null,ht(t.columns,d=>(w(),R("label",{key:d,class:"data-transform-step-sort__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(d),onChange:f=>i(d)},null,40,_ve),Ye(" "+ye(d),1)]))),128))])]),p(o).length>1&&p(r)?(w(),J(p(Cn),{key:0,"model-value":t.step.config.operation??"",label:"Operation",options:s,block:"","onUpdate:modelValue":u[0]||(u[0]=d=>l("operation",d))},null,8,["model-value"])):ie("",!0),H(p(Cn),{"model-value":t.step.config.direction??p(Zt).Ascending,label:"Direction",options:a,block:"","onUpdate:modelValue":u[1]||(u[1]=d=>l("direction",d))},null,8,["model-value"])]))}}),Sve=Be(kve,[["__scopeId","data-v-73ae8834"]]),Ave={},Cve={class:"pipeline-connector"};function $ve(t,e){return w(),R("div",Cve)}const Tve=Be(Ave,[["render",$ve],["__scopeId","data-v-a3406500"]]),Mve={class:"source-block"},Ove={class:"source-block__meta"},Bve=le({__name:"DataTransformSourceBlock",props:{columns:{},rows:{},label:{default:"Raw Data"}},setup(t){return(e,n)=>(w(),R("div",Mve,[n[0]||(n[0]=M("span",{class:"source-block__icon"},[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",width:"14",height:"14"},[M("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),M("path",{d:"M3 9h18M9 21V9"})])],-1)),M("span",null,ye(t.label),1),M("span",Ove,ye(t.columns)+" cols · "+ye(t.rows)+" rows",1)]))}}),Lve=Be(Bve,[["__scopeId","data-v-6b491dca"]]),Pve={class:"pipeline","data-testid":"transform-pipeline"},Dve={key:6,class:"pipeline__config-info"},Eve={key:7,class:"text-muted text-center py-3"},Nve=le({__name:"DataTransformPipeline",setup(t){const{columns:e,rows:n,columnTypes:o}=jo(),{steps:r,addStep:i,removeStep:s,applyTransforms:a,getColumnsAtStep:l,validateStep:c}=Lr(),{activeScene:u,activeIndex:d,scenes:f}=wn(),h=A(()=>{if(!u.value)return"Raw Data";if(d.value<=0)return"Data from Scene 1";const I=f.value[d.value-1];return`Data from ${(I==null?void 0:I.name)||`Scene ${d.value}`}`}),g=Ie(""),b=Ve(new Set),m=A(()=>r.value.findIndex(I=>I.id===g.value)),v=A(()=>m.value<0?{columns:[],columnTypes:[]}:l(m.value,e.value,n.value,o.value)),y=A(()=>v.value.columns),x=A(()=>v.value.columnTypes),_=A(()=>{const I={};for(let C=0;C<r.value.length;C++){const T=r.value[C];if(b.value.has(T.id)){I[T.id]=null;continue}const P=l(C,e.value,n.value,o.value);I[T.id]=c(T,P.columns,P.columnTypes)}return I}),k=A(()=>a(e.value,n.value,o.value)),E=A(()=>k.value.columns.length),B=A(()=>k.value.rows.length);function S(I){const C=g.value;C&&C!==I&&b.value.delete(C),g.value=I}function L(I){const C=i(I);b.value.add(C),S(C)}function D(I){b.value.delete(I),s(I),g.value===I&&(g.value=r.value.length>0?r.value[r.value.length-1].id:"")}return(I,C)=>{const T=Lve,P=Tve,$=Sve,F=bve,V=mve,U=cve,K=sve,se=ove,he=Wge,ce=xge,be=fge;return w(),R("div",Pve,[H(T,{columns:p(e).length,rows:p(n).length,label:p(h)},null,8,["columns","rows","label"]),(w(!0),R(He,null,ht(p(r),(oe,de)=>(w(),R(He,{key:oe.id},[H(P),H(he,{step:oe,index:de,active:p(g)===oe.id,error:p(_)[oe.id],onSelect:we=>S(oe.id),onDelete:we=>D(oe.id)},{default:te(()=>[oe.type===p(Je).Sort?(w(),J($,{key:0,step:oe,columns:p(y),"column-types":p(x)},null,8,["step","columns","column-types"])):oe.type===p(Je).Filter?(w(),J(F,{key:1,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).HideColumns?(w(),J(V,{key:2,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).Parse?(w(),J(U,{key:3,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).Rename?(w(),J(K,{key:4,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).GroupBy?(w(),J(se,{key:5,step:oe,columns:p(y),"column-types":p(x)},null,8,["step","columns","column-types"])):oe.type===p(Je).Transpose?(w(),R("div",Dve," Transpose swaps rows and columns. The first column values become headers and column headers become the first column. ")):(w(),R("div",Eve," Coming soon "))]),_:2},1032,["step","index","active","error","onSelect","onDelete"])],64))),128)),H(P),H(ce,{onAdd:L}),H(P),H(be,{columns:p(E),rows:p(B)},null,8,["columns","rows"])])}}}),Ive=Be(Nve,[["__scopeId","data-v-b653c7ed"]]),Rve=[0,.30103,.17609,.12494,.09691,.07918,.06695,.05799,.05115,.04576],oB=10,Fve=.1;function Vve(t){const e=parseFloat(t);if(!Number.isFinite(e)||e===0)return null;const o=Math.abs(e).toExponential(),r=parseInt(o[0],10);return r>=1&&r<=9?r:null}function zve(t,e,n){if(t==="number")return!0;let o=0;for(const r of e){const i=r[n];if(i!=null&&i!==""){const s=parseFloat(i);Number.isFinite(s)&&o++}}return o>=oB}function rB(t,e,n){const o=[];let r=!1;for(let i=0;i<t.length;i++){if(!zve(n[i],e,i))continue;const s=new Array(10).fill(0);let a=0;for(const c of e){const u=Vve(c[i]);u!==null&&(s[u]++,a++)}if(a<oB)continue;r=!0;let l=!1;for(let c=1;c<=9;c++){const u=s[c]/a;if(Math.abs(u-Rve[c])>Fve){l=!0;break}}l&&o.push(t[i])}return{pass:o.length===0,suspicious:o,eligible:r}}const Hve={class:"data-column-settings"},Wve={class:"data-column-settings__field"},Uve={class:"data-column-settings__section"},Gve={class:"data-column-settings__section__detections"},qve={class:"data-column-settings__section__detections__item data-column-settings__section__detections__item--success"},Yve={class:"data-column-settings__section__detections__item data-column-settings__section__detections__item--info"},jve={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},Xve={key:0,d:"M20 6L9 17l-5-5"},Kve={key:1,d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},Zve={key:1,class:"data-column-settings__picker"},Qve=le({__name:"DataColumnSettings",setup(t){const e=cr(),{selectedColumnIndex:n}=Ct(e),{selectColumn:o}=e,{columns:r,rows:i,columnTypes:s,setColumnType:a}=jo(),l=Ie("string"),c=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"date",label:"Date"}];Ge(n,v=>{v>=0&&v<r.value.length&&(l.value=s.value[v]??"string")},{immediate:!0});function u(v){a(n.value,v)}const d=A(()=>r.value.map((v,y)=>({value:String(y),label:v})));function f(v){o(parseInt(v,10))}const h=A(()=>{const v=n.value;if(v<0)return{unique:0,total:0};const y=i.value.map(_=>_[v]??"").filter(_=>_.length>0);return{unique:new Set(y).size,total:y.length}}),g=A(()=>{const{unique:v,total:y}=h.value;return v===y?`${v} unique values — no duplicates`:`${y-v} duplicates found`}),b=A(()=>{const v=s.value[n.value];return v==="number"?"Numeric measure detected":v==="date"?"Date axis detected":"Categorical dimension detected"}),m=A(()=>{const v=n.value;if(v<0)return null;const y=r.value[v],x=rB([y],i.value.map(_=>[_[v]]),[s.value[v]]);return x.eligible?{pass:x.pass,label:x.pass?"Follows Benford's law":"Doesn't follow Benford's law"}:null});return(v,y)=>(w(),R("div",Hve,[p(n)>=0&&p(n)<p(r).length?(w(),R(He,{key:0},[M("div",Wve,[y[1]||(y[1]=M("div",{class:"data-column-settings__field__label"}," Type ",-1)),H(p(En),{modelValue:p(l),"onUpdate:modelValue":[y[0]||(y[0]=x=>Ze(l)?l.value=x:null),u],label:"",options:c,block:""},null,8,["modelValue"])]),y[5]||(y[5]=M("hr",{class:"data-column-settings__divider"},null,-1)),M("div",Uve,[y[4]||(y[4]=M("div",{class:"data-column-settings__section__title"}," Detections ",-1)),M("div",Gve,[M("span",qve,[y[2]||(y[2]=M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("path",{d:"M20 6L9 17l-5-5"})],-1)),Ye(" "+ye(p(g)),1)]),M("span",Yve,[y[3]||(y[3]=M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("circle",{cx:"12",cy:"12",r:"10"}),M("path",{d:"M12 16v-4M12 8h.01"})],-1)),Ye(" "+ye(p(b)),1)]),p(m)?(w(),R("span",{key:0,class:Me(["data-column-settings__section__detections__item",p(m).pass?"data-column-settings__section__detections__item--success":"data-column-settings__section__detections__item--warn"])},[(w(),R("svg",jve,[p(m).pass?(w(),R("path",Xve)):(w(),R("path",Kve))])),Ye(" "+ye(p(m).label),1)],2)):ie("",!0)])])],64)):(w(),R("div",Zve,[y[6]||(y[6]=M("div",{class:"data-column-settings__picker__label"}," Column ",-1)),H(p(En),{"model-value":"",label:"",options:p(d),block:"",placeholder:"Select a column…","onUpdate:modelValue":f},null,8,["options"])]))]))}}),Jve=Be(Qve,[["__scopeId","data-v-fadb97cc"]]),e1e={key:0,class:"data-check-empty"},t1e={key:1,class:"data-check-table"},n1e={class:"data-check-table__col-header__name"},o1e={class:"data-check-table__col-header__type"},r1e=le({__name:"DataCheckTable",setup(t){const e=cr(),{selectedColumnIndex:n}=Ct(e),{selectColumn:o}=e,{displayColumns:r,displayRows:i,displayColumnTypes:s}=jo(),a=A(()=>i.value.length===0);return(l,c)=>p(a)?(w(),R("div",e1e,[H(p(Fy),{class:"data-check-empty__icon"}),c[0]||(c[0]=M("p",null,"No rows match your filters",-1))])):(w(),R("div",t1e,[H(p(YE),{hover:"",bordered:""},{default:te(()=>[H(p(JE),null,{default:te(()=>[H(p(l_),null,{default:te(()=>[H(p(a_),{class:"data-check-table__row-num"},{default:te(()=>[...c[1]||(c[1]=[Ye(" # ",-1)])]),_:1}),(w(!0),R(He,null,ht(p(r),(u,d)=>(w(),J(p(a_),{key:d,class:Me(["data-check-table__col-header",{"data-check-table__col--selected":d===p(n)}]),onClick:f=>p(o)(d)},{default:te(()=>[M("div",n1e,ye(u),1),M("div",o1e,ye(p(s)[d]??"string"),1)]),_:2},1032,["class","onClick"]))),128))]),_:1})]),_:1}),H(p(jE),null,{default:te(()=>[(w(!0),R(He,null,ht(p(i),(u,d)=>(w(),J(p(l_),{key:d},{default:te(()=>[H(p(s_),{class:"data-check-table__row-num"},{default:te(()=>[Ye(ye(d+1),1)]),_:2},1024),(w(!0),R(He,null,ht(u,(f,h)=>(w(),J(p(s_),{key:h,class:Me({"data-check-table__col--selected":h===p(n),"data-check-table__cell--numeric":p(s)[h]==="number"})},{default:te(()=>[Ye(ye(f),1)]),_:2},1032,["class"]))),128))]),_:2},1024))),128))]),_:1})]),_:1})]))}}),i1e=Be(r1e,[["__scopeId","data-v-670500db"]]),s1e={class:"data-insight-badges"},a1e={class:"data-insight-badge data-insight-badge--shape"},l1e={class:"data-insight-badge__icon"},c1e={class:"data-insight-badge__icon"},u1e=le({__name:"DataInsightBadges",props:{columns:{},rows:{},columnTypes:{}},setup(t){const e=t,n=ft("benfordBadgeRef"),o=A(()=>{let d=0;for(const f of e.rows)for(let h=0;h<e.columns.length;h++){const g=f[h];(g==null||g==="")&&d++}return d}),r=A(()=>o.value===0?"✓":"⚠"),i=A(()=>o.value===0?"No missing values":`${o.value} missing value${o.value===1?"":"s"}`),s=A(()=>o.value===0?"data-insight-badge--quality-ok":"data-insight-badge--quality-warn"),a=A(()=>{const d=rB(e.columns,e.rows,e.columnTypes);return d.eligible?d:null}),l=A(()=>{var d;return(d=a.value)!=null&&d.pass?"✓":"⚠"}),c=A(()=>{var d;return(d=a.value)!=null&&d.pass?"data-insight-badge--benford-ok":"data-insight-badge--benford-warn"}),u=A(()=>a.value?a.value.pass?"All numeric columns follow Benford's Law — the expected distribution of leading digits in real-world data.":`Column(s) ${a.value.suspicious.join(", ")} don't follow Benford's Law — the expected distribution of leading digits. This may indicate fabricated or anomalous data.`:"");return(d,f)=>(w(),R("div",s1e,[M("span",a1e,ye(t.columns.length)+" cols · "+ye(t.rows.length)+" rows ",1),M("span",{class:Me(["data-insight-badge",p(s)])},[M("span",l1e,ye(p(r)),1),Ye(" "+ye(p(i)),1)],2),p(a)?(w(),R("span",{key:0,ref_key:"benfordBadgeRef",ref:n,class:Me(["data-insight-badge",p(c)])},[M("span",c1e,ye(p(l)),1),f[0]||(f[0]=Ye(" Benford's law ",-1)),H(p(Ud),{"teleport-to":"body",target:p(n),title:p(u),placement:"top"},null,8,["target","title"])],2)):ie("",!0)]))}}),d1e=Be(u1e,[["__scopeId","data-v-d0fa5a33"]]),f1e={class:"data-structure-panel__main__pills-bar"},h1e={key:0,class:"data-structure-panel__main__scene-banner"},p1e=le({__name:"DataStructurePanel",setup(t){const{columns:e,rows:n,columnTypes:o}=jo(),r=cr(),{dataPanelOpen:i,dataPanelTab:s}=Ct(r),{openDataPanel:a,closeDataPanel:l,setDataView:c,setLastNarrowDataTab:u}=r,{mode:d}=rc(),{activeScene:f,activeIndex:h,scenes:g}=wn(),b=A(()=>f.value!==null);Ge(d,P=>{P==="drawer"&&s.value&&(u(s.value),l())},{immediate:!0});const m=A(()=>tT(g.value,h.value)),v=A(()=>{const P=m.value;if(P===h.value)return"Custom data on this scene.";if(P>=0){const $=g.value[P];return`Data inherited from ${($==null?void 0:$.name)||`Scene ${P+1}`}.`}return"Scene override active."}),y=A(()=>{const P=m.value;return P===h.value?"This scene uses its own data, independent of the base dataset.":P>=0?"Replace data to set different data for this scene.":"The table below shows the base data. Replace data to set custom data for this scene."});function x(){c("upload")}function _(P){u(P),a(P)}const{isNarrow:k}=Ji(),E=ft("mainRef"),{sections:B}=eB(),S=A(()=>b.value?["parsing"]:[]),L=A(()=>b.value?B.filter(P=>P.key!=="parsing"):B),D=A({get:()=>!!s.value,set:P=>{P||l()}}),I={column:"Column Settings",transforms:"Transforms",parsing:"Parsing",reco:"Recommendations"},C=A(()=>I[s.value]??"Panel"),T=A(()=>({"data-structure-panel--narrow":k.value}));return(P,$)=>{const F=d1e,V=i1e,U=W2,K=Jve,se=Ive,he=lge,ce=nge,be=H2,oe=ug,de=Wme;return w(),R("div",{class:Me(["data-structure-panel",p(T)])},[M("div",{ref_key:"mainRef",ref:E,class:"data-structure-panel__main"},[M("div",f1e,[p(b)?(w(),R("div",h1e,[M("strong",null,ye(p(v)),1),Ye(" "+ye(p(y)),1)])):(w(),J(F,{key:1,columns:p(e),rows:p(n),"column-types":p(o)},null,8,["columns","rows","column-types"])),H(p(Kn),{"icon-left":p(nB),label:"Replace data",variant:"outline-primary",size:"sm",onClick:x},null,8,["icon-left"])]),H(V)],512),p(i)?(w(),J(oe,{key:0,"drawer-open":p(D),"onUpdate:drawerOpen":$[0]||($[0]=we=>Ze(D)?D.value=we:null),title:p(C),"container-ref":p(E),onClose:p(l)},bi({default:te(()=>[p(s)==="column"?(w(),J(K,{key:0})):p(s)==="transforms"?(w(),J(se,{key:1})):p(s)==="parsing"?(w(),J(he,{key:2})):p(s)==="reco"?(w(),J(ce,{key:3})):ie("",!0)]),_:2},[p(d)==="drawer"?{name:"tabs",fn:te(()=>[H(U,{tabs:p(L),"model-value":p(s),sticky:"","onUpdate:modelValue":_},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(d)!=="drawer"?{name:"footer",fn:te(()=>[H(be)]),key:"1"}:void 0]),1032,["drawer-open","title","container-ref","onClose"])):ie("",!0),p(k)?ie("",!0):(w(),J(de,{key:1,"disabled-tabs":p(S)},null,8,["disabled-tabs"]))],2)}}}),m1e=Be(p1e,[["__scopeId","data-v-f811e1e6"]]),g1e={class:"samples-grid"},v1e=["onClick","onKeydown"],b1e={class:"sample-card__thumb"},y1e=["src","alt"],x1e={class:"sample-card__info"},w1e={class:"sample-card__info__name"},_1e={class:"sample-card__info__meta"},k1e=le({__name:"DataUploadSamples",emits:["select"],setup(t){const e={[Le.BarVertical]:"Columns",[Le.BarHorizontal]:"Bars",[Le.BarMulti]:"Grouped Columns",[Le.Line]:"Line",[Le.LineMulti]:"Lines",[Le.Donut]:"Donut",[Le.Pie]:"Pie",[Le.Area]:"Area",[Le.AreaStacked]:"Stacked Area",[Le.ColumnStacked]:"Stacked Columns",[Le.BarStacked]:"Stacked Bars",[Le.BarSplit]:"Split Bars",[Le.BarGrouped]:"Grouped Bars"};function n(i){const s=i.split(`
|
|
859
|
-
`).filter(a=>a.trim().length>0);return Math.max(0,s.length-1)}const o=ir(new Map),r=A(()=>O6.map(i=>({...i,typeLabel:e[i.chartType]??i.chartType,rowCount:n(i.tsvData),thumbSrc:o.get(i.id)})));return un(()=>{for(const i of O6)if(i.dsl){const s=hT(i.dsl);s&&o.set(i.id,Sc(s))}}),(i,s)=>(w(),R("div",g1e,[(w(!0),R(He,null,ht(p(r),a=>(w(),R("div",{key:a.id,class:"sample-card",role:"button",tabindex:"0",onClick:l=>i.$emit("select",a),onKeydown:er(l=>i.$emit("select",a),["enter"])},[M("div",b1e,[a.thumbSrc?(w(),R("img",{key:0,class:"sample-card__thumb__img",src:a.thumbSrc,alt:a.title},null,8,y1e)):ie("",!0)]),M("div",x1e,[M("div",w1e,ye(a.title),1),M("div",_1e,[Ye(ye(a.typeLabel)+" ",1),s[0]||(s[0]=M("span",{class:"sample-card__info__meta__sep"},"·",-1)),Ye(" "+ye(a.rowCount)+" rows ",1)])])],40,v1e))),128))]))}}),S1e=Be(k1e,[["__scopeId","data-v-23920b61"]]),A1e=le({__name:"DataUploadFileDrop",emits:["loaded","bpc","dragState"],setup(t,{emit:e}){const n=e,o=Ve(null),r=Ie(!1);function i(f){r.value=f,n("dragState",f)}function s(){i(!0)}function a(){i(!1)}function l(f){return f.name.toLowerCase().endsWith(".bpc")}function c(f){const h=new globalThis.FileReader;h.onload=()=>{typeof h.result=="string"&&n(l(f)?"bpc":"loaded",h.result,f.name)},h.readAsText(f)}function u(f){var g;i(!1);const h=(g=f.dataTransfer)==null?void 0:g.files[0];h&&c(h)}function d(f){var b;const h=f.target,g=(b=h.files)==null?void 0:b[0];g&&c(g),h.value=""}return(f,h)=>(w(),R("div",{class:Me(["file-drop",{"file-drop--active":p(r)}]),onDragover:pn(s,["prevent"]),onDragleave:pn(a,["prevent"]),onDrop:pn(u,["prevent"]),onClick:h[1]||(h[1]=g=>{var b;return(b=p(o))==null?void 0:b.click()})},[h[2]||(h[2]=EL('<div class="file-drop__icon" data-v-f6ebbbc1><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" data-v-f6ebbbc1><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12" data-v-f6ebbbc1></path></svg></div><div class="file-drop__title" data-v-f6ebbbc1> Drag & drop your file here </div><div class="file-drop__or" data-v-f6ebbbc1> or </div>',3)),M("button",{class:"file-drop__btn",onClick:h[0]||(h[0]=pn(g=>{var b;return(b=p(o))==null?void 0:b.click()},["stop"]))}," Browse files "),h[3]||(h[3]=M("div",{class:"file-drop__formats"},[M("span",{class:"file-drop__formats__tag"},".csv"),M("span",{class:"file-drop__formats__tag"},".tsv"),M("span",{class:"file-drop__formats__tag"},".bpc")],-1)),M("input",{ref_key:"fileInput",ref:o,type:"file",accept:".csv,.tsv,.txt,.bpc",class:"file-drop__input",onChange:d},null,544)],34))}}),C1e=Be(A1e,[["__scopeId","data-v-f6ebbbc1"]]),$1e={class:"upload-card"},T1e={class:"input-card__tabs"},M1e=["onClick"],O1e={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},B1e={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},L1e={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},P1e={key:1,class:"upload-card__paste"},D1e={class:"upload-card__paste__wrap"},E1e={key:0,class:"upload-card__paste__wrap__placeholder"},N1e={class:"upload-card__paste__footer"},I1e=["disabled"],R1e=le({__name:"DataUploadCard",emits:["loaded","bpc","sample","cancel"],setup(t){const{rawInput:e,sourceFormat:n,columns:o,rows:r,displayColumns:i,displayRows:s}=jo(),{activeIndex:a,scenes:l}=wn();function c(){if(a.value<0)return!1;const v=Ra(l.value,a.value);return!!(v!=null&&v.data)}function u(){return c()?R6(i.value,s.value):(n==null?void 0:n.value)==="bpc"&&o.value.length>0?R6(o.value,r.value):e.value}const d=Ie("paste"),f=Ie(u()),h=ft("pasteArea"),g=Ie(!1);function b(v){var x;const y=(x=v.clipboardData)==null?void 0:x.getData("text/plain");y&&(v.preventDefault(),f.value=y,xn(()=>{h.value&&h.value.focus()}))}const m=[{value:"file",text:"File"},{value:"paste",text:"Paste"},{value:"samples",text:"Samples"}];return(v,y)=>{const x=C1e,_=S1e;return w(),R("div",$1e,[y[12]||(y[12]=M("h2",{class:"upload-card__title"}," Add your data ",-1)),y[13]||(y[13]=M("p",{class:"upload-card__subtitle"}," Drop a file, paste from a spreadsheet, or pick a sample dataset ",-1)),p(o).length>0?(w(),R("button",{key:0,class:"upload-card__back",onClick:y[0]||(y[0]=k=>v.$emit("cancel"))}," ← Back to table ")):ie("",!0),M("div",{class:Me(["input-card",{"input-card--drag-over":p(g)}])},[M("div",T1e,[(w(),R(He,null,ht(m,k=>M("button",{key:k.value,class:Me(["input-card__tabs__tab",{"input-card__tabs__tab--active":p(d)===k.value}]),onClick:E=>d.value=k.value},[k.value==="file"?(w(),R("svg",O1e,[...y[7]||(y[7]=[M("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"},null,-1)])])):k.value==="paste"?(w(),R("svg",B1e,[...y[8]||(y[8]=[M("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"},null,-1),M("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"},null,-1)])])):(w(),R("svg",L1e,[...y[9]||(y[9]=[M("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"},null,-1),M("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"},null,-1)])])),Ye(" "+ye(k.text),1)],10,M1e)),64))]),p(d)==="file"?(w(),J(x,{key:0,onLoaded:y[1]||(y[1]=(k,E)=>v.$emit("loaded",k,E)),onBpc:y[2]||(y[2]=(k,E)=>v.$emit("bpc",k,E)),onDragState:y[3]||(y[3]=k=>g.value=k)})):p(d)==="paste"?(w(),R("div",P1e,[M("div",D1e,[p(f)?ie("",!0):(w(),R("div",E1e,[...y[10]||(y[10]=[Ye(" category Gold Silver Bronze",-1),M("br",null,null,-1),Ye(" USA 40 44 42",-1),M("br",null,null,-1),Ye(" China 38 32 19 ",-1)])])),rr(M("textarea",{ref_key:"pasteArea",ref:h,"onUpdate:modelValue":y[4]||(y[4]=k=>Ze(f)?f.value=k:null),class:"upload-card__paste__wrap__area",spellcheck:"false",onPaste:b},null,544),[[_p,p(f)]])]),M("div",N1e,[y[11]||(y[11]=M("div",{class:"upload-card__paste__footer__hint"},[M("span",{class:"upload-card__paste__footer__hint__kbd"},"⌘"),M("span",{class:"upload-card__paste__footer__hint__kbd"},"V"),Ye(" paste from spreadsheet ")],-1)),M("button",{class:"upload-card__paste__footer__btn",disabled:!p(f).trim(),onClick:y[5]||(y[5]=k=>v.$emit("loaded",p(f),"Pasted"))}," Load data ",8,I1e)])])):p(d)==="samples"?(w(),J(_,{key:2,onSelect:y[6]||(y[6]=k=>v.$emit("sample",k))})):ie("",!0)],2)])}}}),F1e=Be(R1e,[["__scopeId","data-v-b501779f"]]),V1e=le({__name:"DataPanel",setup(t){const e=cr(),{dataView:n}=Ct(e),{setDataView:o}=e,r=jo(),{applyDsl:i}=Ic(),{loadSample:s}=js(),{next:a}=z2(),l=Ct(tB()),{activeScene:c,activeIndex:u,update:d}=wn(),f=A(()=>c.value!==null);un(()=>{r.columns.value.length>0?o("structure"):o("upload")});function h(){if(!r.rawInput.value||r.sourceFormat.value!=="delimited")return;const v=J1(r.rawInput.value,{firstRowIsHeader:l.firstRowIsHeader.value,delimiter:l.delimiter.value,decimalSeparator:l.decimalSeparator.value,trimWhitespace:l.trimWhitespace.value});r.loadParsed(v)}function g(v,y){if(f.value&&u.value>=0){const x=J1(v,{firstRowIsHeader:l.firstRowIsHeader.value,delimiter:l.delimiter.value,decimalSeparator:l.decimalSeparator.value,trimWhitespace:l.trimWhitespace.value}),_=cg(x.columns,x.rows);d(u.value,{data:_}),o("structure");return}r.rawInput.value=v,r.sourceFormat.value="delimited",r.sourceLabel.value=y||"Pasted",h(),o("structure")}function b(v,y){i(v),r.sourceLabel.value=y||"Blueprint file",a()}function m(v){if(f.value&&u.value>=0){d(u.value,{data:v.serializedData}),o("structure");return}s(v),a()}return Ge([()=>l.firstRowIsHeader.value,()=>l.delimiter.value,()=>l.decimalSeparator.value,()=>l.trimWhitespace.value],()=>{r.rawInput.value&&n.value==="structure"&&h()}),(v,y)=>{const x=F1e,_=m1e;return w(),R("div",{class:Me(["data-panel",{"data-panel--structure":p(n)==="structure"}])},[p(n)==="upload"?(w(),J(x,{key:0,onLoaded:g,onBpc:b,onSample:m,onCancel:y[0]||(y[0]=k=>p(o)("structure"))})):(w(),J(_,{key:1}))],2)}}}),z1e=Be(V1e,[["__scopeId","data-v-4fa651c7"]]),H1e=["aria-label","aria-disabled","disabled"],W1e={class:"panel-open-button__label"},U1e=le({__name:"PanelOpenButton",props:{label:{},icon:{default:()=>CT},disabled:{type:Boolean,default:!1}},emits:["open"],setup(t,{emit:e}){const n=e;function o(){n("open")}return(r,i)=>(w(),R("button",{class:"panel-open-button",type:"button","aria-label":t.label,"aria-disabled":t.disabled?"true":void 0,disabled:t.disabled,onClick:o},[(w(),J(Gt(t.icon),{class:"panel-open-button__icon","aria-hidden":"true"})),M("span",W1e,ye(t.label),1)],8,H1e))}}),G1e=Be(U1e,[["__scopeId","data-v-218f5209"]]),q1e={class:"layout-narrow-dock",role:"toolbar","aria-label":"Wizard controls"},Y1e={class:"layout-narrow-dock__timeline"},j1e={class:"layout-narrow-dock__action"},X1e=le({__name:"LayoutNarrowDock",props:{showTimeline:{type:Boolean},scenes:{},activeIndex:{},playing:{type:Boolean},panelLabel:{},panelIcon:{default:void 0},panelDisabled:{type:Boolean,default:!1},scenesSheetOpen:{type:Boolean,default:!1}},emits:["update:activeIndex","play","pause","expand-timeline","open-panel"],setup(t,{emit:e}){const n=e;function o(r){n("update:activeIndex",r)}return(r,i)=>(w(),R("div",q1e,[M("div",Y1e,[t.showTimeline?(w(),J(p(FG),{key:0,scenes:t.scenes,"active-index":t.activeIndex,playing:t.playing,expanded:t.scenesSheetOpen,"onUpdate:activeIndex":o,onPlay:i[0]||(i[0]=s=>n("play")),onPause:i[1]||(i[1]=s=>n("pause")),onExpand:i[2]||(i[2]=s=>n("expand-timeline"))},null,8,["scenes","active-index","playing","expanded"])):ie("",!0)]),M("div",j1e,[H(G1e,{label:t.panelLabel,icon:t.panelIcon,disabled:t.panelDisabled,onOpen:i[3]||(i[3]=s=>n("open-panel"))},null,8,["label","icon","disabled"])])]))}}),K1e=Be(X1e,[["__scopeId","data-v-cc656101"]]),Z1e={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Q1e(t,e){return w(),R("svg",Z1e,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 48H32a8 8 0 0 0-8 8v136a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a8 8 0 0 0-8-8M40 112h40v32H40Zm56 0h120v32H96Zm120-48v32H40V64ZM40 160h40v32H40Zm176 32H96v-32h120z"},null,-1)])])}const uS=Oe({name:"ph-table",render:Q1e}),J1e={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function ebe(t,e){return w(),R("svg",J1e,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 112v96a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16v-96a16 16 0 0 1 16-16h24a8 8 0 0 1 0 16H56v96h144v-96h-24a8 8 0 0 1 0-16h24a16 16 0 0 1 16 16M93.66 69.66L120 43.31V136a8 8 0 0 0 16 0V43.31l26.34 26.35a8 8 0 0 0 11.32-11.32l-40-40a8 8 0 0 0-11.32 0l-40 40a8 8 0 0 0 11.32 11.32"},null,-1)])])}const dS=Oe({name:"ph-export",render:ebe}),tbe={class:"layout-scene-timeline"},nbe=le({__name:"LayoutSceneTimeline",setup(t){return(e,n)=>(w(),R("div",tbe,[Ce(e.$slots,"default",{},void 0,!0)]))}}),obe=Be(nbe,[["__scopeId","data-v-0ba61bc0"]]),rbe={class:"wizard-shell"},ibe=["title","aria-label"],sbe={class:"wizard-shell__main"},abe={class:"wizard-shell__content"},lbe=le({__name:"WizardShell",setup(t){const{currentStep:e,currentIndex:n,steps:o,registerCreateSession:r}=z2(),i=jo(),s=dn(),{sessionId:a,createSession:l,lastSavedAt:c}=js(),u=wn(),{scenes:d,activeIndex:f,activeScene:h,playing:g,startPlayback:b,stopPlayback:m}=u,v=A(()=>h.value!==null),{baseOptions:y}=_n(),x=Lr(),_=Ve([]),k=A(()=>c.value?new Date(c.value):""),E=UI(k),B=A(()=>k.value?`saved ${E.value}`:null),{isNarrow:S}=Ji("lg"),{isNarrow:L}=Ji("md"),{isNarrow:D}=Ji(),I=cr(),C=dg(),T=Ve(!1),P=A(()=>{switch(e.value.key){case"data":return"Data panel";case"edit":return"Edit panel";case"export":return"Export panel";default:return"Open panel"}}),$=A(()=>{switch(e.value.key){case"data":return uS;case"edit":return Ls;case"export":return dS;default:return Ls}}),F=A(()=>e.value.key==="data"&&i.rows.value.length===0);function V(){if(!F.value)if(e.value.key==="data"){let q=I.lastNarrowDataTab.value;v.value&&q==="parsing"&&(q="column"),I.openDataPanel(q)}else e.value.key==="edit"?I.selectTab(I.lastNarrowEditTab.value):e.value.key==="export"&&C.setExportTab(C.lastNarrowExportTab.value)}function U(){T.value=!0}function K(q){G(q),T.value=!1}const se={data:uS,edit:Ls,export:dS},he=o.map(q=>({label:q.label,key:q.key,icon:se[q.key]})),ce=A(()=>i.rows.value.length>0?[]:[1,2]);function be(){u.add(),u.setActive(d.value.length-1)}const oe=Ve({}),de=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];function we(q){var j,X,Z;const ne=fs(q.dataStr);if((j=ne.series)!=null&&j.length&&de.includes(q.chartType)){const fe=ne.series.find(pe=>pe.name===s._base.selectedColumn.value);fe&&(ne.values=fe.values),delete ne.series}return R2(q.chartType,ne,q.typeOpts,q.sort,{colorizes:(X=q.colorizes)!=null&&X.length?q.colorizes:void 0,seriesOverrides:(Z=q.seriesOverrides)!=null&&Z.length?q.seriesOverrides:void 0})}function ee(q,ne){var j;if((q==null?void 0:q.data)!==void 0)return q.data;if((j=q==null?void 0:q.transforms)!=null&&j.length&&i.columns.value.length>0){const X=x.applyStepList(q.transforms,i.columns.value,i.rows.value,i.columnTypes.value);return cg(X.columns,X.rows)}return ne}function ge(){const q=s._base,ne={};ne[0]=we({chartType:q.chartType.value,dataStr:q.data.value,typeOpts:y.value,sort:q.sort.value,colorizes:q.colorizes.value,seriesOverrides:q.seriesOverrides.value});for(let j=0;j<d.value.length;j++){const X=Ra(d.value,j);ne[j+1]=we({chartType:(X==null?void 0:X.chartType)??q.chartType.value,dataStr:ee(X,q.data.value),typeOpts:X!=null&&X.chartTypeOptions?{...y.value,...X.chartTypeOptions}:y.value,sort:nT(X)??q.sort.value,colorizes:(X==null?void 0:X.colorizes)??q.colorizes.value,seriesOverrides:(X==null?void 0:X.seriesOverrides)??q.seriesOverrides.value})}oe.value=ne}const Q=TI(ge,300);Ge([()=>d.value,s._base.chartType,s._base.data,s._base.sort,s._base.colorizes,s._base.seriesOverrides,s._base.selectedColumn,y,e],()=>{e.value.key==="edit"&&Q()},{deep:!0});function re(q){var Z;const ne=s._base.title.value;if(q<0)return ne||" ";const j=Ra(d.value,q),X=(Z=j==null?void 0:j.properties)==null?void 0:Z.title;return X!==void 0?X||" ":ne||" "}const ve=A(()=>{const q={name:re(-1),index:0,removable:!1,thumbnail:oe.value[0]??null,hint:"base scene"},ne=d.value.map((j,X)=>{const Z=X+1,fe=tT(d.value,X);let pe;return fe===X?pe="custom data":fe<0?pe="inherits base":pe=`inherits ${re(fe)||`Scene ${fe+1}`}`,{name:re(X),index:Z,removable:!0,thumbnail:oe.value[Z]??null,hint:pe}});return[q,...ne]}),N=A(()=>f.value+1);function G(q){u.setActive(q-1)}function Y(q){q<=0||u.remove(q-1)}const ue=A(()=>{const q=e.value.key;return q==="export"?!1:q==="edit"?!0:d.value.length>=1});Ge(f,(q,ne)=>{var j,X;e.value.key==="data"&&(ne===-1&&q>=0?(_.value=x.snapshot(),x.hydrate(((j=d.value[q])==null?void 0:j.transforms)??[])):ne>=0&&q===-1?(u.update(ne,{transforms:x.snapshot()}),x.hydrate(_.value)):ne>=0&&q>=0&&(u.update(ne,{transforms:x.snapshot()}),x.hydrate(((X=d.value[q])==null?void 0:X.transforms)??[])))}),un(()=>{e.value.key==="edit"&&s._base.data.value&&ge()});function ae(){f.value>=0&&(u.update(f.value,{transforms:x.snapshot()}),x.hydrate(_.value),u.setActive(-1)),s._base.data.value=i.serialize();const q=s._base.chartType.value,ne=q.includes("multi")||q.includes("stacked")||q===Le.BarSplit||q===Le.BarGrouped;if(i.columns.value.length>2&&!ne){const j=i.columnTypes.value[0]==="date";s._base.chartType.value=j?Le.LineMulti:Le.BarMulti}}return r(()=>(ae(),l())),Ge(()=>e.value.key,(q,ne)=>{ne==="data"&&q==="edit"&&a.value&&ae()}),qN(()=>{$re()}),(q,ne)=>{const j=z1e,X=Pme,Z=rle;return w(),R("div",rbe,[H(ST,{class:"wizard-shell__header"},{start:te(()=>[H(AT),p(B)&&p(S)?(w(),R("span",{key:0,class:"wizard-shell__saved-dot",role:"status","aria-live":"polite",title:p(B),"aria-label":p(B)},null,8,ibe)):ie("",!0)]),center:te(()=>[H(p(eU),{"current-step":p(n),"onUpdate:currentStep":ne[0]||(ne[0]=fe=>Ze(n)?n.value=fe:null),steps:p(he),"disabled-steps":p(ce),layout:p(L)?"stacked":"inline"},null,8,["current-step","steps","disabled-steps","layout"])]),end:te(()=>[p(B)&&!p(S)?(w(),J(p(xy),{key:0,variant:"success",pill:"",class:"wizard-shell__saved",role:"status","aria-live":"polite"},{default:te(()=>[ne[2]||(ne[2]=M("span",{class:"wizard-shell__saved__dot"},null,-1)),Ye(" "+ye(p(B)),1)]),_:1})):ie("",!0)]),_:1}),M("div",sbe,[M("div",abe,[p(e).key==="data"?(w(),J(j,{key:0})):p(e).key==="edit"?(w(),J(X,{key:1})):p(e).key==="export"?(w(),J(Z,{key:2})):ie("",!0)]),p(D)?(w(),J(K1e,{key:0,"show-timeline":p(ue),scenes:p(ve),"active-index":p(N),playing:p(g),"panel-label":p(P),"panel-icon":p($),"panel-disabled":p(F),"scenes-sheet-open":p(T),"onUpdate:activeIndex":G,onPlay:p(b),onPause:p(m),onExpandTimeline:U,onOpenPanel:V},null,8,["show-timeline","scenes","active-index","playing","panel-label","panel-icon","panel-disabled","scenes-sheet-open","onPlay","onPause"])):p(ue)?(w(),J(obe,{key:1},{default:te(()=>[H(p(BG),{scenes:p(ve),"active-index":p(N),playing:p(g),"onUpdate:activeIndex":G,onAdd:be,onRemove:Y,onPlay:p(b),onPause:p(m)},null,8,["scenes","active-index","playing","onPlay","onPause"])]),_:1})):ie("",!0),p(D)?(w(),J(p(VA),{key:2,modelValue:p(T),"onUpdate:modelValue":ne[1]||(ne[1]=fe=>Ze(T)?T.value=fe:null),title:"Scenes"},{default:te(()=>[H(p(QG),{scenes:p(ve),"active-index":p(N),playing:p(g),"onUpdate:activeIndex":K,onAdd:be,onRemove:Y,onPlay:p(b),onPause:p(m)},null,8,["scenes","active-index","playing","onPlay","onPause"])]),_:1},8,["modelValue"])):ie("",!0)])])}}}),zh=Be(lbe,[["__scopeId","data-v-58139d04"]]),cbe={class:"render-page"},ube=le({__name:"RenderPage",setup(t){const e=Xl(),n=ft("containerRef"),{applyDsl:o}=Ic();G2(n);const{layout:r}=dn(),{cardClass:i,cardStyle:s}=U2(r,"render-page__card"),{scenes:a,activeIndex:l,playing:c,setActive:u,nextScene:d,previousScene:f,startPlayback:h,stopPlayback:g}=wn(),b={buttons:T1,"progress-bar":YA,"dot-stepper":jA,"minimal-arrows":XA},m=A(()=>b[r.value.playerType]||T1),v=A(()=>a.value.length+1),y=A(()=>l.value+2),x=A(()=>a.value.length>=1);function _(S){u(S-2)}const k=Ve(null);function E(){var S;return((S=n.value)==null?void 0:S.querySelector(".bc-frame-footer"))??null}let B=null;return Ge(n,S=>{if(B&&(B.disconnect(),B=null),!S){k.value=null;return}k.value=E(),B=new MutationObserver(()=>{k.value=E()}),B.observe(S,{childList:!0,subtree:!0})},{immediate:!0}),Gs(()=>{B&&(B.disconnect(),B=null)}),un(()=>{const S=e.query.bpc64;if(S)try{const L=globalThis.atob(S),D=Uint8Array.from(L,C=>C.charCodeAt(0)),I=new TextDecoder().decode(D);o(I)}catch{}}),(S,L)=>(w(),R("div",cbe,[M("div",{ref_key:"containerRef",ref:n,class:Me(["render-page__card",p(i)]),style:Et(p(s))},null,6),p(k)&&p(x)?(w(),J(ty,{key:0,to:p(k)},[(w(),J(Gt(p(m)),{total:p(v),current:p(y),playing:p(c),position:p(r).playerPosition,"onUpdate:current":_,onPrevious:p(f),onNext:p(d),onPlay:p(h),onPause:p(g)},null,40,["total","current","playing","position","onPrevious","onNext","onPlay","onPause"]))],8,["to"])):ie("",!0)]))}}),dbe=Be(ube,[["__scopeId","data-v-76a513dd"]]);function Xv(t){const{sessionId:e,loadChart:n,startAutoSave:o}=js();if(e.value===t.params.id)return;if(!n(t.params.id))return"/charts";o()}function fbe(t){if(!t)return null;try{const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),o=atob(e+n),r=new Uint8Array(o.length);for(let i=0;i<o.length;i++)r[i]=o.charCodeAt(i);return new TextDecoder().decode(r)}catch{return null}}const hbe=xI({history:QN(),scrollBehavior(t,e,n){return n||(t.hash?{el:t.hash,behavior:"smooth"}:{top:0})},routes:[{path:"/",component:()=>q6(()=>import("./LandingPage-CXRy2bAJ.js"),__vite__mapDeps([0,1]))},{path:"/charts",component:vse},{path:"/new",component:zh,beforeEnter:()=>{const{prepareNew:t}=js();t()}},{path:"/edit/:id",redirect:t=>`/edit/${t.params.id}/visualize`},{path:"/copy/:base64",component:()=>q6(()=>import("./CopyRedirect-BKbmd042.js"),[]),meta:{bare:!0},beforeEnter:t=>{const e=fbe(String(t.params.base64??""));if(!e)return"/";const{createFromDsl:n}=js(),o=n(e);if(!o)return"/";t.meta.copyTarget=`/edit/${o}/visualize`}},{path:"/edit/:id/data",component:zh,beforeEnter:Xv},{path:"/edit/:id/visualize",component:zh,beforeEnter:Xv},{path:"/edit/:id/export",component:zh,beforeEnter:Xv},{path:"/render",component:dbe,meta:{bare:!0}}]}),iB=SP();iB.use(DP);wP(lie).use(iB).use(hbe).use(fN()).mount("#app");export{ty as $,Sf as A,Kn as B,MI as C,X$ as D,ft as E,zt as F,O6 as G,xy as H,Rre as I,Py as J,He as K,ht as L,ye as M,lU as N,Oe as O,Me as P,fue as Q,ET as R,NT as S,Bge as T,F2 as U,nB as V,Ie as W,vbe as X,Gs as Y,kse as Z,Be as _,M as a,T1 as a0,Xl as a1,Ay as a2,ie as b,R as c,le as d,Ty as e,J as f,p as g,H as h,Ye as i,KA as j,A as k,nm as l,JA as m,QA as n,w as o,Rq as p,Eq as q,Ce as r,Lq as s,Ge as t,Cf as u,is as v,te as w,ag as x,Ve as y,Ze as z};
|
|
851
|
+
`){[e,n]=lu(this,e,n);let r="";for(let i=0,s=0;i<this.children.length&&s<=n;i++){let a=this.children[i],l=s+a.length;s>e&&i&&(r+=o),e<l&&n>s&&(r+=a.sliceString(e-s,n-s,o)),s=l+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ui))return 0;let o=0,[r,i,s,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,i+=n){if(r==s||i==a)return o;let l=this.children[r],c=e.children[i];if(l!=c)return o+l.scanIdentical(c,n);o+=l.length+1}}static from(e,n=e.reduce((o,r)=>o+r.length+1,-1)){let o=0;for(let h of e)o+=h.lines;if(o<32){let h=[];for(let g of e)g.flatten(h);return new An(h,n)}let r=Math.max(32,o>>5),i=r<<1,s=r>>1,a=[],l=0,c=-1,u=[];function d(h){let g;if(h.lines>i&&h instanceof Ui)for(let b of h.children)d(b);else h.lines>s&&(l>s||!l)?(f(),a.push(h)):h instanceof An&&l&&(g=u[u.length-1])instanceof An&&h.lines+g.lines<=32?(l+=h.lines,c+=h.length+1,u[u.length-1]=new An(g.text.concat(h.text),g.length+1+h.length)):(l+h.lines>r&&f(),l+=h.lines,c+=h.length+1,u.push(h))}function f(){l!=0&&(a.push(u.length==1?u[0]:Ui.from(u,c)),c=-1,l=u.length=0)}for(let h of e)d(h);return f(),a.length==1?a[0]:new Ui(a,n)}}Ut.empty=new An([""],0);function tfe(t){let e=-1;for(let n of t)e+=n.length+1;return e}function ip(t,e,n=0,o=1e9){for(let r=0,i=0,s=!0;i<t.length&&r<=o;i++){let a=t[i],l=r+a.length;l>=n&&(l>o&&(a=a.slice(0,o-r)),r<n&&(a=a.slice(n-r)),s?(e[e.length-1]+=a,s=!1):e.push(a)),r=l+1}return e}function tk(t,e,n){return ip(t,[""],e,n)}class Md{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof An?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let o=this.nodes.length-1,r=this.nodes[o],i=this.offsets[o],s=i>>1,a=r instanceof An?r.text.length:r.children.length;if(s==(n>0?a:0)){if(o==0)return this.done=!0,this.value="",this;n>0&&this.offsets[o-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(n>0?0:1)){if(this.offsets[o]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
852
|
+
`,this;e--}else if(r instanceof An){let l=r.text[s+(n<0?-1:0)];if(this.offsets[o]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[s+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[o]+=n):(n<0&&this.offsets[o]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof An?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class oM{constructor(e,n,o){this.value="",this.done=!1,this.cursor=new Md(e,n>o?-1:1),this.pos=n>o?e.length:0,this.from=Math.min(n,o),this.to=Math.max(n,o)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let o=n<0?this.pos-this.from:this.to-this.pos;e>o&&(e=o),o-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=o?r:n<0?r.slice(r.length-o):r.slice(0,o),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class rM{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:o,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):o?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this.iter()},Md.prototype[Symbol.iterator]=oM.prototype[Symbol.iterator]=rM.prototype[Symbol.iterator]=function(){return this});class nfe{constructor(e,n,o,r){this.from=e,this.to=n,this.number=o,this.text=r}get length(){return this.to-this.from}}function lu(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function To(t,e,n=!0,o=!0){return Jde(t,e,n,o)}function ofe(t){return t>=56320&&t<57344}function rfe(t){return t>=55296&&t<56320}function ife(t,e){let n=t.charCodeAt(e);if(!rfe(n)||e+1==t.length)return n;let o=t.charCodeAt(e+1);return ofe(o)?(n-55296<<10)+(o-56320)+65536:n}function sfe(t){return t<65536?1:2}const ab=/\r\n?|\n/;var br=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(br||(br={}));class os{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let o=this.sections[n+1];e+=o<0?this.sections[n]:o}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,o=0,r=0;n<this.sections.length;){let i=this.sections[n++],s=this.sections[n++];s<0?(e(o,r,i),r+=i):r+=s,o+=i}}iterChangedRanges(e,n=!1){lb(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let o=this.sections[n++],r=this.sections[n++];r<0?e.push(o,r):e.push(r,o)}return new os(e)}composeDesc(e){return this.empty?e:e.empty?this:iM(this,e)}mapDesc(e,n=!1){return e.empty?this:cb(this,e,n)}mapPos(e,n=-1,o=br.Simple){let r=0,i=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=r+a;if(l<0){if(c>e)return i+(e-r);i+=a}else{if(o!=br.Simple&&c>=e&&(o==br.TrackDel&&r<e&&c>e||o==br.TrackBefore&&r<e||o==br.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!a)return e==r||n<0?i:i+l;i+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,n=e){for(let o=0,r=0;o<this.sections.length&&r<=n;){let i=this.sections[o++],s=this.sections[o++],a=r+i;if(s>=0&&r<=n&&a>=e)return r<e&&a>n?"cover":!0;r=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let o=this.sections[n++],r=this.sections[n++];e+=(e?" ":"")+o+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new os(e)}static create(e){return new os(e)}}class zn extends os{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return lb(this,(n,o,r,i,s)=>e=e.replace(r,r+(o-n),s),!1),e}mapDesc(e,n=!1){return cb(this,e,n,!0)}invert(e){let n=this.sections.slice(),o=[];for(let r=0,i=0;r<n.length;r+=2){let s=n[r],a=n[r+1];if(a>=0){n[r]=a,n[r+1]=s;let l=r>>1;for(;o.length<l;)o.push(Ut.empty);o.push(s?e.slice(i,i+s):Ut.empty)}i+=s}return new zn(n,o)}compose(e){return this.empty?e:e.empty?this:iM(this,e,!0)}map(e,n=!1){return e.empty?this:cb(this,e,n,!0)}iterChanges(e,n=!1){lb(this,e,n)}get desc(){return os.create(this.sections)}filter(e){let n=[],o=[],r=[],i=new uf(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,l-a);vo(r,u,-1);let d=i.ins==-1?-1:i.off==0?i.ins:0;vo(n,u,d),d>0&&ka(o,n,i.text),i.forward(u),a+=u}let c=e[s++];for(;a<c;){if(i.done)break e;let u=Math.min(i.len,c-a);vo(n,u,-1),vo(r,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),a+=u}}return{changes:new zn(n,o),filtered:os.create(r)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let o=this.sections[n],r=this.sections[n+1];r<0?e.push(o):r==0?e.push([o]):e.push([o].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,o){let r=[],i=[],s=0,a=null;function l(u=!1){if(!u&&!r.length)return;s<n&&vo(r,n-s,-1);let d=new zn(r,i);a=a?a.compose(d.map(a)):d,r=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof zn){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:f=d,insert:h}=u;if(d>f||d<0||f>n)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${n})`);let g=h?typeof h=="string"?Ut.of(h.split(o||ab)):h:Ut.empty,b=g.length;if(d==f&&b==0)return;d<s&&l(),d>s&&vo(r,d-s,-1),vo(r,f-d,b),ka(i,r,g),s=f}}return c(e),l(!a),a}static empty(e){return new zn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],o=[];for(let r=0;r<e.length;r++){let i=e[r];if(typeof i=="number")n.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)n.push(i[0],0);else{for(;o.length<r;)o.push(Ut.empty);o[r]=Ut.of(i.slice(1)),n.push(i[0],o[r].length)}}}return new zn(n,o)}static createSet(e,n){return new zn(e,n)}}function vo(t,e,n,o=!1){if(e==0&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:o?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function ka(t,e,n){if(n.length==0)return;let o=e.length-2>>1;if(o<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<o;)t.push(Ut.empty);t.push(n)}}function lb(t,e,n){let o=t.inserted;for(let r=0,i=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)r+=a,i+=a;else{let c=r,u=i,d=Ut.empty;for(;c+=a,u+=l,l&&o&&(d=d.append(o[s-2>>1])),!(n||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(r,c,i,u,d),r=c,i=u}}}function cb(t,e,n,o=!1){let r=[],i=o?[]:null,s=new uf(t),a=new uf(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);vo(r,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!n))){let c=a.len;for(vo(r,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(vo(r,0,s.ins),i&&ka(i,r,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;vo(r,c,l<s.i?s.ins:0),i&&l<s.i&&ka(i,r,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return i?zn.createSet(r,i):os.create(r);throw new Error("Mismatched change set lengths")}}}function iM(t,e,n=!1){let o=[],r=n?[]:null,i=new uf(t),s=new uf(e);for(let a=!1;;){if(i.done&&s.done)return r?zn.createSet(o,r):os.create(o);if(i.ins==0)vo(o,i.len,0,a),i.next();else if(s.len==0&&!s.done)vo(o,0,s.ins,a),r&&ka(r,o,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(i.len2,s.len),c=o.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;vo(o,l,u,a),r&&u&&ka(r,o,s.text)}else s.ins==-1?(vo(o,i.off?0:i.len,l,a),r&&ka(r,o,i.textBit(l))):(vo(o,i.off?0:i.len,s.off?0:s.ins,a),r&&!s.off&&ka(r,o,s.text));a=(i.ins>l||s.ins>=0&&s.len>l)&&(a||o.length>c),i.forward2(l),s.forward(l)}}}}class uf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?Ut.empty:e[n]}textBit(e){let{inserted:n}=this.set,o=this.i-2>>1;return o>=n.length&&!e?Ut.empty:n[o].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class xl{constructor(e,n,o){this.from=e,this.to=n,this.flags=o}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let o,r;return this.empty?o=r=e.mapPos(this.from,n):(o=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),o==this.from&&r==this.to?this:new xl(o,r,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ze.range(e,n);let o=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ze.range(this.anchor,o)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ze.range(e.anchor,e.head)}static create(e,n,o){return new xl(e,n,o)}}class ze{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ze.create(this.ranges.map(o=>o.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let o=0;o<this.ranges.length;o++)if(!this.ranges[o].eq(e.ranges[o],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ze([this.main],0)}addRange(e,n=!0){return ze.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let o=this.ranges.slice();return o[n]=e,ze.create(o,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ze(e.ranges.map(n=>xl.fromJSON(n)),e.main)}static single(e,n=e){return new ze([ze.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let o=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=o:i.from<o)return ze.normalized(e.slice(),n);o=i.to}return new ze(e,n)}static cursor(e,n=0,o,r){return xl.create(e,e,(n==0?0:n<0?8:16)|(o==null?7:Math.min(6,o))|(r??16777215)<<6)}static range(e,n,o,r){let i=(o??16777215)<<6|(r==null?7:Math.min(6,r));return n<e?xl.create(n,e,48|i):xl.create(e,n,(n>e?8:0)|i)}static normalized(e,n=0){let o=e[n];e.sort((r,i)=>r.from-i.from),n=e.indexOf(o);for(let r=1;r<e.length;r++){let i=e[r],s=e[r-1];if(i.empty?i.from<=s.to:i.from<s.to){let a=s.from,l=Math.max(i.to,s.to);r<=n&&n--,e.splice(--r,2,i.anchor>i.head?ze.range(l,a):ze.range(a,l))}}return new ze(e,n)}}function sM(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Y2=0;class pt{constructor(e,n,o,r,i){this.combine=e,this.compareInput=n,this.compare=o,this.isStatic=r,this.id=Y2++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}get reader(){return this}static define(e={}){return new pt(e.combine||(n=>n),e.compareInput||((n,o)=>n===o),e.compare||(e.combine?(n,o)=>n===o:j2),!!e.static,e.enables)}of(e){return new sp([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new sp(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new sp(e,this,2,n)}from(e,n){return n||(n=o=>o),this.compute([e],o=>n(o.field(e)))}}function j2(t,e){return t==e||t.length==e.length&&t.every((n,o)=>n===e[o])}class sp{constructor(e,n,o,r){this.dependencies=e,this.facet=n,this.type=o,this.value=r,this.id=Y2++}dynamicSlot(e){var n;let o=this.value,r=this.facet.compareInput,i=this.id,s=e[i]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=e[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[s]=o(d),1},update(d,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||ub(d,u)){let h=o(d);if(a?!nk(h,d.values[s],r):!r(h,d.values[s]))return d.values[s]=h,1}return 0},reconfigure:(d,f)=>{let h,g=f.config.address[i];if(g!=null){let b=y0(f,g);if(this.dependencies.every(m=>m instanceof pt?f.facet(m)===d.facet(m):m instanceof el?f.field(m,!1)==d.field(m,!1):!0)||(a?nk(h=o(d),b,r):r(h=o(d),b)))return d.values[s]=b,0}else h=o(d);return d.values[s]=h,1}}}}function nk(t,e,n){if(t.length!=e.length)return!1;for(let o=0;o<t.length;o++)if(!n(t[o],e[o]))return!1;return!0}function ub(t,e){let n=!1;for(let o of e)Od(t,o)&1&&(n=!0);return n}function afe(t,e,n){let o=n.map(l=>t[l.id]),r=n.map(l=>l.type),i=o.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<o.length;u++){let d=y0(l,o[u]);if(r[u]==2)for(let f of d)c.push(f);else c.push(d)}return e.combine(c)}return{create(l){for(let c of o)Od(l,c);return l.values[s]=a(l),1},update(l,c){if(!ub(l,i))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=ub(l,o),d=c.config.facets[e.id],f=c.facet(e);if(d&&!u&&j2(n,d))return l.values[s]=f,0;let h=a(l);return e.compare(h,f)?(l.values[s]=f,0):(l.values[s]=h,1)}}}const Sh=pt.define({static:!0});class el{constructor(e,n,o,r,i){this.id=e,this.createF=n,this.updateF=o,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let n=new el(Y2++,e.create,e.update,e.compare||((o,r)=>o===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Sh).find(o=>o.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:o=>(o.values[n]=this.create(o),1),update:(o,r)=>{let i=o.values[n],s=this.updateF(i,r);return this.compareF(i,s)?0:(o.values[n]=s,1)},reconfigure:(o,r)=>{let i=o.facet(Sh),s=r.facet(Sh),a;return(a=i.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(o.values[n]=a.create(o),1):r.config.address[this.id]!=null?(o.values[n]=r.field(this),0):(o.values[n]=this.create(o),1)}}}init(e){return[this,Sh.of({field:this,create:e})]}get extension(){return this}}const vl={lowest:4,low:3,default:2,high:1,highest:0};function Ku(t){return e=>new aM(e,t)}const X2={highest:Ku(vl.highest),high:Ku(vl.high),default:Ku(vl.default),low:Ku(vl.low),lowest:Ku(vl.lowest)};class aM{constructor(e,n){this.inner=e,this.prec=n}}class fg{of(e){return new db(this,e)}reconfigure(e){return fg.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class db{constructor(e,n){this.compartment=e,this.inner=n}}class b0{constructor(e,n,o,r,i,s){for(this.base=e,this.compartments=n,this.dynamicSlots=o,this.address=r,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<o.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,o){let r=[],i=Object.create(null),s=new Map;for(let f of lfe(e,n,s))f instanceof el?r.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of r)a[f.id]=c.length<<1,c.push(h=>f.slot(h));let u=o==null?void 0:o.config.facets;for(let f in i){let h=i[f],g=h[0].facet,b=u&&u[f]||[];if(h.every(m=>m.type==0))if(a[g.id]=l.length<<1|1,j2(b,h))l.push(o.facet(g));else{let m=g.combine(h.map(v=>v.value));l.push(o&&g.compare(m,o.facet(g))?o.facet(g):m)}else{for(let m of h)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(v=>m.dynamicSlot(v)));a[g.id]=c.length<<1,c.push(m=>afe(m,g,h))}}let d=c.map(f=>f(a));return new b0(e,s,d,a,l,i)}}function lfe(t,e,n){let o=[[],[],[],[],[]],r=new Map;function i(s,a){let l=r.get(s);if(l!=null){if(l<=a)return;let c=o[l].indexOf(s);c>-1&&o[l].splice(c,1),s instanceof db&&n.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let c of s)i(c,a);else if(s instanceof db){if(n.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;n.set(s.compartment,c),i(c,a)}else if(s instanceof aM)i(s.inner,s.prec);else if(s instanceof el)o[a].push(s),s.provides&&i(s.provides,a);else if(s instanceof sp)o[a].push(s),s.facet.extensions&&i(s.facet.extensions,vl.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,a)}}return i(t,vl.default),o.reduce((s,a)=>s.concat(a))}function Od(t,e){if(e&1)return 2;let n=e>>1,o=t.status[n];if(o==4)throw new Error("Cyclic dependency between fields and/or facets");if(o&2)return o;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function y0(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const lM=pt.define(),fb=pt.define({combine:t=>t.some(e=>e),static:!0}),cM=pt.define({combine:t=>t.length?t[0]:void 0,static:!0}),uM=pt.define(),dM=pt.define(),fM=pt.define(),hM=pt.define({combine:t=>t.length?t[0]:!1});class tl{constructor(e,n){this.type=e,this.value=n}static define(){return new cfe}}class cfe{of(e){return new tl(this,e)}}class ufe{constructor(e){this.map=e}of(e){return new $n(this,e)}}class $n{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new $n(this.type,n)}is(e){return this.type==e}static define(e={}){return new ufe(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let o=[];for(let r of e){let i=r.map(n);i&&o.push(i)}return o}}$n.reconfigure=$n.define();$n.appendConfig=$n.define();class Wn{constructor(e,n,o,r,i,s){this.startState=e,this.changes=n,this.selection=o,this.effects=r,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,o&&sM(o,n.newLength),i.some(a=>a.type==Wn.time)||(this.annotations=i.concat(Wn.time.of(Date.now())))}static create(e,n,o,r,i,s){return new Wn(e,n,o,r,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Wn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Wn.time=tl.define();Wn.userEvent=tl.define();Wn.addToHistory=tl.define();Wn.remote=tl.define();function dfe(t,e){let n=[];for(let o=0,r=0;;){let i,s;if(o<t.length&&(r==e.length||e[r]>=t[o]))i=t[o++],s=t[o++];else if(r<e.length)i=e[r++],s=e[r++];else return n;!n.length||n[n.length-1]<i?n.push(i,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function pM(t,e,n){var o;let r,i,s;return n?(r=e.changes,i=zn.empty(e.changes.length),s=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),i=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(r)),{changes:s,selection:e.selection?e.selection.map(i):(o=t.selection)===null||o===void 0?void 0:o.map(r),effects:$n.mapEffects(t.effects,r).concat($n.mapEffects(e.effects,i)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function hb(t,e,n){let o=e.selection,r=Rc(e.annotations);return e.userEvent&&(r=r.concat(Wn.userEvent.of(e.userEvent))),{changes:e.changes instanceof zn?e.changes:zn.of(e.changes||[],n,t.facet(cM)),selection:o&&(o instanceof ze?o:ze.single(o.anchor,o.head)),effects:Rc(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function mM(t,e,n){let o=hb(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(n=!1);let s=!!e[i].sequential;o=pM(o,hb(t,e[i],s?o.changes.newLength:t.doc.length),s)}let r=Wn.create(t,o.changes,o.selection,o.effects,o.annotations,o.scrollIntoView);return hfe(n?ffe(r):r)}function ffe(t){let e=t.startState,n=!0;for(let r of e.facet(uM)){let i=r(t);if(i===!1){n=!1;break}Array.isArray(i)&&(n=n===!0?i:dfe(n,i))}if(n!==!0){let r,i;if(n===!1)i=t.changes.invertedDesc,r=zn.empty(e.doc.length);else{let s=t.changes.filter(n);r=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}t=Wn.create(e,r,t.selection&&t.selection.map(i),$n.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let o=e.facet(dM);for(let r=o.length-1;r>=0;r--){let i=o[r](t);i instanceof Wn?t=i:Array.isArray(i)&&i.length==1&&i[0]instanceof Wn?t=i[0]:t=mM(e,Rc(i),!1)}return t}function hfe(t){let e=t.startState,n=e.facet(fM),o=t;for(let r=n.length-1;r>=0;r--){let i=n[r](t);i&&Object.keys(i).length&&(o=pM(o,hb(e,i,t.changes.newLength),!0))}return o==t?t:Wn.create(e,t.changes,t.selection,o.effects,o.annotations,o.scrollIntoView)}const pfe=[];function Rc(t){return t==null?pfe:Array.isArray(t)?t:[t]}var Es=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(Es||(Es={}));const mfe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let pb;try{pb=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function gfe(t){if(pb)return pb.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||mfe.test(n)))return!0}return!1}function vfe(t){return e=>{if(!/\S/.test(e))return Es.Space;if(gfe(e))return Es.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Es.Word;return Es.Other}}class Kt{constructor(e,n,o,r,i,s){this.config=e,this.doc=n,this.selection=o,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Od(this,a<<1);this.computeSlot=null}field(e,n=!0){let o=this.config.address[e.id];if(o==null){if(n)throw new RangeError("Field is not present in this state");return}return Od(this,o),y0(this,o)}update(...e){return mM(this,e,!0)}applyTransaction(e){let n=this.config,{base:o,compartments:r}=n;for(let a of e.effects)a.is(fg.reconfigure)?(n&&(r=new Map,n.compartments.forEach((l,c)=>r.set(c,l)),n=null),r.set(a.value.compartment,a.value.extension)):a.is($n.reconfigure)?(n=null,o=a.value):a.is($n.appendConfig)&&(n=null,o=Rc(o).concat(a.value));let i;n?i=e.startState.values.slice():(n=b0.resolve(o,r,this),i=new Kt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(fb)?e.newSelection:e.newSelection.asSingle();new Kt(n,e.newDoc,s,i,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ze.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,o=e(n.ranges[0]),r=this.changes(o.changes),i=[o.range],s=Rc(o.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),c=this.changes(l.changes),u=c.map(r);for(let f=0;f<a;f++)i[f]=i[f].map(u);let d=r.mapDesc(c,!0);i.push(l.range.map(d)),r=r.compose(u),s=$n.mapEffects(s,u).concat($n.mapEffects(Rc(l.effects),d))}return{changes:r,selection:ze.create(i,n.mainIndex),effects:s}}changes(e=[]){return e instanceof zn?e:zn.of(e,this.doc.length,this.facet(Kt.lineSeparator))}toText(e){return Ut.of(e.split(this.facet(Kt.lineSeparator)||ab))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Od(this,n),y0(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let o in e){let r=e[o];r instanceof el&&this.config.address[r.id]!=null&&(n[o]=r.spec.toJSON(this.field(e[o]),this))}return n}static fromJSON(e,n={},o){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(o){for(let i in o)if(Object.prototype.hasOwnProperty.call(e,i)){let s=o[i],a=e[i];r.push(s.init(l=>s.spec.fromJSON(a,l)))}}return Kt.create({doc:e.doc,selection:ze.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=b0.resolve(e.extensions||[],new Map),o=e.doc instanceof Ut?e.doc:Ut.of((e.doc||"").split(n.staticFacet(Kt.lineSeparator)||ab)),r=e.selection?e.selection instanceof ze?e.selection:ze.single(e.selection.anchor,e.selection.head):ze.single(0);return sM(r,o.length),n.staticFacet(fb)||(r=r.asSingle()),new Kt(n,o,r,n.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Kt.tabSize)}get lineBreak(){return this.facet(Kt.lineSeparator)||`
|
|
853
|
+
`}get readOnly(){return this.facet(hM)}phrase(e,...n){for(let o of this.facet(Kt.phrases))if(Object.prototype.hasOwnProperty.call(o,e)){e=o[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(o,r)=>{if(r=="$")return"$";let i=+(r||1);return!i||i>n.length?o:n[i-1]})),e}languageDataAt(e,n,o=-1){let r=[];for(let i of this.facet(lM))for(let s of i(this,n,o))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return vfe(n.length?n[0]:"")}wordAt(e){let{text:n,from:o,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-o,a=e-o;for(;s>0;){let l=To(n,s,!1);if(i(n.slice(l,s))!=Es.Word)break;s=l}for(;a<r;){let l=To(n,a);if(i(n.slice(a,l))!=Es.Word)break;a=l}return s==a?null:ze.range(s+o,a+o)}}Kt.allowMultipleSelections=fb;Kt.tabSize=pt.define({combine:t=>t.length?t[0]:4});Kt.lineSeparator=cM;Kt.readOnly=hM;Kt.phrases=pt.define({compare(t,e){let n=Object.keys(t),o=Object.keys(e);return n.length==o.length&&n.every(r=>t[r]==e[r])}});Kt.languageData=lM;Kt.changeFilter=uM;Kt.transactionFilter=dM;Kt.transactionExtender=fM;fg.reconfigure=$n.define();function bfe(t,e,n={}){let o={};for(let r of t)for(let i of Object.keys(r)){let s=r[i],a=o[i];if(a===void 0)o[i]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(n,i))o[i]=n[i](a,s);else throw new Error("Config merge conflict for field "+i)}for(let r in e)o[r]===void 0&&(o[r]=e[r]);return o}class Vl{eq(e){return this==e}range(e,n=e){return mb.create(e,n,this)}}Vl.prototype.startSide=Vl.prototype.endSide=0;Vl.prototype.point=!1;Vl.prototype.mapMode=br.TrackDel;function K2(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let mb=class gM{constructor(e,n,o){this.from=e,this.to=n,this.value=o}static create(e,n,o){return new gM(e,n,o)}};function gb(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Z2{constructor(e,n,o,r){this.from=e,this.to=n,this.value=o,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,n,o,r=0){let i=o?this.to:this.from;for(let s=r,a=i.length;;){if(s==a)return s;let l=s+a>>1,c=i[l]-e||(o?this.value[l].endSide:this.value[l].startSide)-n;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,n,o,r){for(let i=this.findIndex(n,-1e9,!0),s=this.findIndex(o,1e9,!1,i);i<s;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,n){let o=[],r=[],i=[],s=-1,a=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],u=this.from[l]+e,d=this.to[l]+e,f,h;if(u==d){let g=n.mapPos(u,c.startSide,c.mapMode);if(g==null||(f=h=g,c.startSide!=c.endSide&&(h=n.mapPos(u,c.endSide),h<f)))continue}else if(f=n.mapPos(u,c.startSide),h=n.mapPos(d,c.endSide),f>h||f==h&&c.startSide>0&&c.endSide<=0)continue;(h-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(a=Math.max(a,h-f)),o.push(c),r.push(f-s),i.push(h-s))}return{mapped:o.length?new Z2(r,i,o,a):null,pos:s}}}class tn{constructor(e,n,o,r){this.chunkPos=e,this.chunk=n,this.nextLayer=o,this.maxPoint=r}static create(e,n,o,r){return new tn(e,n,o,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:o=!1,filterFrom:r=0,filterTo:i=this.length}=e,s=e.filter;if(n.length==0&&!s)return this;if(o&&(n=n.slice().sort(gb)),this.isEmpty)return n.length?tn.of(n):this;let a=new vM(this,null,-1).goto(0),l=0,c=[],u=new df;for(;a.value||l<n.length;)if(l<n.length&&(a.from-n[l].from||a.startSide-n[l].value.startSide)>=0){let d=n[l++];u.addInner(d.from,d.to,d.value)||c.push(d)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==n.length||this.chunkEnd(a.chunkIndex)<n[l].from)&&(!s||r>this.chunkEnd(a.chunkIndex)||i<this.chunkPos[a.chunkIndex])&&u.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!s||r>a.to||i<a.from||s(a.from,a.to,a.value))&&(u.addInner(a.from,a.to,a.value)||c.push(mb.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?tn.empty:this.nextLayer.update({add:c,filter:s,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let n=[],o=[],r=-1;for(let s=0;s<this.chunk.length;s++){let a=this.chunkPos[s],l=this.chunk[s],c=e.touchesRange(a,a+l.length);if(c===!1)r=Math.max(r,l.maxPoint),n.push(l),o.push(e.mapPos(a));else if(c===!0){let{mapped:u,pos:d}=l.map(a,e);u&&(r=Math.max(r,u.maxPoint),n.push(u),o.push(d))}}let i=this.nextLayer.map(e);return n.length==0?i:new tn(o,n,i||tn.empty,r)}between(e,n,o){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],s=this.chunk[r];if(n>=i&&e<=i+s.length&&s.between(i,e-i,n-i,o)===!1)return}this.nextLayer.between(e,n,o)}}iter(e=0){return ff.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return ff.from(e).goto(n)}static compare(e,n,o,r,i=-1){let s=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),a=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),l=ok(s,a,o),c=new Zu(s,l,i),u=new Zu(a,l,i);o.iterGaps((d,f,h)=>rk(c,d,u,f,h,r)),o.empty&&o.length==0&&rk(c,0,u,0,0,r)}static eq(e,n,o=0,r){r==null&&(r=999999999);let i=e.filter(u=>!u.isEmpty&&n.indexOf(u)<0),s=n.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(i.length!=s.length)return!1;if(!i.length)return!0;let a=ok(i,s),l=new Zu(i,a,0).goto(o),c=new Zu(s,a,0).goto(o);for(;;){if(l.to!=c.to||!vb(l.active,c.active)||l.point&&(!c.point||!K2(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,n,o,r,i=-1){let s=new Zu(e,null,i).goto(n),a=n,l=s.openStart;for(;;){let c=Math.min(s.to,o);if(s.point){let u=s.activeForPoint(s.to),d=s.pointFrom<n?u.length+1:s.point.startSide<0?u.length:Math.min(u.length,l);r.point(a,c,s.point,u,d,s.pointRank),l=Math.min(s.openEnd(c),u.length)}else c>a&&(r.span(a,c,s.active,l),l=s.openEnd(c));if(s.to>o)return l+(s.point&&s.to>o?1:0);a=s.to,s.next()}}static of(e,n=!1){let o=new df;for(let r of e instanceof mb?[e]:n?yfe(e):e)o.add(r.from,r.to,r.value);return o.finish()}static join(e){if(!e.length)return tn.empty;let n=e[e.length-1];for(let o=e.length-2;o>=0;o--)for(let r=e[o];r!=tn.empty;r=r.nextLayer)n=new tn(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}tn.empty=new tn([],[],null,-1);function yfe(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let o=t[n];if(gb(e,o)>0)return t.slice().sort(gb);e=o}return t}tn.empty.nextLayer=tn.empty;class df{finishChunk(e){this.chunks.push(new Z2(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,o){this.addInner(e,n,o)||(this.nextLayer||(this.nextLayer=new df)).add(e,n,o)}addInner(e,n,o){let r=e-this.lastTo||o.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||o.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=o,this.lastFrom=e,this.lastTo=n,this.value.push(o),o.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let o=n.value.length-1;return this.last=n.value[o],this.lastFrom=n.from[o]+e,this.lastTo=n.to[o]+e,!0}finish(){return this.finishInner(tn.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=tn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ok(t,e,n){let o=new Map;for(let i of t)for(let s=0;s<i.chunk.length;s++)i.chunk[s].maxPoint<=0&&o.set(i.chunk[s],i.chunkPos[s]);let r=new Set;for(let i of e)for(let s=0;s<i.chunk.length;s++){let a=o.get(i.chunk[s]);a!=null&&(n?n.mapPos(a):a)==i.chunkPos[s]&&!(n!=null&&n.touchesRange(a,a+i.chunk[s].length))&&r.add(i.chunk[s])}return r}class vM{constructor(e,n,o,r=0){this.layer=e,this.skip=n,this.minPoint=o,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,n=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,n,!1),this}gotoInner(e,n,o){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,o=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],n,!0);(!o||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,n){(this.to-e||this.endSide-n)<0&&this.gotoInner(e,n,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],n=this.layer.chunk[this.chunkIndex],o=e+n.from[this.rangeIndex];if(this.from=o,this.to=e+n.to[this.rangeIndex],this.value=n.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class ff{constructor(e){this.heap=e}static from(e,n=null,o=-1){let r=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=o&&r.push(new vM(s,n,o,i));return r.length==1?r[0]:new ff(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let o of this.heap)o.goto(e,n);for(let o=this.heap.length>>1;o>=0;o--)Ov(this.heap,o);return this.next(),this}forward(e,n){for(let o of this.heap)o.forward(e,n);for(let o=this.heap.length>>1;o>=0;o--)Ov(this.heap,o);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Ov(this.heap,0)}}}function Ov(t,e){for(let n=t[e];;){let o=(e<<1)+1;if(o>=t.length)break;let r=t[o];if(o+1<t.length&&r.compare(t[o+1])>=0&&(r=t[o+1],o++),n.compare(r)<0)break;t[o]=n,t[e]=r,e=o}}class Zu{constructor(e,n,o){this.minPoint=o,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ff.from(e,n,o)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Ah(this.active,e),Ah(this.activeTo,e),Ah(this.activeRank,e),this.minActive=ik(this.active,this.activeTo)}addActive(e){let n=0,{value:o,to:r,rank:i}=this.cursor;for(;n<this.activeRank.length&&(i-this.activeRank[n]||r-this.activeTo[n])>0;)n++;Ch(this.active,n,o),Ch(this.activeTo,n,r),Ch(this.activeRank,n,i),e&&Ch(e,n,this.cursor.from),this.minActive=ik(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let o=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),o&&Ah(o,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(o),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(o){this.openStart=0;for(let r=o.length-1;r>=0&&o[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let n=[];for(let o=this.active.length-1;o>=0&&!(this.activeRank[o]<this.pointRank);o--)(this.activeTo[o]>e||this.activeTo[o]==e&&this.active[o].endSide>=this.point.endSide)&&n.push(this.active[o]);return n.reverse()}openEnd(e){let n=0;for(let o=this.activeTo.length-1;o>=0&&this.activeTo[o]>e;o--)n++;return n}}function rk(t,e,n,o,r,i){t.goto(e),n.goto(o);let s=o+r,a=o,l=o-e,c=!!i.boundChange;for(let u=!1;;){let d=t.to+l-n.to,f=d||t.endSide-n.endSide,h=f<0?t.to+l:n.to,g=Math.min(h,s);if(t.point||n.point?(t.point&&n.point&&K2(t.point,n.point)&&vb(t.activeForPoint(t.to),n.activeForPoint(n.to))||i.comparePoint(a,g,t.point,n.point),u=!1):(u&&i.boundChange(a),g>a&&!vb(t.active,n.active)&&i.compareRange(a,g,t.active,n.active),c&&g<s&&(d||t.openEnd(h)!=n.openEnd(h))&&(u=!0)),h>s)break;a=h,f<=0&&t.next(),f>=0&&n.next()}}function vb(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!K2(t[n],e[n]))return!1;return!0}function Ah(t,e){for(let n=e,o=t.length-1;n<o;n++)t[n]=t[n+1];t.pop()}function Ch(t,e,n){for(let o=t.length-1;o>=e;o--)t[o+1]=t[o];t[e]=n}function ik(t,e){let n=-1,o=1e9;for(let r=0;r<e.length;r++)(e[r]-o||t[r].endSide-t[n].endSide)<0&&(n=r,o=e[r]);return n}function hg(t,e,n=t.length){let o=0;for(let r=0;r<n&&r<t.length;)t.charCodeAt(r)==9?(o+=e-o%e,r++):(o++,r=To(t,r));return o}function xfe(t,e,n,o){for(let r=0,i=0;;){if(i>=e)return r;if(r==t.length)break;i+=t.charCodeAt(r)==9?n-i%n:1,r=To(t,r)}return t.length}const bb="ͼ",sk=typeof Symbol>"u"?"__"+bb:Symbol.for(bb),yb=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ak=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Fa{constructor(e,n){this.rules=[];let{finish:o}=n||{};function r(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,a,l,c){let u=[],d=/^@(\w+)\b/.exec(s[0]),f=d&&d[1]=="keyframes";if(d&&a==null)return l.push(s[0]+";");for(let h in a){let g=a[h];if(/&/.test(h))i(h.split(/,\s*/).map(b=>s.map(m=>b.replace(/&/,m))).reduce((b,m)=>b.concat(m)),g,l);else if(g&&typeof g=="object"){if(!d)throw new RangeError("The value of a property ("+h+") should be a primitive value.");i(r(h),g,u,f)}else g!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+g+";")}(u.length||f)&&l.push((o&&!d&&!c?s.map(o):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)i(r(s),e[s],this.rules)}getRules(){return this.rules.join(`
|
|
854
|
+
`)}static newName(){let e=ak[sk]||1;return ak[sk]=e+1,bb+e.toString(36)}static mount(e,n,o){let r=e[yb],i=o&&o.nonce;r?i&&r.setNonce(i):r=new wfe(e,i),r.mount(Array.isArray(n)?n:[n],e)}}let lk=new Map;class wfe{constructor(e,n){let o=e.ownerDocument||e,r=o.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let i=lk.get(o);if(i)return e[yb]=i;this.sheet=new r.CSSStyleSheet,lk.set(o,this)}else this.styleTag=o.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[yb]=this}mount(e,n){let o=this.sheet,r=0,i=0;for(let s=0;s<e.length;s++){let a=e[s],l=this.modules.indexOf(a);if(l<i&&l>-1&&(this.modules.splice(l,1),i--,l=-1),l==-1){if(this.modules.splice(i++,0,a),o)for(let c=0;c<a.rules.length;c++)o.insertRule(a.rules[c],r++)}else{for(;i<l;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(o)n.adoptedStyleSheets.indexOf(this.sheet)<0&&(n.adoptedStyleSheets=[this.sheet,...n.adoptedStyleSheets]);else{let s="";for(let l=0;l<this.modules.length;l++)s+=this.modules[l].getRules()+`
|
|
855
|
+
`;this.styleTag.textContent=s;let a=n.head||n;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Va={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_fe=typeof navigator<"u"&&/Mac/.test(navigator.platform),kfe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var oo=0;oo<10;oo++)Va[48+oo]=Va[96+oo]=String(oo);for(var oo=1;oo<=24;oo++)Va[oo+111]="F"+oo;for(var oo=65;oo<=90;oo++)Va[oo]=String.fromCharCode(oo+32),hf[oo]=String.fromCharCode(oo);for(var Bv in Va)hf.hasOwnProperty(Bv)||(hf[Bv]=Va[Bv]);function Sfe(t){var e=_fe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||kfe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hf:Va)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Io=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},xb=typeof document<"u"?document:{documentElement:{style:{}}};const wb=/Edge\/(\d+)/.exec(Io.userAgent),bM=/MSIE \d/.test(Io.userAgent),_b=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Io.userAgent),pg=!!(bM||_b||wb),ck=!pg&&/gecko\/(\d+)/i.test(Io.userAgent),Lv=!pg&&/Chrome\/(\d+)/.exec(Io.userAgent),Afe="webkitFontSmoothing"in xb.documentElement.style,kb=!pg&&/Apple Computer/.test(Io.vendor),uk=kb&&(/Mobile\/\w+/.test(Io.userAgent)||Io.maxTouchPoints>2);var ot={mac:uk||/Mac/.test(Io.platform),windows:/Win/.test(Io.platform),linux:/Linux|X11/.test(Io.platform),ie:pg,ie_version:bM?xb.documentMode||6:_b?+_b[1]:wb?+wb[1]:0,gecko:ck,gecko_version:ck?+(/Firefox\/(\d+)/.exec(Io.userAgent)||[0,0])[1]:0,chrome:!!Lv,chrome_version:Lv?+Lv[1]:0,ios:uk,android:/Android\b/.test(Io.userAgent),webkit_version:Afe?+(/\bAppleWebKit\/(\d+)/.exec(Io.userAgent)||[0,0])[1]:0,safari:kb,safari_version:kb?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Io.userAgent)||[0,0])[1]:0,tabSize:xb.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Q2(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const x0=Object.create(null);function J2(t,e,n){if(t==e)return!0;t||(t=x0),e||(e=x0);let o=Object.keys(t),r=Object.keys(e);if(o.length-0!=r.length-0)return!1;for(let i of o)if(i!=n&&(r.indexOf(i)==-1||t[i]!==e[i]))return!1;return!0}function Cfe(t,e){for(let n=t.attributes.length-1;n>=0;n--){let o=t.attributes[n].name;e[o]==null&&t.removeAttribute(o)}for(let n in e){let o=e[n];n=="style"?t.style.cssText=o:t.getAttribute(n)!=o&&t.setAttribute(n,o)}}function dk(t,e,n){let o=!1;if(e)for(let r in e)n&&r in n||(o=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(o=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return o}function $fe(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let o=t.attributes[n];e[o.name]=o.value}return e}class mg{eq(e){return!1}updateDOM(e,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,o){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var zr=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})(zr||(zr={}));class Xn extends Vl{constructor(e,n,o,r){super(),this.startSide=e,this.endSide=n,this.widget=o,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Rf(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),o=!!e.block;return n+=o&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new zl(e,n,n,o,e.widget||null,!1)}static replace(e){let n=!!e.block,o,r;if(e.isBlockGap)o=-5e8,r=4e8;else{let{start:i,end:s}=yM(e,n);o=(i?n?-3e8:-1:5e8)-1,r=(s?n?2e8:1:-6e8)+1}return new zl(e,o,r,n,e.widget||null,!0)}static line(e){return new Ff(e)}static set(e,n=!1){return tn.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Xn.none=tn.empty;class Rf extends Xn{constructor(e){let{start:n,end:o}=yM(e);super(n?-1:5e8,o?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Q2(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||x0}eq(e){return this==e||e instanceof Rf&&this.tagName==e.tagName&&J2(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Rf.prototype.point=!1;class Ff extends Xn{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ff&&this.spec.class==e.spec.class&&J2(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ff.prototype.mapMode=br.TrackBefore;Ff.prototype.point=!0;class zl extends Xn{constructor(e,n,o,r,i,s){super(n,o,i,e),this.block=r,this.isReplace=s,this.mapMode=r?n<=0?br.TrackBefore:br.TrackAfter:br.TrackDel}get type(){return this.startSide!=this.endSide?zr.WidgetRange:this.startSide<=0?zr.WidgetBefore:zr.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof zl&&Tfe(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}zl.prototype.point=!0;function yM(t,e=!1){let{inclusiveStart:n,inclusiveEnd:o}=t;return n==null&&(n=t.inclusive),o==null&&(o=t.inclusive),{start:n??e,end:o??e}}function Tfe(t,e){return t==e||!!(t&&e&&t.compare(e))}function Fc(t,e,n,o=0){let r=n.length-1;r>=0&&n[r]+o>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class pf extends Vl{constructor(e,n){super(),this.tagName=e,this.attributes=n}eq(e){return e==this||e instanceof pf&&this.tagName==e.tagName&&J2(this.attributes,e.attributes)}static create(e){return new pf(e.tagName,e.attributes||x0)}static set(e,n=!1){return tn.of(e,n)}}pf.prototype.startSide=pf.prototype.endSide=-1;function mf(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Sb(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Bd(t,e){if(!e.anchorNode)return!1;try{return Sb(t,e.anchorNode)}catch{return!1}}function ap(t){return t.nodeType==3?gf(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Ld(t,e,n,o){return n?fk(t,e,n,o,-1)||fk(t,e,n,o,1):!1}function za(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function w0(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function fk(t,e,n,o,r){for(;;){if(t==n&&e==o)return!0;if(e==(r<0?0:Xs(t))){if(t.nodeName=="DIV")return!1;let i=t.parentNode;if(!i||i.nodeType!=1)return!1;e=za(t)+(r<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?Xs(t):0}else return!1}}function Xs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _0(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function Mfe(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function xM(t,e){let n=e.width/t.offsetWidth,o=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(e.height-t.offsetHeight)<1)&&(o=1),{scaleX:n,scaleY:o}}function Ofe(t,e,n,o,r,i,s,a){let l=t.ownerDocument,c=l.defaultView||window;for(let u=t,d=!1;u&&!d;)if(u.nodeType==1){let f,h=u==l.body,g=1,b=1;if(h)f=Mfe(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let y=u.getBoundingClientRect();({scaleX:g,scaleY:b}=xM(u,y)),f={left:y.left,right:y.left+u.clientWidth*g,top:y.top,bottom:y.top+u.clientHeight*b}}let m=0,v=0;if(r=="nearest")e.top<f.top?(v=e.top-(f.top+s),n>0&&e.bottom>f.bottom+v&&(v=e.bottom-f.bottom+s)):e.bottom>f.bottom&&(v=e.bottom-f.bottom+s,n<0&&e.top-v<f.top&&(v=e.top-(f.top+s)));else{let y=e.bottom-e.top,x=f.bottom-f.top;v=(r=="center"&&y<=x?e.top+y/2-x/2:r=="start"||r=="center"&&n<0?e.top-s:e.bottom-x+s)-f.top}if(o=="nearest"?e.left<f.left?(m=e.left-(f.left+i),n>0&&e.right>f.right+m&&(m=e.right-f.right+i)):e.right>f.right&&(m=e.right-f.right+i,n<0&&e.left<f.left+m&&(m=e.left-(f.left+i))):m=(o=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:o=="start"==a?e.left-i:e.right-(f.right-f.left)+i)-f.left,m||v)if(h)c.scrollBy(m,v);else{let y=0,x=0;if(v){let _=u.scrollTop;u.scrollTop+=v/b,x=(u.scrollTop-_)*b}if(m){let _=u.scrollLeft;u.scrollLeft+=m/g,y=(u.scrollLeft-_)*g}e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x},y&&Math.abs(y-m)<1&&(o="nearest"),x&&Math.abs(x-v)<1&&(r="nearest")}if(h)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Bfe(t){let e=t.ownerDocument,n,o;for(let r=t.parentNode;r&&!(r==e.body||n&&o);)if(r.nodeType==1)!o&&r.scrollHeight>r.clientHeight&&(o=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:n,y:o}}class Lfe{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:o}=e;this.set(n,Math.min(e.anchorOffset,n?Xs(n):0),o,Math.min(e.focusOffset,o?Xs(o):0))}set(e,n,o,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=o,this.focusOffset=r}}let pl=null;ot.safari&&ot.safari_version>=26&&(pl=!1);function wM(t){if(t.setActive)return t.setActive();if(pl)return t.focus(pl);let e=[];for(let n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(pl==null?{get preventScroll(){return pl={preventScroll:!0},!0}}:void 0),!pl){pl=!1;for(let n=0;n<e.length;){let o=e[n++],r=e[n++],i=e[n++];o.scrollTop!=r&&(o.scrollTop=r),o.scrollLeft!=i&&(o.scrollLeft=i)}}}let hk;function gf(t,e,n=e){let o=hk||(hk=document.createRange());return o.setEnd(t,n),o.setStart(t,e),o}function Vc(t,e,n,o){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};o&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=o);let i=new KeyboardEvent("keydown",r);i.synthetic=!0,t.dispatchEvent(i);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,t.dispatchEvent(s),i.defaultPrevented||s.defaultPrevented}function Pfe(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Dfe(t,e){let n=e.focusNode,o=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=o)return!1;for(o=Math.min(o,Xs(n));;)if(o){if(n.nodeType!=1)return!1;let r=n.childNodes[o-1];r.contentEditable=="false"?o--:(n=r,o=Xs(n))}else{if(n==t)return!0;o=za(n),n=n.parentNode}}function _M(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function kM(t,e){for(let n=t,o=e;;){if(n.nodeType==3&&o>0)return{node:n,offset:o};if(n.nodeType==1&&o>0){if(n.contentEditable=="false")return null;n=n.childNodes[o-1],o=Xs(n)}else if(n.parentNode&&!w0(n))o=za(n),n=n.parentNode;else return null}}function SM(t,e){for(let n=t,o=e;;){if(n.nodeType==3&&o<n.nodeValue.length)return{node:n,offset:o};if(n.nodeType==1&&o<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[o],o=0}else if(n.parentNode&&!w0(n))o=za(n)+1,n=n.parentNode;else return null}}class ci{constructor(e,n,o=!0){this.node=e,this.offset=n,this.precise=o}static before(e,n){return new ci(e.parentNode,za(e),n)}static after(e,n){return new ci(e.parentNode,za(e)+1,n)}}var Dn=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(Dn||(Dn={}));const Hl=Dn.LTR,ex=Dn.RTL;function AM(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const Efe=AM("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Nfe=AM("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ab=Object.create(null),Ii=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);Ab[e]=n,Ab[n]=-e}function CM(t){return t<=247?Efe[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Nfe[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Ife=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Yi{get dir(){return this.level%2?ex:Hl}constructor(e,n,o){this.from=e,this.to=n,this.level=o}side(e,n){return this.dir==n==e?this.to:this.from}forward(e,n){return e==(this.dir==n)}static find(e,n,o,r){let i=-1;for(let s=0;s<e.length;s++){let a=e[s];if(a.from<=n&&a.to>=n){if(a.level==o)return s;(i<0||(r!=0?r<0?a.from<n:a.to>n:e[i].level>a.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}}function $M(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let o=t[n],r=e[n];if(o.from!=r.from||o.to!=r.to||o.direction!=r.direction||!$M(o.inner,r.inner))return!1}return!0}const sn=[];function Rfe(t,e,n,o,r){for(let i=0;i<=o.length;i++){let s=i?o[i-1].to:e,a=i<o.length?o[i].from:n,l=i?256:r;for(let c=s,u=l,d=l;c<a;c++){let f=CM(t.charCodeAt(c));f==512?f=u:f==8&&d==4&&(f=16),sn[c]=f==4?2:f,f&7&&(d=f),u=f}for(let c=s,u=l,d=l;c<a;c++){let f=sn[c];if(f==128)c<a-1&&u==sn[c+1]&&u&24?f=sn[c]=u:sn[c]=256;else if(f==64){let h=c+1;for(;h<a&&sn[h]==64;)h++;let g=c&&u==8||h<n&&sn[h]==8?d==1?1:8:256;for(let b=c;b<h;b++)sn[b]=g;c=h-1}else f==8&&d==1&&(sn[c]=1);u=f,f&7&&(d=f)}}}function Ffe(t,e,n,o,r){let i=r==1?2:1;for(let s=0,a=0,l=0;s<=o.length;s++){let c=s?o[s-1].to:e,u=s<o.length?o[s].from:n;for(let d=c,f,h,g;d<u;d++)if(h=Ab[f=t.charCodeAt(d)])if(h<0){for(let b=a-3;b>=0;b-=3)if(Ii[b+1]==-h){let m=Ii[b+2],v=m&2?r:m&4?m&1?i:r:0;v&&(sn[d]=sn[Ii[b]]=v),a=b;break}}else{if(Ii.length==189)break;Ii[a++]=d,Ii[a++]=f,Ii[a++]=l}else if((g=sn[d])==2||g==1){let b=g==r;l=b?0:1;for(let m=a-3;m>=0;m-=3){let v=Ii[m+2];if(v&2)break;if(b)Ii[m+2]|=2;else{if(v&4)break;Ii[m+2]|=4}}}}}function Vfe(t,e,n,o){for(let r=0,i=o;r<=n.length;r++){let s=r?n[r-1].to:t,a=r<n.length?n[r].from:e;for(let l=s;l<a;){let c=sn[l];if(c==256){let u=l+1;for(;;)if(u==a){if(r==n.length)break;u=n[r++].to,a=r<n.length?n[r].from:e}else if(sn[u]==256)u++;else break;let d=i==1,f=(u<e?sn[u]:o)==1,h=d==f?d?1:2:o;for(let g=u,b=r,m=b?n[b-1].to:t;g>l;)g==m&&(g=n[--b].from,m=b?n[b-1].to:t),sn[--g]=h;l=u}else i=c,l++}}}function Cb(t,e,n,o,r,i,s){let a=o%2?2:1;if(o%2==r%2)for(let l=e,c=0;l<n;){let u=!0,d=!1;if(c==i.length||l<i[c].from){let b=sn[l];b!=a&&(u=!1,d=b==16)}let f=!u&&a==1?[]:null,h=u?o:o+1,g=l;e:for(;;)if(c<i.length&&g==i[c].from){if(d)break e;let b=i[c];if(!u)for(let m=b.to,v=c+1;;){if(m==n)break e;if(v<i.length&&i[v].from==m)m=i[v++].to;else{if(sn[m]==a)break e;break}}if(c++,f)f.push(b);else{b.from>l&&s.push(new Yi(l,b.from,h));let m=b.direction==Hl!=!(h%2);$b(t,m?o+1:o,r,b.inner,b.from,b.to,s),l=b.to}g=b.to}else{if(g==n||(u?sn[g]!=a:sn[g]==a))break;g++}f?Cb(t,l,g,o+1,r,f,s):l<g&&s.push(new Yi(l,g,h)),l=g}else for(let l=n,c=i.length;l>e;){let u=!0,d=!1;if(!c||l>i[c-1].to){let b=sn[l-1];b!=a&&(u=!1,d=b==16)}let f=!u&&a==1?[]:null,h=u?o:o+1,g=l;e:for(;;)if(c&&g==i[c-1].to){if(d)break e;let b=i[--c];if(!u)for(let m=b.from,v=c;;){if(m==e)break e;if(v&&i[v-1].to==m)m=i[--v].from;else{if(sn[m-1]==a)break e;break}}if(f)f.push(b);else{b.to<l&&s.push(new Yi(b.to,l,h));let m=b.direction==Hl!=!(h%2);$b(t,m?o+1:o,r,b.inner,b.from,b.to,s),l=b.from}g=b.from}else{if(g==e||(u?sn[g-1]!=a:sn[g-1]==a))break;g--}f?Cb(t,g,l,o+1,r,f,s):g<l&&s.push(new Yi(g,l,h)),l=g}}function $b(t,e,n,o,r,i,s){let a=e%2?2:1;Rfe(t,r,i,o,a),Ffe(t,r,i,o,a),Vfe(r,i,o,a),Cb(t,r,i,e,n,o,s)}function zfe(t,e,n){if(!t)return[new Yi(0,0,e==ex?1:0)];if(e==Hl&&!n.length&&!Ife.test(t))return TM(t.length);if(n.length)for(;t.length>sn.length;)sn[sn.length]=256;let o=[],r=e==Hl?0:1;return $b(t,r,r,n,0,t.length,o),o}function TM(t){return[new Yi(0,t,0)]}let MM="";function Hfe(t,e,n,o,r){var i;let s=o.head-t.from,a=Yi.find(e,s,(i=o.bidiLevel)!==null&&i!==void 0?i:-1,o.assoc),l=e[a],c=l.side(r,n);if(s==c){let f=a+=r?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],s=l.side(!r,n),c=l.side(r,n)}let u=To(t.text,s,l.forward(r,n));(u<l.from||u>l.to)&&(u=c),MM=t.text.slice(Math.min(s,u),Math.max(s,u));let d=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return d&&u==c&&d.level+(r?0:1)<l.level?ze.cursor(d.side(!r,n)+t.from,d.forward(r,n)?1:-1,d.level):ze.cursor(u+t.from,l.forward(r,n)?-1:1,l.level)}function Wfe(t,e,n){for(let o=e;o<n;o++){let r=CM(t.charCodeAt(o));if(r==1)return Hl;if(r==2||r==4)return ex}return Hl}const OM=pt.define(),BM=pt.define(),LM=pt.define(),PM=pt.define(),Tb=pt.define(),DM=pt.define(),EM=pt.define(),tx=pt.define(),nx=pt.define(),NM=pt.define({combine:t=>t.some(e=>e)}),Ufe=pt.define({combine:t=>t.some(e=>e)}),IM=pt.define();class zc{constructor(e,n="nearest",o="nearest",r=5,i=5,s=!1){this.range=e,this.y=n,this.x=o,this.yMargin=r,this.xMargin=i,this.isSnapshot=s}map(e){return e.empty?this:new zc(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new zc(ze.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const $h=$n.define({map:(t,e)=>t.map(e)}),RM=$n.define();function ji(t,e,n){let o=t.facet(PM);o.length?o[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Bs=pt.define({combine:t=>t.length?t[0]:!0});let Gfe=0;const Ac=pt.define({combine(t){return t.filter((e,n)=>{for(let o=0;o<n;o++)if(t[o].plugin==e.plugin)return!1;return!0})}});class Wl{constructor(e,n,o,r,i){this.id=e,this.create=n,this.domEventHandlers=o,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ac.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ac.of({plugin:this,arg:e}))}static define(e,n){const{eventHandlers:o,eventObservers:r,provide:i,decorations:s}=n||{};return new Wl(Gfe++,e,o,r,a=>{let l=[];return s&&l.push(gg.of(c=>{let u=c.plugin(a);return u?s(u):Xn.none})),i&&l.push(i(a)),l})}static fromClass(e,n){return Wl.define((o,r)=>new e(o,r),n)}}class Pv{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(o){if(ji(n.state,o,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){ji(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(o){ji(e.state,o,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const FM=pt.define(),ox=pt.define(),gg=pt.define(),VM=pt.define(),rx=pt.define(),Vf=pt.define(),zM=pt.define();function pk(t,e){let n=t.state.facet(zM);if(!n.length)return n;let o=n.map(i=>i instanceof Function?i(t):i),r=[];return tn.spans(o,e.from,e.to,{point(){},span(i,s,a,l){let c=i-e.from,u=s-e.from,d=r;for(let f=a.length-1;f>=0;f--,l--){let h=a[f].spec.bidiIsolate,g;if(h==null&&(h=Wfe(e.text,c,u)),l>0&&d.length&&(g=d[d.length-1]).to==c&&g.direction==h)g.to=u,d=g.inner;else{let b={from:c,to:u,direction:h,inner:[]};d.push(b),d=b.inner}}}}),r}const HM=pt.define();function WM(t){let e=0,n=0,o=0,r=0;for(let i of t.state.facet(HM)){let s=i(t);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(n=Math.max(n,s.right)),s.top!=null&&(o=Math.max(o,s.top)),s.bottom!=null&&(r=Math.max(r,s.bottom)))}return{left:e,right:n,top:o,bottom:r}}const ud=pt.define();class Nr{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}join(e){return new Nr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,o=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>o.toA)){if(r.toA<o.fromA)break;o=o.join(r),e.splice(n-1,1)}}return e.splice(n,0,o),e}static extendWithRanges(e,n){if(n.length==0)return e;let o=[];for(let r=0,i=0,s=0;;){let a=r<e.length?e[r].fromB:1e9,l=i<n.length?n[i]:1e9,c=Math.min(a,l);if(c==1e9)break;let u=c+s,d=c,f=u;for(;;)if(i<n.length&&n[i]<=d){let h=n[i+1];i+=2,d=Math.max(d,h);for(let g=r;g<e.length&&e[g].fromB<=d;g++)s=e[g].toA-e[g].toB;f=Math.max(f,h+s)}else if(r<e.length&&e[r].fromB<=d){let h=e[r++];d=Math.max(d,h.toB),f=Math.max(f,h.toA),s=h.toA-h.toB}else break;o.push(new Nr(u,f,c,d))}return o}}class k0{constructor(e,n,o){this.view=e,this.state=n,this.transactions=o,this.flags=0,this.startState=e.state,this.changes=zn.empty(this.startState.doc.length);for(let i of o)this.changes=this.changes.compose(i.changes);let r=[];this.changes.iterChangedRanges((i,s,a,l)=>r.push(new Nr(i,s,a,l))),this.changedRanges=r}static create(e,n,o){return new k0(e,n,o)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const qfe=[];class Nn{constructor(e,n,o=0){this.dom=e,this.length=n,this.flags=o,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return qfe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&Cfe(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let o=n;for(let r of this.children){if(r==e)return o;o+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n){return null}domPosFor(e,n){let o=za(this.dom),r=this.length?e>0:n>0;return new ci(this.parent.dom,o+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof bg)return e;return null}static get(e){return e.cmTile}}class vg extends Nn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,o=null,r,i=(e==null?void 0:e.node)==n?e:null,s=0;for(let a of this.children){if(a.sync(e),s+=a.length+a.breakAfter,r=o?o.nextSibling:n.firstChild,i&&r!=a.dom&&(i.written=!0),a.dom.parentNode==n)for(;r&&r!=a.dom;)r=mk(r);else n.insertBefore(a.dom,r);o=a.dom}for(r=o?o.nextSibling:n.firstChild,i&&r&&(i.written=!0);r;)r=mk(r);this.length=s}}function mk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class bg extends vg{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Nn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],o=this,r=0,i=0;;)if(r==o.children.length){if(!n.length)return;o=o.parent,o.breakAfter&&i++,r=n.pop()}else{let s=o.children[r++];if(s instanceof zs)n.push(r),o=s,r=0;else{let a=i+s.length,l=e(s,i);if(l!==void 0)return l;i=a+s.breakAfter}}}resolveBlock(e,n){let o,r=-1,i,s=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&n>=-1&&n<=1){if(a.flags&32)return!0;a.flags&16&&(o=void 0)}(l<e||e==c&&(n<-1?a.length:a.covers(1)))&&(!o||!a.isWidget()&&o.isWidget())&&(o=a,r=e-l),(c>e||e==l&&(n>1?a.length:a.covers(-1)))&&(!i||!a.isWidget()&&i.isWidget())&&(i=a,s=e-l)}}),!o&&!i)throw new Error("No tile at position "+e);return o&&n<0||!i?{tile:o,offset:r}:{tile:i,offset:s}}}class zs extends vg{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let o=new zs(n||document.createElement(e.tagName),e);return n||(o.flags|=4),o}}class cu extends vg{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,o){let r=new cu(n||document.createElement("div"),e);return(!n||!o)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,o){let r=null,i=-1,s=null,a=-1;function l(u,d){for(let f=0,h=0;f<u.children.length&&h<=d;f++){let g=u.children[f],b=h+g.length;b>=d&&(g.isComposite()?l(g,d-h):(!s||s.isHidden&&(n>0||o&&jfe(s,g)))&&(b>d||g.flags&32)?(s=g,a=d-h):(h<d||g.flags&16&&!g.isHidden)&&(r=g,i=d-h)),h=b}}l(this,e);let c=(n<0?r:s)||r||s;return c?{tile:c,offset:c==r?i:a}:null}coordsIn(e,n){let o=this.resolveInline(e,n,!0);return o?o.tile.coordsIn(Math.max(0,o.offset),n):Yfe(this)}domIn(e,n){let o=this.resolveInline(e,n);if(o){let{tile:r,offset:i}=o;if(this.dom.contains(r.dom))return r.isText()?new ci(r.dom,Math.min(r.dom.nodeValue.length,i)):r.domPosFor(i,r.flags&16?1:r.flags&32?-1:n);let s=o.tile.parent,a=!1;for(let l of s.children){if(a)return new ci(l.dom,0);l==o.tile&&(a=!0)}}return new ci(this.dom,0)}}function Yfe(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ap(e);return n[n.length-1]||null}function jfe(t,e){let n=t.coordsIn(0,1),o=e.coordsIn(0,1);return n&&o&&o.top<n.bottom}class Jo extends vg{constructor(e,n){super(e),this.mark=n}get domAttrs(){return this.mark.attrs}static of(e,n){let o=new Jo(n||document.createElement(e.tagName),e);return n||(o.flags|=4),o}}class wl extends Nn{constructor(e,n){super(e,n.length),this.text=n}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,n){let o=this.dom.nodeValue.length;e>o&&(e=o);let r=e,i=e,s=0;e==0&&n<0||e==o&&n>=0?ot.chrome||ot.gecko||(e?(r--,s=1):i<o&&(i++,s=-1)):n<0?r--:i<o&&i++;let a=gf(this.dom,r,i).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];return ot.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?_0(l,s<0):l||null}static of(e,n){let o=new wl(n||document.createTextNode(e),e);return n||(o.flags|=2),o}}class Ul extends Nn{constructor(e,n,o,r){super(e,n,r),this.widget=o}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,o){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(o)return _0(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let i=this.dom.getClientRects(),s=null;if(!i.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?i.length-1:0;s=i[l],!(e>0?l==0:l==i.length-1||s.top<s.bottom);l+=a?-1:1);return _0(s,!a)}}get overrideDOMText(){if(!this.length)return Ut.empty;let{root:e}=this;if(!e)return Ut.empty;let n=this.posAtStart;return e.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,n,o,r,i){return i||(i=e.toDOM(n),e.editable||(i.contentEditable="false")),new Ul(i,o,e,r)}}class S0 extends Nn{constructor(e){let n=document.createElement("img");n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),super(n,0,e)}get isHidden(){return!0}get overrideDOMText(){return Ut.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Xfe{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,o){let{tile:r,index:i,beforeBreak:s,parents:a}=this;for(;e||n>0;)if(r.isComposite())if(s){if(!e)break;o&&o.break(),e--,s=!1}else if(i==r.children.length){if(!e&&!a.length)break;o&&o.leave(r),s=!!r.breakAfter,{tile:r,index:i}=a.pop(),i++}else{let l=r.children[i],c=l.breakAfter;(n>0?l.length<=e:l.length<e)&&(!o||o.skip(l,0,l.length)!==!1||!l.isComposite)?(s=!!c,i++,e-=l.length):(a.push({tile:r,index:i}),r=l,i=0,o&&l.isComposite()&&o.enter(l))}else if(i==r.length)s=!!r.breakAfter,{tile:r,index:i}=a.pop(),i++;else if(e){let l=Math.min(e,r.length-i);o&&o.skip(r,i,i+l),e-=l,i+=l}else break;return this.tile=r,this.index=i,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Kfe{constructor(e,n,o,r){this.from=e,this.to=n,this.wrapper=o,this.rank=r}}class Zfe{constructor(e,n,o){this.cache=e,this.root=n,this.blockWrappers=o,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,n,o,r){var i;this.flushBuffer();let s=this.ensureMarks(n,o),a=s.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let l=s.children[s.children.length-1]=new wl(a.dom,a.text+e);l.parent=s}else s.append(r||wl.of(e,(i=this.cache.find(wl))===null||i===void 0?void 0:i.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,n){let o=this.curLine;o.dom!=n.line.dom&&(o.setDOM(this.cache.reused.has(n.line)?Dv(n.line.dom):n.line.dom),this.cache.reused.set(n.line,2));let r=o;for(let a=n.marks.length-1;a>=0;a--){let l=n.marks[a],c=r.lastChild;if(c instanceof Jo&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Dv(l.dom)),r=c;else{if(this.cache.reused.get(l)){let d=Nn.get(l.dom);d&&d.setDOM(Dv(l.dom))}let u=Jo.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let i=Nn.get(e.text);i&&this.cache.reused.set(i,2);let s=new wl(e.text,e.text.nodeValue);s.flags|=8,r.append(s)}addInlineWidget(e,n,o){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(n,o);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,o){this.flushBuffer(),this.ensureMarks(n,o).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var o;e||(e=UM);let r=cu.start(e,n||((o=this.cache.find(cu))===null||o===void 0?void 0:o.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var o;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let s=e[i],a;if(n>0&&(a=r.lastChild)&&a instanceof Jo&&a.mark.eq(s))r=a,n--;else{let l=Jo.of(s,(o=this.cache.find(Jo,c=>c.mark.eq(s)))===null||o===void 0?void 0:o.dom);r.append(l),r=l,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!gk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(ot.ios&&gk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ev,0,32)||new Ul(Ev.toDOM(),0,Ev,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let n=new Kfe(e.from,e.to,e.value,e.rank),o=this.wrappers.length;for(;o>0&&(this.wrappers[o-1].rank-n.rank||this.wrappers[o-1].to-n.to)<0;)o--;this.wrappers.splice(o,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let o of this.wrappers){let r=n.lastChild;if(o.from<this.pos&&r instanceof zs&&r.wrapper.eq(o.wrapper))n=r;else{let i=zs.of(o.wrapper,(e=this.cache.find(zs,s=>s.wrapper.eq(o.wrapper)))===null||e===void 0?void 0:e.dom);n.append(i),n=i}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),o=this.cache.find(S0,void 0,1);return o&&(o.flags=n),o||new S0(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Qfe{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:i,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=r;let a=this.textOff=Math.min(e,r.length);return i?null:r.slice(0,a)}let n=Math.min(this.text.length,this.textOff+e),o=this.text.slice(this.textOff,n);return this.textOff=n,o}}const A0=[Ul,cu,wl,Jo,S0,zs,bg];for(let t=0;t<A0.length;t++)A0[t].bucket=t;class Jfe{constructor(e){this.view=e,this.buckets=A0.map(()=>[]),this.index=A0.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,o=this.buckets[n];o.length<6?o.push(e):o[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,o=2){let r=e.bucket,i=this.buckets[r],s=this.index[r];for(let a=i.length-1;a>=0;a--){let l=(a+s)%i.length,c=i[l];if((!n||n(c))&&!this.reused.has(c))return i.splice(l,1),l<s&&this.index[r]--,this.reused.set(c,o),c}return null}findWidget(e,n,o){let r=this.buckets[0];if(r.length)for(let i=0,s=0;;i++){if(i==r.length){if(s)return null;s=1,i=0}let a=r[i];if(!this.reused.has(a)&&(s==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,a.widget==e&&a.length==n&&(a.flags&497)==o?(this.reused.set(a,1),a):(this.reused.set(a,2),new Ul(a.dom,n,e,a.flags&-498|o))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,n=2){if(!this.reused.has(e))return this.reused.set(e,n),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class ehe{constructor(e,n,o,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Jfe(e),this.text=new Qfe(e.state.doc),this.builder=new Zfe(this.cache,new bg(e,e.contentDOM),tn.iter(o)),this.cache.reused.set(n,2),this.old=new Xfe(n),this.reuseWalker={skip:(s,a,l)=>{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(e,n){let o=n&&this.getCompositionContext(n.text);for(let r=0,i=0,s=0;;){let a=s<e.length?e[s++]:null,l=a?a.fromA:this.old.root.length;if(l>r){let c=l-r;this.preserve(c,!s,!a),r=l,i+=c}if(!a)break;n&&a.fromA<=n.range.fromA&&a.toA>=n.range.toA?(this.forward(a.fromA,n.range.fromA,n.range.fromA<n.range.toA?1:-1),this.emit(i,n.range.fromB),this.cache.clear(),this.builder.addComposition(n,o),this.text.skip(n.range.toB-n.range.fromB),this.forward(n.range.fromA,a.toA),this.emit(n.range.toB,a.toB)):(this.forward(a.fromA,a.toA),this.emit(i,a.toB)),i=a.toB,r=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,n,o){let r=ohe(this.old),i=this.openMarks;this.old.advance(e,o?1:-1,{skip:(s,a,l)=>{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a<s.length?Ul.of(s.widget,this.view,l-a,s.flags&496,this.cache.maybeReuse(s)):this.cache.reuse(s);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,i),i=r.length)}else if(s.isText())this.builder.ensureLine(null),!a&&l==s.length?this.builder.addText(s.text,r,i,this.cache.reuse(s)):(this.cache.add(s),this.builder.addText(s.text.slice(a,l),r,i)),i=r.length;else if(s.isLine())s.flags&=-2,this.cache.reused.set(s,1),this.builder.addLine(s);else if(s instanceof S0)this.cache.add(s);else if(s instanceof Jo)this.builder.ensureLine(null),this.builder.addMark(s,r,i),this.cache.reused.set(s,1),i=r.length;else return!1;this.openWidget=!1},enter:s=>{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof Jo&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=i=0):s instanceof Jo&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let o=null,r=this.builder,i=0,s=tn.spans(this.decorations,e,n,{point:(a,l,c,u,d,f)=>{if(c instanceof zl){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=u.length,d>u.length)r.continueWidget(l-a);else{let h=c.widget||(c.block?uu.block:uu.inline),g=the(c),b=this.cache.findWidget(h,l-a,g)||Ul.of(h,this.view,l-a,g);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(o),r.addBlockWidget(b)):(r.ensureLine(o),r.addInlineWidget(b,u,d))}o=null}else o=nhe(o,c);l>a&&this.text.skip(l-a)},span:(a,l,c,u)=>{for(let d=a;d<l;){let f=this.text.next(Math.min(512,l-d));f==null?(r.addLineStartIfNotCovered(o),r.addBreak(),d++):(r.ensureLine(o),r.addText(f,c,d==a?u:c.length),d+=f.length),o=null}}});r.addLineStartIfNotCovered(o),this.openWidget=s>i,this.openMarks=s}forward(e,n,o=1){n-e<=10?this.old.advance(n-e,o,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,o,this.reuseWalker))}getCompositionContext(e){let n=[],o=null;for(let r=e.parentNode;;r=r.parentNode){let i=Nn.get(r);if(r==this.view.contentDOM)break;i instanceof Jo?n.push(i):i!=null&&i.isLine()?o=i:i instanceof zs||(r.nodeName=="DIV"&&!o&&r!=this.view.contentDOM?o=new cu(r,UM):o||n.push(Jo.of(new Rf({tagName:r.nodeName.toLowerCase(),attributes:$fe(r)}),r)))}return{line:o,marks:n}}}function gk(t,e){let n=o=>{for(let r of o.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function the(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const UM={class:"cm-line"};function nhe(t,e){let n=e.spec.attributes,o=e.spec.class;return!n&&!o||(t||(t={class:"cm-line"}),n&&Q2(n,t),o&&(t.class+=" "+o)),t}function ohe(t){let e=[];for(let n=t.parents.length;n>1;n--){let o=n==t.parents.length?t.tile:t.parents[n].tile;o instanceof Jo&&e.push(o.mark)}return e}function Dv(t){let e=Nn.get(t);return e&&e.setDOM(t.cloneNode()),t}class uu extends mg{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}uu.inline=new uu("span");uu.block=new uu("div");const Ev=new class extends mg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class vk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Xn.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new bg(e,e.contentDOM),this.updateInner([new Nr(0,0,0,e.state.doc.length)],null)}update(e){var n;let o=e.changedRanges;this.minWidth>0&&o.length&&(o.every(({fromA:u,toA:d})=>d<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!fhe(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?ihe(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:d}=this.hasComposition;o=new Nr(u,d,e.changes.mapPos(u,-1),e.changes.mapPos(d,1)).addToSet(o.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(ot.ie||ot.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,a=this.blockWrappers;this.updateDeco();let l=lhe(s,this.decorations,e.changes);l.length&&(o=Nr.extendWithRanges(o,l));let c=uhe(a,this.blockWrappers,e.changes);return c.length&&(o=Nr.extendWithRanges(o,c)),i&&!o.some(u=>u.fromA<=i.range.fromA&&u.toA>=i.range.toA)&&(o=i.range.addToSet(o.slice())),this.tile.flags&2&&o.length==0?!1:(this.updateInner(o,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:o}=this.view;o.ignore(()=>{if(n||e.length){let s=this.tile,a=new ehe(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=a.run(e,n),Mb(s,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=ot.chrome||ot.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),i&&(i.written||o.selectionRange.focusNode!=i.node||!this.tile.dom.contains(i.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let i of this.tile.children)i.isWidget()&&i.widget instanceof Nv&&r.push(i.dom);o.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let o of n.effects)o.is(RM)&&(this.editContextFormatting=o.value)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:o}=this.tile,r=this.view.root.activeElement,i=r==o,s=!i&&!(this.view.state.facet(Bs)||o.tabIndex>-1)&&Bd(o,this.view.observer.selectionRange)&&!(r&&o.contains(r));if(!(i||n||s))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,u;if(l.empty?u=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(u=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),ot.gecko&&l.empty&&!this.hasComposition&&rhe(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=u=new ci(f,0),a=!0}let d=this.view.observer.selectionRange;(a||!d.focusNode||(!Ld(c.node,c.offset,d.anchorNode,d.anchorOffset)||!Ld(u.node,u.offset,d.focusNode,d.focusOffset))&&!this.suppressWidgetCursorChange(d,l))&&(this.view.observer.ignore(()=>{ot.android&&ot.chrome&&o.contains(d.focusNode)&&dhe(d.focusNode,o)&&(o.blur(),o.focus({preventScroll:!0}));let f=mf(this.view.root);if(f)if(l.empty){if(ot.gecko){let h=she(c.node,c.offset);if(h&&h!=3){let g=(h==1?kM:SM)(c.node,c.offset);g&&(c=new ci(g.node,g.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(u.node,u.offset)}catch{}}else{let h=document.createRange();l.anchor>l.head&&([c,u]=[u,c]),h.setEnd(u.node,u.offset),h.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(h)}s&&this.view.root.activeElement==o&&(o.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new ci(d.anchorNode,d.anchorOffset),this.impreciseHead=u.precise?null:new ci(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Ld(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,o=mf(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!o||!n.empty||!n.assoc||!o.modify)return;let s=this.lineAt(n.head,n.assoc);if(!s)return;let a=s.posAtStart;if(n.head==a||n.head==a+s.length)return;let l=this.coordsAt(n.head,-1),c=this.coordsAt(n.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(n.head+n.assoc,n.assoc);o.collapse(u.node,u.offset),o.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=n.from&&o.collapse(r,i)}posFromDOM(e,n){let o=this.tile.nearest(e);if(!o)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=o.posAtStart;if(o.isComposite()){let i;if(e==o.dom)i=o.dom.childNodes[n];else{let s=Xs(e)==0?0:n==0?-1:1;for(;;){let a=e.parentNode;if(a==o.dom)break;s==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?s=-1:s=1),e=a}s<0?i=e:i=e.nextSibling}if(i==o.dom.firstChild)return r;for(;i&&!Nn.get(i);)i=i.nextSibling;if(!i)return r+o.length;for(let s=0,a=r;;s++){let l=o.children[s];if(l.dom==i)return a;a+=l.length+l.breakAfter}}else return o.isText()?e==o.dom?r+n:r+(n?o.length:0):r}domAtPos(e,n){let{tile:o,offset:r}=this.tile.resolveBlock(e,n);return o.isWidget()?o.domPosFor(e,n):o.domIn(r,n)}inlineDOMNearPos(e,n){let o,r=-1,i=!1,s,a=-1,l=!1;return this.tile.blockTiles((c,u)=>{if(c.isWidget()){if(c.flags&32&&u>=e)return!0;c.flags&16&&(i=!0)}else{let d=u+c.length;if(u<=e&&(o=c,r=e-u,i=d<e),d>=e&&!s&&(s=c,a=e-u,l=u>e),u>e&&s)return!0}}),!o&&!s?this.domAtPos(e,n):(i&&s?o=null:l&&o&&(s=null),o&&n<0||!s?o.domIn(r,n):s.domIn(a,n))}coordsAt(e,n){let{tile:o,offset:r}=this.tile.resolveBlock(e,n);return o.isWidget()?o.widget instanceof Nv?null:o.coordsInWidget(r,n,!0):o.coordsIn(r,n)}lineAt(e,n){let{tile:o}=this.tile.resolveBlock(e,n);return o.isLine()?o:null}coordsForChar(e){let{tile:n,offset:o}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(i,s){if(i.isComposite())for(let a of i.children){if(a.length>=s){let l=r(a,s);if(l)return l}if(s-=a.length,s<0)break}else if(i.isText()&&s<i.length){let a=To(i.text,s);if(a==s)return null;let l=gf(i.dom,s,a).getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(c==l.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}return r(n,o)}measureVisibleLineHeights(e){let n=[],{from:o,to:r}=e,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Dn.LTR,c=0,u=(d,f,h)=>{for(let g=0;g<d.children.length&&!(f>r);g++){let b=d.children[g],m=f+b.length,v=b.dom.getBoundingClientRect(),{height:y}=v;if(h&&!g&&(c+=v.top-h.top),b instanceof zs)m>o&&u(b,f,v);else if(f>=o&&(c>0&&n.push(-c),n.push(y+c),c=0,s)){let x=b.dom.lastChild,_=x?ap(x):[];if(_.length){let k=_[_.length-1],E=l?k.right-v.left:v.right-k.left;E>a&&(a=E,this.minWidth=i,this.minWidthFrom=f,this.minWidthTo=m)}}h&&g==d.children.length-1&&(c+=h.bottom-v.bottom),f=m+b.breakAfter}};return u(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Dn.RTL:Dn.LTR}measureTextSize(){let e=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let a=0,l;for(let c of s.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let u=ap(c.dom);if(u.length!=1)return;a+=u[0].width,l=u[0].height}if(a)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:a/s.length,textHeight:l}}});if(e)return e;let n=document.createElement("div"),o,r,i;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let s=ap(n.firstChild)[0];o=n.getBoundingClientRect().height,r=s&&s.width?s.width/27:7,i=s&&s.height?s.height:o,n.remove()}),{lineHeight:o,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let o=0,r=0;;r++){let i=r==n.viewports.length?null:n.viewports[r],s=i?i.from-1:this.view.state.doc.length;if(s>o){let a=(n.lineBlockAt(s).bottom-n.lineBlockAt(o).top)/this.view.scaleY;e.push(Xn.replace({widget:new Nv(a),block:!0,inclusive:!0,isBlockGap:!0}).range(o,s))}if(!i)break;o=i.to+1}return Xn.set(e)}updateDeco(){let e=1,n=this.view.state.facet(gg).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),o=!1,r=this.view.state.facet(rx).map((i,s)=>{let a=typeof i=="function";return a&&(o=!0),a?i(this.view):i});for(r.length&&(this.dynamicDecorationMap[e++]=o,n.push(tn.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(VM).map(i=>typeof i=="function"?i(this.view):i)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(IM))try{if(c(this.view,e.range,e))return!0}catch(u){ji(this.view.state,u,"scroll handler")}let{range:n}=e,o=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1),r;if(!o)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(o={left:Math.min(o.left,r.left),top:Math.min(o.top,r.top),right:Math.max(o.right,r.right),bottom:Math.max(o.bottom,r.bottom)});let i=WM(this.view),s={left:o.left-i.left,top:o.top-i.top,right:o.right+i.right,bottom:o.bottom+i.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(Ofe(this.view.scrollDOM,s,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Dn.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(o.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||o.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(n.head,1);c&&c.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let n=o=>o.isWidget()||o.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){Mb(this.tile)}}function Mb(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let o of t.children)Mb(o,e)}}function rhe(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function GM(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let o=kM(n.focusNode,n.focusOffset),r=SM(n.focusNode,n.focusOffset),i=o||r;if(r&&o&&r.node!=o.node){let a=Nn.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)i=r;else if(t.docView.lastCompositionAfterCursor){let l=Nn.get(o.node);!l||l.isText()&&l.text!=o.node.nodeValue||(i=r)}}if(t.docView.lastCompositionAfterCursor=i!=o,!i)return null;let s=e-i.offset;return{from:s,to:s+i.node.nodeValue.length,node:i.node}}function ihe(t,e,n){let o=GM(t,n);if(!o)return null;let{node:r,from:i,to:s}=o,a=r.nodeValue;if(/[\n\r]/.test(a)||t.state.doc.sliceString(o.from,o.to)!=a)return null;let l=e.invertedDesc;return{range:new Nr(l.mapPos(i),l.mapPos(s),i,s),text:r}}function she(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let ahe=class{constructor(){this.changes=[]}compareRange(e,n){Fc(e,n,this.changes)}comparePoint(e,n){Fc(e,n,this.changes)}boundChange(e){Fc(e,e,this.changes)}};function lhe(t,e,n){let o=new ahe;return tn.compare(t,e,n,o),o.changes}class che{constructor(){this.changes=[]}compareRange(e,n){Fc(e,n,this.changes)}comparePoint(){}boundChange(e){Fc(e,e,this.changes)}}function uhe(t,e,n){let o=new che;return tn.compare(t,e,n,o),o.changes}function dhe(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function fhe(t,e){let n=!1;return e&&t.iterChangedRanges((o,r)=>{o<e.to&&r>e.from&&(n=!0)}),n}class Nv extends mg{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function hhe(t,e,n=1){let o=t.charCategorizer(e),r=t.doc.lineAt(e),i=e-r.from;if(r.length==0)return ze.cursor(e);i==0?n=1:i==r.length&&(n=-1);let s=i,a=i;n<0?s=To(r.text,i,!1):a=To(r.text,i);let l=o(r.text.slice(s,a));for(;s>0;){let c=To(r.text,s,!1);if(o(r.text.slice(c,s))!=l)break;s=c}for(;a<r.length;){let c=To(r.text,a);if(o(r.text.slice(a,c))!=l)break;a=c}return ze.range(s+r.from,a+r.from)}function phe(t,e,n,o,r){let i=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>t.defaultLineHeight*1.5){let a=t.viewState.heightOracle.textHeight,l=Math.floor((r-n.top-(t.defaultLineHeight-a)*.5)/a);i+=l*t.viewState.heightOracle.lineLength}let s=t.state.sliceDoc(n.from,n.to);return n.from+xfe(s,i,t.state.tabSize)}function mhe(t,e,n){let o=t.lineBlockAt(e);if(Array.isArray(o.type)){let r;for(let i of o.type){if(i.from>e)break;if(!(i.to<e)){if(i.from<e&&i.to>e)return i;(!r||i.type==zr.Text&&(r.type!=i.type||(n<0?i.from<e:i.to>e)))&&(r=i)}}return r||o}return o}function ghe(t,e,n,o){let r=mhe(t,e.head,e.assoc||-1),i=!o||r.type!=zr.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(i){let s=t.dom.getBoundingClientRect(),a=t.textDirectionAt(r.from),l=t.posAtCoords({x:n==(a==Dn.LTR)?s.right-1:s.left+1,y:(i.top+i.bottom)/2});if(l!=null)return ze.cursor(l,n?-1:1)}return ze.cursor(n?r.to:r.from,n?-1:1)}function bk(t,e,n,o){let r=t.state.doc.lineAt(e.head),i=t.bidiSpans(r),s=t.textDirectionAt(r.from);for(let a=e,l=null;;){let c=Hfe(r,i,s,a,n),u=MM;if(!c){if(r.number==(n?t.state.doc.lines:1))return a;u=`
|
|
856
|
+
`,r=t.state.doc.line(r.number+(n?1:-1)),i=t.bidiSpans(r),c=t.visualLineSide(r,!n)}if(l){if(!l(u))return a}else{if(!o)return c;l=o(u)}a=c}}function vhe(t,e,n){let o=t.state.charCategorizer(e),r=o(n);return i=>{let s=o(i);return r==Es.Space&&(r=s),r==s}}function bhe(t,e,n,o){let r=e.head,i=n?1:-1;if(r==(n?t.state.doc.length:0))return ze.cursor(r,e.assoc);let s=e.goalColumn,a,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,(e.empty?e.assoc:0)||(n?1:-1)),u=t.documentTop;if(c)s==null&&(s=c.left-l.left),a=i<0?c.top:c.bottom;else{let g=t.viewState.lineBlockAt(r);s==null&&(s=Math.min(l.right-l.left,t.defaultCharacterWidth*(r-g.from))),a=(i<0?g.top:g.bottom)+u}let d=l.left+s,f=o??t.viewState.heightOracle.textHeight>>1,h=Ob(t,{x:d,y:a+f*i},!1,i);return ze.cursor(h.pos,h.assoc,void 0,s)}function Pd(t,e,n){for(;;){let o=0;for(let r of t)r.between(e-1,e+1,(i,s,a)=>{if(e>i&&e<s){let l=o||n||(e-i<s-e?-1:1);e=l<0?i:s,o=l}});if(!o)return e}}function qM(t,e){let n=null;for(let o=0;o<e.ranges.length;o++){let r=e.ranges[o],i=null;if(r.empty){let s=Pd(t,r.from,0);s!=r.from&&(i=ze.cursor(s,-1))}else{let s=Pd(t,r.from,-1),a=Pd(t,r.to,1);(s!=r.from||a!=r.to)&&(i=ze.range(r.from==r.anchor?s:a,r.from==r.head?s:a))}i&&(n||(n=e.ranges.slice()),n[o]=i)}return n?ze.create(n,e.mainIndex):e}function Iv(t,e,n){let o=Pd(t.state.facet(Vf).map(r=>r(t)),n.from,e.head>n.from?-1:1);return o==n.from?n:ze.cursor(o,o<n.from?1:-1)}class Gi{constructor(e,n){this.pos=e,this.assoc=n}}function Ob(t,e,n,o){let r=t.contentDOM.getBoundingClientRect(),i=r.top+t.viewState.paddingTop,{x:s,y:a}=e,l=a-i,c;for(;;){if(l<0)return new Gi(0,1);if(l>t.viewState.docHeight)return new Gi(t.state.doc.length,-1);if(c=t.elementAtHeight(l),o==null)break;if(c.type==zr.Text){if(o<0?c.to<t.viewport.from:c.from>t.viewport.to)break;let f=t.docView.coordsAt(o<0?c.from:c.to,o>0?-1:1);if(f&&(o<0?f.top<=l+i:f.bottom>=l+i))break}let d=t.viewState.heightOracle.textHeight/2;l=o>0?c.bottom+d:c.top-d}if(t.viewport.from>=c.to||t.viewport.to<=c.from){if(n)return null;if(c.type==zr.Text){let d=phe(t,r,c,s,a);return new Gi(d,d==c.from?1:-1)}}if(c.type!=zr.Text)return l<(c.top+c.bottom)/2?new Gi(c.from,1):new Gi(c.to,-1);let u=t.docView.lineAt(c.from,2);return(!u||u.length!=c.length)&&(u=t.docView.lineAt(c.from,-2)),new yhe(t,s,a,t.textDirectionAt(c.from)).scanTile(u,c.from)}class yhe{constructor(e,n,o,r){this.view=e,this.x=n,this.y=o,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,n){let{line:o,spans:r}=this.bidiSpansAt(e);return r[Yi.find(r,e-o.from,-1,n)].level==this.baseDir}dirAt(e,n){let{line:o,spans:r}=this.bidiSpansAt(e);return r[Yi.find(r,e-o.from,-1,n)].dir}bidiIn(e,n){let{spans:o,line:r}=this.bidiSpansAt(e);return o.length>1||o.length&&(o[0].level!=this.baseDir||o[0].to+r.from<n)}scan(e,n){let o=0,r=e.length-1,i=new Set,s=this.bidiIn(e[0],e[r]),a,l,c=-1,u=1e9,d;e:for(;o<r;){let h=r-o,g=o+r>>1;t:if(i.has(g)){let m=o+Math.floor(Math.random()*h);for(let v=0;v<h;v++){if(!i.has(m)){g=m;break t}m++,m==r&&(m=o)}break e}i.add(g);let b=n(g);if(b)for(let m=0;m<b.length;m++){let v=b[m],y=0;if(v.bottom<this.y)(!a||a.bottom<v.bottom)&&(a=v),y=1;else if(v.top>this.y)(!l||l.top>v.top)&&(l=v),y=-1;else{let x=v.left>this.x?this.x-v.left:v.right<this.x?this.x-v.right:0,_=Math.abs(x);_<u&&(c=g,u=_,d=v),x&&(y=x<0==(this.baseDir==Dn.LTR)?-1:1)}y==-1&&(!s||this.baseDirAt(e[g],1))?r=g:y==1&&(!s||this.baseDirAt(e[g+1],-1))&&(o=g+1)}}if(!d){let h=a&&(!l||this.y-a.bottom<l.top-this.y)?a:l;return this.y=(h.top+h.bottom)/2,this.scan(e,n)}let f=(s?this.dirAt(e[c],1):this.baseDir)==Dn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==f}}scanText(e,n){let o=[];for(let i=0;i<e.length;i=To(e.text,i))o.push(n+i);o.push(n+e.length);let r=this.scan(o,i=>{let s=o[i]-n,a=o[i+1]-n;return gf(e.dom,s,a).getClientRects()});return r.after?new Gi(o[r.i+1],-1):new Gi(o[r.i],1)}scanTile(e,n){if(!e.length)return new Gi(n,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,n);if(a.isComposite())return this.scanTile(a,n)}let o=[n];for(let a=0,l=n;a<e.children.length;a++)o.push(l+=e.children[a].length);let r=this.scan(o,a=>{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:gf(l.dom,0,l.length)).getClientRects()}),i=e.children[r.i],s=o[r.i];return i.isText()?this.scanText(i,s):i.isComposite()?this.scanTile(i,s):r.after?new Gi(o[r.i+1],-1):new Gi(s,1)}}const dd="";class xhe{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(Kt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=dd}readRange(e,n){if(!e)return this;let o=e.parentNode;for(let r=e;;){this.findPointBefore(o,r);let i=this.text.length;this.readNode(r);let s=Nn.get(r),a=r.nextSibling;if(a==n){s!=null&&s.breakAfter&&!a&&o!=this.view.contentDOM&&this.lineBreak();break}let l=Nn.get(a);(s&&l?s.breakAfter:(s?s.breakAfter:w0(r))||w0(a)&&(r.nodeName!="BR"||s!=null&&s.isWidget())&&this.text.length>i)&&!_he(a,n)&&this.lineBreak(),r=a}return this.findPointBefore(o,n),this}readTextNode(e){let n=e.nodeValue;for(let o of this.points)o.node==e&&(o.pos=this.text.length+Math.min(o.offset,n.length));for(let o=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,s=1,a;if(this.lineSeparator?(i=n.indexOf(this.lineSeparator,o),s=this.lineSeparator.length):(a=r.exec(n))&&(i=a.index,s=a[0].length),this.append(n.slice(o,i<0?n.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=s-1);o=i+s}}readNode(e){let n=Nn.get(e),o=n&&n.overrideDOMText;if(o!=null){this.findPointInside(e,o.length);for(let r=o.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let o of this.points)o.node==e&&e.childNodes[o.offset]==n&&(o.pos=this.text.length)}findPointInside(e,n){for(let o of this.points)(e.nodeType==3?o.node==e:e.contains(o.node))&&(o.pos=this.text.length+(whe(e,o.node,o.offset)?n:0))}}function whe(t,e,n){for(;;){if(!e||n<Xs(e))return!1;if(e==t)return!0;n=za(e)+1,e=e.parentNode}}function _he(t,e){let n;for(;!(t==e||!t);t=t.nextSibling){let o=Nn.get(t);if(!(o!=null&&o.isWidget()))return!1;o&&(n||(n=[])).push(o)}if(n)for(let o of n){let r=o.overrideDOMText;if(r!=null&&r.length)return!1}return!0}class yk{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class khe{constructor(e,n,o,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:i,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=YM(e.docView.tile,n,o,0))){let a=i||s?[]:Ahe(e),l=new xhe(a,e);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=Che(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=i&&i.node==a.focusNode&&i.offset==a.focusOffset||!Sb(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=s&&s.node==a.anchorNode&&s.offset==a.anchorOffset||!Sb(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((ot.ios||ot.chrome)&&e.state.selection.main.empty&&l!=c&&(u.from>0||u.to<e.state.doc.length)){let d=Math.min(l,c),f=Math.max(l,c),h=u.from-d,g=u.to-f;(h==0||h==1||d==0)&&(g==0||g==-1||f==e.state.doc.length)&&(l=0,c=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(ze.range(c,l)):this.newSel=ze.single(c,l)}}}function YM(t,e,n,o){if(t.isComposite()){let r=-1,i=-1,s=-1,a=-1;for(let l=0,c=o,u=o;l<t.children.length;l++){let d=t.children[l],f=c+d.length;if(c<e&&f>n)return YM(d,e,n,c);if(f>=e&&r==-1&&(r=l,i=c),c>n&&d.dom.parentNode==t.dom){s=l,a=u;break}u=f,c=f+d.breakAfter}return{from:i,to:a<0?o+t.length:a,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:s<t.children.length&&s>=0?t.children[s].dom:null}}else return t.isText()?{from:o,to:o+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function jM(t,e){let n,{newSel:o}=e,r=t.state.selection.main,i=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:a}=e.bounds,l=r.from,c=null;(i===8||ot.android&&e.text.length<a-s)&&(l=r.to,c="end");let u=XM(t.state.doc.sliceString(s,a,dd),e.text,l-s,c);u&&(ot.chrome&&i==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==dd+dd&&u.toB--,n={from:s+u.from,to:s+u.toA,insert:Ut.of(e.text.slice(u.from,u.toB).split(dd))})}else o&&(!t.hasFocus&&t.state.facet(Bs)||C0(o,r))&&(o=null);if(!n&&!o)return!1;if(!n&&e.typeOver&&!r.empty&&o&&o.main.empty?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:(ot.mac||ot.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(o&&n.insert.length==2&&(o=ze.single(o.main.anchor-1,o.main.head-1)),n={from:n.from,to:n.to,insert:Ut.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,n.from).append(n.insert).append(t.state.doc.slice(n.to,r.to))}:t.state.doc.lineAt(r.from).to<r.to&&t.docView.lineHasWidget(r.to)&&t.inputState.insertingTextAt>Date.now()-50?n={from:r.from,to:r.to,insert:t.state.toText(t.inputState.insertingText)}:ot.chrome&&n&&n.from==n.to&&n.from==r.head&&n.insert.toString()==`
|
|
857
|
+
`&&t.lineWrapping&&(o&&(o=ze.single(o.main.anchor-1,o.main.head-1)),n={from:r.from,to:r.to,insert:Ut.of([" "])}),n)return ix(t,n,o,i);if(o&&!C0(o,r)){let s=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(s=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(o=qM(t.state.facet(Vf).map(l=>l(t)),o))),t.dispatch({selection:o,scrollIntoView:s,userEvent:a}),!0}else return!1}function ix(t,e,n,o=-1){if(ot.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(ot.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Vc(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||o==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Vc(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Vc(t.contentDOM,"Delete",46)))return!0;let i=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let s,a=()=>s||(s=She(t,e,n));return t.state.facet(DM).some(l=>l(t,e.from,e.to,i,a))||t.dispatch(a()),!0}function She(t,e,n){let o,r=t.state,i=r.selection.main,s=-1;if(e.from==e.to&&e.from<i.from||e.from>i.to){let l=e.from<i.from?-1:1,c=l<0?i.from:i.to,u=Pd(r.facet(Vf).map(d=>d(t)),c,l);e.from==u&&(s=u)}if(s>-1)o={changes:e,selection:ze.cursor(e.from+e.insert.length,-1)};else if(e.from>=i.from&&e.to<=i.to&&e.to-e.from>=(i.to-i.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let l=i.from<e.from?r.sliceDoc(i.from,e.from):"",c=i.to>e.to?r.sliceDoc(e.to,i.to):"";o=r.replaceSelection(t.state.toText(l+e.insert.sliceString(0,void 0,t.state.lineBreak)+c))}else{let l=r.changes(e),c=n&&n.main.to<=l.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=i.to+10&&e.to>=i.to-10){let u=t.state.sliceDoc(e.from,e.to),d,f=n&&GM(t,n.main.head);if(f){let g=e.insert.length-(e.to-e.from);d={from:f.from,to:f.to-g}}else d=t.state.doc.lineAt(i.head);let h=i.to-e.to;o=r.changeByRange(g=>{if(g.from==i.from&&g.to==i.to)return{changes:l,range:c||g.map(l)};let b=g.to-h,m=b-u.length;if(t.state.sliceDoc(m,b)!=u||b>=d.from&&m<=d.to)return{range:g};let v=r.changes({from:m,to:b,insert:e.insert}),y=g.to-i.to;return{changes:v,range:c?ze.range(Math.max(0,c.anchor+y),Math.max(0,c.head+y)):g.map(v)}})}else o={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1)),r.update(o,{userEvent:a,scrollIntoView:!0})}function XM(t,e,n,o){let r=Math.min(t.length,e.length),i=0;for(;i<r&&t.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==r&&t.length==e.length)return null;let s=t.length,a=e.length;for(;s>0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(o=="end"){let l=Math.max(0,i-Math.min(s,a));n-=s+l-i}if(s<i&&t.length<e.length){let l=n<=i&&n>=s?i-n:0;i-=l,a=i+(a-s),s=i}else if(a<i){let l=n<=i&&n>=a?i-n:0;i-=l,s=i+(s-a),a=i}return{from:i,toA:s,toB:a}}function Ahe(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}=t.observer.selectionRange;return n&&(e.push(new yk(n,o)),(r!=n||i!=o)&&e.push(new yk(r,i))),e}function Che(t,e){if(t.length==0)return null;let n=t[0].pos,o=t.length==2?t[1].pos:n;return n>-1&&o>-1?ze.single(n+e,o+e):null}function C0(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class $he{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ot.safari&&e.contentDOM.addEventListener("input",()=>null),ot.gecko&&Hhe(e.contentDOM.ownerDocument)}handleEvent(e){!Ehe(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let o=this.handlers[e];if(o){for(let r of o.observers)r(this.view,n);for(let r of o.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=The(e),o=this.handlers,r=this.view.contentDOM;for(let i in n)if(i!="scroll"){let s=!n[i].handlers.length,a=o[i];a&&s!=!a.handlers.length&&(r.removeEventListener(i,this.handleEvent),a=null),a||r.addEventListener(i,this.handleEvent,{passive:s})}for(let i in o)i!="scroll"&&!n[i]&&r.removeEventListener(i,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ZM.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ot.android&&ot.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return ot.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=KM.find(o=>o.keyCode==e.keyCode))&&!e.ctrlKey||Mhe.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Vc(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:ot.safari&&!ot.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function xk(t,e){return(n,o)=>{try{return e.call(t,o,n)}catch(r){ji(n.state,r)}}}function The(t){let e=Object.create(null);function n(o){return e[o]||(e[o]={observers:[],handlers:[]})}for(let o of t){let r=o.spec,i=r&&r.plugin.domEventHandlers,s=r&&r.plugin.domEventObservers;if(i)for(let a in i){let l=i[a];l&&n(a).handlers.push(xk(o.value,l))}if(s)for(let a in s){let l=s[a];l&&n(a).observers.push(xk(o.value,l))}}for(let o in $i)n(o).handlers.push($i[o]);for(let o in Gr)n(o).observers.push(Gr[o]);return e}const KM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Mhe="dthko",ZM=[16,17,18,20,91,92,224,225],Th=6;function Mh(t){return Math.max(0,t)*.7+8}function Ohe(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Bhe{constructor(e,n,o,r){this.view=e,this.startEvent=n,this.style=o,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=Bfe(e.contentDOM),this.atoms=e.state.facet(Vf).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Kt.allowMultipleSelections)&&Lhe(e,n),this.dragging=Dhe(e,n)&&eO(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ohe(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,r=0,i=0,s=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=WM(this.view);e.clientX-l.left<=r+Th?n=-Mh(r-e.clientX):e.clientX+l.right>=s-Th&&(n=Mh(e.clientX-s)),e.clientY-l.top<=i+Th?o=-Mh(i-e.clientY):e.clientY+l.bottom>=a-Th&&(o=Mh(e.clientY-a)),this.setScrollSpeed(n,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,o=qM(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!o.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:o,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Lhe(t,e){let n=t.state.facet(OM);return n.length?n[0](e):ot.mac?e.metaKey:e.ctrlKey}function Phe(t,e){let n=t.state.facet(BM);return n.length?n[0](e):ot.mac?!e.altKey:!e.ctrlKey}function Dhe(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let o=mf(t.root);if(!o||o.rangeCount==0)return!0;let r=o.getRangeAt(0).getClientRects();for(let i=0;i<r.length;i++){let s=r[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function Ehe(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,o;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(o=Nn.get(n))&&o.isWidget()&&!o.isHidden&&o.widget.ignoreEvent(e))return!1;return!0}const $i=Object.create(null),Gr=Object.create(null),QM=ot.ie&&ot.ie_version<15||ot.ios&&ot.webkit_version<604;function Nhe(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),JM(t,n.value)},50)}function yg(t,e,n){for(let o of t.facet(e))n=o(n,t);return n}function JM(t,e){e=yg(t.state,tx,e);let{state:n}=t,o,r=1,i=n.toText(e),s=i.lines==n.selection.ranges.length;if(Bb!=null&&n.selection.ranges.every(l=>l.empty)&&Bb==i.toString()){let l=-1;o=n.changeByRange(c=>{let u=n.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let d=n.toText((s?i.line(r++).text:e)+n.lineBreak);return{changes:{from:u.from,insert:d},range:ze.cursor(c.from+d.length)}})}else s?o=n.changeByRange(l=>{let c=i.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:ze.cursor(l.from+c.length)}}):o=n.replaceSelection(i);t.dispatch(o,{userEvent:"input.paste",scrollIntoView:!0})}Gr.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};$i.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Gr.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};Gr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};$i.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let o of t.state.facet(LM))if(n=o(t,e),n)break;if(!n&&e.button==0&&(n=Rhe(t,e)),n){let o=!t.hasFocus;t.inputState.startMouseSelection(new Bhe(t,e,n,o)),o&&t.observer.ignore(()=>{wM(t.contentDOM);let i=t.root.activeElement;i&&!i.contains(t.contentDOM)&&i.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function wk(t,e,n,o){if(o==1)return ze.cursor(e,n);if(o==2)return hhe(t.state,e,n);{let r=t.docView.lineAt(e,n),i=t.state.doc.lineAt(r?r.posAtEnd:e),s=r?r.posAtStart:i.from,a=r?r.posAtEnd:i.to;return a<t.state.doc.length&&a==i.to&&a++,ze.range(s,a)}}const Ihe=ot.ie&&ot.ie_version<=11;let _k=null,kk=0,Sk=0;function eO(t){if(!Ihe)return t.detail;let e=_k,n=Sk;return _k=t,Sk=Date.now(),kk=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(kk+1)%3:1}function Rhe(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),o=eO(e),r=t.state.selection;return{update(i){i.docChanged&&(n.pos=i.changes.mapPos(n.pos),r=r.map(i.changes))},get(i,s,a){let l=t.posAndSideAtCoords({x:i.clientX,y:i.clientY},!1),c,u=wk(t,l.pos,l.assoc,o);if(n.pos!=l.pos&&!s){let d=wk(t,n.pos,n.assoc,o),f=Math.min(d.from,u.from),h=Math.max(d.to,u.to);u=f<u.from?ze.range(f,h):ze.range(h,f)}return s?r.replaceRange(r.main.extend(u.from,u.to)):a&&o==1&&r.ranges.length>1&&(c=Fhe(r,l.pos))?c:a?r.addRange(u):ze.create([u])}}}function Fhe(t,e){for(let n=0;n<t.ranges.length;n++){let{from:o,to:r}=t.ranges[n];if(o<=e&&r>=e)return ze.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}$i.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let i=r.posAtStart,s=i+r.length;(i>=n.to||s<=n.from)&&(n=ze.range(i,s))}}let{inputState:o}=t;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",yg(t.state,nx,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};$i.dragend=t=>(t.inputState.draggedContent=null,!1);function Ak(t,e,n,o){if(n=yg(t.state,tx,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:i}=t.inputState,s=o&&i&&Phe(t,e)?{from:i.from,to:i.to}:null,a={from:r,insert:n},l=t.state.changes(s?[s,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),t.inputState.draggedContent=null}$i.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let o=Array(n.length),r=0,i=()=>{++r==n.length&&Ak(t,e,o.filter(s=>s!=null).join(t.state.lineBreak),!1)};for(let s=0;s<n.length;s++){let a=new FileReader;a.onerror=i,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(o[s]=a.result),i()},a.readAsText(n[s])}return!0}else{let o=e.dataTransfer.getData("Text");if(o)return Ak(t,e,o,!0),!0}return!1};$i.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=QM?null:e.clipboardData;return n?(JM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Nhe(t),!1)};function Vhe(t,e){let n=t.dom.parentNode;if(!n)return;let o=n.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout(()=>{o.remove(),t.focus()},50)}function zhe(t){let e=[],n=[],o=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:i}of t.selection.ranges){let s=t.doc.lineAt(i);s.number>r&&(e.push(s.text),n.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}o=!0}return{text:yg(t,nx,e.join(t.lineBreak)),ranges:n,linewise:o}}let Bb=null;$i.copy=$i.cut=(t,e)=>{if(!Bd(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:o,linewise:r}=zhe(t.state);if(!n&&!r)return!1;Bb=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"});let i=QM?null:e.clipboardData;return i?(i.clearData(),i.setData("text/plain",n),!0):(Vhe(t,n),!1)};const tO=tl.define();function nO(t,e){let n=[];for(let o of t.facet(EM)){let r=o(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:tO.of(!0)}):null}function oO(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=nO(t.state,e);n?t.dispatch(n):t.update([])}},10)}Gr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),oO(t)};Gr.blur=t=>{t.observer.clearSelectionRange(),oO(t)};Gr.compositionstart=Gr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Gr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,ot.chrome&&ot.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Gr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};$i.beforeinput=(t,e)=>{var n,o;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let i=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),s=e.getTargetRanges();if(i&&s.length){let a=s[0],l=t.posAtDOM(a.startContainer,a.startOffset),c=t.posAtDOM(a.endContainer,a.endOffset);return ix(t,{from:l,to:c,insert:t.state.toText(i)},null),!0}}let r;if(ot.chrome&&ot.android&&(r=KM.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let i=((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return ot.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),ot.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Gr.compositionend(t,e),20),!1};const Ck=new Set;function Hhe(t){Ck.has(t)||(Ck.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const $k=["pre-wrap","normal","pre-line","break-spaces"];let du=!1;function Tk(){du=!1}class Whe{constructor(e){this.lineWrapping=e,this.doc=Ut.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let o=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(o+=Math.max(0,Math.ceil((n-e-o*this.lineLength*.5)/this.lineLength))),this.lineHeight*o}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return $k.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let o=0;o<e.length;o++){let r=e[o];r<0?o++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,o,r,i,s){let a=$k.indexOf(e)>-1,l=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=a||Math.abs(o-this.charWidth)>.1;if(this.lineWrapping=a,this.lineHeight=n,this.charWidth=o,this.textHeight=r,this.lineLength=i,l){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class Uhe{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class ii{constructor(e,n,o,r,i){this.from=e,this.length=n,this.top=o,this.height=r,this._content=i}get type(){return typeof this._content=="number"?zr.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zl?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ii(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var cn=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(cn||(cn={}));const lp=.001;class Ho{constructor(e,n,o=2){this.length=e,this.height=n,this.flags=o}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>lp&&(du=!0),this.height=e)}replace(e,n,o){return Ho.of(o)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,o,r){let i=this,s=o.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:d}=r[a],f=i.lineAt(l,cn.ByPosNoHeight,o.setDoc(n),0,0),h=f.to>=c?f:i.lineAt(c,cn.ByPosNoHeight,o,0,0);for(d+=h.to-c,c=h.to;a>0&&f.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,l<f.from&&(f=i.lineAt(l,cn.ByPosNoHeight,o,0,0));u+=f.from-l,l=f.from;let g=sx.build(o.setDoc(s),e,u,d);i=$0(i,i.replace(l,c,g))}return i.updateHeight(o,0)}static empty(){return new gr(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,o=e.length,r=0,i=0;for(;;)if(n==o)if(r>i*2){let a=e[n-1];a.break?e.splice(--n,1,a.left,null,a.right):e.splice(--n,1,a.left,a.right),o+=1+a.break,r-=a.size}else if(i>r*2){let a=e[o];a.break?e.splice(o,1,a.left,null,a.right):e.splice(o,1,a.left,a.right),o+=2+a.break,i-=a.size}else break;else if(r<i){let a=e[n++];a&&(r+=a.size)}else{let a=e[--o];a&&(i+=a.size)}let s=0;return e[n-1]==null?(s=1,n--):e[n]==null&&(s=1,o++),new qhe(Ho.of(e.slice(0,n)),s,Ho.of(e.slice(o)))}}function $0(t,e){return t==e?t:(t.constructor!=e.constructor&&(du=!0),e)}Ho.prototype.size=1;const Ghe=Xn.replace({});class rO extends Ho{constructor(e,n,o){super(e,n),this.deco=o,this.spaceAbove=0}mainBlock(e,n){return new ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,o,r){return this.spaceAbove&&e<o+this.spaceAbove?new ii(r,0,o,this.spaceAbove,Ghe):this.mainBlock(o,r)}lineAt(e,n,o,r,i){let s=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,o,r,i).join(s):s}forEachLine(e,n,o,r,i,s){e<=i+this.length&&n>=i&&s(this.lineAt(0,cn.ByPos,o,r,i))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,o=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class gr extends rO{constructor(e,n,o){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=o}mainBlock(e,n){return new ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,o){let r=o[0];return o.length==1&&(r instanceof gr||r instanceof to&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof to?r=new gr(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ho.of(o)}updateHeight(e,n=0,o=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(o||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class to extends Ho{constructor(e){super(e,0)}heightMetrics(e,n){let o=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,i=r-o+1,s,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*i);s=l/i,this.length>i+1&&(a=(this.height-l)/(this.length-i-1))}else s=this.height/i;return{firstLine:o,lastLine:r,perLine:s,perChar:a}}blockAt(e,n,o,r){let{firstLine:i,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);if(n.lineWrapping){let c=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-o)/this.height))*this.length)),u=n.doc.lineAt(c),d=a+u.length*l,f=Math.max(o,e-d/2);return new ii(u.from,u.length,f,d,0)}else{let c=Math.max(0,Math.min(s-i,Math.floor((e-o)/a))),{from:u,length:d}=n.doc.line(i+c);return new ii(u,d,o+a*c,a,0)}}lineAt(e,n,o,r,i){if(n==cn.ByHeight)return this.blockAt(e,o,r,i);if(n==cn.ByPosNoHeight){let{from:h,to:g}=o.doc.lineAt(e);return new ii(h,g-h,0,0,0)}let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(o,i),c=o.doc.lineAt(e),u=a+c.length*l,d=c.number-s,f=r+a*d+l*(c.from-i-d);return new ii(c.from,c.length,Math.max(r,Math.min(f,r+this.height-u)),u,0)}forEachLine(e,n,o,r,i,s){e=Math.max(e,i),n=Math.min(n,i+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(o,i);for(let u=e,d=r;u<=n;){let f=o.doc.lineAt(u);if(u==e){let g=f.number-a;d+=l*g+c*(e-i-g)}let h=l+c*f.length;s(new ii(f.from,f.length,d,h,0)),d+=h,u=f.to+1}}replace(e,n,o){let r=this.length-n;if(r>0){let i=o[o.length-1];i instanceof to?o[o.length-1]=new to(i.length+r):o.push(null,new to(r-1))}if(e>0){let i=o[0];i instanceof to?o[0]=new to(e+i.length):o.unshift(new to(e-1),null)}return Ho.of(o)}decomposeLeft(e,n){n.push(new to(e-1),null)}decomposeRight(e,n){n.push(null,new to(this.length-e-1))}updateHeight(e,n=0,o=!1,r){let i=n+this.length;if(r&&r.from<=n+this.length&&r.more){let s=[],a=Math.max(n,r.from),l=-1;for(r.from>n&&s.push(new to(r.from-n-1).updateHeight(e,n));a<=i&&r.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let d=r.heights[r.index++],f=0;d<0&&(f=-d,d=r.heights[r.index++]),l==-1?l=d:Math.abs(d-l)>=lp&&(l=-2);let h=new gr(u,d,f);h.outdated=!1,s.push(h),a+=u+1}a<=i&&s.push(null,new to(i-a).updateHeight(e,a));let c=Ho.of(s);return(l<0||Math.abs(c.height-this.height)>=lp||Math.abs(l-this.heightMetrics(e,n).perLine)>=lp)&&(du=!0),$0(this,c)}else(o||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class qhe extends Ho{constructor(e,n,o){super(e.length+n+o.length,e.height+o.height,n|(e.outdated||o.outdated?2:0)),this.left=e,this.right=o,this.size=e.size+o.size}get break(){return this.flags&1}blockAt(e,n,o,r){let i=o+this.left.height;return e<i?this.left.blockAt(e,n,o,r):this.right.blockAt(e,n,i,r+this.left.length+this.break)}lineAt(e,n,o,r,i){let s=r+this.left.height,a=i+this.left.length+this.break,l=n==cn.ByHeight?e<s:e<a,c=l?this.left.lineAt(e,n,o,r,i):this.right.lineAt(e,n,o,s,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=n==cn.ByPosNoHeight?cn.ByPosNoHeight:cn.ByPos;return l?c.join(this.right.lineAt(a,u,o,s,a)):this.left.lineAt(a,u,o,r,i).join(c)}forEachLine(e,n,o,r,i,s){let a=r+this.left.height,l=i+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,n,o,r,i,s),n>=l&&this.right.forEachLine(e,n,o,a,l,s);else{let c=this.lineAt(l,cn.ByPos,o,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,o,r,i,s),c.to>=e&&c.from<=n&&s(c),n>c.to&&this.right.forEachLine(c.to+1,n,o,a,l,s)}}replace(e,n,o){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,o),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,o));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let a of o)i.push(a);if(e>0&&Mk(i,s-1),n<this.length){let a=i.length;this.decomposeRight(n,i),Mk(i,a)}return Ho.of(i)}decomposeLeft(e,n){let o=this.left.length;if(e<=o)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(o++,e>=o&&n.push(null)),e>o&&this.right.decomposeLeft(e-o,n)}decomposeRight(e,n){let o=this.left.length,r=o+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<o&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Ho.of(this.break?[e,null,n]:[e,n]):(this.left=$0(this.left,e),this.right=$0(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,o=!1,r){let{left:i,right:s}=this,a=n+i.length+this.break,l=null;return r&&r.from<=n+i.length&&r.more?l=i=i.updateHeight(e,n,o,r):i.updateHeight(e,n,o),r&&r.from<=a+s.length&&r.more?l=s=s.updateHeight(e,a,o,r):s.updateHeight(e,a,o),l?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Mk(t,e){let n,o;t[e]==null&&(n=t[e-1])instanceof to&&(o=t[e+1])instanceof to&&t.splice(e-1,3,new to(n.length+1+o.length))}const Yhe=5;class sx{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let o=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof gr?r.length+=o-this.pos:(o>this.pos||!this.isCovered)&&this.nodes.push(new gr(o-this.pos,-1,0)),this.writtenTo=o,n>o&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,o){if(e<n||o.heightRelevant){let r=o.widget?o.widget.estimatedHeight:0,i=o.widget?o.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let s=n-e;o.block?this.addBlock(new rO(s,r,o)):(s||i||r>=Yhe)&&this.addLineDeco(r,i,s)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new gr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let o=new to(n-e);return this.oracle.doc.lineAt(e).to==n&&(o.flags|=4),o}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof gr)return e;let n=new gr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,o){let r=this.ensureLine();r.length+=o,r.collapsed+=o,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+o}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof gr)&&!this.isCovered?this.nodes.push(new gr(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let o=e;for(let r of this.nodes)r instanceof gr&&r.updateHeight(this.oracle,o),o+=r?r.length:1;return this.nodes}static build(e,n,o,r){let i=new sx(o,e);return tn.spans(n,o,r,i,0),i.finish(o)}}function jhe(t,e,n){let o=new Xhe;return tn.compare(t,e,n,o,0),o.changes}class Xhe{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,o,r){(e<n||o&&o.heightRelevant||r&&r.heightRelevant)&&Fc(e,n,this.changes,5)}}function Khe(t,e){let n=t.getBoundingClientRect(),o=t.ownerDocument,r=o.defaultView||window,i=Math.max(0,n.left),s=Math.min(r.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let c=t.parentNode;c&&c!=o.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let f=u.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),a=Math.max(a,f.top),l=Math.min(c==t.parentNode?r.innerHeight:l,f.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-n.left,right:Math.max(i,s)-n.left,top:a-(n.top+e),bottom:Math.max(a,l)-(n.top+e)}}function Zhe(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function Qhe(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Rv{constructor(e,n,o,r){this.from=e,this.to=n,this.size=o,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],i=n[o];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,n){return Xn.replace({widget:new Jhe(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Jhe extends mg{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Ok{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Bk,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Dn.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(ox).some(o=>typeof o!="function"&&o.class=="cm-lineWrapping");this.heightOracle=new Whe(n),this.stateDeco=Lk(e),this.heightMap=Ho.empty().applyChanges(this.stateDeco,Ut.empty,this.heightOracle.setDoc(e.doc),[new Nr(0,0,0,e.doc.length)]);for(let o=0;o<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());o++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Xn.set(this.lineGaps.map(o=>o.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let o=0;o<=1;o++){let r=o?n.head:n.anchor;if(!e.some(({from:i,to:s})=>r>=i&&r<=s)){let{from:i,to:s}=this.lineBlockAt(r);e.push(new Oh(i,s))}}return this.viewports=e.sort((o,r)=>o.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Bk:new ax(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(fd(e,this.scaler))})}update(e,n=null){this.state=e.state;let o=this.stateDeco;this.stateDeco=Lk(this.state);let r=e.changedRanges,i=Nr.extendWithRanges(r,jhe(o,this.stateDeco,e?e.changes:zn.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Tk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=s||du)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<l.from||n.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,n));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ufe)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,o=window.getComputedStyle(n),r=this.heightOracle,i=o.whiteSpace;this.defaultTextDirection=o.direction=="rtl"?Dn.RTL:Dn.LTR;let s=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent==="refresh",a=n.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:_,scaleY:k}=xM(n,a);(_>.005&&Math.abs(this.scaleX-_)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=_,this.scaleY=k,c|=16,s=l=!0)}let d=(parseInt(o.paddingTop)||0)*this.scaleY,f=(parseInt(o.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let h=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=h&&(this.scrollAnchorHeight=-1,this.scrollTop=h),this.scrolledToBottom=_M(e.scrollDOM);let g=(this.printing?Qhe:Khe)(n,this.paddingTop),b=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget&&!Zhe(e.dom))return 0;let y=a.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let _=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(_)&&(s=!0),s||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:E,textHeight:B}=e.docView.measureTextSize();s=k>0&&r.refresh(i,k,E,B,Math.max(5,y/E),_),s&&(e.docView.minWidth=0,c|=16)}b>0&&m>0?u=Math.max(b,m):b<0&&m<0&&(u=Math.min(b,m)),Tk();for(let k of this.viewports){let E=k.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(k);this.heightMap=(s?Ho.empty().applyChanges(this.stateDeco,Ut.empty,this.heightOracle,[new Nr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new Uhe(k.from,E))}du&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let o=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:s,visibleBottom:a}=this,l=new Oh(r.lineAt(s-o*1e3,cn.ByHeight,i,0,0).from,r.lineAt(a+(1-o)*1e3,cn.ByHeight,i,0,0).to);if(n){let{head:c}=n.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=r.lineAt(c,cn.ByPos,i,0,0),f;n.y=="center"?f=(d.top+d.bottom)/2-u/2:n.y=="start"||n.y=="nearest"&&c<l.from?f=d.top:f=d.bottom-u,l=new Oh(r.lineAt(f-1e3/2,cn.ByHeight,i,0,0).from,r.lineAt(f+u+1e3/2,cn.ByHeight,i,0,0).to)}}return l}mapViewport(e,n){let o=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new Oh(this.heightMap.lineAt(o,cn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,cn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},o=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,cn.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(n,cn.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:a}=this;return(e==0||r<=s-Math.max(10,Math.min(-o,250)))&&(n==this.state.doc.length||i>=a+Math.max(10,Math.min(o,250)))&&r>s-2*1e3&&i<a+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let o=[];for(let r of e)n.touchesRange(r.from,r.to)||o.push(new Rv(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return o}ensureLineGaps(e,n){let o=this.heightOracle.lineWrapping,r=o?1e4:2e3,i=r>>1,s=r<<1;if(this.defaultTextDirection!=Dn.LTR&&!o)return[];let a=[],l=(u,d,f,h)=>{if(d-u<i)return;let g=this.state.selection.main,b=[g.from];g.empty||b.push(g.to);for(let v of b)if(v>u&&v<d){l(u,v-10,f,h),l(v+10,d,f,h);return}let m=tpe(e,v=>v.from>=f.from&&v.to<=f.to&&Math.abs(v.from-u)<i&&Math.abs(v.to-d)<i&&!b.some(y=>v.from<y&&v.to>y));if(!m){if(d<f.to&&n&&o&&n.visibleRanges.some(x=>x.from<=d&&x.to>=d)){let x=n.moveToLineBoundary(ze.cursor(d),!1,!0).head;x>u&&(d=x)}let v=this.gapSize(f,u,d,h),y=o||v<2e6?v:2e6;m=new Rv(u,d,v,y)}a.push(m)},c=u=>{if(u.length<s||u.type!=zr.Text)return;let d=epe(u.from,u.to,this.stateDeco);if(d.total<s)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,h,g;if(o){let b=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,v;if(f!=null){let y=Lh(d,f),x=((this.visibleBottom-this.visibleTop)/2+b)/u.height;m=y-x,v=y+x}else m=(this.visibleTop-u.top-b)/u.height,v=(this.visibleBottom-u.top+b)/u.height;h=Bh(d,m),g=Bh(d,v)}else{let b=d.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,v=0;if(b>2e6)for(let E of e)E.from>=u.from&&E.from<u.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+v<this.pixelViewport.left&&(v=E.size-E.displaySize);let y=this.pixelViewport.left+v,x=this.pixelViewport.right+v,_,k;if(f!=null){let E=Lh(d,f),B=((x-y)/2+m)/b;_=E-B,k=E+B}else _=(y-m)/b,k=(x+m)/b;h=Bh(d,_),g=Bh(d,k)}h>u.from&&l(u.from,h,u,d),g<u.to&&l(g,u.to,u,d)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,n,o,r){let i=Lh(r,o)-Lh(r,n);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Rv.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Xn.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let o=[];tn.spans(n,this.viewport.from,this.viewport.to,{span(i,s){o.push({from:i,to:s})},point(){}},20);let r=0;if(o.length!=this.visibleRanges.length)r=12;else for(let i=0;i<o.length&&!(r&8);i++){let s=this.visibleRanges[i],a=o[i];(s.from!=a.from||s.to!=a.to)&&(r|=4,e&&e.mapPos(s.from,-1)==a.from&&e.mapPos(s.to,1)==a.to||(r|=8))}return this.visibleRanges=o,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||fd(this.heightMap.lineAt(e,cn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||fd(this.heightMap.lineAt(this.scaler.fromDOM(e),cn.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return fd(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Oh{constructor(e,n){this.from=e,this.to=n}}function epe(t,e,n){let o=[],r=t,i=0;return tn.spans(n,t,e,{span(){},point(s,a){s>r&&(o.push({from:r,to:s}),i+=s-r),r=a}},20),r<e&&(o.push({from:r,to:e}),i+=e-r),{total:i,ranges:o}}function Bh({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let o=Math.floor(t*n);for(let r=0;;r++){let{from:i,to:s}=e[r],a=s-i;if(o<=a)return i+o;o-=a}}function Lh(t,e){let n=0;for(let{from:o,to:r}of t.ranges){if(e<=r){n+=e-o;break}n+=r-o}return n/t.total}function tpe(t,e){for(let n of t)if(e(n))return n}const Bk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Lk(t){let e=t.facet(gg).filter(o=>typeof o!="function"),n=t.facet(rx).filter(o=>typeof o!="function");return n.length&&e.push(tn.join(n)),e}class ax{constructor(e,n,o){let r=0,i=0,s=0;this.viewports=o.map(({from:a,to:l})=>{let c=n.lineAt(a,cn.ByPos,e,0,0).top,u=n.lineAt(l,cn.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let a of this.viewports)a.domTop=s+(a.top-i)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),i=a.bottom}toDOM(e){for(let n=0,o=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.top)return r+(e-o)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);o=i.bottom,r=i.domBottom}}fromDOM(e){for(let n=0,o=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.domTop)return o+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);o=i.bottom,r=i.domBottom}}eq(e){return e instanceof ax?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,o)=>n.from==e.viewports[o].from&&n.to==e.viewports[o].to):!1}}function fd(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),o=e.toDOM(t.bottom);return new ii(t.from,t.length,n,o-n,Array.isArray(t._content)?t._content.map(r=>fd(r,e)):t._content)}const Ph=pt.define({combine:t=>t.join(" ")}),Lb=pt.define({combine:t=>t.indexOf(!0)>-1}),Pb=Fa.newName(),iO=Fa.newName(),sO=Fa.newName(),aO={"&light":"."+iO,"&dark":"."+sO};function Db(t,e,n){return new Fa(e,{finish(o){return/&/.test(o)?o.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+o}})}const npe=Db("."+Pb,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},aO),ope={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fv=ot.ie&&ot.ie_version<=11;class rpe{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Lfe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let o of n)this.queue.push(o);(ot.ie&&ot.ie_version<=11||ot.ios&&e.composing)&&n.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&ot.android&&e.constructor.EDIT_CONTEXT!==!1&&!(ot.chrome&&ot.chrome_version<126)&&(this.editContext=new spe(e),e.state.facet(Bs)&&(e.contentDOM.editContext=this.editContext.editContext)),Fv&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,o)=>n!=e[o]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:o}=this,r=this.selectionRange;if(o.state.facet(Bs)?o.root.activeElement!=this.dom:!Bd(this.dom,r))return;let i=r.anchorNode&&o.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(ot.ie&&ot.ie_version<=11||ot.android&&ot.chrome)&&!o.state.selection.main.empty&&r.focusNode&&Ld(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=mf(e.root);if(!n)return!1;let o=ot.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&ipe(this.view,n)||n;if(!o||this.selectionRange.eq(o))return!1;let r=Bd(this.dom,o);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Dfe(this.dom,o)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(o),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let o=this.dom;o;)if(o.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==o?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let o of this.scrollTargets)o.removeEventListener("scroll",this.onScroll);for(let o of this.scrollTargets=n)o.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ope),Fv&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fv&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var o;if(!this.delayedAndroidKey){let r=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Vc(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((o=this.delayedAndroidKey)===null||o===void 0)&&o.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,o=-1,r=!1;for(let i of e){let s=this.readMutation(i);s&&(s.typeOver&&(r=!0),n==-1?{from:n,to:o}=s:(n=Math.min(s.from,n),o=Math.max(s.to,o)))}return{from:n,to:o,typeOver:r}}readChange(){let{from:e,to:n,typeOver:o}=this.processRecords(),r=this.selectionChanged&&Bd(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new khe(this.view,e,n,o);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let o=this.view.state,r=jM(this.view,n);return this.view.state==o&&(n.domChanged||n.newSel&&!C0(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let o=Pk(n,e.previousSibling||e.target.previousSibling,-1),r=Pk(n,e.nextSibling||e.target.nextSibling,1);return{from:o?n.posAfter(o):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Bs)!=e.state.facet(Bs)&&(e.view.contentDOM.editContext=e.state.facet(Bs)?this.editContext.editContext:null))}destroy(){var e,n,o;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(o=this.resizeScroll)===null||o===void 0||o.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Pk(t,e,n){for(;e;){let o=Nn.get(e);if(o&&o.parent==t)return o;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function Dk(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.docView.domAtPos(t.state.selection.main.anchor,1);return Ld(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function ipe(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Dk(t,r)}let n=null;function o(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",o,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",o,!0),n?Dk(t,n):null}class spe{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=o=>{let r=e.state.selection.main,{anchor:i,head:s}=r,a=this.toEditorPos(o.updateRangeStart),l=this.toEditorPos(o.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:o.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>o.text.length;a==this.from&&i<this.from?a=i:l==this.to&&i>this.to&&(l=i);let u=XM(e.state.sliceDoc(a,l),o.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let f=ze.single(this.toEditorPos(o.selectionStart),this.toEditorPos(o.selectionEnd));C0(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let d={from:u.from+a,to:u.toA+a,insert:Ut.of(o.text.slice(u.from,u.toB).split(`
|
|
858
|
+
`))};if((ot.mac||ot.android)&&d.from==s-1&&/^\. ?$/.test(o.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(d={from:a,to:l,insert:Ut.of([o.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let f=this.to-this.from+(d.to-d.from+d.insert.length);ix(e,d,ze.single(this.toEditorPos(o.selectionStart,f),this.toEditorPos(o.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from<d.to&&!d.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,o.updateRangeStart-1),Math.min(n.text.length,o.updateRangeStart+1)))&&this.handlers.compositionend(o)},this.handlers.characterboundsupdate=o=>{let r=[],i=null;for(let s=this.toEditorPos(o.rangeStart),a=this.toEditorPos(o.rangeEnd);s<a;s++){let l=e.coordsForChar(s);i=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||i||new DOMRect,r.push(i)}n.updateCharacterBounds(o.rangeStart,r)},this.handlers.textformatupdate=o=>{let r=[];for(let i of o.getTextFormats()){let s=i.underlineStyle,a=i.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(a)){let l=this.toEditorPos(i.rangeStart),c=this.toEditorPos(i.rangeEnd);if(l<c){let u=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;r.push(Xn.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:RM.of(Xn.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:o}=this.composing;this.composing=null,o&&this.reset(e.state)}};for(let o in this.handlers)n.addEventListener(o,this.handlers[o]);this.measureReq={read:o=>{this.editContext.updateControlBounds(o.contentDOM.getBoundingClientRect());let r=mf(o.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,o=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,s,a,l,c)=>{if(o)return;let u=c.length-(s-i);if(r&&s>=r.to)if(r.from==i&&r.to==s&&r.insert.eq(c)){r=this.pendingContextChange=null,n+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(i+=n,s+=n,s<=this.from)this.from+=u,this.to+=u;else if(i<this.to){if(i<this.from||s>this.to||this.to-this.from+c.length>3e4){o=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(s),c.toString()),this.to+=u}n+=u}),r&&!o&&this.revertPending(e.state),!o}update(e){let n=this.pendingContextChange,o=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(o.from,o.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,o=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=o||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(o,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let o=this.composing;return o&&o.drifted?o.editorBase+(e-o.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class _t{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:o}=e;this.dispatchTransactions=e.dispatchTransactions||o&&(r=>r.forEach(i=>o(i,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pfe(e.parent)||document,this.viewState=new Ok(e.state||Kt.create(e)),e.scrollTo&&e.scrollTo.is($h)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ac).map(r=>new Pv(r));for(let r of this.plugins)r.update(this);this.observer=new rpe(this),this.inputState=new $he(this),this.inputState.ensureHandlers(this.plugins),this.docView=new vk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Wn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,o=!1,r,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let s=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(tO))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=nO(i,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Kt.phrases)!=this.state.facet(Kt.phrases))return this.setState(i);r=k0.create(this,i,e),r.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:h}=f.state.selection;d=new zc(h.empty?h:ze.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of f.effects)h.is($h)&&(d=h.value.clip(this.state))}this.viewState.update(r,d),this.bidiCache=T0.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(ud)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Ph)!=r.state.facet(Ph)&&(this.viewState.mustMeasureContent=!0),(n||o||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Tb))try{f(r)}catch(h){ji(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!jM(this,u)&&c.force&&Vc(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let o of this.plugins)o.destroy(this);this.viewState=new Ok(e),this.plugins=e.facet(Ac).map(o=>new Pv(o)),this.pluginMap.clear();for(let o of this.plugins)o.update(this);this.docView.destroy(),this.docView=new vk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Ac),o=e.state.facet(Ac);if(n!=o){let r=[];for(let i of o){let s=n.indexOf(i);if(s<0)r.push(new Pv(i));else{let a=this.plugins[s];a.mustUpdate=e,r.push(a)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=o&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(o){ji(this.state,o,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,o=this.scrollDOM,r=o.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:s}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(_M(o))i=-1,s=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(r);i=h.from,s=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(g){return ji(this.state,g),Ek}}),d=k0.create(this,this.state,[]),f=!1;d.flags|=l,n?n.flags|=l:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d),f&&this.docViewUpdate());for(let h=0;h<c.length;h++)if(u[h]!=Ek)try{let g=c[h];g.write&&g.write(u[h],this)}catch(g){ji(this.state,g)}if(f&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let g=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-s;if(g>1||g<-1){r=r+g,o.scrollTop=r/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(Tb))a(n)}get themeClasses(){return Pb+" "+(this.state.facet(Lb)?sO:iO)+" "+this.state.facet(Ph)}updateAttrs(){let e=Nk(this,FM,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Bs)?"true":"false",class:"cm-content",style:`${ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Nk(this,ox,n);let o=this.observer.ignore(()=>{let r=dk(this.contentDOM,this.contentAttrs,n),i=dk(this.dom,this.editorAttrs,e);return r||i});return this.editorAttrs=e,this.contentAttrs=n,o}showAnnouncements(e){let n=!0;for(let o of e)for(let r of o.effects)if(r.is(_t.announce)){n&&(this.announceDOM.textContent=""),n=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(ud);let e=this.state.facet(_t.cspNonce);Fa.mount(this.root,this.styleModules.concat(npe).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(o=>o.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,o){return Iv(this,e,bk(this,e,n,o))}moveByGroup(e,n){return Iv(this,e,bk(this,e,n,o=>vhe(this,e.head,o)))}visualLineSide(e,n){let o=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=o[n?o.length-1:0];return ze.cursor(i.side(n,r)+e.from,i.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,o=!0){return ghe(this,e,n,o)}moveVertically(e,n,o){return Iv(this,e,bhe(this,e,n,o))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let o=Ob(this,e,n);return o&&o.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Ob(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let o=this.docView.coordsAt(e,n);if(!o||o.left==o.right)return o;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Yi.find(i,e-r.from,-1,n)];return _0(o,s.dir==Dn.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(NM)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ape)return TM(e.length);let n=this.textDirectionAt(e.from),o;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||$M(i.isolates,o=pk(this,e))))return i.order;o||(o=pk(this,e));let r=zfe(e.text,n,o);return this.bidiCache.push(new T0(e.from,e.to,n,o,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ot.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{wM(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return $h.of(new zc(typeof e=="number"?ze.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,o=this.viewState.scrollAnchorAt(e);return $h.of(new zc(ze.cursor(o.from),"start","start",o.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Wl.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Wl.define(()=>({}),{eventObservers:e})}static theme(e,n){let o=Fa.newName(),r=[Ph.of(o),ud.of(Db(`.${o}`,e))];return n&&n.dark&&r.push(Lb.of(!0)),r}static baseTheme(e){return X2.lowest(ud.of(Db("."+Pb,e,aO)))}static findFromDOM(e){var n;let o=e.querySelector(".cm-content"),r=o&&Nn.get(o)||Nn.get(e);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}_t.styleModule=ud;_t.inputHandler=DM;_t.clipboardInputFilter=tx;_t.clipboardOutputFilter=nx;_t.scrollHandler=IM;_t.focusChangeEffect=EM;_t.perLineTextDirection=NM;_t.exceptionSink=PM;_t.updateListener=Tb;_t.editable=Bs;_t.mouseSelectionStyle=LM;_t.dragMovesSelection=BM;_t.clickAddsSelectionRange=OM;_t.decorations=gg;_t.blockWrappers=VM;_t.outerDecorations=rx;_t.atomicRanges=Vf;_t.bidiIsolatedRanges=zM;_t.scrollMargins=HM;_t.darkTheme=Lb;_t.cspNonce=pt.define({combine:t=>t.length?t[0]:""});_t.contentAttributes=ox;_t.editorAttributes=FM;_t.lineWrapping=_t.contentAttributes.of({class:"cm-lineWrapping"});_t.announce=$n.define();const ape=4096,Ek={};class T0{constructor(e,n,o,r,i,s){this.from=e,this.to=n,this.dir=o,this.isolates=r,this.fresh=i,this.order=s}static update(e,n){if(n.empty&&!e.some(i=>i.fresh))return e;let o=[],r=e.length?e[e.length-1].dir:Dn.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let s=e[i];s.dir==r&&!n.touchesRange(s.from,s.to)&&o.push(new T0(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return o}}function Nk(t,e,n){for(let o=t.state.facet(e),r=o.length-1;r>=0;r--){let i=o[r],s=typeof i=="function"?i(t):i;s&&Q2(s,n)}return n}const lpe=ot.mac?"mac":ot.windows?"win":ot.linux?"linux":"key";function cpe(t,e){const n=t.split(/-(?!$)/);let o=n[n.length-1];o=="Space"&&(o=" ");let r,i,s,a;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(o="Alt-"+o),i&&(o="Ctrl-"+o),a&&(o="Meta-"+o),s&&(o="Shift-"+o),o}function Dh(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const upe=X2.default(_t.domEventHandlers({keydown(t,e){return ppe(dpe(e.state),t,e,"editor")}})),lO=pt.define({enables:upe}),Ik=new WeakMap;function dpe(t){let e=t.facet(lO),n=Ik.get(e);return n||Ik.set(e,n=hpe(e.reduce((o,r)=>o.concat(r),[]))),n}let ya=null;const fpe=4e3;function hpe(t,e=lpe){let n=Object.create(null),o=Object.create(null),r=(s,a)=>{let l=o[s];if(l==null)o[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},i=(s,a,l,c,u)=>{var d,f;let h=n[s]||(n[s]=Object.create(null)),g=a.split(/ (?!$)/).map(v=>cpe(v,e));for(let v=1;v<g.length;v++){let y=g.slice(0,v).join(" ");r(y,!0),h[y]||(h[y]={preventDefault:!0,stopPropagation:!1,run:[x=>{let _=ya={view:x,prefix:y,scope:s};return setTimeout(()=>{ya==_&&(ya=null)},fpe),!0}]})}let b=g.join(" ");r(b,!1);let m=h[b]||(h[b]={preventDefault:!1,stopPropagation:!1,run:((f=(d=h._any)===null||d===void 0?void 0:d.run)===null||f===void 0?void 0:f.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let s of t){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=s;for(let f in u)u[f].run.push(h=>d(h,Eb))}let l=s[e]||s.key;if(l)for(let c of a)i(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&i(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return n}let Eb=null;function ppe(t,e,n,o){Eb=e;let r=Sfe(e),i=ife(r,0),s=sfe(i)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;ya&&ya.view==n&&ya.scope==o&&(a=ya.prefix+" ",ZM.indexOf(e.keyCode)<0&&(c=!0,ya=null));let d=new Set,f=m=>{if(m){for(let v of m.run)if(!d.has(v)&&(d.add(v),v(n)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},h=t[o],g,b;return h&&(f(h[a+Dh(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ot.windows&&e.ctrlKey&&e.altKey)&&!(ot.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(g=Va[e.keyCode])&&g!=r?(f(h[a+Dh(g,e,!0)])||e.shiftKey&&(b=hf[e.keyCode])!=r&&b!=g&&f(h[a+Dh(b,e,!1)]))&&(l=!0):s&&e.shiftKey&&f(h[a+Dh(r,e,!0)])&&(l=!0),!l&&f(h._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),Eb=null,l}class fu extends Vl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}fu.prototype.elementClass="";fu.prototype.toDOM=void 0;fu.prototype.mapMode=br.TrackBefore;fu.prototype.startSide=fu.prototype.endSide=-1;fu.prototype.point=!0;const cO=1024;let mpe=0;class Vv{constructor(e,n){this.from=e,this.to=n}}class Nt{constructor(e={}){this.id=mpe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=lr.match(e)),n=>{let o=e(n);return o===void 0?null:[this,o]}}}Nt.closedBy=new Nt({deserialize:t=>t.split(" ")});Nt.openedBy=new Nt({deserialize:t=>t.split(" ")});Nt.group=new Nt({deserialize:t=>t.split(" ")});Nt.isolate=new Nt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Nt.contextHash=new Nt({perNode:!0});Nt.lookAhead=new Nt({perNode:!0});Nt.mounted=new Nt({perNode:!0});class Dd{constructor(e,n,o,r=!1){this.tree=e,this.overlay=n,this.parser=o,this.bracketed=r}static get(e){return e&&e.props&&e.props[Nt.mounted.id]}}const gpe=Object.create(null);class lr{constructor(e,n,o,r=0){this.name=e,this.props=n,this.id=o,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):gpe,o=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new lr(e.name||"",n,e.id,o);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Nt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let o in e)for(let r of o.split(" "))n[r]=e[o];return o=>{for(let r=o.prop(Nt.group),i=-1;i<(r?r.length:0);i++){let s=n[i<0?o.name:r[i]];if(s)return s}}}}lr.none=new lr("",Object.create(null),0,8);class lx{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let o of this.types){let r=null;for(let i of e){let s=i(o);if(s){r||(r=Object.assign({},o.props));let a=s[1],l=s[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}n.push(r?new lr(o.name,r,o.id,o.flags):o)}return new lx(n)}}const Eh=new WeakMap,Rk=new WeakMap;var yn;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(yn||(yn={}));class Tn{constructor(e,n,o,r,i){if(this.type=e,this.children=n,this.positions=o,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=Dd.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let o of this.children){let r=o.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Ib(this.topNode,e)}cursorAt(e,n=0,o=0){let r=Eh.get(this)||this.topNode,i=new Ib(r);return i.moveTo(e,n),Eh.set(this,i._tree),i}get topNode(){return new Hr(this,0,0,null)}resolve(e,n=0){let o=vf(Eh.get(this)||this.topNode,e,n,!1);return Eh.set(this,o),o}resolveInner(e,n=0){let o=vf(Rk.get(this)||this.topNode,e,n,!0);return Rk.set(this,o),o}resolveStack(e,n=0){return ype(this,e,n)}iterate(e){let{enter:n,leave:o,from:r=0,to:i=this.length}=e,s=e.mode||0,a=(s&yn.IncludeAnonymous)>0;for(let l=this.cursor(s|yn.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=r&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&o&&(a||!l.type.isAnonymous)&&o(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:dx(lr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,o,r)=>new Tn(this.type,n,o,r,this.propValues),e.makeTree||((n,o,r)=>new Tn(lr.none,n,o,r)))}static build(e){return xpe(e)}}Tn.empty=new Tn(lr.none,[],[],0);class cx{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new cx(this.buffer,this.index)}}class Ha{constructor(e,n,o){this.buffer=e,this.length=n,this.set=o}get type(){return lr.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],o=this.buffer[e+3],r=this.set.types[n],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,o==e)return i;let s=[];for(;e<o;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,o,r,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(uO(i,r,s[l+1],s[l+2])&&(a=l,o>0));l=s[l+3]);return a}slice(e,n,o){let r=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=r[a++],i[l++]=r[a++]-o;let c=i[l++]=r[a++]-o;i[l++]=r[a++]-e,s=Math.max(s,c)}return new Ha(i,s,this.set)}}function uO(t,e,n,o){switch(t){case-2:return n<e;case-1:return o>=e&&n<e;case 0:return n<e&&o>e;case 1:return n<=e&&o>e;case 2:return o>e;case 4:return!0}}function vf(t,e,n,o){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!o&&t instanceof Hr&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=o?0:yn.IgnoreOverlays;if(o)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Hr&&s.index<0&&((r=a.enter(e,n,i))===null||r===void 0?void 0:r.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class dO{cursor(e=0){return new Ib(this,e)}getChild(e,n=null,o=null){let r=Fk(this,e,n,o);return r.length?r[0]:null}getChildren(e,n=null,o=null){return Fk(this,e,n,o)}resolve(e,n=0){return vf(this,e,n,!1)}resolveInner(e,n=0){return vf(this,e,n,!0)}matchContext(e){return Nb(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),o=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(o=n,n=r.prevSibling):n=r}return o}get node(){return this}get next(){return this.parent}}class Hr extends dO{constructor(e,n,o,r){super(),this._tree=e,this.from=n,this.index=o,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,o,r,i=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=n>0?a.length:-1;e!=c;e+=n){let u=a[e],d=l[e]+s.from,f;if(!(!(i&yn.EnterBracketed&&u instanceof Tn&&(f=Dd.get(u))&&!f.overlay&&f.bracketed&&o>=d&&o<=d+u.length)&&!uO(r,o,d,d+u.length))){if(u instanceof Ha){if(i&yn.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,o-d,r);if(h>-1)return new Sa(new vpe(s,u,e,d),null,h)}else if(i&yn.IncludeAnonymous||!u.type.isAnonymous||ux(u)){let h;if(!(i&yn.IgnoreMounts)&&(h=Dd.get(u))&&!h.overlay)return new Hr(h.tree,d,e,s);let g=new Hr(u,d,e,s);return i&yn.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?u.children.length-1:0,n,o,r,i)}}}if(i&yn.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+n:e=n<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,o=0){let r;if(!(o&yn.IgnoreOverlays)&&(r=Dd.get(this._tree))&&r.overlay){let i=e-this.from,s=o&yn.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Hr(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,o)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Fk(t,e,n,o){let r=t.cursor(),i=[];if(!r.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=r.type.is(n),!r.nextSibling())return i}for(;;){if(o!=null&&r.type.is(o))return i;if(r.type.is(e)&&i.push(r.node),!r.nextSibling())return o==null?i:[]}}function Nb(t,e,n=e.length-1){for(let o=t;n>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}class vpe{constructor(e,n,o,r){this.parent=e,this.buffer=n,this.index=o,this.start=r}}class Sa extends dO{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,o){super(),this.context=e,this._parent=n,this.index=o,this.type=e.buffer.set.types[e.buffer.buffer[o]]}child(e,n,o){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,o);return i<0?null:new Sa(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,o=0){if(o&yn.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new Sa(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Sa(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Sa(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:o}=this.context,r=this.index+4,i=o.buffer[this.index+3];if(i>r){let s=o.buffer[this.index+1];e.push(o.slice(r,i,s)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function fO(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let o=n instanceof Hr&&n.index<0?null:n.parent,r=t.slice();return o?r[e]=o:r.splice(e,1),new bpe(r,n)}class bpe{constructor(e,n){this.heads=e,this.node=n}get next(){return fO(this.heads)}}function ype(t,e,n){let o=t.resolveInner(e,n),r=null;for(let i=o instanceof Hr?o:o.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(r||(r=[o])).push(s.resolve(e,n)),i=s}else{let s=Dd.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Hr(s.tree,s.overlay[0].from+i.from,-1,i);(r||(r=[o])).push(vf(a,e,n,!1))}}return r?fO(r):o}class Ib{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~yn.EnterBracketed,e instanceof Hr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let o=e._parent;o;o=o._parent)this.stack.unshift(o.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:o,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=o+r.buffer[e+1],this.to=o+r.buffer[e+2],!0}yield(e){return e?e instanceof Hr?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,o){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,o,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,o);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,o=this.mode){return this.buffer?o&yn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,o))}parent(){if(!this.buffer)return this.yieldNode(this.mode&yn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&yn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,o=this.stack.length-1;if(e<0){let r=o<0?0:this.stack[o]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(o<0?n.buffer.length:n.buffer[this.stack[o]+3]))return this.yieldBuf(r)}return o<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,o,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:o}=r)}else({index:n,_parent:o}=this._tree);for(;o;{index:n,_parent:o}=o)if(n>-1)for(let i=n+e,s=e<0?-1:o._tree.children.length;i!=s;i+=e){let a=o._tree.children[i];if(this.mode&yn.IncludeAnonymous||a instanceof Ha||!a.type.isAnonymous||ux(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,o=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;n=s,o=i+1;break e}r=this.stack[--i]}for(let r=o;r<this.stack.length;r++)n=new Sa(this.buffer,n,this.stack[r]);return this.bufferNode=new Sa(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let o=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){o++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!o)return;if(this.nextSibling())break;this.parent(),o--,r=!0}}}matchContext(e){if(!this.buffer)return Nb(this.node.parent,e);let{buffer:n}=this.buffer,{types:o}=n.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return Nb(this._tree,e,r);let s=o[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}}function ux(t){return t.children.some(e=>e instanceof Ha||!e.type.isAnonymous||ux(e))}function xpe(t){var e;let{buffer:n,nodeSet:o,maxBufferLength:r=cO,reused:i=[],minRepeatType:s=o.types.length}=t,a=Array.isArray(n)?new cx(n,n.length):n,l=o.types,c=0,u=0;function d(k,E,B,S,L,D){let{id:I,start:C,end:T,size:P}=a,$=u,F=c;if(P<0)if(a.next(),P==-1){let he=i[I];B.push(he),S.push(C-k);return}else if(P==-3){c=I;return}else if(P==-4){u=I;return}else throw new RangeError(`Unrecognized record size: ${P}`);let V=l[I],U,K,se=C-k;if(T-C<=r&&(K=m(a.pos-E,L))){let he=new Uint16Array(K.size-K.skip),ce=a.pos-K.size,be=he.length;for(;a.pos>ce;)be=v(K.start,he,be);U=new Ha(he,T-K.start,o),se=K.start-k}else{let he=a.pos-P;a.next();let ce=[],be=[],oe=I>=s?I:-1,de=0,we=T;for(;a.pos>he;)oe>=0&&a.id==oe&&a.size>=0?(a.end<=we-r&&(g(ce,be,C,de,a.end,we,oe,$,F),de=ce.length,we=a.end),a.next()):D>2500?f(C,he,ce,be):d(C,he,ce,be,oe,D+1);if(oe>=0&&de>0&&de<ce.length&&g(ce,be,C,de,C,we,oe,$,F),ce.reverse(),be.reverse(),oe>-1&&de>0){let ee=h(V,F);U=dx(V,ce,be,0,ce.length,0,T-C,ee,ee)}else U=b(V,ce,be,T-C,$-T,F)}B.push(U),S.push(se)}function f(k,E,B,S){let L=[],D=0,I=-1;for(;a.pos>E;){let{id:C,start:T,end:P,size:$}=a;if($>4)a.next();else{if(I>-1&&T<I)break;I<0&&(I=P-r),L.push(C,T,P),D++,a.next()}}if(D){let C=new Uint16Array(D*4),T=L[L.length-2];for(let P=L.length-3,$=0;P>=0;P-=3)C[$++]=L[P],C[$++]=L[P+1]-T,C[$++]=L[P+2]-T,C[$++]=$;B.push(new Ha(C,L[2]-T,o)),S.push(T-k)}}function h(k,E){return(B,S,L)=>{let D=0,I=B.length-1,C,T;if(I>=0&&(C=B[I])instanceof Tn){if(!I&&C.type==k&&C.length==L)return C;(T=C.prop(Nt.lookAhead))&&(D=S[I]+C.length+T)}return b(k,B,S,L,D,E)}}function g(k,E,B,S,L,D,I,C,T){let P=[],$=[];for(;k.length>S;)P.push(k.pop()),$.push(E.pop()+B-L);k.push(b(o.types[I],P,$,D-L,C-D,T)),E.push(L-B)}function b(k,E,B,S,L,D,I){if(D){let C=[Nt.contextHash,D];I=I?[C].concat(I):[C]}if(L>25){let C=[Nt.lookAhead,L];I=I?[C].concat(I):[C]}return new Tn(k,E,B,S,I)}function m(k,E){let B=a.fork(),S=0,L=0,D=0,I=B.end-r,C={size:0,start:0,skip:0};e:for(let T=B.pos-k;B.pos>T;){let P=B.size;if(B.id==E&&P>=0){C.size=S,C.start=L,C.skip=D,D+=4,S+=4,B.next();continue}let $=B.pos-P;if(P<0||$<T||B.start<I)break;let F=B.id>=s?4:0,V=B.start;for(B.next();B.pos>$;){if(B.size<0)if(B.size==-3||B.size==-4)F+=4;else break e;else B.id>=s&&(F+=4);B.next()}L=V,S+=P,D+=F}return(E<0||S==k)&&(C.size=S,C.start=L,C.skip=D),C.size>4?C:void 0}function v(k,E,B){let{id:S,start:L,end:D,size:I}=a;if(a.next(),I>=0&&S<s){let C=B;if(I>4){let T=a.pos-(I-4);for(;a.pos>T;)B=v(k,E,B)}E[--B]=C,E[--B]=D-k,E[--B]=L-k,E[--B]=S}else I==-3?c=S:I==-4&&(u=S);return B}let y=[],x=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,y,x,-1,0);let _=(e=t.length)!==null&&e!==void 0?e:y.length?x[0]+y[0].length:0;return new Tn(l[t.topID],y.reverse(),x.reverse(),_)}const Vk=new WeakMap;function cp(t,e){if(!t.isAnonymous||e instanceof Ha||e.type!=t)return 1;let n=Vk.get(e);if(n==null){n=1;for(let o of e.children){if(o.type!=t||!(o instanceof Tn)){n=1;break}n+=cp(t,o)}Vk.set(e,n)}return n}function dx(t,e,n,o,r,i,s,a,l){let c=0;for(let g=o;g<r;g++)c+=cp(t,e[g]);let u=Math.ceil(c*1.5/8),d=[],f=[];function h(g,b,m,v,y){for(let x=m;x<v;){let _=x,k=b[x],E=cp(t,g[x]);for(x++;x<v;x++){let B=cp(t,g[x]);if(E+B>=u)break;E+=B}if(x==_+1){if(E>u){let B=g[_];h(B.children,B.positions,0,B.children.length,b[_]+y);continue}d.push(g[_])}else{let B=b[x-1]+g[x-1].length-k;d.push(dx(t,g,b,_,x,k,B,null,l))}f.push(k+y-i)}}return h(e,n,o,r,0),(a||l)(d,f,s)}class Ml{constructor(e,n,o,r,i=!1,s=!1){this.from=e,this.to=n,this.tree=o,this.offset=r,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],o=!1){let r=[new Ml(0,e.length,e,0,!1,o)];for(let i of n)i.to>e.length&&r.push(i);return r}static applyChanges(e,n,o=128){if(!n.length)return e;let r=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=o)for(;s&&s.from<d;){let f=s;if(l>=f.from||d<=f.to||c){let h=Math.max(f.from,l)-c,g=Math.min(f.to,d)-c;f=h>=g?null:new Ml(h,g,f.tree,f.offset+c,a>0,!!u)}if(f&&r.push(f),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return r}}class hO{startParse(e,n,o){return typeof e=="string"&&(e=new wpe(e)),o=o?o.length?o.map(r=>new Vv(r.from,r.to)):[new Vv(0,0)]:[new Vv(0,e.length)],this.createParse(e,n||[],o)}parse(e,n,o){let r=this.startParse(e,n,o);for(;;){let i=r.advance();if(i)return i}}}class wpe{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Nt({perNode:!0});let _pe=0;class Dr{constructor(e,n,o,r){this.name=e,this.set=n,this.base=o,this.modified=r,this.id=_pe++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let o=typeof e=="string"?e:"?";if(e instanceof Dr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new Dr(o,[],null,[]);if(r.set.push(r),n)for(let i of n.set)r.set.push(i);return r}static defineModifier(e){let n=new M0(e);return o=>o.modified.indexOf(n)>-1?o:M0.get(o.base||o,o.modified.concat(n).sort((r,i)=>r.id-i.id))}}let kpe=0;class M0{constructor(e){this.name=e,this.instances=[],this.id=kpe++}static get(e,n){if(!n.length)return e;let o=n[0].instances.find(a=>a.base==e&&Spe(n,a.modified));if(o)return o;let r=[],i=new Dr(e.name,r,e,n);for(let a of n)a.instances.push(i);let s=Ape(n);for(let a of e.set)if(!a.modified.length)for(let l of s)r.push(M0.get(a,l));return i}}function Spe(t,e){return t.length==e.length&&t.every((n,o)=>n==e[o])}function Ape(t){let e=[[]];for(let n=0;n<t.length;n++)for(let o=0,r=e.length;o<r;o++)e.push(e[o].concat(t[n]));return e.sort((n,o)=>o.length-n.length)}function pO(t){let e=Object.create(null);for(let n in t){let o=t[n];Array.isArray(o)||(o=[o]);for(let r of n.split(" "))if(r){let i=[],s=2,a=r;for(let d=0;;){if(a=="..."&&d>0&&d+3==r.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+r);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==r.length)break;let h=r[d++];if(d==r.length&&h=="!"){s=0;break}if(h!="/")throw new RangeError("Invalid path: "+r);a=r.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new bf(o,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return mO.add(e)}const mO=new Nt({combine(t,e){let n,o,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let i=new bf(r.tags,r.mode,r.context);n?n.next=i:o=i,n=i}return o}});class bf{constructor(e,n,o,r){this.tags=e,this.mode=n,this.context=o,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}bf.empty=new bf([],2,null);function gO(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:o,all:r=null}=e||{};return{style:i=>{let s=r;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:o}}function Cpe(t,e){let n=null;for(let o of t){let r=o.style(e);r&&(n=n?n+" "+r:r)}return n}function vO(t,e,n,o=0,r=t.length){let i=new $pe(o,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),o,r,"",i.highlighters),i.flush(r)}class $pe{constructor(e,n,o){this.at=e,this.highlighters=n,this.span=o,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,o,r,i){let{type:s,from:a,to:l}=e;if(a>=o||l<=n)return;s.isTop&&(i=this.highlighters.filter(h=>!h.scope||h.scope(s)));let c=r,u=Tpe(e)||bf.empty,d=Cpe(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let f=e.tree&&e.tree.prop(Nt.mounted);if(f&&f.overlay){let h=e.node.enter(f.overlay[0].from+a,1),g=this.highlighters.filter(m=>!m.scope||m.scope(f.tree.type)),b=e.firstChild();for(let m=0,v=a;;m++){let y=m<f.overlay.length?f.overlay[m]:null,x=y?y.from+a:l,_=Math.max(n,v),k=Math.min(o,x);if(_<k&&b)for(;e.from<k&&(this.highlightRange(e,_,k,r,i),this.startSpan(Math.min(k,e.to),c),!(e.to>=x||!e.nextSibling())););if(!y||x>o)break;v=y.to+a,v>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+a),Math.min(o,v),"",g),this.startSpan(Math.min(o,v),c))}b&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=n)){if(e.from>=o)break;this.highlightRange(e,n,o,r,i),this.startSpan(Math.min(o,e.to),c)}while(e.nextSibling());e.parent()}}}function Tpe(t){let e=t.type.prop(mO);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Ke=Dr.define,Nh=Ke(),ga=Ke(),zk=Ke(ga),Hk=Ke(ga),va=Ke(),Ih=Ke(va),zv=Ke(va),Vi=Ke(),cl=Ke(Vi),Ri=Ke(),Fi=Ke(),Rb=Ke(),Qu=Ke(Rb),Rh=Ke(),at={comment:Nh,lineComment:Ke(Nh),blockComment:Ke(Nh),docComment:Ke(Nh),name:ga,variableName:Ke(ga),typeName:zk,tagName:Ke(zk),propertyName:Hk,attributeName:Ke(Hk),className:Ke(ga),labelName:Ke(ga),namespace:Ke(ga),macroName:Ke(ga),literal:va,string:Ih,docString:Ke(Ih),character:Ke(Ih),attributeValue:Ke(Ih),number:zv,integer:Ke(zv),float:Ke(zv),bool:Ke(va),regexp:Ke(va),escape:Ke(va),color:Ke(va),url:Ke(va),keyword:Ri,self:Ke(Ri),null:Ke(Ri),atom:Ke(Ri),unit:Ke(Ri),modifier:Ke(Ri),operatorKeyword:Ke(Ri),controlKeyword:Ke(Ri),definitionKeyword:Ke(Ri),moduleKeyword:Ke(Ri),operator:Fi,derefOperator:Ke(Fi),arithmeticOperator:Ke(Fi),logicOperator:Ke(Fi),bitwiseOperator:Ke(Fi),compareOperator:Ke(Fi),updateOperator:Ke(Fi),definitionOperator:Ke(Fi),typeOperator:Ke(Fi),controlOperator:Ke(Fi),punctuation:Rb,separator:Ke(Rb),bracket:Qu,angleBracket:Ke(Qu),squareBracket:Ke(Qu),paren:Ke(Qu),brace:Ke(Qu),content:Vi,heading:cl,heading1:Ke(cl),heading2:Ke(cl),heading3:Ke(cl),heading4:Ke(cl),heading5:Ke(cl),heading6:Ke(cl),contentSeparator:Ke(Vi),list:Ke(Vi),quote:Ke(Vi),emphasis:Ke(Vi),strong:Ke(Vi),link:Ke(Vi),monospace:Ke(Vi),strikethrough:Ke(Vi),inserted:Ke(),deleted:Ke(),changed:Ke(),invalid:Ke(),meta:Rh,documentMeta:Ke(Rh),annotation:Ke(Rh),processingInstruction:Ke(Rh),definition:Dr.defineModifier("definition"),constant:Dr.defineModifier("constant"),function:Dr.defineModifier("function"),standard:Dr.defineModifier("standard"),local:Dr.defineModifier("local"),special:Dr.defineModifier("special")};for(let t in at){let e=at[t];e instanceof Dr&&(e.name=t)}const bO=gO([{tag:at.link,class:"tok-link"},{tag:at.heading,class:"tok-heading"},{tag:at.emphasis,class:"tok-emphasis"},{tag:at.strong,class:"tok-strong"},{tag:at.keyword,class:"tok-keyword"},{tag:at.atom,class:"tok-atom"},{tag:at.bool,class:"tok-bool"},{tag:at.url,class:"tok-url"},{tag:at.labelName,class:"tok-labelName"},{tag:at.inserted,class:"tok-inserted"},{tag:at.deleted,class:"tok-deleted"},{tag:at.literal,class:"tok-literal"},{tag:at.string,class:"tok-string"},{tag:at.number,class:"tok-number"},{tag:[at.regexp,at.escape,at.special(at.string)],class:"tok-string2"},{tag:at.variableName,class:"tok-variableName"},{tag:at.local(at.variableName),class:"tok-variableName tok-local"},{tag:at.definition(at.variableName),class:"tok-variableName tok-definition"},{tag:at.special(at.variableName),class:"tok-variableName2"},{tag:at.definition(at.propertyName),class:"tok-propertyName tok-definition"},{tag:at.typeName,class:"tok-typeName"},{tag:at.namespace,class:"tok-namespace"},{tag:at.className,class:"tok-className"},{tag:at.macroName,class:"tok-macroName"},{tag:at.propertyName,class:"tok-propertyName"},{tag:at.operator,class:"tok-operator"},{tag:at.comment,class:"tok-comment"},{tag:at.meta,class:"tok-meta"},{tag:at.invalid,class:"tok-invalid"},{tag:at.punctuation,class:"tok-punctuation"}]);var Hv;const Cc=new Nt;function Mpe(t){return pt.define({combine:t?e=>e.concat(t):void 0})}const Ope=new Nt;class ui{constructor(e,n,o=[],r=""){this.data=e,this.name=r,Kt.prototype.hasOwnProperty("tree")||Object.defineProperty(Kt.prototype,"tree",{get(){return as(this)}}),this.parser=n,this.extension=[pu.of(this),Kt.languageData.of((i,s,a)=>{let l=Wk(i,s,a),c=l.type.prop(Cc);if(!c)return[];let u=i.facet(c),d=l.type.prop(Ope);if(d){let f=l.resolve(s-l.from,a);for(let h of d)if(h.test(f,i)){let g=i.facet(h.facet);return h.type=="replace"?g:g.concat(u)}}return u})].concat(o)}isActiveAt(e,n,o=-1){return Wk(e,n,o).type.prop(Cc)==this.data}findRegions(e){let n=e.facet(pu);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let o=[],r=(i,s)=>{if(i.prop(Cc)==this.data){o.push({from:s,to:s+i.length});return}let a=i.prop(Nt.mounted);if(a){if(a.tree.prop(Cc)==this.data){if(a.overlay)for(let l of a.overlay)o.push({from:l.from+s,to:l.to+s});else o.push({from:s,to:s+i.length});return}else if(a.overlay){let l=o.length;if(r(a.tree,a.overlay[0].from+s),o.length>l)return}}for(let l=0;l<i.children.length;l++){let c=i.children[l];c instanceof Tn&&r(c,i.positions[l]+s)}};return r(as(e),0),o}get allowsNesting(){return!0}}ui.setState=$n.define();function Wk(t,e,n){let o=t.facet(pu),r=as(t).topNode;if(!o||o.allowsNesting)for(let i=r;i;i=i.enter(e,n,yn.ExcludeBuffers|yn.EnterBracketed))i.type.isTop&&(r=i);return r}class O0 extends ui{constructor(e,n,o){super(e,n,[],o),this.parser=n}static define(e){let n=Mpe(e.languageData);return new O0(n,e.parser.configure({props:[Cc.add(o=>o.isTop?n:void 0)]}),e.name)}configure(e,n){return new O0(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function as(t){let e=t.field(ui.state,!1);return e?e.tree:Tn.empty}class Bpe{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let o=this.cursorPos-this.string.length;return e<o||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-o,n-o)}}let Ju=null;class B0{constructor(e,n,o=[],r,i,s,a,l){this.parser=e,this.state=n,this.fragments=o,this.tree=r,this.treeLen=i,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,o){return new B0(e,n,[],Tn.empty,0,o,[],null)}startParse(){return this.parser.startParse(new Bpe(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var o;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Ml.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(o=this.parse.stoppedAt)!==null&&o!==void 0?o:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Ml.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ju;Ju=this;try{return e()}finally{Ju=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Uk(e,n.from,n.to);return e}changes(e,n){let{fragments:o,tree:r,treeLen:i,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,d,f)=>l.push({fromA:c,toA:u,fromB:d,toB:f})),o=Ml.applyChanges(o,l),r=Tn.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&a.push({from:u,to:d})}}}return new B0(this.parser,n,o,r,i,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let o=0;o<this.skipped.length;o++){let{from:r,to:i}=this.skipped[o];r<e.to&&i>e.from&&(this.fragments=Uk(this.fragments,r,i),this.skipped.splice(o--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends hO{createParse(n,o,r){let i=r[0].from,s=r[r.length-1].to;return{parsedPos:i,advance(){let l=Ju;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new Tn(lr.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ju}}function Uk(t,e,n){return Ml.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class hu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),o=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,o)||n.takeTree(),new hu(n)}static init(e){let n=Math.min(3e3,e.doc.length),o=B0.create(e.facet(pu).parser,e,{from:0,to:n});return o.work(20,n)||o.takeTree(),new hu(o)}}ui.state=el.define({create:hu.init,update(t,e){for(let n of e.effects)if(n.is(ui.setState))return n.value;return e.startState.facet(pu)!=e.state.facet(pu)?hu.init(e.state):t.apply(e)}});let yO=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(yO=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Wv=typeof navigator<"u"&&(!((Hv=navigator.scheduling)===null||Hv===void 0)&&Hv.isInputPending)?()=>navigator.scheduling.isInputPending():null,Lpe=Wl.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(ui.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ui.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=yO(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:o,viewport:{to:r}}=this.view,i=o.field(ui.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Wv?Math.max(25,e.timeRemaining()-5):1e9),a=i.context.treeLen<r&&o.doc.length>r+1e3,l=i.context.work(()=>Wv&&Wv()||Date.now()>s,r+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:ui.setState.of(new hu(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>ji(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),pu=pt.define({combine(t){return t.length?t[0]:null},enables:t=>[ui.state,Lpe,_t.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Ppe{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Dpe=pt.define(),fx=pt.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function L0(t){let e=t.facet(fx);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function P0(t,e){let n="",o=t.tabSize,r=t.facet(fx)[0];if(r==" "){for(;e>=o;)n+=" ",e-=o;r=" "}for(let i=0;i<e;i++)n+=r;return n}function xO(t,e){t instanceof Kt&&(t=new xg(t));for(let o of t.state.facet(Dpe)){let r=o(t,e);if(r!==void 0)return r}let n=as(t.state);return n.length>=e?Npe(t,n,e):null}class xg{constructor(e,n={}){this.state=e,this.options=n,this.unit=L0(e)}lineAt(e,n=1){let o=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=o.from&&r<=o.to?i&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:o.text.slice(r-o.from),from:r}:{text:o.text.slice(0,r-o.from),from:o.from}:o}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:o,from:r}=this.lineAt(e,n);return o.slice(e-r,Math.min(o.length,e+100-r))}column(e,n=1){let{text:o,from:r}=this.lineAt(e,n),i=this.countColumn(o,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(i+=s-this.countColumn(o,o.search(/\S|$/))),i}countColumn(e,n=e.length){return hg(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:o,from:r}=this.lineAt(e,n),i=this.options.overrideIndentation;if(i){let s=i(r);if(s>-1)return s}return this.countColumn(o,o.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Epe=new Nt;function Npe(t,e,n){let o=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=o.node){let i=[];for(let s=r;s&&!(s.from<o.node.from||s.to>o.node.to||s.from==o.node.from&&s.type==o.node.type);s=s.parent)i.push(s);for(let s=i.length-1;s>=0;s--)o={node:i[s],next:o}}return wO(o,t,n)}function wO(t,e,n){for(let o=t;o;o=o.next){let r=Rpe(o.node);if(r)return r(hx.create(e,n,o))}return 0}function Ipe(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Rpe(t){let e=t.type.prop(Epe);if(e)return e;let n=t.firstChild,o;if(n&&(o=n.type.prop(Nt.closedBy))){let r=t.lastChild,i=r&&o.indexOf(r.name)>-1;return s=>Hpe(s,!0,1,void 0,i&&!Ipe(s)?r.from:void 0)}return t.parent==null?Fpe:null}function Fpe(){return 0}class hx extends xg{constructor(e,n,o){super(e.state,e.options),this.base=e,this.pos=n,this.context=o}get node(){return this.context.node}static create(e,n,o){return new hx(e,n,o)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let o=e.resolve(n.from);for(;o.parent&&o.parent.from==o.from;)o=o.parent;if(Vpe(o,e))break;n=this.state.doc.lineAt(o.from)}return this.lineIndent(n.from)}continue(){return wO(this.context.next,this.base,this.pos)}}function Vpe(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function zpe(t){let e=t.node,n=e.childAfter(e.from),o=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,i=t.state.doc.lineAt(n.from),s=r==null||r<=i.from?i.to:Math.min(i.to,r);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==o)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function Hpe(t,e,n,o,r){let i=t.textAfter,s=i.match(/^\s*/)[0].length,a=o&&i.slice(s,s+o.length)==o||r==t.pos+s,l=zpe(t);return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}class px{constructor(e,n){this.specs=e;let o;function r(a){let l=Fa.newName();return(o||(o=Object.create(null)))["."+l]=a,l}const i=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,s=n.scope;this.scope=s instanceof ui?a=>a.prop(Cc)==s.data:s?a=>a==s:void 0,this.style=gO(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=o?new Fa(o):null,this.themeType=n.themeType}static define(e,n){return new px(e,n||{})}}const Fb=pt.define(),Wpe=pt.define({combine(t){return t.length?[t[0]]:null}});function Uv(t){let e=t.facet(Fb);return e.length?e:t.facet(Wpe)}function Upe(t,e){let n=[qpe],o;return t instanceof px&&(t.module&&n.push(_t.styleModule.of(t.module)),o=t.themeType),o?n.push(Fb.computeN([_t.darkTheme],r=>r.facet(_t.darkTheme)==(o=="dark")?[t]:[])):n.push(Fb.of(t)),n}class Gpe{constructor(e){this.markCache=Object.create(null),this.tree=as(e.state),this.decorations=this.buildDeco(e,Uv(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=as(e.state),o=Uv(e.state),r=o!=Uv(e.startState),{viewport:i}=e.view,s=e.changes.mapPos(this.decoratedTo,1);n.length<i.to&&!r&&n.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,o),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return Xn.none;let o=new df;for(let{from:r,to:i}of e.visibleRanges)vO(this.tree,n,(s,a,l)=>{o.add(s,a,this.markCache[l]||(this.markCache[l]=Xn.mark({class:l})))},r,i);return o.finish()}}const qpe=X2.high(Wl.fromClass(Gpe,{decorations:t=>t.decorations})),Ype=1e4,jpe="()[]{}",Xpe=new Nt;function Vb(t,e,n){let o=t.prop(e<0?Nt.openedBy:Nt.closedBy);if(o)return o;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function zb(t){let e=t.type.prop(Xpe);return e?e(t.node):t}function $c(t,e,n,o={}){let r=o.maxScanDistance||Ype,i=o.brackets||jpe,s=as(t),a=s.resolveInner(e,n);for(let l=a;l;l=l.parent){let c=Vb(l.type,n,i);if(c&&l.from<l.to){let u=zb(l);if(u&&(n>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return Kpe(t,e,n,l,u,c,i)}}return Zpe(t,e,n,s,a.type,r,i)}function Kpe(t,e,n,o,r,i,s){let a=o.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(n<0?u.childBefore(o.from):u.childAfter(o.to)))do if(n<0?u.to<=o.from:u.from>=o.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let d=zb(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(Vb(u.type,n,s))c++;else if(Vb(u.type,-n,s)){if(c==0){let d=zb(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function Zpe(t,e,n,o,r,i,s){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?e-1:e,to:n>0?e+1:e},u=t.doc.iterRange(e,n>0?t.doc.length:0),d=0;for(let f=0;!u.next().done&&f<=i;){let h=u.value;n<0&&(f+=h.length);let g=e+f*n;for(let b=n>0?0:h.length-1,m=n>0?h.length:-1;b!=m;b+=n){let v=s.indexOf(h[b]);if(!(v<0||o.resolveInner(g+b,1).type!=r))if(v%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:g+b,to:g+b+1},matched:v>>1==l>>1};d--}}n>0&&(f+=h.length)}return u.done?{start:c,matched:!1}:null}const Qpe=Object.create(null),Gk=[lr.none],qk=[],Yk=Object.create(null),Jpe=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Jpe[t]=e0e(Qpe,e);function Gv(t,e){qk.indexOf(t)>-1||(qk.push(t),console.warn(e))}function e0e(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=t[c]||at[c];u?typeof u=="function"?l.length?l=l.map(u):Gv(c,`Modifier ${c} used at start of tag`):l.length?Gv(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Gv(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let o=e.replace(/ /g,"_"),r=o+" "+n.map(a=>a.id),i=Yk[r];if(i)return i.id;let s=Yk[r]=lr.define({id:Gk.length,name:o,props:[pO({[o]:n})]});return Gk.push(s),s.id}Dn.RTL,Dn.LTR;const t0e=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),o=gx(t.state,n.from);return o.line?n0e(t):o.block?r0e(t):!1};function mx(t,e){return({state:n,dispatch:o})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(o(n.update(r)),!0):!1}}const n0e=mx(a0e,0),o0e=mx(_O,0),r0e=mx((t,e)=>_O(t,e,s0e(e)),0);function gx(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const ed=50;function i0e(t,{open:e,close:n},o,r){let i=t.sliceDoc(o-ed,o),s=t.sliceDoc(r,r+ed),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(s)[0].length,c=i.length-a;if(i.slice(c-e.length,c)==e&&s.slice(l,l+n.length)==n)return{open:{pos:o-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,d;r-o<=2*ed?u=d=t.sliceDoc(o,r):(u=t.sliceDoc(o,o+ed),d=t.sliceDoc(r-ed,r));let f=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(d)[0].length,g=d.length-h-n.length;return u.slice(f,f+e.length)==e&&d.slice(g,g+n.length)==n?{open:{pos:o+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:r-h-n.length,margin:/\s/.test(d.charAt(g-1))?1:0}}:null}function s0e(t){let e=[];for(let n of t.selection.ranges){let o=t.doc.lineAt(n.from),r=n.to<=o.to?o:t.doc.lineAt(n.to);r.from>o.from&&r.from==n.to&&(r=n.to==o.to+1?o:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>o.from?e[i].to=r.to:e.push({from:o.from+/^\s*/.exec(o.text)[0].length,to:r.to})}return e}function _O(t,e,n=e.selection.ranges){let o=n.map(i=>gx(e,i.from).block);if(!o.every(i=>i))return null;let r=n.map((i,s)=>i0e(e,o[s],i.from,i.to));if(t!=2&&!r.every(i=>i))return{changes:e.changes(n.map((i,s)=>r[s]?[]:[{from:i.from,insert:o[s].open+" "},{from:i.to,insert:" "+o[s].close}]))};if(t!=1&&r.some(i=>i)){let i=[];for(let s=0,a;s<r.length;s++)if(a=r[s]){let l=o[s],{open:c,close:u}=a;i.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:i}}return null}function a0e(t,e,n=e.selection.ranges){let o=[],r=-1;e:for(let{from:i,to:s}of n){let a=o.length,l=1e9,c;for(let u=i;u<=s;){let d=e.doc.lineAt(u);if(c==null&&(c=gx(e,d.from).line,!c))continue e;if(d.from>r&&(i==s||s>d.from)){r=d.from;let f=/^\s*/.exec(d.text)[0].length,h=f==d.length,g=d.text.slice(f,f+c.length)==c?f:-1;f<d.text.length&&f<l&&(l=f),o.push({line:d,comment:g,token:c,indent:f,empty:h,single:!1})}u=d.to+1}if(l<1e9)for(let u=a;u<o.length;u++)o[u].indent<o[u].line.text.length&&(o[u].indent=l);o.length==a+1&&(o[a].single=!0)}if(t!=2&&o.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:c,empty:u,single:d}of o)(d||!u)&&i.push({from:a.from+c,insert:l+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&o.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:a,token:l}of o)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}const Hb=tl.define(),l0e=tl.define(),c0e=pt.define(),kO=pt.define({combine(t){return bfe(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(o,r)=>e(o,r)||n(o,r)})}}),SO=el.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(kO),o=e.annotation(Hb);if(o){let l=or.fromTransaction(e,o.selection),c=o.side,u=c==0?t.undone:t.done;return l?u=D0(u,u.length,n.minDepth,l):u=$O(u,e.startState.selection),new Xi(c==0?o.rest:u,c==0?u:o.rest)}let r=e.annotation(l0e);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Wn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=or.fromTransaction(e),s=e.annotation(Wn.time),a=e.annotation(Wn.userEvent);return i?t=t.addChanges(i,s,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(or.fromJSON),t.undone.map(or.fromJSON))}});function u0e(t={}){return[SO,kO.of(t),_t.domEventHandlers({beforeinput(e,n){let o=e.inputType=="historyUndo"?AO:e.inputType=="historyRedo"?Wb:null;return o?(e.preventDefault(),o(n)):!1}})]}function wg(t,e){return function({state:n,dispatch:o}){if(!e&&n.readOnly)return!1;let r=n.field(SO,!1);if(!r)return!1;let i=r.pop(t,n,e);return i?(o(i),!0):!1}}const AO=wg(0,!1),Wb=wg(1,!1),d0e=wg(0,!0),f0e=wg(1,!0);class or{constructor(e,n,o,r,i){this.changes=e,this.effects=n,this.mapped=o,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new or(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,o;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(o=this.startSelection)===null||o===void 0?void 0:o.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new or(e.changes&&zn.fromJSON(e.changes),[],e.mapped&&os.fromJSON(e.mapped),e.startSelection&&ze.fromJSON(e.startSelection),e.selectionsAfter.map(ze.fromJSON))}static fromTransaction(e,n){let o=Ir;for(let r of e.startState.facet(c0e)){let i=r(e);i.length&&(o=o.concat(i))}return!o.length&&e.changes.empty?null:new or(e.changes.invert(e.startState.doc),o,void 0,n||e.startState.selection,Ir)}static selection(e){return new or(void 0,Ir,void 0,void 0,e)}}function D0(t,e,n,o){let r=e+1>n+20?e-n-1:0,i=t.slice(r,e);return i.push(o),i}function h0e(t,e){let n=[],o=!1;return t.iterChangedRanges((r,i)=>n.push(r,i)),e.iterChangedRanges((r,i,s,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&s<=u&&(o=!0)}}),o}function p0e(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,o)=>n.empty!=e.ranges[o].empty).length===0}function CO(t,e){return t.length?e.length?t.concat(e):t:e}const Ir=[],m0e=200;function $O(t,e){if(t.length){let n=t[t.length-1],o=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-m0e));return o.length&&o[o.length-1].eq(e)?t:(o.push(e),D0(t,t.length-1,1e9,n.setSelAfter(o)))}else return[or.selection([e])]}function g0e(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function qv(t,e){if(!t.length)return t;let n=t.length,o=Ir;for(;n;){let r=v0e(t[n-1],e,o);if(r.changes&&!r.changes.empty||r.effects.length){let i=t.slice(0,n);return i[n-1]=r,i}else e=r.mapped,n--,o=r.selectionsAfter}return o.length?[or.selection(o)]:Ir}function v0e(t,e,n){let o=CO(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Ir,n);if(!t.changes)return or.selection(o);let r=t.changes.map(e),i=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(i):i;return new or(r,$n.mapEffects(t.effects,e),s,t.startSelection.map(i),o)}const b0e=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,o=0,r=void 0){this.done=e,this.undone=n,this.prevTime=o,this.prevUserEvent=r}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,o,r,i){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!o||b0e.test(o))&&(!a.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,h0e(a.changes,e.changes))||o=="input.type.compose")?s=D0(s,s.length-1,r.minDepth,new or(e.changes.compose(a.changes),CO($n.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Ir)):s=D0(s,s.length,r.minDepth,e),new Xi(s,Ir,n,o)}addSelection(e,n,o,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Ir;return i.length>0&&n-this.prevTime<r&&o==this.prevUserEvent&&o&&/^select($|\.)/.test(o)&&p0e(i[i.length-1],e)?this:new Xi($O(this.done,e),this.undone,n,o)}addMapping(e){return new Xi(qv(this.done,e),qv(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,o){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(o&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Hb.of({side:e,rest:g0e(r),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=r.length==1?Ir:r.slice(0,r.length-1);return i.mapped&&(a=qv(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Hb.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Xi.empty=new Xi(Ir,Ir);const y0e=[{key:"Mod-z",run:AO,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Wb,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Wb,preventDefault:!0},{key:"Mod-u",run:d0e,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:f0e,preventDefault:!0}];function Lu(t,e){return ze.create(t.ranges.map(e),t.mainIndex)}function Li(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Pi({state:t,dispatch:e},n){let o=Lu(t.selection,n);return o.eq(t.selection,!0)?!1:(e(Li(t,o)),!0)}function _g(t,e){return ze.cursor(e?t.to:t.from)}function TO(t,e){return Pi(t,n=>n.empty?t.moveByChar(n,e):_g(n,e))}function Bo(t){return t.textDirectionAt(t.state.selection.main.head)==Dn.LTR}const MO=t=>TO(t,!Bo(t)),OO=t=>TO(t,Bo(t));function BO(t,e){return Pi(t,n=>n.empty?t.moveByGroup(n,e):_g(n,e))}const x0e=t=>BO(t,!Bo(t)),w0e=t=>BO(t,Bo(t));function _0e(t,e,n){if(e.type.prop(n))return!0;let o=e.to-e.from;return o&&(o>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function kg(t,e,n){let o=as(t).resolveInner(e.head),r=n?Nt.closedBy:Nt.openedBy;for(let l=e.head;;){let c=n?o.childAfter(l):o.childBefore(l);if(!c)break;_0e(t,c,r)?o=c:l=n?c.to:c.from}let i=o.type.prop(r),s,a;return i&&(s=n?$c(t,o.from,1):$c(t,o.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?o.to:o.from,ze.cursor(a,n?-1:1)}const k0e=t=>Pi(t,e=>kg(t.state,e,!Bo(t))),S0e=t=>Pi(t,e=>kg(t.state,e,Bo(t)));function LO(t,e){return Pi(t,n=>{if(!n.empty)return _g(n,e);let o=t.moveVertically(n,e);return o.head!=n.head?o:t.moveToLineBoundary(n,e)})}const PO=t=>LO(t,!1),DO=t=>LO(t,!0);function EO(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,o=0,r;if(e){for(let i of t.state.facet(_t.scrollMargins)){let s=i(t);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(o=Math.max(s==null?void 0:s.bottom,o))}r=t.scrollDOM.clientHeight-n-o}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:o,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function NO(t,e){let n=EO(t),{state:o}=t,r=Lu(o.selection,s=>s.empty?t.moveVertically(s,e,n.height):_g(s,e));if(r.eq(o.selection))return!1;let i;if(n.selfScroll){let s=t.coordsAtPos(o.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<c&&(i=_t.scrollIntoView(r.main.head,{y:"start",yMargin:s.top-l}))}return t.dispatch(Li(o,r),{effects:i}),!0}const jk=t=>NO(t,!1),Ub=t=>NO(t,!0);function nl(t,e,n){let o=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?o.to:o.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==o.from&&o.length){let i=/^\s*/.exec(t.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;i&&e.head!=o.from+i&&(r=ze.cursor(o.from+i))}return r}const A0e=t=>Pi(t,e=>nl(t,e,!0)),C0e=t=>Pi(t,e=>nl(t,e,!1)),$0e=t=>Pi(t,e=>nl(t,e,!Bo(t))),T0e=t=>Pi(t,e=>nl(t,e,Bo(t))),M0e=t=>Pi(t,e=>ze.cursor(t.lineBlockAt(e.head).from,1)),O0e=t=>Pi(t,e=>ze.cursor(t.lineBlockAt(e.head).to,-1));function B0e(t,e,n){let o=!1,r=Lu(t.selection,i=>{let s=$c(t,i.head,-1)||$c(t,i.head,1)||i.head>0&&$c(t,i.head-1,1)||i.head<t.doc.length&&$c(t,i.head+1,-1);if(!s||!s.end)return i;o=!0;let a=s.start.from==i.head?s.end.to:s.end.from;return ze.cursor(a)});return o?(e(Li(t,r)),!0):!1}const L0e=({state:t,dispatch:e})=>B0e(t,e);function Zr(t,e){let n=Lu(t.state.selection,o=>{let r=e(o);return ze.range(o.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(Li(t.state,n)),!0)}function IO(t,e){return Zr(t,n=>t.moveByChar(n,e))}const RO=t=>IO(t,!Bo(t)),FO=t=>IO(t,Bo(t));function VO(t,e){return Zr(t,n=>t.moveByGroup(n,e))}const P0e=t=>VO(t,!Bo(t)),D0e=t=>VO(t,Bo(t)),E0e=t=>Zr(t,e=>kg(t.state,e,!Bo(t))),N0e=t=>Zr(t,e=>kg(t.state,e,Bo(t)));function zO(t,e){return Zr(t,n=>t.moveVertically(n,e))}const HO=t=>zO(t,!1),WO=t=>zO(t,!0);function UO(t,e){return Zr(t,n=>t.moveVertically(n,e,EO(t).height))}const Xk=t=>UO(t,!1),Kk=t=>UO(t,!0),I0e=t=>Zr(t,e=>nl(t,e,!0)),R0e=t=>Zr(t,e=>nl(t,e,!1)),F0e=t=>Zr(t,e=>nl(t,e,!Bo(t))),V0e=t=>Zr(t,e=>nl(t,e,Bo(t))),z0e=t=>Zr(t,e=>ze.cursor(t.lineBlockAt(e.head).from)),H0e=t=>Zr(t,e=>ze.cursor(t.lineBlockAt(e.head).to)),Zk=({state:t,dispatch:e})=>(e(Li(t,{anchor:0})),!0),Qk=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.doc.length})),!0),Jk=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.selection.main.anchor,head:0})),!0),eS=({state:t,dispatch:e})=>(e(Li(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),W0e=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),U0e=({state:t,dispatch:e})=>{let n=Sg(t).map(({from:o,to:r})=>ze.range(o,Math.min(r+1,t.doc.length)));return e(t.update({selection:ze.create(n),userEvent:"select"})),!0},G0e=({state:t,dispatch:e})=>{let n=Lu(t.selection,o=>{let r=as(t),i=r.resolveStack(o.from,1);if(o.empty){let s=r.resolveStack(o.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:a}=s;if((a.from<o.from&&a.to>=o.to||a.to>o.to&&a.from<=o.from)&&s.next)return ze.range(a.to,a.from)}return o});return n.eq(t.selection)?!1:(e(Li(t,n)),!0)};function GO(t,e){let{state:n}=t,o=n.selection,r=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=i;;){let l=t.moveVertically(a,e);if(l.head<s.from||l.head>s.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==o.ranges.length?!1:(t.dispatch(Li(n,ze.create(r,r.length-1))),!0)}const q0e=t=>GO(t,!1),Y0e=t=>GO(t,!0),j0e=({state:t,dispatch:e})=>{let n=t.selection,o=null;return n.ranges.length>1?o=ze.create([n.main]):n.main.empty||(o=ze.create([ze.cursor(n.main.head)])),o?(e(Li(t,o)),!0):!1};function zf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:o}=t,r=o.changeByRange(i=>{let{from:s,to:a}=i;if(s==a){let l=e(i);l<s?(n="delete.backward",l=Fh(t,l,!1)):l>s&&(n="delete.forward",l=Fh(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Fh(t,s,!1),a=Fh(t,a,!0);return s==a?{range:i}:{changes:{from:s,to:a},range:ze.cursor(s,s<i.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(o.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?_t.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function Fh(t,e,n){if(t instanceof _t)for(let o of t.state.facet(_t.atomicRanges).map(r=>r(t)))o.between(e,e,(r,i)=>{r<e&&i>e&&(e=n?i:r)});return e}const qO=(t,e,n)=>zf(t,o=>{let r=o.from,{state:i}=t,s=i.doc.lineAt(r),a,l;if(n&&!e&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,r-s.from))){if(a[a.length-1]==" ")return r-1;let c=hg(a,i.tabSize),u=c%L0(i)||L0(i);for(let d=0;d<u&&a[a.length-1-d]==" ";d++)r--;l=r}else l=To(s.text,r-s.from,e,e)+s.from,l==r&&s.number!=(e?i.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,r-s.from))&&(l=To(s.text,l-s.from,!1,!1)+s.from);return l}),Gb=t=>qO(t,!1,!0),YO=t=>qO(t,!0,!1),jO=(t,e)=>zf(t,n=>{let o=n.head,{state:r}=t,i=r.doc.lineAt(o),s=r.charCategorizer(o);for(let a=null;;){if(o==(e?i.to:i.from)){o==n.head&&i.number!=(e?r.doc.lines:1)&&(o+=e?1:-1);break}let l=To(i.text,o-i.from,e)+i.from,c=i.text.slice(Math.min(o,l)-i.from,Math.max(o,l)-i.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||o!=n.head)&&(a=u),o=l}return o}),XO=t=>jO(t,!1),X0e=t=>jO(t,!0),K0e=t=>zf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Z0e=t=>zf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),Q0e=t=>zf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),J0e=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(o=>({changes:{from:o.from,to:o.to,insert:Ut.of(["",""])},range:ze.cursor(o.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},eme=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(o=>{if(!o.empty||o.from==0||o.from==t.doc.length)return{range:o};let r=o.from,i=t.doc.lineAt(r),s=r==i.from?r-1:To(i.text,r-i.from,!1)+i.from,a=r==i.to?r+1:To(i.text,r-i.from,!0)+i.from;return{changes:{from:s,to:a,insert:t.doc.slice(r,a).append(t.doc.slice(s,r))},range:ze.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sg(t){let e=[],n=-1;for(let o of t.selection.ranges){let r=t.doc.lineAt(o.from),i=t.doc.lineAt(o.to);if(!o.empty&&o.to==i.from&&(i=t.doc.lineAt(o.to-1)),n>=r.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(o)}else e.push({from:r.from,to:i.to,ranges:[o]});n=i.number+1}return e}function KO(t,e,n){if(t.readOnly)return!1;let o=[],r=[];for(let i of Sg(t)){if(n?i.to==t.doc.length:i.from==0)continue;let s=t.doc.lineAt(n?i.to+1:i.from-1),a=s.length+1;if(n){o.push({from:i.to,to:s.to},{from:i.from,insert:s.text+t.lineBreak});for(let l of i.ranges)r.push(ze.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{o.push({from:s.from,to:i.from},{from:i.to,insert:t.lineBreak+s.text});for(let l of i.ranges)r.push(ze.range(l.anchor-a,l.head-a))}}return o.length?(e(t.update({changes:o,scrollIntoView:!0,selection:ze.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const tme=({state:t,dispatch:e})=>KO(t,e,!1),nme=({state:t,dispatch:e})=>KO(t,e,!0);function ZO(t,e,n){if(t.readOnly)return!1;let o=[];for(let i of Sg(t))n?o.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):o.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let r=t.changes(o);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ome=({state:t,dispatch:e})=>ZO(t,e,!1),rme=({state:t,dispatch:e})=>ZO(t,e,!0),ime=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Sg(e).map(({from:r,to:i})=>(r>0?r--:i<e.doc.length&&i++,{from:r,to:i}))),o=Lu(e.selection,r=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(r.head),a=t.coordsAtPos(r.head,r.assoc||1);a&&(i=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,i)}).map(n);return t.dispatch({changes:n,selection:o,scrollIntoView:!0,userEvent:"delete.line"}),!0};function sme(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=as(t).resolveInner(e),o=n.childBefore(e),r=n.childAfter(e),i;return o&&r&&o.to<=e&&r.from>=e&&(i=o.type.prop(Nt.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(o.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(o.to,r.from))?{from:o.to,to:r.from}:null}const tS=QO(!1),ame=QO(!0);function QO(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let o=e.changeByRange(r=>{let{from:i,to:s}=r,a=e.doc.lineAt(i),l=!t&&i==s&&sme(e,i);t&&(i=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new xg(e,{simulateBreak:i,simulateDoubleBreak:!!l}),u=xO(c,i);for(u==null&&(u=hg(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:i,to:s}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let d=["",P0(e,u)];return l&&d.push(P0(e,c.lineIndent(a.from,-1))),{changes:{from:i,to:s,insert:Ut.of(d)},range:ze.cursor(i+1+d[1].length)}});return n(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0}}function vx(t,e){let n=-1;return t.changeByRange(o=>{let r=[];for(let s=o.from;s<=o.to;){let a=t.doc.lineAt(s);a.number>n&&(o.empty||o.to>a.from)&&(e(a,r,o),n=a.number),s=a.to+1}let i=t.changes(r);return{changes:r,range:ze.range(i.mapPos(o.anchor,1),i.mapPos(o.head,1))}})}const lme=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),o=new xg(t,{overrideIndentation:i=>{let s=n[i];return s??-1}}),r=vx(t,(i,s,a)=>{let l=xO(o,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let c=/^\s*/.exec(i.text)[0],u=P0(t,l);(c!=u||a.from<i.from+c.length)&&(n[i.from]=l,s.push({from:i.from,to:i.from+c.length,insert:u}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},cme=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(vx(t,(n,o)=>{o.push({from:n.from,insert:t.facet(fx)})}),{userEvent:"input.indent"})),!0),ume=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(vx(t,(n,o)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let i=hg(r,t.tabSize),s=0,a=P0(t,Math.max(0,i-L0(t)));for(;s<r.length&&s<a.length&&r.charCodeAt(s)==a.charCodeAt(s);)s++;o.push({from:n.from+s,to:n.from+r.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),dme=t=>(t.setTabFocusMode(),!0),fme=[{key:"Ctrl-b",run:MO,shift:RO,preventDefault:!0},{key:"Ctrl-f",run:OO,shift:FO},{key:"Ctrl-p",run:PO,shift:HO},{key:"Ctrl-n",run:DO,shift:WO},{key:"Ctrl-a",run:M0e,shift:z0e},{key:"Ctrl-e",run:O0e,shift:H0e},{key:"Ctrl-d",run:YO},{key:"Ctrl-h",run:Gb},{key:"Ctrl-k",run:K0e},{key:"Ctrl-Alt-h",run:XO},{key:"Ctrl-o",run:J0e},{key:"Ctrl-t",run:eme},{key:"Ctrl-v",run:Ub}],hme=[{key:"ArrowLeft",run:MO,shift:RO,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:x0e,shift:P0e,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:$0e,shift:F0e,preventDefault:!0},{key:"ArrowRight",run:OO,shift:FO,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:w0e,shift:D0e,preventDefault:!0},{mac:"Cmd-ArrowRight",run:T0e,shift:V0e,preventDefault:!0},{key:"ArrowUp",run:PO,shift:HO,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Zk,shift:Jk},{mac:"Ctrl-ArrowUp",run:jk,shift:Xk},{key:"ArrowDown",run:DO,shift:WO,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Qk,shift:eS},{mac:"Ctrl-ArrowDown",run:Ub,shift:Kk},{key:"PageUp",run:jk,shift:Xk},{key:"PageDown",run:Ub,shift:Kk},{key:"Home",run:C0e,shift:R0e,preventDefault:!0},{key:"Mod-Home",run:Zk,shift:Jk},{key:"End",run:A0e,shift:I0e,preventDefault:!0},{key:"Mod-End",run:Qk,shift:eS},{key:"Enter",run:tS,shift:tS},{key:"Mod-a",run:W0e},{key:"Backspace",run:Gb,shift:Gb,preventDefault:!0},{key:"Delete",run:YO,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:XO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:X0e,preventDefault:!0},{mac:"Mod-Backspace",run:Z0e,preventDefault:!0},{mac:"Mod-Delete",run:Q0e,preventDefault:!0}].concat(fme.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),pme=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:k0e,shift:E0e},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:S0e,shift:N0e},{key:"Alt-ArrowUp",run:tme},{key:"Shift-Alt-ArrowUp",run:ome},{key:"Alt-ArrowDown",run:nme},{key:"Shift-Alt-ArrowDown",run:rme},{key:"Mod-Alt-ArrowUp",run:q0e},{key:"Mod-Alt-ArrowDown",run:Y0e},{key:"Escape",run:j0e},{key:"Mod-Enter",run:ame},{key:"Alt-l",mac:"Ctrl-l",run:U0e},{key:"Mod-i",run:G0e,preventDefault:!0},{key:"Mod-[",run:ume},{key:"Mod-]",run:cme},{key:"Mod-Alt-\\",run:lme},{key:"Shift-Mod-k",run:ime},{key:"Shift-Mod-\\",run:L0e},{key:"Mod-/",run:t0e},{key:"Alt-A",run:o0e},{key:"Ctrl-m",mac:"Shift-Alt-m",run:dme}].concat(hme);var nS={};class E0{constructor(e,n,o,r,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=o,this.reducePos=r,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,o=0){let r=e.parser.context;return new E0(e,[],n,o,o,0,[],0,r?new oS(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let o=e>>19,r=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(r);if(a&&(this.score+=a),o==0){this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(o-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-d;if(r<i.minRepeatTerm||e&131072){let h=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,h,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let h=this.stack[l-3];this.state=i.getGoto(h,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,n,o,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==o)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=o;return}}}if(!i||this.pos==o)this.buffer.push(e,n,o,r);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>o;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>o;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,r>4&&(r-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=o,this.buffer[s+3]=r}}shift(e,n,o,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=r;let a=s.stateFlag(i,1);!a&&(r>o||n<=s.maxNode)&&(this.reducePos=r),this.pushState(i,a?o:Math.min(o,this.reducePos)),this.shiftContext(n,o),n<=s.maxNode&&this.buffer.push(n,o,r,4)}else this.pos=r,this.shiftContext(n,o),n<=this.p.parser.maxNode&&this.buffer.push(n,o,r,4)}apply(e,n,o,r){e&65536?this.reduce(e):this.shift(e,n,o,r)}useNode(e,n){let o=this.p.reused.length-1;(o<0||this.p.reused[o]!=e)&&(this.p.reused.push(e),o++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(o,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let o=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new E0(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,o,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let o=e<=this.p.parser.maxNode;o&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,o?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new mme(this);;){let o=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(o==0)return!1;if((o&65536)==0)return!0;n.reduce(o)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&r.push(n[i],s);if(this.stack.length<120)for(let i=0;r.length<8&&i<n.length;i+=2){let s=n[i+1];r.some((a,l)=>l&1&&a==s)||r.push(n[i],s)}n=r}let o=[];for(let r=0;r<n.length&&o.length<4;r+=2){let i=n[r+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[r],this.pos),s.reducePos=this.pos,s.score-=200,o.push(s)}return o}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let o=n>>19,r=n&65535,i=this.stack.length-o*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],o=(r,i)=>{if(!n.includes(r))return n.push(r),e.allActions(r,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=o(s,i+1);if(a!=null)return a}})};return o(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new oS(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class oS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class mme{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,o=e>>19;o==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(o-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class N0{constructor(e,n,o){this.stack=e,this.pos=n,this.index=o,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new N0(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new N0(this.stack,this.pos,this.index)}}function Vh(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let o=0,r=0;o<t.length;){let i=0;for(;;){let s=t.charCodeAt(o++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[r++]=i:n=new e(i)}return n}class up{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const rS=new up;class gme{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=rS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let o=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<o.from;){if(!r)return null;let s=this.ranges[--r];i-=o.from-s.to,o=s}for(;n<0?i>o.to:i>=o.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];i+=s.from-o.to,o=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,o,r;if(n>=0&&n<this.chunk.length)o=this.pos+e,r=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(o=i,o>=this.chunk2Pos&&o<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(o-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=o;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=o),o+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-o)),r=this.chunk2.charCodeAt(0)}}return o>=this.token.lookAhead&&(this.token.lookAhead=o+1),r}acceptToken(e,n=0){let o=n?this.resolveOffset(n,-1):this.pos;if(o==null||o<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=o}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=rS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let o="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(o+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return o}}class Hc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:o}=n.p;vme(this.data,e,n,this.id,o.data,o.tokenPrecTable)}}Hc.prototype.contextual=Hc.prototype.fallback=Hc.prototype.extend=!1;Hc.prototype.fallback=Hc.prototype.extend=!1;function vme(t,e,n,o,r,i){let s=0,a=1<<o,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let h=s+3;h<c;h+=2)if((t[h+1]&a)>0){let g=t[h];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||bme(g,e.token.value,r,i))){e.acceptToken(g);break}}let u=e.next,d=0,f=t[s+2];if(e.next<0&&f>d&&t[c+f*3-3]==65535){s=t[c+f*3-1];continue e}for(;d<f;){let h=d+f>>1,g=c+h+(h<<1),b=t[g],m=t[g+1]||65536;if(u<b)f=h;else if(u>=m)d=h+1;else{s=t[g+2],e.advance();continue e}}break}}function iS(t,e,n){for(let o=e,r;(r=t[o])!=65535;o++)if(r==n)return o-e;return-1}function bme(t,e,n,o){let r=iS(n,o,e);return r<0||iS(n,o,t)<r}const hr=typeof process<"u"&&nS&&/\bparse\b/.test(nS.LOG);let Yv=null;function sS(t,e,n){let o=t.cursor(yn.IncludeAnonymous);for(o.moveTo(e);;)if(!(n<0?o.childBefore(e):o.childAfter(e)))for(;;){if((n<0?o.to<e:o.from>e)&&!o.type.isError)return n<0?Math.max(0,Math.min(o.to-1,e-25)):Math.min(t.length,Math.max(o.from+1,e+25));if(n<0?o.prevSibling():o.nextSibling())break;if(!o.parent())return n<0?0:t.length}}class yme{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?sS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?sS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let o=this.trees[n],r=this.index[n];if(r==o.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=o.children[r],s=this.start[n]+o.positions[r];if(s>e)return this.nextStart=s,null;if(i instanceof Tn){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Nt.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class xme{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(o=>new up)}getActions(e){let n=0,o=null,{parser:r}=e.p,{tokenizers:i}=r,s=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(o&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let f=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(o=d,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!o&&e.pos==this.stream.end&&(o=new up,o.value=e.p.parser.eofTerm,o.start=o.end=e.pos,n=this.addActions(e,o.value,o.end,n)),this.mainToken=o,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new up,{pos:o,p:r}=e;return n.start=o,n.end=Math.min(o+1,r.stream.end),n.value=o==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,o){let r=this.stream.clipPos(o.pos);if(n.token(this.stream.reset(r,e),o),e.value>-1){let{parser:i}=o.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),o);if(a>=0&&o.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,o,r){for(let i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=o,r}addActions(e,n,o,r){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=$s(a,c+2);else{r==0&&a[c+1]==2&&(r=this.putAction($s(a,c+2),n,o,r));break}a[c]==n&&(r=this.putAction($s(a,c+1),n,o,r))}return r}}class wme{constructor(e,n,o,r){this.parser=e,this.input=n,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new gme(n,r),this.tokens=new xme(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[E0.start(this,e.top[0],i)],this.fragments=o.length&&this.stream.end-i>e.bufferLength*4?new yme(o,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,o=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)o.push(a);else{if(this.advanceStack(a,o,e))continue;{r||(r=[],i=[]),r.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!o.length){let s=r&&kme(r);if(s)return hr&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw hr&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,o);if(s)return hr&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(o.length>s)for(o.sort((a,l)=>l.score-a.score);o.length>s;)o.pop();o.some(a=>a.reducePos>n)&&this.recovering--}else if(o.length>1){e:for(let s=0;s<o.length-1;s++){let a=o[s];for(let l=s+1;l<o.length;l++){let c=o[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)o.splice(l--,1);else{o.splice(s--,1);continue e}}}o.length>12&&(o.sort((s,a)=>a.score-s.score),o.splice(12,o.length-12))}this.minStackPos=o[0].pos;for(let s=1;s<o.length;s++)o[s].pos<this.minStackPos&&(this.minStackPos=o[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,o){let r=e.pos,{parser:i}=this,s=hr?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(r);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(Nt.contextHash)||0)==u))return e.useNode(d,f),hr&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof Tn)||d.children.length==0||d.positions[0]>0)break;let h=d.children[0];if(h instanceof Tn&&d.positions[0]==0)d=h;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),hr&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],f=l[c++],h=c==l.length||!o,g=h?e:e.split(),b=this.tokens.mainToken;if(g.apply(u,d,b?b.start:g.pos,f),hr&&console.log(s+this.stackID(g)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${r}${g==e?"":", split"})`),h)return!0;g.pos>r?n.push(g):o.push(g)}return!1}advanceFully(e,n){let o=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>o)return aS(e,n),!0}}runRecovery(e,n,o){let r=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=hr?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),hr&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,o))))continue;let d=a.split(),f=u;for(let h=0;h<10&&d.forceReduce()&&(hr&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,o));h++)hr&&(f=this.stackID(d)+" -> ");for(let h of a.recoverByInsert(l))hr&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,o);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),hr&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),aS(a,o)):(!r||r.score<d.score)&&(r=d)}return r}stackToTree(e){return e.close(),Tn.build({buffer:N0.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Yv||(Yv=new WeakMap)).get(e);return n||Yv.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function aS(t,e){for(let n=0;n<e.length;n++){let o=e[n];if(o.pos==t.pos&&o.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class _me{constructor(e,n,o){this.source=e,this.flags=n,this.disabled=o}allows(e){return!this.disabled||this.disabled[e]==0}}class I0 extends hO{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let o=Object.keys(e.topRules).map(a=>e.topRules[a][1]),r=[];for(let a=0;a<n.length;a++)r.push([]);function i(a,l,c){r[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Nt[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let f=-u;f>0;f--)i(a[c++],l,d);c++}}}this.nodeSet=new lx(n.map((a,l)=>lr.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:o.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=cO;let s=Vh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(lS),this.states=Vh(e.states,Uint32Array),this.data=Vh(e.stateData),this.goto=Vh(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Hc(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,o){let r=new wme(this,e,n,o);for(let i of this.wrappers)r=i(r,e,n,o);return r}getGoto(e,n,o=!1){let r=this.goto;if(n>=r[0])return-1;for(let i=r[n+1];;){let s=r[i++],a=s&1,l=r[i++];if(a&&o)return l;for(let c=i+(s>>1);i<c;i++)if(r[i]==e)return l;if(a)return-1}}hasAction(e,n){let o=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),s;;i+=3){if((s=o[i])==65535)if(o[i+1]==1)s=o[i=$s(o,i+2)];else{if(o[i+1]==2)return $s(o,i+2);break}if(s==n||s==0)return $s(o,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,o=>o==n?!0:null)}allActions(e,n){let o=this.stateSlot(e,4),r=o?n(o):void 0;for(let i=this.stateSlot(e,1);r==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$s(this.data,i+2);else break;r=n($s(this.data,i+1))}return r}nextStates(e){let n=[];for(let o=this.stateSlot(e,1);;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=$s(this.data,o+2);else break;if((this.data[o+2]&1)==0){let r=this.data[o+1];n.some((i,s)=>s&1&&i==r)||n.push(this.data[o],r)}}return n}configure(e){let n=Object.assign(Object.create(I0.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let o=this.topRules[e.top];if(!o)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=o}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(o=>{let r=e.tokenizers.find(i=>i.from==o);return r?r.to:o})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((o,r)=>{let i=e.specializers.find(a=>a.from==o.external);if(!i)return o;let s=Object.assign(Object.assign({},o),{external:i.to});return n.specializers[r]=lS(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),o=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(o[s]=!0)}let r=null;for(let i=0;i<n.length;i++)if(!o[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new _me(e,o,r)}static deserialize(e){return new I0(e)}}function $s(t,e){return t[e]|t[e+1]<<16}function kme(t){let e=null;for(let n of t){let o=n.p.stoppedAt;(n.pos==n.p.stream.end||o!=null&&n.pos>o)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function lS(t){if(t.external){let e=t.extend?1:0;return(n,o)=>t.external(n,o)<<1|e}return t.get}const Sme={__proto__:null,chart:10,data:16,colorize:38,highlight:40,areafill:44,range:48,note:52,annotation:56,series:60,scene:64,step:66,transform:72},Ame=I0.deserialize({version:14,states:",`OYQPOOQOQPOOO_QPO'#C_OdQPO,58yO!dQPO1G.eOOQO'#Cf'#CfO!kQPO'#CmOOQO'#Cb'#CbOOQO'#DR'#DRO!pQPO7+$PO!wQPO'#CcO!|QPO'#CnO#RQPO'#CqO#WQPO'#CsO#]QPO'#CuO#bQPO'#CwO#gQPO'#CyO#lQPO'#DPO#qQPO'#C{OOQO7+$P7+$PO#yQPO,59XOOQO-E7P-E7POOQO<<Gk<<GkO$XQPO,58}O$dQPO,59YO$iQPO,59]O$nQPO,59_O$yQPO,59aO%UQPO,59cO%ZQPO,59eO%`QPO,59kO&YQPO,59gO&aQPO,59gOOQO'#Cj'#CjOOQO1G.s1G.sO&fQPO'#CmOOQO'#Ce'#CeOOQO'#DS'#DSO&kQPO1G.iOOQO1G.i1G.iO&vQPO1G.tO'RQPO1G.wOOQO'#DU'#DUO'WQPO1G.yOOQO1G.y1G.yO'cQPO1G.{OOQO1G.{1G.{O'nQPO1G.}O'yQPO1G/PO(UQPO1G/VOOQO'#DO'#DOOOQO'#DV'#DVO(aQPO1G/ROOQO1G/R1G/RO(aQPO1G/RO#yQPO,59XOOQO-E7Q-E7QOOQO7+$T7+$TO(hQPO7+$`OOQO7+$`7+$`O(sQPO7+$cOOQO-E7S-E7SOOQO7+$e7+$eOOQO7+$g7+$gO)OQPO7+$iOOQO7+$i7+$iO)ZQPO7+$kOOQO7+$k7+$kO)fQPO7+$qOOQO7+$q7+$qOOQO-E7T-E7TOOQO7+$m7+$mO)qQPO7+$mO)xQPO1G.sOOQO1G.k1G.kOOQO<<Gz<<GzO*WQPO<<G}OOQO<<G}<<G}OOQO<<HT<<HTOOQO<<HV<<HVOOQO<<H]<<H]OOQO<<HX<<HXO#yQPO'#DTO*cQPO,59TOOQOAN=iAN=iOOQO,59o,59oOOQO-E7R-E7R",stateData:"*w~O|OSPOS~OTQO~OSRO~O}SO~OSTOWYOZTOcZOdZOf[Oh]Oj^Ol_On`OpbOqbOtaO~O!PcO~PiO[dO~O!PfO~PiO}gO~OZhO~OZiO~O}jO~O}kO~OZlO~OZmO~OSnO~OZpO}oO~OSqOZqO_qO`qO~OSTOZTO!PwO~O}xO~OZyO~OSTOZTO!P|O~OSTOZTO!P!OO~O}!PO~O}!QO~O}!RO~OSTOWYOZTOcZOdZOf[Oh]Oj^Ol_On`OtaO~O!P!VO~P%eO}!WO~O[!XO~OSTOZTO!P!ZO~OSTOZTO!P!]O~O}!^O~OSTOZTO!P!`O~OSTOZTO!P!aO~OSTOZTO!P!cO~OSTOZTO!P!eO~OSTOZTO!P!gO~O!P!iO~P%eOSTOZTO!P!mO~OSTOZTO!P!oO~OSTOZTO!P!pO~OSTOZTO!P!qO~OSTOZTO!P!rO~O!P!sO~P%eO!O!tOSaiZai!Pai~OSTOZTO!P!vO~O!O!tOS]aZ]a!P]a~O_`PSP~",goto:"%`zPPP{PP!O!SP!^!bPP!|#PPP#Y!SPP!SP!SP!SP!SP!SP#xPP#|!SP$S$Y$`$f%URPOTWSXSVSXX!So!U!W!jTugvxUSXjkox{}!P!Q!R!U!W![!^!b!d!f!j!nTsgvR!l!XQrdQ!k!XR!w!tSVSXStgvlzjkx{}!P!Q!R![!^!b!d!f!nX!So!U!W!jTVSXX!To!U!W!jQXSReXQvgR!YvQ!u!kR!x!uQ{jQ}kQ![x^!_{}![!b!d!f!nQ!b!PQ!d!QQ!f!RR!n!^Q!UoS!h!U!jR!j!W",nodeNames:"⚠ LineComment Chart ChartDecl Identifier chart ChartMember DataBlock data DataEntry PropertyKey String Equals ValueList PropertyValue Percentage Number Property Colorize colorize highlight AreaFill areafill RangeAnnotation range NoteAnnotation note Annotation annotation Series series Scene scene step SceneMember Transform transform",maxTerm:47,skippedNodes:[0,1],repeatNodeCount:5,tokenData:"']~RfX^!gpq!grs#[st$u|}%^}!O%c!P!Q&_!Q![%i!_!`&|!c!}$u#R#S$u#T#o$u#o#p'R#q#r'W#y#z!g$f$g!g#BY#BZ!g$IS$I_!g$I|$JO!g$JT$JU!g$KV$KW!g&FU&FV!g~!lY|~X^!gpq!g#y#z!g$f$g!g#BY#BZ!g$IS$I_!g$I|$JO!g$JT$JU!g$KV$KW!g&FU&FV!g~#_VOr#[rs#ts#O#[#O#P#y#P;'S#[;'S;=`$o<%lO#[~#yOZ~~#|ZOr#[rs#[s#O#[#O#P#[#P#b#[#b#c#[#c#h#[#h#i#[#i;'S#[;'S;=`$o<%lO#[~$rP;=`<%l#[~$zUS~st$u}!O$u!Q![$u!c!}$u#R#S$u#T#o$u~%cO!O~~%fP!Q![%i~%nR`~uv%w!O!P%|!Q![%i~%|O_~~&PP!Q![&S~&XQ`~uv%w!Q![&S~&bP!P!Q&e~&jSP~OY&eZ;'S&e;'S;=`&v<%lO&e~&yP;=`<%l&e~'RO[~~'WO}~~']O!P~",tokenizers:[0],topRules:{Chart:[0,2]},specialized:[{term:4,get:t=>Sme[t]||-1}],tokenPrec:447}),JO=Ame.configure({props:[pO({chart:at.keyword,data:at.keyword,colorize:at.keyword,highlight:at.keyword,areafill:at.keyword,annotation:at.keyword,range:at.keyword,note:at.keyword,series:at.keyword,scene:at.keyword,step:at.keyword,transform:at.keyword,Identifier:at.variableName,String:at.string,Number:at.number,Percentage:at.number,Equals:at.operator,LineComment:at.lineComment,"{ }":at.brace})]}),Cme=O0.define({parser:JO,languageData:{commentTokens:{line:"//"}}}),$me=Upe(bO);function Tme(){return new Ppe(Cme)}function jv(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function bbe(t){const e=JO.parse(t);let n=0,o="";return vO(e,bO,(r,i,s)=>{r>n&&(o+=jv(t.slice(n,r))),o+=`<span class="${s}">${jv(t.slice(r,i))}</span>`,n=i}),n<t.length&&(o+=jv(t.slice(n))),o}const Mme={class:"d-flex flex-column h-100"},Ome={key:0,class:"text-danger small mt-1"},Bme=le({__name:"ChartEditDsl",setup(t){const{dsl:e}=Nf(),{applyDsl:n}=Ic(),o=ft("editorEl"),r=Ve();let i,s=!1;function a(l){if(!l.docChanged||s)return;const c=l.state.doc.toString(),u=n(c);u.success?r.value=void 0:r.value=u.error}return un(()=>{const l=Kt.create({doc:e.value,extensions:[lO.of([...pme,...y0e]),u0e(),Tme(),$me,_t.updateListener.of(a),_t.theme({"&":{height:"100%",backgroundColor:"var(--bc-tile-bg-elevated)"},".cm-scroller":{overflow:"auto"},".cm-content":{fontFamily:"var(--bs-font-monospace)"},".cm-gutters":{backgroundColor:"var(--bc-tile-bg-elevated)",color:"var(--bs-secondary-color)",borderRight:"1px solid var(--bs-border-color)"}})]});i=new _t({state:l,parent:o.value})}),Ge(e,l=>{!i||i.state.doc.toString()===l||(s=!0,i.dispatch({changes:{from:0,to:i.state.doc.length,insert:l}}),s=!1)}),Qs(()=>{i==null||i.destroy(),i=void 0}),(l,c)=>(w(),R("div",Mme,[M("div",{ref_key:"editorEl",ref:o,class:"flex-grow-1 overflow-auto"},null,512),p(r)?(w(),R("div",Ome,ye(p(r)),1)):ie("",!0)]))}}),Lme={key:1,class:"position-absolute",width:"0",height:"0","aria-hidden":"true"},Pme=le({__name:"PreviewChart",setup(t){const e=ft("containerRef");G2(e);const{containerRef:n}=HT();Ge(e,D=>{n.value=D},{immediate:!0});const{selectAnnotation:o}=cr();function r(D){var $;const C=D.target.closest("g[data-annotation-index]");if(!C)return;D.preventDefault(),($=window.getSelection())==null||$.removeAllRanges();const T=C.getAttribute("data-annotation-id");if(T){o(T);return}const P=parseInt(C.getAttribute("data-annotation-index")||"",10);isNaN(P)||o(P)}un(()=>{var D;(D=e.value)==null||D.addEventListener("dblclick",r)}),Gs(()=>{var D;(D=e.value)==null||D.removeEventListener("dblclick",r)});const{cvdMode:i}=Ct(GT()),s=ft("cvdDefsRef");Ge([i,s],([D,I])=>{if(I){for(;I.firstChild;)I.removeChild(I.firstChild);D&&I.appendChild(toe(D))}},{immediate:!0});const a=A(()=>{if(i.value)return{filter:`url(#${Y$(i.value)})`}}),{layout:l}=dn(),{scenes:c,activeIndex:u,playing:d,setActive:f,nextScene:h,previousScene:g,startPlayback:b,stopPlayback:m}=wn(),v=Ve(null),y={buttons:T1,"progress-bar":YA,"dot-stepper":jA,"minimal-arrows":XA},x=A(()=>y[l.value.playerType]),_=A(()=>c.value.length+1),k=A(()=>u.value+2),E=A(()=>c.value.length>=1&&l.value.playerType!=="none");function B(D){f(D-2)}let S=null;function L(){const D=e.value;return D?D.querySelector(".bc-frame-footer"):null}return Ge(e,D=>{if(S&&(S.disconnect(),S=null),!D){v.value=null;return}v.value=L(),S=new MutationObserver(()=>{v.value=L()}),S.observe(D,{childList:!0,subtree:!0})},{immediate:!0}),Gs(()=>{S&&(S.disconnect(),S=null)}),(D,I)=>(w(),R(He,null,[M("div",{ref_key:"containerRef",ref:e,class:"w-100 h-100",style:Et(p(a))},null,4),p(v)&&p(E)?(w(),J(ty,{key:0,to:p(v)},[(w(),J(Gt(p(x)),{total:p(_),current:p(k),playing:p(d),position:p(l).playerPosition,"onUpdate:current":B,onPrevious:p(g),onNext:p(h),onPlay:p(b),onPause:p(m)},null,40,["total","current","playing","position","onPrevious","onNext","onPlay","onPause"]))],8,["to"])):ie("",!0),p(i)?(w(),R("svg",Lme,[M("defs",{ref_key:"cvdDefsRef",ref:s},null,512)])):ie("",!0)],64))}}),Dme=le({__name:"ChartEditPanel",setup(t){const e=cr(),{viewMode:n,activeTab:o,canvasMode:r,showDimensions:i}=Ct(e),{selectTab:s,setLastNarrowEditTab:a}=e,{mode:l}=rc(),{isNarrow:c}=Ji(),{layout:u}=dn(),{cardClass:d,cardStyle:f}=U2(u,"chart-edit-panel__canvas__card"),{sections:h}=IT(),g=A({get:()=>!!o.value,set:I=>{I||s("")}});Ge(l,I=>{I==="drawer"&&o.value&&(a(o.value),s(""))},{immediate:!0});function b(I){a(I),s(I)}const m=A(()=>h.value.map(I=>({key:I.key,label:I.label,icon:I.icon}))),v=A(()=>({"chart-edit-panel--narrow":c.value})),y=A(()=>({[`chart-edit-panel__canvas--${r.value}`]:r.value!=="blueprint","chart-edit-panel__canvas--dsl":n.value!=="preview"})),x={type:"Chart Type",text:"Text",style:"Style",layout:"Layout",series:"Series",axes:"Axes",annotate:"Annotate",interactions:"Interactions"},_=A(()=>x[o.value]??"Panel"),k=ft("canvasRef"),E=ft("cardRef"),B=Ie(0),S=Ie(0);function L(){const I=E.value;I&&(B.value=I.offsetLeft,S.value=I.offsetTop)}is(k,L),is(E,L);const D=A(()=>({"--grid-offset-x":`${B.value}px`,"--grid-offset-y":`${S.value}px`}));return(I,C)=>{const T=Pme,P=Bme,$=DT,F=PT,V=W2,U=Zde,K=Gde,se=Rde,he=Nde,ce=Xue,be=Hue,oe=Eue,de=oue,we=Wle,ee=H2,ge=ug,Q=Sle;return w(),R("div",{class:Me(["chart-edit-panel",p(v)])},[M("div",{ref_key:"canvasRef",ref:k,class:Me(["chart-edit-panel__canvas",p(y)]),style:Et(p(D))},[p(n)==="preview"?(w(),R("div",{key:0,ref_key:"cardRef",ref:E,class:Me(["chart-edit-panel__canvas__card",p(d)]),style:Et(p(f))},[H(T)],6)):(w(),J(P,{key:1,class:"chart-edit-panel__canvas__dsl"})),p(n)==="preview"&&p(i)?(w(),J($,{key:2,"card-ref":p(E),"canvas-ref":p(k),layout:p(u)},null,8,["card-ref","canvas-ref","layout"])):ie("",!0),p(n)==="preview"?(w(),J(F,{key:3})):ie("",!0)],6),H(ge,{"drawer-open":p(g),"onUpdate:drawerOpen":C[0]||(C[0]=re=>Ze(g)?g.value=re:null),title:p(_),"container-ref":p(k),onClose:C[1]||(C[1]=re=>p(s)(""))},bi({default:te(()=>[p(o)==="type"?(w(),J(K,{key:0})):p(o)==="text"?(w(),J(se,{key:1})):p(o)==="style"?(w(),J(he,{key:2})):p(o)==="series"?(w(),J(ce,{key:3})):p(o)==="axes"?(w(),J(be,{key:4})):p(o)==="layout"?(w(),J(oe,{key:5})):p(o)==="annotate"?(w(),J(de,{key:6})):p(o)==="interactions"?(w(),J(we,{key:7})):ie("",!0)]),_:2},[p(l)==="drawer"?{name:"tabs",fn:te(()=>[H(V,{tabs:p(m),"model-value":p(o),sticky:"","onUpdate:modelValue":b},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(l)!=="drawer"?{name:"header",fn:te(()=>[H(U)]),key:"1"}:void 0,p(l)!=="drawer"?{name:"footer",fn:te(()=>[H(ee)]),key:"2"}:void 0]),1032,["drawer-open","title","container-ref"]),p(c)?ie("",!0):(w(),J(Q,{key:0}))],2)}}}),Eme=Be(Dme,[["__scopeId","data-v-70b3f6b1"]]),Nme={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Ime(t,e){return w(),R("svg",Nme,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M104 32H64a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176H64V48h40Zm88-176h-40a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176h-40V48h40Z"},null,-1)])])}const Rme=Oe({name:"ph-columns",render:Ime}),Fme={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Vme(t,e){return w(),R("svg",Fme,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"m245.66 74.34l-32-32a8 8 0 0 0-11.32 11.32L220.69 72H208c-49.33 0-61.05 28.12-71.38 52.92c-9.38 22.51-16.92 40.59-49.48 42.84a40 40 0 1 0 .1 16c43.26-2.65 54.34-29.15 64.14-52.69C161.41 107 169.33 88 208 88h12.69l-18.35 18.34a8 8 0 0 0 11.32 11.32l32-32a8 8 0 0 0 0-11.32M48 200a24 24 0 1 1 24-24a24 24 0 0 1-24 24"},null,-1)])])}const zme=Oe({name:"ph-flow-arrow",render:Vme}),Hme={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Wme(t,e){return w(),R("svg",Hme,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M176 232a8 8 0 0 1-8 8H88a8 8 0 0 1 0-16h80a8 8 0 0 1 8 8m40-128a87.55 87.55 0 0 1-33.64 69.21A16.24 16.24 0 0 0 176 186v6a16 16 0 0 1-16 16H96a16 16 0 0 1-16-16v-6a16 16 0 0 0-6.23-12.66A87.59 87.59 0 0 1 40 104.49C39.74 56.83 78.26 17.14 125.88 16A88 88 0 0 1 216 104m-16 0a72 72 0 0 0-73.74-72c-39 .92-70.47 33.39-70.26 72.39a71.65 71.65 0 0 0 27.64 56.3A32 32 0 0 1 96 186v6h64v-6a32.15 32.15 0 0 1 12.47-25.35A71.65 71.65 0 0 0 200 104m-16.11-9.34a57.6 57.6 0 0 0-46.56-46.55a8 8 0 0 0-2.66 15.78c16.57 2.79 30.63 16.85 33.44 33.45A8 8 0 0 0 176 104a9 9 0 0 0 1.35-.11a8 8 0 0 0 6.54-9.23"},null,-1)])])}const Ume=Oe({name:"ph-lightbulb",render:Wme});function eB(){return{sections:[{key:"column",label:"Columns",icon:Rme},{key:"transforms",label:"Transforms",icon:zme},{key:"parsing",label:"Parsing",icon:BT},{key:"reco",label:"Recommendations",icon:Ume}]}}const Gme=le({__name:"DataSideIconRail",props:{disabledTabs:{default:()=>[]}},setup(t){const e=t,n=cr(),{dataPanelTab:o}=Ct(n),{openDataPanel:r}=n,{mode:i,toggleMode:s}=rc(),{sections:a}=eB(),l=A(()=>a.filter(d=>!e.disabledTabs.includes(d.key)).map(d=>({value:d.key,icon:d.icon,tooltip:d.tooltip??d.label})));function c(d){r(d)}function u(){i.value==="closed"&&r(o.value||"column"),s()}return(d,f)=>{const h=V2;return w(),J(h,{"active-tab":p(o),items:p(l),onSelect:c,onToggleMode:u},null,8,["active-tab","items"])}}}),qme={class:"reco-card__preview"},Yme={class:"reco-card__body"},jme={class:"reco-card__body__title"},Xme={class:"reco-card__body__reason"},Kme=le({__name:"DataRecommendationCard",props:{chartType:{},label:{},fitness:{},reason:{}},emits:["select"],setup(t){const e={[Le.BarVertical]:Oe(qT),[Le.BarHorizontal]:Oe(YT),[Le.BarMulti]:Oe(jT),[Le.Line]:Oe(XT),[Le.LineMulti]:Oe(KT),[Le.Donut]:Oe(ZT),[Le.Pie]:Oe(QT)},n=t,o=A(()=>e[n.chartType]),r=A(()=>n.fitness==="best"?"reco-card__body__title__badge--best":n.fitness==="good"?"reco-card__body__title__badge--good":"reco-card__body__title__badge--alt"),i=A(()=>n.fitness==="best"?"Best match":n.fitness==="good"?"Good fit":"Alternative");return(s,a)=>(w(),R("button",{class:Me(["reco-card",{"reco-card--best":t.fitness==="best"}]),onClick:a[0]||(a[0]=l=>s.$emit("select",t.chartType))},[M("div",qme,[p(o)?(w(),J(Gt(p(o)),{key:0,class:"reco-card__preview__thumb-svg"})):ie("",!0)]),M("div",Yme,[M("div",jme,[Ye(ye(t.label)+" ",1),M("span",{class:Me(["reco-card__body__title__badge",p(r)])},ye(p(i)),3)]),M("div",Xme,ye(t.reason),1)])],2))}}),Zme=Be(Kme,[["__scopeId","data-v-0e22d5d1"]]);function Qme(){const{displayRows:t,displayColumnTypes:e}=jo(),n=A(()=>{const r=e.value,i=r.filter(c=>c==="string").length,s=r.filter(c=>c==="number").length,a=r.filter(c=>c==="date").length,l=[];return i>0&&l.push(`${i} categorical`),a>0&&l.push(`${a} date`),s>0&&l.push(`${s} numeric`),l.length>0?`${l.join(" + ")} column${r.length!==1?"s":""}`:"No data"});return{recommendations:A(()=>Jne(e.value,t.value.length)),dataSummary:n}}const Jme={class:"data-recommendations"},ege={class:"data-recommendations__summary"},tge={key:0,class:"text-muted text-center py-3"},nge=le({__name:"DataRecommendations",setup(t){const{recommendations:e,dataSummary:n}=Qme(),o=dn();function r(i){o.chartType.value=i}return(i,s)=>{const a=Zme;return w(),R("div",Jme,[M("p",ege," Based on your data: "+ye(p(n)),1),p(e).length===0?(w(),R("div",tge," Load data to see recommendations ")):ie("",!0),(w(!0),R(He,null,ht(p(e),l=>(w(),J(a,{key:l.chartType,"chart-type":l.chartType,label:l.label,fitness:l.fitness,reason:l.reason,onSelect:r},null,8,["chart-type","label","fitness","reason"]))),128))])}}}),oge=Be(nge,[["__scopeId","data-v-47bbaf64"]]),cS={firstRowIsHeader:!0,delimiter:"auto",decimalSeparator:".",treatEmptyAsNull:!0,trimWhitespace:!0},rge=Oo("parseOptions",()=>{const t=ir({...cS});function e(o,r){t[o]=r}function n(){Object.assign(t,{...cS})}return{...K0(t),setOption:e,reset:n}});function tB(){const t=rge(),{firstRowIsHeader:e,delimiter:n,decimalSeparator:o,treatEmptyAsNull:r,trimWhitespace:i}=Ct(t);return{firstRowIsHeader:e,delimiter:n,decimalSeparator:o,treatEmptyAsNull:r,trimWhitespace:i,setOption:t.setOption,reset:t.reset}}const ige={class:"data-parse-settings"},sge={class:"data-parse-settings__field"},age={class:"data-parse-settings__field"},lge=le({__name:"DataParseSettings",setup(t){const e=tB(),{firstRowIsHeader:n,delimiter:o,decimalSeparator:r,treatEmptyAsNull:i,trimWhitespace:s}=Ct(e),{setOption:a}=e,{sourceFormat:l}=jo(),c=A(()=>l.value!=="delimited"),u=A({get:()=>n.value,set:v=>a("firstRowIsHeader",v)}),d=A({get:()=>o.value,set:v=>a("delimiter",v)}),f=A({get:()=>r.value,set:v=>a("decimalSeparator",v)}),h=A({get:()=>i.value,set:v=>a("treatEmptyAsNull",v)}),g=A({get:()=>s.value,set:v=>a("trimWhitespace",v)}),b=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma (,)"},{value:" ",label:"Tab"},{value:";",label:"Semicolon (;)"},{value:"|",label:"Pipe (|)"}],m=[{value:".",label:"Period (.)"},{value:",",label:"Comma (,)"}];return(v,y)=>(w(),R("div",ige,[H(p(Rs),{modelValue:p(u),"onUpdate:modelValue":y[0]||(y[0]=x=>Ze(u)?u.value=x:null),switch:""},{default:te(()=>[...y[5]||(y[5]=[Ye(" First row is header ",-1)])]),_:1},8,["modelValue"]),M("div",sge,[y[6]||(y[6]=M("div",{class:"data-parse-settings__field__label"}," Delimiter ",-1)),H(p(En),{modelValue:p(d),"onUpdate:modelValue":y[1]||(y[1]=x=>Ze(d)?d.value=x:null),label:"",options:b,disabled:p(c),block:""},null,8,["modelValue","disabled"])]),M("div",age,[y[7]||(y[7]=M("div",{class:"data-parse-settings__field__label"}," Decimal Separator ",-1)),H(p(En),{modelValue:p(f),"onUpdate:modelValue":y[2]||(y[2]=x=>Ze(f)?f.value=x:null),label:"",options:m,block:""},null,8,["modelValue"])]),H(p(Rs),{modelValue:p(h),"onUpdate:modelValue":y[3]||(y[3]=x=>Ze(h)?h.value=x:null),switch:""},{default:te(()=>[...y[8]||(y[8]=[Ye(" Treat empty as null ",-1)])]),_:1},8,["modelValue"]),H(p(Rs),{modelValue:p(g),"onUpdate:modelValue":y[4]||(y[4]=x=>Ze(g)?g.value=x:null),switch:""},{default:te(()=>[...y[9]||(y[9]=[Ye(" Trim whitespace ",-1)])]),_:1},8,["modelValue"])]))}}),cge=Be(lge,[["__scopeId","data-v-872473d2"]]),uge={class:"output-block"},dge={class:"output-block__meta"},fge=le({__name:"DataTransformOutputBlock",props:{columns:{},rows:{}},setup(t){return(e,n)=>(w(),R("div",uge,[n[0]||(n[0]=M("span",{class:"output-block__icon"},[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",width:"14",height:"14"},[M("path",{d:"M20 6L9 17l-5-5"})])],-1)),n[1]||(n[1]=M("span",null,"Output",-1)),M("span",dge,ye(t.columns)+" cols · "+ye(t.rows)+" rows",1)]))}}),hge=Be(fge,[["__scopeId","data-v-b1080d62"]]),pge={class:"add-wrap"},mge={key:0,class:"add-wrap__dropdown"},gge=["disabled","onClick"],vge={class:"add-wrap__dropdown__item__text"},bge={class:"add-wrap__dropdown__item__text__name"},yge={class:"add-wrap__dropdown__item__text__desc"},xge=le({__name:"DataTransformAddButton",emits:["add"],setup(t,{emit:e}){const n=e,o=Ie(!1),r=[{value:Je.Sort,label:"Sort",desc:"Reorder rows by column values",disabled:!1},{value:Je.Filter,label:"Filter",desc:"Keep or exclude rows by condition",disabled:!1},{value:Je.HideColumns,label:"Hide Columns",desc:"Remove columns from output",disabled:!1},{value:Je.Transpose,label:"Transpose",desc:"Swap rows and columns",disabled:!1},{value:Je.Parse,label:"Parse",desc:"Transform column values",disabled:!1},{value:Je.Rename,label:"Rename Column",desc:"Change a column name",disabled:!1},{value:Je.GroupBy,label:"Group By",desc:"Aggregate rows by column values",disabled:!1},{value:Je.Computed,label:"Computed Column",desc:"Derive new column (coming soon)",disabled:!0}];function i(l){return{[Je.Sort]:"add-wrap__dropdown__item__icon--sort",[Je.Filter]:"add-wrap__dropdown__item__icon--filter",[Je.HideColumns]:"add-wrap__dropdown__item__icon--hide-columns",[Je.Transpose]:"add-wrap__dropdown__item__icon--transpose",[Je.Parse]:"add-wrap__dropdown__item__icon--parse",[Je.Rename]:"add-wrap__dropdown__item__icon--rename",[Je.GroupBy]:"add-wrap__dropdown__item__icon--group",[Je.Computed]:"add-wrap__dropdown__item__icon--computed"}[l]??""}function s(l){return{[Je.Sort]:"S",[Je.Filter]:"F",[Je.HideColumns]:"H",[Je.Transpose]:"T",[Je.Parse]:"P",[Je.Rename]:"R",[Je.GroupBy]:"G",[Je.Computed]:"C"}[l]??"?"}function a(l){n("add",l),o.value=!1}return(l,c)=>(w(),R("div",pge,[H(p(Sl),{label:"Add",onClick:c[0]||(c[0]=u=>o.value=!p(o))}),p(o)?(w(),R("div",mge,[(w(),R(He,null,ht(r,u=>M("button",{key:u.value,class:"add-wrap__dropdown__item",disabled:u.disabled,onClick:d=>a(u.value)},[M("span",{class:Me(["add-wrap__dropdown__item__icon",i(u.value)])},ye(s(u.value)),3),M("div",vge,[M("div",bge,ye(u.label),1),M("div",yge,ye(u.desc),1)])],8,gge)),64))])):ie("",!0)]))}}),wge=Be(xge,[["__scopeId","data-v-ac055819"]]),_ge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function kge(t,e){return w(),R("svg",_ge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M128 128a8 8 0 0 1-8 8H48a8 8 0 0 1 0-16h72a8 8 0 0 1 8 8M48 72h136a8 8 0 0 0 0-16H48a8 8 0 0 0 0 16m56 112H48a8 8 0 0 0 0 16h56a8 8 0 0 0 0-16m125.66-21.66a8 8 0 0 0-11.32 0L192 188.69V112a8 8 0 0 0-16 0v76.69l-26.34-26.35a8 8 0 0 0-11.32 11.32l40 40a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0 0-11.32"},null,-1)])])}const Sge=Oe({name:"ph-sort-ascending",render:kge}),Age={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Cge(t,e){return w(),R("svg",Age,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M230.6 49.53A15.81 15.81 0 0 0 216 40H40a16 16 0 0 0-11.81 26.76l.08.09L96 139.17V216a16 16 0 0 0 24.87 13.32l32-21.34a16 16 0 0 0 7.13-13.32v-55.49l67.74-72.32l.08-.09a15.8 15.8 0 0 0 2.78-17.23m-84.42 81.05A8 8 0 0 0 144 136v58.66L112 216v-80a8 8 0 0 0-2.16-5.47L40 56h176Z"},null,-1)])])}const $ge=Oe({name:"ph-funnel",render:Cge}),Tge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Mge(t,e){return w(),R("svg",Tge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 48v48a8 8 0 0 1-8 8h-48a8 8 0 0 1 0-16h28.69l-14.63-14.63a79.56 79.56 0 0 0-56.13-23.43h-.45a79.52 79.52 0 0 0-55.89 22.77a8 8 0 0 1-11.18-11.44a96 96 0 0 1 135 .79L208 76.69V48a8 8 0 0 1 16 0m-37.59 135.29a80 80 0 0 1-112.47-.66L59.31 168H88a8 8 0 0 0 0-16H40a8 8 0 0 0-8 8v48a8 8 0 0 0 16 0v-28.69l14.63 14.63A95.43 95.43 0 0 0 130 222.06h.53a95.36 95.36 0 0 0 67.07-27.33a8 8 0 0 0-11.18-11.44Z"},null,-1)])])}const nB=Oe({name:"ph-arrows-clockwise",render:Mge}),Oge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Bge(t,e){return w(),R("svg",Oge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M226.76 69a8 8 0 0 0-12.84-2.88l-40.3 37.19l-17.23-3.7l-3.7-17.23l37.19-40.3A8 8 0 0 0 187 29.24A72 72 0 0 0 88 96a72.3 72.3 0 0 0 6 28.94L33.79 177c-.15.12-.29.26-.43.39a32 32 0 0 0 45.26 45.26c.13-.13.27-.28.39-.42L131.06 162A72 72 0 0 0 232 96a71.6 71.6 0 0 0-5.24-27M160 152a56.14 56.14 0 0 1-27.07-7a8 8 0 0 0-9.92 1.77l-55.9 64.74a16 16 0 0 1-22.62-22.62L109.18 133a8 8 0 0 0 1.77-9.93a56 56 0 0 1 58.36-82.31l-31.2 33.81a8 8 0 0 0-1.94 7.1l5.66 26.33a8 8 0 0 0 6.14 6.14l26.35 5.66a8 8 0 0 0 7.1-1.94l33.81-31.2A56.06 56.06 0 0 1 160 152"},null,-1)])])}const Lge=Oe({name:"ph-wrench",render:Bge}),Pge={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function Dge(t,e){return w(),R("svg",Pge,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M230.91 172a8 8 0 0 1-2.91 10.91l-96 56a8 8 0 0 1-8.06 0l-96-56A8 8 0 0 1 36 169.09l92 53.65l92-53.65a8 8 0 0 1 10.91 2.91M220 121.09l-92 53.65l-92-53.65a8 8 0 0 0-8 13.82l96 56a8 8 0 0 0 8.06 0l96-56a8 8 0 1 0-8.06-13.82M24 80a8 8 0 0 1 4-6.91l96-56a8 8 0 0 1 8.06 0l96 56a8 8 0 0 1 0 13.82l-96 56a8 8 0 0 1-8.06 0l-96-56A8 8 0 0 1 24 80m23.88 0L128 126.74L208.12 80L128 33.26Z"},null,-1)])])}const Ege=Oe({name:"ph-stack",render:Dge}),Nge={[Je.Sort]:{iconClass:"step-card__body__icon--sort",iconComponent:Sge,fallback:"S",label:"Sort"},[Je.Filter]:{iconClass:"step-card__body__icon--filter",iconComponent:$ge,fallback:"F",label:"Filter"},[Je.HideColumns]:{iconClass:"step-card__body__icon--hide-columns",iconComponent:cf,fallback:"H",label:"Hide Columns"},[Je.Transpose]:{iconClass:"step-card__body__icon--transpose",iconComponent:nB,fallback:"T",label:"Transpose"},[Je.Parse]:{iconClass:"step-card__body__icon--parse",iconComponent:Lge,fallback:"P",label:"Parse"},[Je.Rename]:{iconClass:"step-card__body__icon--rename",iconComponent:F2,fallback:"R",label:"Rename"},[Je.GroupBy]:{iconClass:"step-card__body__icon--group",iconComponent:Ege,fallback:"G",label:"Group By"},[Je.Computed]:{iconClass:"step-card__body__icon--computed",fallback:"C",label:"Computed"}},Ige={class:"step-card__number"},Rge={class:"step-card__body"},Fge={key:1},Vge={class:"step-card__body__text"},zge={class:"step-card__body__text__name"},Hge={class:"step-card__actions"},Wge=le({__name:"DataTransformStepCard",props:{step:{},index:{},active:{type:Boolean},error:{}},emits:["select","delete"],setup(t){const e=t,n=A(()=>Nge[e.step.type]),o=A(()=>n.value.iconClass),r=A(()=>n.value.iconComponent??null),i=A(()=>n.value.fallback),s=A(()=>n.value.label),a=A(()=>{const{step:l}=e;if(l.type===Je.Sort&&l.config.column)return`${l.config.column} ${l.config.direction??Zt.Ascending}`;if(l.type===Je.Filter&&l.config.column)return`${l.config.column} ${l.config.condition??go.Equals} ${l.config.value??""}`;if(l.type===Je.HideColumns){const c=l.config.columns?l.config.columns.split(",").map(u=>u.trim()).filter(Boolean):[];return c.length>0?`Hiding ${c.join(", ")}`:"Configure..."}if(l.type===Je.Transpose)return"Swap rows ↔ columns";if(l.type===Je.Parse&&l.config.column&&l.config.operation)return`${l.config.column} → ${l.config.operation}`;if(l.type===Je.Rename&&l.config.column&&l.config.newName)return`${l.config.column} → ${l.config.newName}`;if(l.type===Je.GroupBy&&l.config.groupColumns&&l.config.aggregates){const c=l.config.groupColumns.split(",").map(d=>d.trim()).filter(Boolean).join(", "),u=l.config.aggregates.split(",").map(d=>{const f=d.lastIndexOf(":");return f<0?d.trim():`${d.slice(f+1).trim()}(${d.slice(0,f).trim()})`}).join(", ");return`Group by ${c} — ${u}`}return"Configure..."});return(l,c)=>(w(),R("div",{class:Me(["step-card",{"step-card--active":t.active,"step-card--error":t.error}]),onClick:c[2]||(c[2]=u=>l.$emit("select"))},[M("div",Ige,ye(t.index+1),1),M("div",Rge,[M("span",{class:Me(["step-card__body__icon",p(o)])},[p(r)?(w(),J(Gt(p(r)),{key:0})):(w(),R("span",Fge,ye(p(i)),1))],2),M("div",Vge,[M("div",zge,ye(p(s)),1),M("div",{class:Me(["step-card__body__text__desc",{"step-card__body__text__desc--error":t.error}])},ye(t.error||p(a)),3)])]),M("div",Hge,[M("button",{class:"step-card__actions__btn","aria-label":"Remove step",onClick:c[0]||(c[0]=pn(u=>l.$emit("delete"),["stop"]))},[...c[3]||(c[3]=[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("path",{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]),t.active&&l.$slots.default?(w(),R("div",{key:0,class:"step-card__config",onClick:c[1]||(c[1]=pn(()=>{},["stop"]))},[Ce(l.$slots,"default",{},void 0,!0)])):ie("",!0)],2))}}),Uge=Be(Wge,[["__scopeId","data-v-4ba65e45"]]),Gge={class:"group-by-step"},qge={class:"group-by-step__field"},Yge={class:"group-by-step__field__columns"},jge=["checked","onChange"],Xge={key:0,class:"group-by-step__field"},Kge={class:"group-by-step__field__agg-list"},Zge={class:"group-by-step__field__agg-list__row"},Qge={class:"group-by-step__field__agg-list__row__check"},Jge=["checked"],eve={class:"group-by-step__field__agg-list__row__check"},tve=["checked","onChange"],nve=["value","onChange"],ove=le({__name:"DataTransformStepGroupBy",props:{step:{},columns:{},columnTypes:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.groupColumns?e.step.config.groupColumns.split(",").map(b=>b.trim()).filter(Boolean):[]),r=A(()=>e.columns.filter(b=>!o.value.includes(b))),i=A(()=>e.step.config.aggregates?e.step.config.aggregates.split(",").map(b=>b.trim()).filter(Boolean).map(b=>{const m=b.lastIndexOf(":");return m<0?null:{col:b.slice(0,m),fn:b.slice(m+1)}}).filter(b=>b!==null):[]),s=A(()=>i.value.some(b=>b.fn==="count"));function a(b){return i.value.some(m=>m.col===b&&m.fn!=="count")}function l(b){const m=i.value.find(v=>v.col===b&&v.fn!=="count");return(m==null?void 0:m.fn)??"sum"}function c(b){return b.map(m=>`${m.col}:${m.fn}`).join(",")}function u(b,m){const v={...e.step.config};b.length>0?v.groupColumns=b.join(","):delete v.groupColumns,m.length>0?v.aggregates=c(m):delete v.aggregates,n(e.step.id,v)}function d(b){const m=[...o.value],v=m.indexOf(b);v>=0?m.splice(v,1):m.push(b);const y=i.value.filter(x=>x.fn==="count"||!m.includes(x.col));u(m,y)}function f(){const b=[...i.value],m=b.findIndex(v=>v.fn==="count");m>=0?b.splice(m,1):b.push({col:"rows",fn:"count"}),u(o.value,b)}function h(b){const m=[...i.value],v=m.findIndex(y=>y.col===b&&y.fn!=="count");v>=0?m.splice(v,1):m.push({col:b,fn:"sum"}),u(o.value,m)}function g(b,m){const v=i.value.map(y=>y.col===b&&y.fn!=="count"?{...y,fn:m}:y);u(o.value,v)}return(b,m)=>(w(),R("div",Gge,[M("div",qge,[m[0]||(m[0]=M("label",{class:"group-by-step__field__label"},"Group by",-1)),M("div",Yge,[(w(!0),R(He,null,ht(t.columns,v=>(w(),R("label",{key:v,class:"group-by-step__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(v),onChange:y=>d(v)},null,40,jge),Ye(" "+ye(v),1)]))),128))])]),p(r).length>0||p(o).length>0?(w(),R("div",Xge,[m[4]||(m[4]=M("label",{class:"group-by-step__field__label"},"Aggregates",-1)),M("div",Kge,[M("div",Zge,[M("label",Qge,[M("input",{type:"checkbox",checked:p(s),onChange:f},null,40,Jge),m[1]||(m[1]=Ye(" Row count ",-1))]),m[2]||(m[2]=M("span",{class:"group-by-step__field__agg-list__row__fn-label"},"count",-1))]),(w(!0),R(He,null,ht(p(r),v=>(w(),R("div",{key:v,class:"group-by-step__field__agg-list__row"},[M("label",eve,[M("input",{type:"checkbox",checked:a(v),onChange:y=>h(v)},null,40,tve),Ye(" "+ye(v),1)]),a(v)?(w(),R("select",{key:0,class:"group-by-step__field__agg-list__row__fn",value:l(v),onChange:y=>g(v,y.target.value)},[...m[3]||(m[3]=[M("option",{value:"sum"}," Sum ",-1),M("option",{value:"avg"}," Average ",-1),M("option",{value:"min"}," Min ",-1),M("option",{value:"max"}," Max ",-1)])],40,nve)):ie("",!0)]))),128))])])):ie("",!0)]))}}),rve=Be(ove,[["__scopeId","data-v-c53de076"]]),ive={class:"data-transform-step-rename"},sve=le({__name:"DataTransformStepRename",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(i=>({value:i,label:i})));function r(i,s){n(e.step.id,{...e.step.config,[i]:s})}return(i,s)=>(w(),R("div",ive,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":s[0]||(s[0]=a=>r("column",a))},null,8,["model-value","options"]),H(p(wm),{id:"rename-new-name","model-value":t.step.config.newName??"",label:"New Name",placeholder:"Enter new column name","onUpdate:modelValue":s[1]||(s[1]=a=>r("newName",a))},null,8,["model-value"])]))}}),ave=Be(sve,[["__scopeId","data-v-5f4cb34e"]]),lve={class:"data-transform-step-parse"},cve=le({__name:"DataTransformStepParse",props:{step:{},columns:{}},setup(t){var b;const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(m=>({value:m,label:m}))),r=[{value:"type",label:"Type Conversions"},{value:"string",label:"String"},{value:"numeric",label:"Numeric"},{value:"date",label:"Date/Time"}],i=A(()=>op.find(m=>m.id===e.step.config.operation)),s=Ie(((b=i.value)==null?void 0:b.category)??"type");Ge(()=>e.step.config.operation,m=>{if(m){const v=op.find(y=>y.id===m);v&&(s.value=v.category)}});const a=A(()=>op.filter(m=>m.category===s.value).map(m=>({value:m.id,label:m.label,description:m.description}))),l=A(()=>{var m;return((m=i.value)==null?void 0:m.params)??[]}),c={decimals:"Decimal places",pattern:"Regex pattern",replacement:"Replacement",start:"Start index",end:"End index",length:"Length",char:"Pad character",separator:"Separator",limit:"Limit",min:"Minimum",max:"Maximum",size:"Bucket size",key:"JSON key",amount:"Amount",unit:"Unit",period:"Period",reference:"Reference date"},u={decimals:"0",pattern:"\\d+",replacement:"",start:"0",end:"",length:"10",char:" ",separator:",",limit:"",min:"0",max:"100",size:"10",key:"",amount:"1",unit:"days",period:"month",reference:"YYYY-MM-DD"};function d(m){return c[m]??m}function f(m){return u[m]??""}function h(m){s.value=m;const v={...e.step.config};delete v.operation,n(e.step.id,v)}function g(m,v){n(e.step.id,{...e.step.config,[m]:v})}return(m,v)=>(w(),R("div",lve,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":v[0]||(v[0]=y=>g("column",y))},null,8,["model-value","options"]),H(p(En),{"model-value":p(s),label:"Category",options:r,block:"","onUpdate:modelValue":h},null,8,["model-value"]),H(p(En),{"model-value":t.step.config.operation??"",label:"Operation",placeholder:"Select an operation",options:p(a),block:"","onUpdate:modelValue":v[1]||(v[1]=y=>g("operation",y))},null,8,["model-value","options"]),p(l).length>0?(w(!0),R(He,{key:0},ht(p(l),y=>(w(),J(p(wm),{id:`parse-${y}`,key:y,"model-value":t.step.config[y]??"",label:d(y),placeholder:f(y),"onUpdate:modelValue":x=>g(y,x)},null,8,["id","model-value","label","placeholder","onUpdate:modelValue"]))),128)):ie("",!0)]))}}),uve=Be(cve,[["__scopeId","data-v-37e3f025"]]),dve={class:"data-transform-step-hide-columns"},fve={class:"data-transform-step-hide-columns__field"},hve={class:"data-transform-step-hide-columns__field__columns"},pve=["checked","onChange"],mve=le({__name:"DataTransformStepHideColumns",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.columns?e.step.config.columns.split(",").map(i=>i.trim()).filter(Boolean):e.step.config.column?[e.step.config.column]:[]);function r(i){const s=[...o.value],a=s.indexOf(i);a>=0?s.splice(a,1):s.push(i);const l={...e.step.config};delete l.column,s.length===0?delete l.columns:l.columns=s.join(","),n(e.step.id,l)}return(i,s)=>(w(),R("div",dve,[M("div",fve,[s[0]||(s[0]=M("label",{class:"data-transform-step-hide-columns__field__label"},"Hide columns",-1)),M("div",hve,[(w(!0),R(He,null,ht(t.columns,a=>(w(),R("label",{key:a,class:"data-transform-step-hide-columns__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(a),onChange:l=>r(a)},null,40,pve),Ye(" "+ye(a),1)]))),128))])])]))}}),gve=Be(mve,[["__scopeId","data-v-a74ff0f2"]]),vve={class:"data-transform-step-filter"},bve=le({__name:"DataTransformStepFilter",props:{step:{},columns:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.columns.map(s=>({value:s,label:s}))),r=[{value:go.Equals,label:"Equals"},{value:go.NotEquals,label:"Not equals"},{value:go.Contains,label:"Contains"},{value:go.GreaterThan,label:"Greater than"},{value:go.LessThan,label:"Less than"}];function i(s,a){n(e.step.id,{...e.step.config,[s]:a})}return(s,a)=>(w(),R("div",vve,[H(p(En),{"model-value":t.step.config.column??"",label:"Column",placeholder:"Select a column",options:p(o),block:"","onUpdate:modelValue":a[0]||(a[0]=l=>i("column",l))},null,8,["model-value","options"]),H(p(En),{"model-value":t.step.config.condition??p(go).Equals,label:"Condition",options:r,block:"","onUpdate:modelValue":a[1]||(a[1]=l=>i("condition",l))},null,8,["model-value"]),H(p(wm),{id:"filter-value","model-value":t.step.config.value??"",label:"Value",placeholder:"Filter value","onUpdate:modelValue":a[2]||(a[2]=l=>i("value",l))},null,8,["model-value"])]))}}),yve=Be(bve,[["__scopeId","data-v-65704d71"]]),xve={class:"data-transform-step-sort"},wve={class:"data-transform-step-sort__field"},_ve={class:"data-transform-step-sort__field__columns"},kve=["checked","onChange"],Sve=le({__name:"DataTransformStepSort",props:{step:{},columns:{},columnTypes:{}},setup(t){const e=t,{updateStep:n}=Lr(),o=A(()=>e.step.config.columns?e.step.config.columns.split(",").map(c=>c.trim()).filter(Boolean):e.step.config.column?[e.step.config.column]:[]),r=A(()=>o.value.every(c=>{const u=e.columns.indexOf(c);return u>=0&&e.columnTypes[u]==="number"}));function i(c){const u=[...o.value],d=u.indexOf(c);d>=0?u.splice(d,1):u.push(c);const f={...e.step.config};delete f.column,u.length===0?delete f.columns:f.columns=u.join(",");const h=u.every(g=>{const b=e.columns.indexOf(g);return b>=0&&e.columnTypes[b]==="number"});(u.length<=1||!h)&&delete f.operation,n(e.step.id,f)}const s=[{value:"",text:"None"},{value:"sum",text:"Sum"},{value:"avg",text:"Avg"}],a=[{value:Zt.Ascending,text:"Ascending"},{value:Zt.Descending,text:"Descending"}];function l(c,u){n(e.step.id,{...e.step.config,[c]:u})}return(c,u)=>(w(),R("div",xve,[M("div",wve,[u[2]||(u[2]=M("label",{class:"data-transform-step-sort__field__label"},"Sort by",-1)),M("div",_ve,[(w(!0),R(He,null,ht(t.columns,d=>(w(),R("label",{key:d,class:"data-transform-step-sort__field__columns__column"},[M("input",{type:"checkbox",checked:p(o).includes(d),onChange:f=>i(d)},null,40,kve),Ye(" "+ye(d),1)]))),128))])]),p(o).length>1&&p(r)?(w(),J(p(Cn),{key:0,"model-value":t.step.config.operation??"",label:"Operation",options:s,block:"","onUpdate:modelValue":u[0]||(u[0]=d=>l("operation",d))},null,8,["model-value"])):ie("",!0),H(p(Cn),{"model-value":t.step.config.direction??p(Zt).Ascending,label:"Direction",options:a,block:"","onUpdate:modelValue":u[1]||(u[1]=d=>l("direction",d))},null,8,["model-value"])]))}}),Ave=Be(Sve,[["__scopeId","data-v-73ae8834"]]),Cve={},$ve={class:"pipeline-connector"};function Tve(t,e){return w(),R("div",$ve)}const Mve=Be(Cve,[["render",Tve],["__scopeId","data-v-a3406500"]]),Ove={class:"source-block"},Bve={class:"source-block__meta"},Lve=le({__name:"DataTransformSourceBlock",props:{columns:{},rows:{},label:{default:"Raw Data"}},setup(t){return(e,n)=>(w(),R("div",Ove,[n[0]||(n[0]=M("span",{class:"source-block__icon"},[M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",width:"14",height:"14"},[M("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),M("path",{d:"M3 9h18M9 21V9"})])],-1)),M("span",null,ye(t.label),1),M("span",Bve,ye(t.columns)+" cols · "+ye(t.rows)+" rows",1)]))}}),Pve=Be(Lve,[["__scopeId","data-v-6b491dca"]]),Dve={class:"pipeline","data-testid":"transform-pipeline"},Eve={key:6,class:"pipeline__config-info"},Nve={key:7,class:"text-muted text-center py-3"},Ive=le({__name:"DataTransformPipeline",setup(t){const{columns:e,rows:n,columnTypes:o}=jo(),{steps:r,addStep:i,removeStep:s,applyTransforms:a,getColumnsAtStep:l,validateStep:c}=Lr(),{activeScene:u,activeIndex:d,scenes:f}=wn(),h=A(()=>{if(!u.value)return"Raw Data";if(d.value<=0)return"Data from Scene 1";const I=f.value[d.value-1];return`Data from ${(I==null?void 0:I.name)||`Scene ${d.value}`}`}),g=Ie(""),b=Ve(new Set),m=A(()=>r.value.findIndex(I=>I.id===g.value)),v=A(()=>m.value<0?{columns:[],columnTypes:[]}:l(m.value,e.value,n.value,o.value)),y=A(()=>v.value.columns),x=A(()=>v.value.columnTypes),_=A(()=>{const I={};for(let C=0;C<r.value.length;C++){const T=r.value[C];if(b.value.has(T.id)){I[T.id]=null;continue}const P=l(C,e.value,n.value,o.value);I[T.id]=c(T,P.columns,P.columnTypes)}return I}),k=A(()=>a(e.value,n.value,o.value)),E=A(()=>k.value.columns.length),B=A(()=>k.value.rows.length);function S(I){const C=g.value;C&&C!==I&&b.value.delete(C),g.value=I}function L(I){const C=i(I);b.value.add(C),S(C)}function D(I){b.value.delete(I),s(I),g.value===I&&(g.value=r.value.length>0?r.value[r.value.length-1].id:"")}return(I,C)=>{const T=Pve,P=Mve,$=Ave,F=yve,V=gve,U=uve,K=ave,se=rve,he=Uge,ce=wge,be=hge;return w(),R("div",Dve,[H(T,{columns:p(e).length,rows:p(n).length,label:p(h)},null,8,["columns","rows","label"]),(w(!0),R(He,null,ht(p(r),(oe,de)=>(w(),R(He,{key:oe.id},[H(P),H(he,{step:oe,index:de,active:p(g)===oe.id,error:p(_)[oe.id],onSelect:we=>S(oe.id),onDelete:we=>D(oe.id)},{default:te(()=>[oe.type===p(Je).Sort?(w(),J($,{key:0,step:oe,columns:p(y),"column-types":p(x)},null,8,["step","columns","column-types"])):oe.type===p(Je).Filter?(w(),J(F,{key:1,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).HideColumns?(w(),J(V,{key:2,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).Parse?(w(),J(U,{key:3,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).Rename?(w(),J(K,{key:4,step:oe,columns:p(y)},null,8,["step","columns"])):oe.type===p(Je).GroupBy?(w(),J(se,{key:5,step:oe,columns:p(y),"column-types":p(x)},null,8,["step","columns","column-types"])):oe.type===p(Je).Transpose?(w(),R("div",Eve," Transpose swaps rows and columns. The first column values become headers and column headers become the first column. ")):(w(),R("div",Nve," Coming soon "))]),_:2},1032,["step","index","active","error","onSelect","onDelete"])],64))),128)),H(P),H(ce,{onAdd:L}),H(P),H(be,{columns:p(E),rows:p(B)},null,8,["columns","rows"])])}}}),Rve=Be(Ive,[["__scopeId","data-v-b653c7ed"]]),Fve=[0,.30103,.17609,.12494,.09691,.07918,.06695,.05799,.05115,.04576],oB=10,Vve=.1;function zve(t){const e=parseFloat(t);if(!Number.isFinite(e)||e===0)return null;const o=Math.abs(e).toExponential(),r=parseInt(o[0],10);return r>=1&&r<=9?r:null}function Hve(t,e,n){if(t==="number")return!0;let o=0;for(const r of e){const i=r[n];if(i!=null&&i!==""){const s=parseFloat(i);Number.isFinite(s)&&o++}}return o>=oB}function rB(t,e,n){const o=[];let r=!1;for(let i=0;i<t.length;i++){if(!Hve(n[i],e,i))continue;const s=new Array(10).fill(0);let a=0;for(const c of e){const u=zve(c[i]);u!==null&&(s[u]++,a++)}if(a<oB)continue;r=!0;let l=!1;for(let c=1;c<=9;c++){const u=s[c]/a;if(Math.abs(u-Fve[c])>Vve){l=!0;break}}l&&o.push(t[i])}return{pass:o.length===0,suspicious:o,eligible:r}}const Wve={class:"data-column-settings"},Uve={class:"data-column-settings__field"},Gve={class:"data-column-settings__section"},qve={class:"data-column-settings__section__detections"},Yve={class:"data-column-settings__section__detections__item data-column-settings__section__detections__item--success"},jve={class:"data-column-settings__section__detections__item data-column-settings__section__detections__item--info"},Xve={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},Kve={key:0,d:"M20 6L9 17l-5-5"},Zve={key:1,d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},Qve={key:1,class:"data-column-settings__picker"},Jve=le({__name:"DataColumnSettings",setup(t){const e=cr(),{selectedColumnIndex:n}=Ct(e),{selectColumn:o}=e,{columns:r,rows:i,columnTypes:s,setColumnType:a}=jo(),l=Ie("string"),c=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"date",label:"Date"}];Ge(n,v=>{v>=0&&v<r.value.length&&(l.value=s.value[v]??"string")},{immediate:!0});function u(v){a(n.value,v)}const d=A(()=>r.value.map((v,y)=>({value:String(y),label:v})));function f(v){o(parseInt(v,10))}const h=A(()=>{const v=n.value;if(v<0)return{unique:0,total:0};const y=i.value.map(_=>_[v]??"").filter(_=>_.length>0);return{unique:new Set(y).size,total:y.length}}),g=A(()=>{const{unique:v,total:y}=h.value;return v===y?`${v} unique values — no duplicates`:`${y-v} duplicates found`}),b=A(()=>{const v=s.value[n.value];return v==="number"?"Numeric measure detected":v==="date"?"Date axis detected":"Categorical dimension detected"}),m=A(()=>{const v=n.value;if(v<0)return null;const y=r.value[v],x=rB([y],i.value.map(_=>[_[v]]),[s.value[v]]);return x.eligible?{pass:x.pass,label:x.pass?"Follows Benford's law":"Doesn't follow Benford's law"}:null});return(v,y)=>(w(),R("div",Wve,[p(n)>=0&&p(n)<p(r).length?(w(),R(He,{key:0},[M("div",Uve,[y[1]||(y[1]=M("div",{class:"data-column-settings__field__label"}," Type ",-1)),H(p(En),{modelValue:p(l),"onUpdate:modelValue":[y[0]||(y[0]=x=>Ze(l)?l.value=x:null),u],label:"",options:c,block:""},null,8,["modelValue"])]),y[5]||(y[5]=M("hr",{class:"data-column-settings__divider"},null,-1)),M("div",Gve,[y[4]||(y[4]=M("div",{class:"data-column-settings__section__title"}," Detections ",-1)),M("div",qve,[M("span",Yve,[y[2]||(y[2]=M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("path",{d:"M20 6L9 17l-5-5"})],-1)),Ye(" "+ye(p(g)),1)]),M("span",jve,[y[3]||(y[3]=M("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[M("circle",{cx:"12",cy:"12",r:"10"}),M("path",{d:"M12 16v-4M12 8h.01"})],-1)),Ye(" "+ye(p(b)),1)]),p(m)?(w(),R("span",{key:0,class:Me(["data-column-settings__section__detections__item",p(m).pass?"data-column-settings__section__detections__item--success":"data-column-settings__section__detections__item--warn"])},[(w(),R("svg",Xve,[p(m).pass?(w(),R("path",Kve)):(w(),R("path",Zve))])),Ye(" "+ye(p(m).label),1)],2)):ie("",!0)])])],64)):(w(),R("div",Qve,[y[6]||(y[6]=M("div",{class:"data-column-settings__picker__label"}," Column ",-1)),H(p(En),{"model-value":"",label:"",options:p(d),block:"",placeholder:"Select a column…","onUpdate:modelValue":f},null,8,["options"])]))]))}}),e1e=Be(Jve,[["__scopeId","data-v-fadb97cc"]]),t1e={key:0,class:"data-check-empty"},n1e={key:1,class:"data-check-table"},o1e={class:"data-check-table__col-header__name"},r1e={class:"data-check-table__col-header__type"},i1e=le({__name:"DataCheckTable",setup(t){const e=cr(),{selectedColumnIndex:n}=Ct(e),{selectColumn:o}=e,{displayColumns:r,displayRows:i,displayColumnTypes:s}=jo(),a=A(()=>i.value.length===0);return(l,c)=>p(a)?(w(),R("div",t1e,[H(p(Fy),{class:"data-check-empty__icon"}),c[0]||(c[0]=M("p",null,"No rows match your filters",-1))])):(w(),R("div",n1e,[H(p(YE),{hover:"",bordered:""},{default:te(()=>[H(p(JE),null,{default:te(()=>[H(p(l_),null,{default:te(()=>[H(p(a_),{class:"data-check-table__row-num"},{default:te(()=>[...c[1]||(c[1]=[Ye(" # ",-1)])]),_:1}),(w(!0),R(He,null,ht(p(r),(u,d)=>(w(),J(p(a_),{key:d,class:Me(["data-check-table__col-header",{"data-check-table__col--selected":d===p(n)}]),onClick:f=>p(o)(d)},{default:te(()=>[M("div",o1e,ye(u),1),M("div",r1e,ye(p(s)[d]??"string"),1)]),_:2},1032,["class","onClick"]))),128))]),_:1})]),_:1}),H(p(jE),null,{default:te(()=>[(w(!0),R(He,null,ht(p(i),(u,d)=>(w(),J(p(l_),{key:d},{default:te(()=>[H(p(s_),{class:"data-check-table__row-num"},{default:te(()=>[Ye(ye(d+1),1)]),_:2},1024),(w(!0),R(He,null,ht(u,(f,h)=>(w(),J(p(s_),{key:h,class:Me({"data-check-table__col--selected":h===p(n),"data-check-table__cell--numeric":p(s)[h]==="number"})},{default:te(()=>[Ye(ye(f),1)]),_:2},1032,["class"]))),128))]),_:2},1024))),128))]),_:1})]),_:1})]))}}),s1e=Be(i1e,[["__scopeId","data-v-670500db"]]),a1e={class:"data-insight-badges"},l1e={class:"data-insight-badge data-insight-badge--shape"},c1e={class:"data-insight-badge__icon"},u1e={class:"data-insight-badge__icon"},d1e=le({__name:"DataInsightBadges",props:{columns:{},rows:{},columnTypes:{}},setup(t){const e=t,n=ft("benfordBadgeRef"),o=A(()=>{let d=0;for(const f of e.rows)for(let h=0;h<e.columns.length;h++){const g=f[h];(g==null||g==="")&&d++}return d}),r=A(()=>o.value===0?"✓":"⚠"),i=A(()=>o.value===0?"No missing values":`${o.value} missing value${o.value===1?"":"s"}`),s=A(()=>o.value===0?"data-insight-badge--quality-ok":"data-insight-badge--quality-warn"),a=A(()=>{const d=rB(e.columns,e.rows,e.columnTypes);return d.eligible?d:null}),l=A(()=>{var d;return(d=a.value)!=null&&d.pass?"✓":"⚠"}),c=A(()=>{var d;return(d=a.value)!=null&&d.pass?"data-insight-badge--benford-ok":"data-insight-badge--benford-warn"}),u=A(()=>a.value?a.value.pass?"All numeric columns follow Benford's Law — the expected distribution of leading digits in real-world data.":`Column(s) ${a.value.suspicious.join(", ")} don't follow Benford's Law — the expected distribution of leading digits. This may indicate fabricated or anomalous data.`:"");return(d,f)=>(w(),R("div",a1e,[M("span",l1e,ye(t.columns.length)+" cols · "+ye(t.rows.length)+" rows ",1),M("span",{class:Me(["data-insight-badge",p(s)])},[M("span",c1e,ye(p(r)),1),Ye(" "+ye(p(i)),1)],2),p(a)?(w(),R("span",{key:0,ref_key:"benfordBadgeRef",ref:n,class:Me(["data-insight-badge",p(c)])},[M("span",u1e,ye(p(l)),1),f[0]||(f[0]=Ye(" Benford's law ",-1)),H(p(Ud),{"teleport-to":"body",target:p(n),title:p(u),placement:"top"},null,8,["target","title"])],2)):ie("",!0)]))}}),f1e=Be(d1e,[["__scopeId","data-v-d0fa5a33"]]),h1e={class:"data-structure-panel__main__pills-bar"},p1e={key:0,class:"data-structure-panel__main__scene-banner"},m1e=le({__name:"DataStructurePanel",setup(t){const{columns:e,rows:n,columnTypes:o}=jo(),r=cr(),{dataPanelOpen:i,dataPanelTab:s}=Ct(r),{openDataPanel:a,closeDataPanel:l,setDataView:c,setLastNarrowDataTab:u}=r,{mode:d}=rc(),{activeScene:f,activeIndex:h,scenes:g}=wn(),b=A(()=>f.value!==null);Ge(d,P=>{P==="drawer"&&s.value&&(u(s.value),l())},{immediate:!0});const m=A(()=>tT(g.value,h.value)),v=A(()=>{const P=m.value;if(P===h.value)return"Custom data on this scene.";if(P>=0){const $=g.value[P];return`Data inherited from ${($==null?void 0:$.name)||`Scene ${P+1}`}.`}return"Scene override active."}),y=A(()=>{const P=m.value;return P===h.value?"This scene uses its own data, independent of the base dataset.":P>=0?"Replace data to set different data for this scene.":"The table below shows the base data. Replace data to set custom data for this scene."});function x(){c("upload")}function _(P){u(P),a(P)}const{isNarrow:k}=Ji(),E=ft("mainRef"),{sections:B}=eB(),S=A(()=>b.value?["parsing"]:[]),L=A(()=>b.value?B.filter(P=>P.key!=="parsing"):B),D=A({get:()=>!!s.value,set:P=>{P||l()}}),I={column:"Column Settings",transforms:"Transforms",parsing:"Parsing",reco:"Recommendations"},C=A(()=>I[s.value]??"Panel"),T=A(()=>({"data-structure-panel--narrow":k.value}));return(P,$)=>{const F=f1e,V=s1e,U=W2,K=e1e,se=Rve,he=cge,ce=oge,be=H2,oe=ug,de=Gme;return w(),R("div",{class:Me(["data-structure-panel",p(T)])},[M("div",{ref_key:"mainRef",ref:E,class:"data-structure-panel__main"},[M("div",h1e,[p(b)?(w(),R("div",p1e,[M("strong",null,ye(p(v)),1),Ye(" "+ye(p(y)),1)])):(w(),J(F,{key:1,columns:p(e),rows:p(n),"column-types":p(o)},null,8,["columns","rows","column-types"])),H(p(Kn),{"icon-left":p(nB),label:"Replace data",variant:"outline-primary",size:"sm",onClick:x},null,8,["icon-left"])]),H(V)],512),p(i)?(w(),J(oe,{key:0,"drawer-open":p(D),"onUpdate:drawerOpen":$[0]||($[0]=we=>Ze(D)?D.value=we:null),title:p(C),"container-ref":p(E),onClose:p(l)},bi({default:te(()=>[p(s)==="column"?(w(),J(K,{key:0})):p(s)==="transforms"?(w(),J(se,{key:1})):p(s)==="parsing"?(w(),J(he,{key:2})):p(s)==="reco"?(w(),J(ce,{key:3})):ie("",!0)]),_:2},[p(d)==="drawer"?{name:"tabs",fn:te(()=>[H(U,{tabs:p(L),"model-value":p(s),sticky:"","onUpdate:modelValue":_},null,8,["tabs","model-value"])]),key:"0"}:void 0,p(d)!=="drawer"?{name:"footer",fn:te(()=>[H(be)]),key:"1"}:void 0]),1032,["drawer-open","title","container-ref","onClose"])):ie("",!0),p(k)?ie("",!0):(w(),J(de,{key:1,"disabled-tabs":p(S)},null,8,["disabled-tabs"]))],2)}}}),g1e=Be(m1e,[["__scopeId","data-v-f811e1e6"]]),v1e={class:"samples-grid"},b1e=["onClick","onKeydown"],y1e={class:"sample-card__thumb"},x1e=["src","alt"],w1e={class:"sample-card__info"},_1e={class:"sample-card__info__name"},k1e={class:"sample-card__info__meta"},S1e=le({__name:"DataUploadSamples",emits:["select"],setup(t){const e={[Le.BarVertical]:"Columns",[Le.BarHorizontal]:"Bars",[Le.BarMulti]:"Grouped Columns",[Le.Line]:"Line",[Le.LineMulti]:"Lines",[Le.Donut]:"Donut",[Le.Pie]:"Pie",[Le.Area]:"Area",[Le.AreaStacked]:"Stacked Area",[Le.ColumnStacked]:"Stacked Columns",[Le.BarStacked]:"Stacked Bars",[Le.BarSplit]:"Split Bars",[Le.BarGrouped]:"Grouped Bars"};function n(i){const s=i.split(`
|
|
859
|
+
`).filter(a=>a.trim().length>0);return Math.max(0,s.length-1)}const o=ir(new Map),r=A(()=>O6.map(i=>({...i,typeLabel:e[i.chartType]??i.chartType,rowCount:n(i.tsvData),thumbSrc:o.get(i.id)})));return un(()=>{for(const i of O6)if(i.dsl){const s=hT(i.dsl);s&&o.set(i.id,Sc(s))}}),(i,s)=>(w(),R("div",v1e,[(w(!0),R(He,null,ht(p(r),a=>(w(),R("div",{key:a.id,class:"sample-card",role:"button",tabindex:"0",onClick:l=>i.$emit("select",a),onKeydown:er(l=>i.$emit("select",a),["enter"])},[M("div",y1e,[a.thumbSrc?(w(),R("img",{key:0,class:"sample-card__thumb__img",src:a.thumbSrc,alt:a.title},null,8,x1e)):ie("",!0)]),M("div",w1e,[M("div",_1e,ye(a.title),1),M("div",k1e,[Ye(ye(a.typeLabel)+" ",1),s[0]||(s[0]=M("span",{class:"sample-card__info__meta__sep"},"·",-1)),Ye(" "+ye(a.rowCount)+" rows ",1)])])],40,b1e))),128))]))}}),A1e=Be(S1e,[["__scopeId","data-v-23920b61"]]),C1e=le({__name:"DataUploadFileDrop",emits:["loaded","bpc","dragState"],setup(t,{emit:e}){const n=e,o=Ve(null),r=Ie(!1);function i(f){r.value=f,n("dragState",f)}function s(){i(!0)}function a(){i(!1)}function l(f){return f.name.toLowerCase().endsWith(".bpc")}function c(f){const h=new globalThis.FileReader;h.onload=()=>{typeof h.result=="string"&&n(l(f)?"bpc":"loaded",h.result,f.name)},h.readAsText(f)}function u(f){var g;i(!1);const h=(g=f.dataTransfer)==null?void 0:g.files[0];h&&c(h)}function d(f){var b;const h=f.target,g=(b=h.files)==null?void 0:b[0];g&&c(g),h.value=""}return(f,h)=>(w(),R("div",{class:Me(["file-drop",{"file-drop--active":p(r)}]),onDragover:pn(s,["prevent"]),onDragleave:pn(a,["prevent"]),onDrop:pn(u,["prevent"]),onClick:h[1]||(h[1]=g=>{var b;return(b=p(o))==null?void 0:b.click()})},[h[2]||(h[2]=EL('<div class="file-drop__icon" data-v-f6ebbbc1><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" data-v-f6ebbbc1><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12" data-v-f6ebbbc1></path></svg></div><div class="file-drop__title" data-v-f6ebbbc1> Drag & drop your file here </div><div class="file-drop__or" data-v-f6ebbbc1> or </div>',3)),M("button",{class:"file-drop__btn",onClick:h[0]||(h[0]=pn(g=>{var b;return(b=p(o))==null?void 0:b.click()},["stop"]))}," Browse files "),h[3]||(h[3]=M("div",{class:"file-drop__formats"},[M("span",{class:"file-drop__formats__tag"},".csv"),M("span",{class:"file-drop__formats__tag"},".tsv"),M("span",{class:"file-drop__formats__tag"},".bpc")],-1)),M("input",{ref_key:"fileInput",ref:o,type:"file",accept:".csv,.tsv,.txt,.bpc",class:"file-drop__input",onChange:d},null,544)],34))}}),$1e=Be(C1e,[["__scopeId","data-v-f6ebbbc1"]]),T1e={class:"upload-card"},M1e={class:"input-card__tabs"},O1e=["onClick"],B1e={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},L1e={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},P1e={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},D1e={key:1,class:"upload-card__paste"},E1e={class:"upload-card__paste__wrap"},N1e={key:0,class:"upload-card__paste__wrap__placeholder"},I1e={class:"upload-card__paste__footer"},R1e=["disabled"],F1e=le({__name:"DataUploadCard",emits:["loaded","bpc","sample","cancel"],setup(t){const{rawInput:e,sourceFormat:n,columns:o,rows:r,displayColumns:i,displayRows:s}=jo(),{activeIndex:a,scenes:l}=wn();function c(){if(a.value<0)return!1;const v=Ra(l.value,a.value);return!!(v!=null&&v.data)}function u(){return c()?R6(i.value,s.value):(n==null?void 0:n.value)==="bpc"&&o.value.length>0?R6(o.value,r.value):e.value}const d=Ie("paste"),f=Ie(u()),h=ft("pasteArea"),g=Ie(!1);function b(v){var x;const y=(x=v.clipboardData)==null?void 0:x.getData("text/plain");y&&(v.preventDefault(),f.value=y,xn(()=>{h.value&&h.value.focus()}))}const m=[{value:"file",text:"File"},{value:"paste",text:"Paste"},{value:"samples",text:"Samples"}];return(v,y)=>{const x=$1e,_=A1e;return w(),R("div",T1e,[y[12]||(y[12]=M("h2",{class:"upload-card__title"}," Add your data ",-1)),y[13]||(y[13]=M("p",{class:"upload-card__subtitle"}," Drop a file, paste from a spreadsheet, or pick a sample dataset ",-1)),p(o).length>0?(w(),R("button",{key:0,class:"upload-card__back",onClick:y[0]||(y[0]=k=>v.$emit("cancel"))}," ← Back to table ")):ie("",!0),M("div",{class:Me(["input-card",{"input-card--drag-over":p(g)}])},[M("div",M1e,[(w(),R(He,null,ht(m,k=>M("button",{key:k.value,class:Me(["input-card__tabs__tab",{"input-card__tabs__tab--active":p(d)===k.value}]),onClick:E=>d.value=k.value},[k.value==="file"?(w(),R("svg",B1e,[...y[7]||(y[7]=[M("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"},null,-1)])])):k.value==="paste"?(w(),R("svg",L1e,[...y[8]||(y[8]=[M("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"},null,-1),M("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"},null,-1)])])):(w(),R("svg",P1e,[...y[9]||(y[9]=[M("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"},null,-1),M("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"},null,-1)])])),Ye(" "+ye(k.text),1)],10,O1e)),64))]),p(d)==="file"?(w(),J(x,{key:0,onLoaded:y[1]||(y[1]=(k,E)=>v.$emit("loaded",k,E)),onBpc:y[2]||(y[2]=(k,E)=>v.$emit("bpc",k,E)),onDragState:y[3]||(y[3]=k=>g.value=k)})):p(d)==="paste"?(w(),R("div",D1e,[M("div",E1e,[p(f)?ie("",!0):(w(),R("div",N1e,[...y[10]||(y[10]=[Ye(" category Gold Silver Bronze",-1),M("br",null,null,-1),Ye(" USA 40 44 42",-1),M("br",null,null,-1),Ye(" China 38 32 19 ",-1)])])),rr(M("textarea",{ref_key:"pasteArea",ref:h,"onUpdate:modelValue":y[4]||(y[4]=k=>Ze(f)?f.value=k:null),class:"upload-card__paste__wrap__area",spellcheck:"false",onPaste:b},null,544),[[_p,p(f)]])]),M("div",I1e,[y[11]||(y[11]=M("div",{class:"upload-card__paste__footer__hint"},[M("span",{class:"upload-card__paste__footer__hint__kbd"},"⌘"),M("span",{class:"upload-card__paste__footer__hint__kbd"},"V"),Ye(" paste from spreadsheet ")],-1)),M("button",{class:"upload-card__paste__footer__btn",disabled:!p(f).trim(),onClick:y[5]||(y[5]=k=>v.$emit("loaded",p(f),"Pasted"))}," Load data ",8,R1e)])])):p(d)==="samples"?(w(),J(_,{key:2,onSelect:y[6]||(y[6]=k=>v.$emit("sample",k))})):ie("",!0)],2)])}}}),V1e=Be(F1e,[["__scopeId","data-v-b501779f"]]),z1e=le({__name:"DataPanel",setup(t){const e=cr(),{dataView:n}=Ct(e),{setDataView:o}=e,r=jo(),{applyDsl:i}=Ic(),{loadSample:s}=js(),{next:a}=z2(),l=Ct(tB()),{activeScene:c,activeIndex:u,update:d}=wn(),f=A(()=>c.value!==null);un(()=>{r.columns.value.length>0?o("structure"):o("upload")});function h(){if(!r.rawInput.value||r.sourceFormat.value!=="delimited")return;const v=J1(r.rawInput.value,{firstRowIsHeader:l.firstRowIsHeader.value,delimiter:l.delimiter.value,decimalSeparator:l.decimalSeparator.value,trimWhitespace:l.trimWhitespace.value});r.loadParsed(v)}function g(v,y){if(f.value&&u.value>=0){const x=J1(v,{firstRowIsHeader:l.firstRowIsHeader.value,delimiter:l.delimiter.value,decimalSeparator:l.decimalSeparator.value,trimWhitespace:l.trimWhitespace.value}),_=cg(x.columns,x.rows);d(u.value,{data:_}),o("structure");return}r.rawInput.value=v,r.sourceFormat.value="delimited",r.sourceLabel.value=y||"Pasted",h(),o("structure")}function b(v,y){i(v),r.sourceLabel.value=y||"Blueprint file",a()}function m(v){if(f.value&&u.value>=0){d(u.value,{data:v.serializedData}),o("structure");return}s(v),a()}return Ge([()=>l.firstRowIsHeader.value,()=>l.delimiter.value,()=>l.decimalSeparator.value,()=>l.trimWhitespace.value],()=>{r.rawInput.value&&n.value==="structure"&&h()}),(v,y)=>{const x=V1e,_=g1e;return w(),R("div",{class:Me(["data-panel",{"data-panel--structure":p(n)==="structure"}])},[p(n)==="upload"?(w(),J(x,{key:0,onLoaded:g,onBpc:b,onSample:m,onCancel:y[0]||(y[0]=k=>p(o)("structure"))})):(w(),J(_,{key:1}))],2)}}}),H1e=Be(z1e,[["__scopeId","data-v-4fa651c7"]]),W1e=["aria-label","aria-disabled","disabled"],U1e={class:"panel-open-button__label"},G1e=le({__name:"PanelOpenButton",props:{label:{},icon:{default:()=>CT},disabled:{type:Boolean,default:!1}},emits:["open"],setup(t,{emit:e}){const n=e;function o(){n("open")}return(r,i)=>(w(),R("button",{class:"panel-open-button",type:"button","aria-label":t.label,"aria-disabled":t.disabled?"true":void 0,disabled:t.disabled,onClick:o},[(w(),J(Gt(t.icon),{class:"panel-open-button__icon","aria-hidden":"true"})),M("span",U1e,ye(t.label),1)],8,W1e))}}),q1e=Be(G1e,[["__scopeId","data-v-218f5209"]]),Y1e={class:"layout-narrow-dock",role:"toolbar","aria-label":"Wizard controls"},j1e={class:"layout-narrow-dock__timeline"},X1e={class:"layout-narrow-dock__action"},K1e=le({__name:"LayoutNarrowDock",props:{showTimeline:{type:Boolean},scenes:{},activeIndex:{},playing:{type:Boolean},panelLabel:{},panelIcon:{default:void 0},panelDisabled:{type:Boolean,default:!1},scenesSheetOpen:{type:Boolean,default:!1}},emits:["update:activeIndex","play","pause","expand-timeline","open-panel"],setup(t,{emit:e}){const n=e;function o(r){n("update:activeIndex",r)}return(r,i)=>(w(),R("div",Y1e,[M("div",j1e,[t.showTimeline?(w(),J(p(FG),{key:0,scenes:t.scenes,"active-index":t.activeIndex,playing:t.playing,expanded:t.scenesSheetOpen,"onUpdate:activeIndex":o,onPlay:i[0]||(i[0]=s=>n("play")),onPause:i[1]||(i[1]=s=>n("pause")),onExpand:i[2]||(i[2]=s=>n("expand-timeline"))},null,8,["scenes","active-index","playing","expanded"])):ie("",!0)]),M("div",X1e,[H(q1e,{label:t.panelLabel,icon:t.panelIcon,disabled:t.panelDisabled,onOpen:i[3]||(i[3]=s=>n("open-panel"))},null,8,["label","icon","disabled"])])]))}}),Z1e=Be(K1e,[["__scopeId","data-v-cc656101"]]),Q1e={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function J1e(t,e){return w(),R("svg",Q1e,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M224 48H32a8 8 0 0 0-8 8v136a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a8 8 0 0 0-8-8M40 112h40v32H40Zm56 0h120v32H96Zm120-48v32H40V64ZM40 160h40v32H40Zm176 32H96v-32h120z"},null,-1)])])}const uS=Oe({name:"ph-table",render:J1e}),ebe={viewBox:"0 0 256 256",width:"1.2em",height:"1.2em"};function tbe(t,e){return w(),R("svg",ebe,[...e[0]||(e[0]=[M("path",{fill:"currentColor",d:"M216 112v96a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16v-96a16 16 0 0 1 16-16h24a8 8 0 0 1 0 16H56v96h144v-96h-24a8 8 0 0 1 0-16h24a16 16 0 0 1 16 16M93.66 69.66L120 43.31V136a8 8 0 0 0 16 0V43.31l26.34 26.35a8 8 0 0 0 11.32-11.32l-40-40a8 8 0 0 0-11.32 0l-40 40a8 8 0 0 0 11.32 11.32"},null,-1)])])}const dS=Oe({name:"ph-export",render:tbe}),nbe={class:"layout-scene-timeline"},obe=le({__name:"LayoutSceneTimeline",setup(t){return(e,n)=>(w(),R("div",nbe,[Ce(e.$slots,"default",{},void 0,!0)]))}}),rbe=Be(obe,[["__scopeId","data-v-0ba61bc0"]]),ibe={class:"wizard-shell"},sbe=["title","aria-label"],abe={class:"wizard-shell__main"},lbe={class:"wizard-shell__content"},cbe=le({__name:"WizardShell",setup(t){const{currentStep:e,currentIndex:n,steps:o,registerCreateSession:r}=z2(),i=jo(),s=dn(),{sessionId:a,createSession:l,lastSavedAt:c}=js(),u=wn(),{scenes:d,activeIndex:f,activeScene:h,playing:g,startPlayback:b,stopPlayback:m}=u,v=A(()=>h.value!==null),{baseOptions:y}=_n(),x=Lr(),_=Ve([]),k=A(()=>c.value?new Date(c.value):""),E=UI(k),B=A(()=>k.value?`saved ${E.value}`:null),{isNarrow:S}=Ji("lg"),{isNarrow:L}=Ji("md"),{isNarrow:D}=Ji(),I=cr(),C=dg(),T=Ve(!1),P=A(()=>{switch(e.value.key){case"data":return"Data panel";case"edit":return"Edit panel";case"export":return"Export panel";default:return"Open panel"}}),$=A(()=>{switch(e.value.key){case"data":return uS;case"edit":return Ls;case"export":return dS;default:return Ls}}),F=A(()=>e.value.key==="data"&&i.rows.value.length===0);function V(){if(!F.value)if(e.value.key==="data"){let q=I.lastNarrowDataTab.value;v.value&&q==="parsing"&&(q="column"),I.openDataPanel(q)}else e.value.key==="edit"?I.selectTab(I.lastNarrowEditTab.value):e.value.key==="export"&&C.setExportTab(C.lastNarrowExportTab.value)}function U(){T.value=!0}function K(q){G(q),T.value=!1}const se={data:uS,edit:Ls,export:dS},he=o.map(q=>({label:q.label,key:q.key,icon:se[q.key]})),ce=A(()=>i.rows.value.length>0?[]:[1,2]);function be(){u.add(),u.setActive(d.value.length-1)}const oe=Ve({}),de=[Le.BarVertical,Le.BarHorizontal,Le.Line,Le.VerticalBar,Le.HorizontalBar];function we(q){var j,X,Z;const ne=fs(q.dataStr);if((j=ne.series)!=null&&j.length&&de.includes(q.chartType)){const fe=ne.series.find(pe=>pe.name===s._base.selectedColumn.value);fe&&(ne.values=fe.values),delete ne.series}return R2(q.chartType,ne,q.typeOpts,q.sort,{colorizes:(X=q.colorizes)!=null&&X.length?q.colorizes:void 0,seriesOverrides:(Z=q.seriesOverrides)!=null&&Z.length?q.seriesOverrides:void 0})}function ee(q,ne){var j;if((q==null?void 0:q.data)!==void 0)return q.data;if((j=q==null?void 0:q.transforms)!=null&&j.length&&i.columns.value.length>0){const X=x.applyStepList(q.transforms,i.columns.value,i.rows.value,i.columnTypes.value);return cg(X.columns,X.rows)}return ne}function ge(){const q=s._base,ne={};ne[0]=we({chartType:q.chartType.value,dataStr:q.data.value,typeOpts:y.value,sort:q.sort.value,colorizes:q.colorizes.value,seriesOverrides:q.seriesOverrides.value});for(let j=0;j<d.value.length;j++){const X=Ra(d.value,j);ne[j+1]=we({chartType:(X==null?void 0:X.chartType)??q.chartType.value,dataStr:ee(X,q.data.value),typeOpts:X!=null&&X.chartTypeOptions?{...y.value,...X.chartTypeOptions}:y.value,sort:nT(X)??q.sort.value,colorizes:(X==null?void 0:X.colorizes)??q.colorizes.value,seriesOverrides:(X==null?void 0:X.seriesOverrides)??q.seriesOverrides.value})}oe.value=ne}const Q=TI(ge,300);Ge([()=>d.value,s._base.chartType,s._base.data,s._base.sort,s._base.colorizes,s._base.seriesOverrides,s._base.selectedColumn,y,e],()=>{e.value.key==="edit"&&Q()},{deep:!0});function re(q){var Z;const ne=s._base.title.value;if(q<0)return ne||" ";const j=Ra(d.value,q),X=(Z=j==null?void 0:j.properties)==null?void 0:Z.title;return X!==void 0?X||" ":ne||" "}const ve=A(()=>{const q={name:re(-1),index:0,removable:!1,thumbnail:oe.value[0]??null,hint:"base scene"},ne=d.value.map((j,X)=>{const Z=X+1,fe=tT(d.value,X);let pe;return fe===X?pe="custom data":fe<0?pe="inherits base":pe=`inherits ${re(fe)||`Scene ${fe+1}`}`,{name:re(X),index:Z,removable:!0,thumbnail:oe.value[Z]??null,hint:pe}});return[q,...ne]}),N=A(()=>f.value+1);function G(q){u.setActive(q-1)}function Y(q){q<=0||u.remove(q-1)}const ue=A(()=>{const q=e.value.key;return q==="export"?!1:q==="edit"?!0:d.value.length>=1});Ge(f,(q,ne)=>{var j,X;e.value.key==="data"&&(ne===-1&&q>=0?(_.value=x.snapshot(),x.hydrate(((j=d.value[q])==null?void 0:j.transforms)??[])):ne>=0&&q===-1?(u.update(ne,{transforms:x.snapshot()}),x.hydrate(_.value)):ne>=0&&q>=0&&(u.update(ne,{transforms:x.snapshot()}),x.hydrate(((X=d.value[q])==null?void 0:X.transforms)??[])))}),un(()=>{e.value.key==="edit"&&s._base.data.value&&ge()});function ae(){f.value>=0&&(u.update(f.value,{transforms:x.snapshot()}),x.hydrate(_.value),u.setActive(-1)),s._base.data.value=i.serialize();const q=s._base.chartType.value,ne=q.includes("multi")||q.includes("stacked")||q===Le.BarSplit||q===Le.BarGrouped;if(i.columns.value.length>2&&!ne){const j=i.columnTypes.value[0]==="date";s._base.chartType.value=j?Le.LineMulti:Le.BarMulti}}return r(()=>(ae(),l())),Ge(()=>e.value.key,(q,ne)=>{ne==="data"&&q==="edit"&&a.value&&ae()}),qN(()=>{Mre()}),(q,ne)=>{const j=H1e,X=Eme,Z=sle;return w(),R("div",ibe,[H(ST,{class:"wizard-shell__header"},{start:te(()=>[H(AT),p(B)&&p(S)?(w(),R("span",{key:0,class:"wizard-shell__saved-dot",role:"status","aria-live":"polite",title:p(B),"aria-label":p(B)},null,8,sbe)):ie("",!0)]),center:te(()=>[H(p(eU),{"current-step":p(n),"onUpdate:currentStep":ne[0]||(ne[0]=fe=>Ze(n)?n.value=fe:null),steps:p(he),"disabled-steps":p(ce),layout:p(L)?"stacked":"inline"},null,8,["current-step","steps","disabled-steps","layout"])]),end:te(()=>[p(B)&&!p(S)?(w(),J(p(xy),{key:0,variant:"success",pill:"",class:"wizard-shell__saved",role:"status","aria-live":"polite"},{default:te(()=>[ne[2]||(ne[2]=M("span",{class:"wizard-shell__saved__dot"},null,-1)),Ye(" "+ye(p(B)),1)]),_:1})):ie("",!0)]),_:1}),M("div",abe,[M("div",lbe,[p(e).key==="data"?(w(),J(j,{key:0})):p(e).key==="edit"?(w(),J(X,{key:1})):p(e).key==="export"?(w(),J(Z,{key:2})):ie("",!0)]),p(D)?(w(),J(Z1e,{key:0,"show-timeline":p(ue),scenes:p(ve),"active-index":p(N),playing:p(g),"panel-label":p(P),"panel-icon":p($),"panel-disabled":p(F),"scenes-sheet-open":p(T),"onUpdate:activeIndex":G,onPlay:p(b),onPause:p(m),onExpandTimeline:U,onOpenPanel:V},null,8,["show-timeline","scenes","active-index","playing","panel-label","panel-icon","panel-disabled","scenes-sheet-open","onPlay","onPause"])):p(ue)?(w(),J(rbe,{key:1},{default:te(()=>[H(p(BG),{scenes:p(ve),"active-index":p(N),playing:p(g),"onUpdate:activeIndex":G,onAdd:be,onRemove:Y,onPlay:p(b),onPause:p(m)},null,8,["scenes","active-index","playing","onPlay","onPause"])]),_:1})):ie("",!0),p(D)?(w(),J(p(VA),{key:2,modelValue:p(T),"onUpdate:modelValue":ne[1]||(ne[1]=fe=>Ze(T)?T.value=fe:null),title:"Scenes"},{default:te(()=>[H(p(QG),{scenes:p(ve),"active-index":p(N),playing:p(g),"onUpdate:activeIndex":K,onAdd:be,onRemove:Y,onPlay:p(b),onPause:p(m)},null,8,["scenes","active-index","playing","onPlay","onPause"])]),_:1},8,["modelValue"])):ie("",!0)])])}}}),zh=Be(cbe,[["__scopeId","data-v-58139d04"]]),ube={class:"render-page"},dbe=le({__name:"RenderPage",setup(t){const e=Xl(),n=ft("containerRef"),{applyDsl:o}=Ic();G2(n);const{layout:r}=dn(),{cardClass:i,cardStyle:s}=U2(r,"render-page__card"),{scenes:a,activeIndex:l,playing:c,setActive:u,nextScene:d,previousScene:f,startPlayback:h,stopPlayback:g}=wn(),b={buttons:T1,"progress-bar":YA,"dot-stepper":jA,"minimal-arrows":XA},m=A(()=>b[r.value.playerType]||T1),v=A(()=>a.value.length+1),y=A(()=>l.value+2),x=A(()=>a.value.length>=1);function _(S){u(S-2)}const k=Ve(null);function E(){var S;return((S=n.value)==null?void 0:S.querySelector(".bc-frame-footer"))??null}let B=null;return Ge(n,S=>{if(B&&(B.disconnect(),B=null),!S){k.value=null;return}k.value=E(),B=new MutationObserver(()=>{k.value=E()}),B.observe(S,{childList:!0,subtree:!0})},{immediate:!0}),Gs(()=>{B&&(B.disconnect(),B=null)}),un(()=>{const S=e.query.bpc64;if(S)try{const L=globalThis.atob(S),D=Uint8Array.from(L,C=>C.charCodeAt(0)),I=new TextDecoder().decode(D);o(I)}catch{}}),(S,L)=>(w(),R("div",ube,[M("div",{ref_key:"containerRef",ref:n,class:Me(["render-page__card",p(i)]),style:Et(p(s))},null,6),p(k)&&p(x)?(w(),J(ty,{key:0,to:p(k)},[(w(),J(Gt(p(m)),{total:p(v),current:p(y),playing:p(c),position:p(r).playerPosition,"onUpdate:current":_,onPrevious:p(f),onNext:p(d),onPlay:p(h),onPause:p(g)},null,40,["total","current","playing","position","onPrevious","onNext","onPlay","onPause"]))],8,["to"])):ie("",!0)]))}}),fbe=Be(dbe,[["__scopeId","data-v-76a513dd"]]);function Xv(t){const{sessionId:e,loadChart:n,startAutoSave:o}=js();if(e.value===t.params.id)return;if(!n(t.params.id))return"/charts";o()}function hbe(t){if(!t)return null;try{const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),o=atob(e+n),r=new Uint8Array(o.length);for(let i=0;i<o.length;i++)r[i]=o.charCodeAt(i);return new TextDecoder().decode(r)}catch{return null}}const pbe=xI({history:QN(),scrollBehavior(t,e,n){return n||(t.hash?{el:t.hash,behavior:"smooth"}:{top:0})},routes:[{path:"/",component:()=>q6(()=>import("./LandingPage-DVL-4rGR.js"),__vite__mapDeps([0,1]))},{path:"/charts",component:yse},{path:"/new",component:zh,beforeEnter:()=>{const{prepareNew:t}=js();t()}},{path:"/edit/:id",redirect:t=>`/edit/${t.params.id}/visualize`},{path:"/copy/:base64",component:()=>q6(()=>import("./CopyRedirect-2orINI2X.js"),[]),meta:{bare:!0},beforeEnter:t=>{const e=hbe(String(t.params.base64??""));if(!e)return"/";const{createFromDsl:n}=js(),o=n(e);if(!o)return"/";t.meta.copyTarget=`/edit/${o}/visualize`}},{path:"/edit/:id/data",component:zh,beforeEnter:Xv},{path:"/edit/:id/visualize",component:zh,beforeEnter:Xv},{path:"/edit/:id/export",component:zh,beforeEnter:Xv},{path:"/render",component:fbe,meta:{bare:!0}}]}),iB=SP();iB.use(DP);wP(uie).use(iB).use(pbe).use(fN()).mount("#app");export{ty as $,Sf as A,Kn as B,MI as C,X$ as D,ft as E,zt as F,O6 as G,xy as H,Vre as I,Py as J,He as K,ht as L,ye as M,lU as N,Oe as O,Me as P,pue as Q,ET as R,NT as S,Lge as T,F2 as U,nB as V,Ie as W,bbe as X,Gs as Y,Ase as Z,Be as _,M as a,T1 as a0,Xl as a1,Ay as a2,ie as b,R as c,le as d,Ty as e,J as f,p as g,H as h,Ye as i,KA as j,A as k,nm as l,JA as m,QA as n,w as o,Rq as p,Eq as q,Ce as r,Lq as s,Ge as t,Cf as u,is as v,te as w,ag as x,Ve as y,Ze as z};
|