@motionscript/charts 0.1.1-alpha.2 → 0.1.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +7 -9
- package/dist/bar-chart/bar-chart.d.ts +48 -48
- package/dist/bar-chart/bar-chart.js +2 -2
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +2 -1
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +2 -0
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-FJHNBNPQ.js +2 -0
- package/dist/browser/chunks/chunk-FJHNBNPQ.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/kit/style.d.ts +25 -20
- package/dist/kit/style.d.ts.map +1 -1
- package/dist/kit/style.js +20 -18
- package/dist/kit/style.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +48 -48
- package/dist/line-chart/line-chart.js +2 -2
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +2 -1
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +2 -0
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +18 -24
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/shared.d.ts +7 -9
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +7 -10
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +1 -1
- package/dist/radar-chart/index.d.ts.map +1 -1
- package/dist/radar-chart/index.js +1 -1
- package/dist/radar-chart/index.js.map +1 -1
- package/dist/radar-chart/radar-chart.d.ts +6 -12
- package/dist/radar-chart/radar-chart.d.ts.map +1 -1
- package/dist/radar-chart/radar-chart.js +1 -2
- package/dist/radar-chart/radar-chart.js.map +1 -1
- package/dist/radar-chart/shared.d.ts +2 -5
- package/dist/radar-chart/shared.d.ts.map +1 -1
- package/dist/radar-chart/shared.js +3 -6
- package/dist/radar-chart/shared.js.map +1 -1
- package/dist/radial-chart/radial-chart.d.ts +12 -18
- package/dist/radial-chart/radial-chart.d.ts.map +1 -1
- package/dist/radial-chart/shared.d.ts +5 -7
- package/dist/radial-chart/shared.d.ts.map +1 -1
- package/dist/radial-chart/shared.js +5 -8
- package/dist/radial-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +2 -2
- package/src/bar-chart/shared.ts +3 -0
- package/src/kit/style.ts +21 -19
- package/src/line-chart/line-chart.ts +2 -2
- package/src/line-chart/shared.ts +3 -1
- package/src/pie-chart/shared.ts +6 -10
- package/src/radar-chart/index.ts +1 -1
- package/src/radar-chart/radar-chart.ts +0 -2
- package/src/radar-chart/shared.ts +3 -7
- package/src/radial-chart/shared.ts +4 -8
- package/dist/browser/chunks/chunk-7XCRX6GE.js +0 -2
- package/dist/browser/chunks/chunk-7XCRX6GE.js.map +0 -7
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as Ys,A as ve,B as Z,C as xt,D as Ue,E as y,F as J,G as O,H as C,I as $t,J as yt,K as ir,L as bt,M as Q,N as D,O as L,P as G,Q as sr,R as Xe,S as ar,T as jt,U as Me,V as We,W as Ve,X as Ke,Y as N,Z as k,_ as $,a as H,aa as lr,b as Ns,ba as Us,c as Ye,ca as Xs,d as Re,da as Ee,e as Y,ea as wt,f as lt,fa as qt,g as Se,ga as ee,h as Ae,ha as Te,i as ct,ia as Rt,j as ut,ja as te,k as U,ka as Ws,l as X,la as le,m as ft,ma as cr,n as P,na as Le,o as W,oa as Ce,p as F,pa as _e,q as Hs,qa as Oe,r as ht,ra as ne,s as ke,sa as j,t as B,ta as ce,u as V,ua as ur,v as dt,va as Ie,w as pt,x as K,y as gt,z as mt}from"./chunks/chunk-7XCRX6GE.js";import{Rect as hi,Text as di,Types as re,clamp as un,component2d as pi,easeOut as he}from"@motionscript/sdk";import{formatNumber as gi}from"@motionscript/sdk/component";import{Graphics2D as $e,Types as fe,clamp as je,component2d as xr,fillOps as qe,strokeOps as gr}from"@motionscript/sdk";import{Types as ge}from"@motionscript/sdk";var me={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function ue(e){return e.right>e.left&&e.top>e.bottom}function Zt(e,t,n,r){if(!e||e.x===void 0&&e.y===void 0)return me;let o=(f,[h,d],p,g)=>{if(f===void 0||d<=h)return[p,g,!1];let m=Math.min(f[0],f[1]),x=Math.max(f[0],f[1]),R=v=>p+(v-h)/(d-h)*(g-p);return[Math.max(p,Math.min(g,R(m))),Math.max(p,Math.min(g,R(x))),!0]},[i,s,a]=o(e.x,n,t.left,t.right),[l,c,u]=o(e.y,r,t.bottom,t.top);return{left:i,right:s,bottom:l,top:c,xBounded:a,yBounded:u}}function Jt(e,t){if(e.length<2||!ue(t))return[];let n=[],r=[];for(let o=1;o<e.length;o++){let i=Zo(e[o-1],e[o],t);if(!i){r.length>=2&&n.push(r),r=[];continue}let[s,a]=i;r.length>0&&qo(r[r.length-1],s)?r.push(a):(r.length>=2&&n.push(r),r=[s,a])}return r.length>=2&&n.push(r),n}function qo(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function Zo(e,t,n){let r=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-r,e.x-n.left],[r,n.right-e.x],[-o,e.y-n.bottom],[o,n.top-e.y]];for(let[l,c]of a){if(l===0){if(c<0)return null;continue}let u=c/l;if(l<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*r,y:e.y+i*o},{x:e.x+s*r,y:e.y+s*o}]}function Jo(e,t,n){return e.map((r,o)=>[t.at(o),k(r,n.field)]).sort((r,o)=>r[0]-o[0])}function pr(e,t){let n=1/0,r=-1/0;for(let o of e)for(let i of t){let s=k(o,i.field);s<n&&(n=s),s>r&&(r=s)}return n<=r?[n,r]:[0,1]}function Qo(e,t,n,r){return n??Te(pr(e,t),r)}function Qt(e,t,n,r,o=[]){let i=e.map((c,u)=>u).sort((c,u)=>t.at(c)-t.at(u));if(r!=="stacked"&&r!=="percent")return n.map(c=>({points:i.map(u=>[t.at(u),k(e[u],c.field)]),base:null}));let s=c=>Math.max(0,o[c]??1),a=i.map(c=>n.reduce((u,f,h)=>u+Math.abs(k(e[c],f.field)*s(h)),0)),l=i.map(()=>0);return n.map((c,u)=>{let f=i.map((d,p)=>[t.at(d),l[p]]);return{points:i.map((d,p)=>{let g=k(e[d],c.field)*s(u);return l[p]+=r==="percent"?a[p]>0?g/a[p]*100:0:g,[t.at(d),l[p]]}),base:f}})}function St(e){let t=1/0,n=-1/0;for(let{points:r,base:o}of e)for(let[,i]of[...r,...o??[]])i<t&&(t=i),i>n&&(n=i);return t<=n?[t,n]:[0,1]}var fr=16;function en(e,t){if(t==="step"){let o=e.length>0?[e[0]]:[];for(let i=1;i<e.length;i++){let s=(e[i-1].x+e[i].x)/2;o.push({x:s,y:e[i-1].y},{x:s,y:e[i].y},e[i])}return o}if(t!=="smooth"||e.length<3)return[...e];let n=ei(e),r=[e[0]];for(let o=1;o<e.length;o++){let i=e[o-1],s=e[o],a=(s.x-i.x)/3,l={x:i.x+a,y:i.y+a*n[o-1]},c={x:s.x-a,y:s.y-a*n[o]};for(let u=1;u<=fr;u++){let f=u/fr,h=1-f;r.push({x:h*h*h*i.x+3*h*h*f*l.x+3*h*f*f*c.x+f*f*f*s.x,y:h*h*h*i.y+3*h*h*f*l.y+3*h*f*f*c.y+f*f*f*s.y})}}return r}function ei(e){let t=e.length,n=o=>{let i=e[o+1].x-e[o].x;return i===0?0:(e[o+1].y-e[o].y)/i},r=new Array(t).fill(0);for(let o=1;o<t-1;o++){let i=e[o].x-e[o-1].x,s=e[o+1].x-e[o].x,a=n(o-1),l=n(o),c=i+s===0?0:(a*s+l*i)/(i+s);r[o]=(Math.sign(a)+Math.sign(l))*Math.min(Math.abs(a),Math.abs(l),.5*Math.abs(c))||0}return r[0]=hr(n(0),r[1]),r[t-1]=hr(n(t-2),r[t-2]),r}function hr(e,t){let n=(3*e-t)/2;return e===0||Math.sign(n)!==Math.sign(e)?0:Math.abs(n)>3*Math.abs(e)?3*e:n}function tn(e,t){if(e.length===0||t<e[0].x)return[];let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.x<=t){n.push(o);continue}let i=e[r-1];i&&o.x>i.x&&n.push({x:t,y:i.y+(o.y-i.y)*(t-i.x)/(o.x-i.x)});break}return n}function nn(e,t){if(e.length<3||!ue(t))return[];let n=[o=>o.x-t.left,o=>t.right-o.x,o=>o.y-t.bottom,o=>t.top-o.y],r=[...e];for(let o of n){let i=r;r=[];for(let s=0;s<i.length;s++){let a=i[s],l=i[(s+i.length-1)%i.length],c=o(a),u=o(l);c>=0?(u<0&&r.push(dr(l,a,u,c)),r.push(a)):u>=0&&r.push(dr(l,a,u,c))}if(r.length===0)return[]}return r}function dr(e,t,n,r){let o=n/(n-r);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}var rn={strokeWidth:ge.number(4,{min:0,max:24,step:.5,unit:"px"}),curve:ge.oneOf(["smooth","linear","step"]),dots:ge.boolean(!1),dotSize:ge.number(12,{min:0,max:48,step:1,unit:"px"}),area:ge.oneOf(["none","solid","gradient"]),areaOpacity:ge.number(.4,{min:0,max:1,step:.05})},on={values:ge.oneOf(["none","above","below"],{animatable:!1})};function Ze(e,t){if(e.length===0)return 0;let n=e[0].x,r=e[e.length-1].x;return t>=1?1/0:n+(r-n)*t}function sn(e,t,n){let r=en(e,t);return n>=1?r:tn(r,Ze(e,n))}var yr=()=>fe.custom("smooth");function ti(e){return[...e.map((t,n)=>({type:n===0?"M":"L",x:t.x,y:t.y})),{type:"Z"}]}function ni(e,t,n,r){if(t.length<3||r<=0)return;let{width:o,height:i}=e.size,s=[-o/2,-i/2,o/2,i/2];e.draw(new $e().path({data:ti(t),centerBounds:s}).fill(n).opacity(r))}var At=xr({key:"chartLine",state:{points:y(()=>[]),curve:yr(),stroke:fe.custom([],{resolve:gr.resolve,lerp:gr.lerp}),dotSize:0,dotFill:fe.custom([],{resolve:qe.resolve,lerp:qe.lerp}),progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.dotFill],strokes:[t.stroke]}),commands:{enter:{args:{from:fe.number(0,{min:0,max:1}),to:fe.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}},hold:{args:{shown:fe.boolean(!0)},run:e=>{let{shown:t}=e.args;return e.animate(n=>({progress:1,enabled:t||n<1}),{eased:!1})}}},render:(e,t)=>{if(!t.enabled)return;let n=t.points,r=je(t.progress,0,1);if(n.length===0||r<=0)return;let o=t.spotlight,i=ue(o),s=je(t.dimOpacity,0,1),a=t.stroke,l=a[0]?.weight??0,c=sn(n,t.curve,r);if(c.length>=2&&l>0){let m=t.curve==="linear"?l*2:0;if(e.draw(new $e().line({points:c,radius:m}).stroke(a).opacity(i?s:1)),i)for(let x of Jt(c,o))e.draw(new $e().line({points:x,radius:m}).stroke(a))}let u=t.dotSize;if(u<=0)return;let f=Ze(n,r),h=new $e,d=new $e,p=!1,g=!1;for(let m of n){let x=f===1/0?1:je((f-m.x)/(u*2),0,1);if(x<=0)continue;let R=!i||m.x>=o.left&&m.x<=o.right&&m.y>=o.bottom&&m.y<=o.top;(R?h:d).ellipse({x:m.x,y:m.y,width:u*x,height:u*x}),R?p=!0:g=!0}g&&e.draw(d.fill(t.dotFill).opacity(s)),p&&e.draw(h.fill(t.dotFill))}}),an=xr({key:"chartArea",state:{points:y(()=>[]),base:y(()=>[]),baseline:0,curve:yr(),area:fe.custom("solid"),fill:fe.custom([],{resolve:qe.resolve,lerp:qe.lerp}),areaOpacity:.4,progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.fill]}),render:(e,t)=>{let n=t.points,r=je(t.progress,0,1);if(!t.enabled||t.area==="none"||n.length<2||r<=0||t.fill.length===0)return;let o=c=>{let u=sn(n,t.curve,c);if(u.length<2)return[];let f=t.base.length===n.length?sn(t.base,t.curve,c):[{x:u[0].x,y:t.baseline},{x:u[u.length-1].x,y:t.baseline}];return[...u,...[...f].reverse()]},i=mr(o(1)),s=(c,u)=>ni(e,c,br(t.fill,t.area,t.areaOpacity,i,mr(c)),u),a=o(r),l=t.spotlight;if(!ue(l)){s(a,1);return}s(a,je(t.dimOpacity,0,1)),s(nn(a,l),1)}});function mr(e){let t=-1/0,n=1/0;for(let r of e)r.y>t&&(t=r.y),r.y<n&&(n=r.y);return{top:t,bottom:n}}function br(e,t,n,r,o){let i=e[e.length-1];if(t!=="gradient"||i?.type!=="solid"||!(o.top>o.bottom))return Ue(e,n);let[s,a,l,c]=i.color,u=(o.top+o.bottom)/2,f=(o.top-o.bottom)/2;return qe.resolve({type:"linear-gradient",colors:[[s,a,l,c*n],[s,a,l,c*n*.04]],start:{x:0,y:(r.top-u)/f},end:{x:0,y:(r.bottom-u)/f}})}import{Graphics2D as ri,Types as wr,component2d as oi,fillOps as Rr,strokeOps as Sr}from"@motionscript/sdk";var ln=oi({key:"chartRegion",state:{box:y(()=>me),stroke:wr.custom({weight:2,fill:"white/70",dash:[14,12],cap:"butt",align:"center"},{resolve:Sr.resolve,lerp:Sr.lerp}),fill:wr.custom("white/6",{resolve:Rr.resolve,lerp:Rr.lerp}),reveal:0},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let n=t.box;if(!ue(n))return;let r=Math.max(0,Math.min(1,t.reveal));if(r<=0)return;let o=n.right-n.left,i=n.top-n.bottom,s=(n.left+n.right)/2,a=(n.bottom+n.top)/2;if(t.fill.length>0&&e.draw(new ri().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(r)),t.stroke.length!==0){if(n.xBounded){let l=i/2*r;for(let c of[n.left,n.right])$t(e,{x:c,y:a-l},{x:c,y:a+l},t.stroke,r)}if(n.yBounded){let l=o/2*r;for(let c of[n.bottom,n.top])$t(e,{x:s-l,y:c},{x:s+l,y:c},t.stroke,r)}}}});import{formatNumber as ii}from"@motionscript/sdk/component";var kt=864e5,Tr=["january","february","march","april","may","june","july","august","september","october","november","december"],Ar=2024;function kr(e){return e.length<3?-1:Tr.findIndex(t=>t.startsWith(e))}function si(e,t){let n=Date.UTC(e,0,4),r=(new Date(n).getUTCDay()+6)%7;return n-r*kt+(t-1)*7*kt}function Lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let n=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(n){let s=Number(n[2]),a=n[3]===void 0?1:Number(n[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(n[1]),s-1,a)}let r=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(r){let s=Number(r[2]);return s<1||s>53?null:si(r[1]===void 0?Ar:Number(r[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=kr(o[2]);if(s>=0){let a=o[1]??o[3],l=a===void 0?Ar:Number(a);return Date.UTC(l,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=kr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function Cr(e,t){let n=new Date(e),r=n.getUTCFullYear(),o=Tr[n.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*kt?String(r):t>60*kt?`${i} ${r}`:`${i} ${n.getUTCDate()}`}function ai(e,t){let n=!1;for(let r of e){let o=r[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;n=!0}}return n}function li(e,t){let n=[],r=!1;for(let s of e){let a=s[t];if(a==null||a===""){n.push(null);continue}let l=Lr(a);if(l===null)return null;n.push(l),r=!0}if(!r)return null;let i=n.find(s=>s!==null);return n.map(s=>s===null?i:i=s)}function vr(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t<=n?[t,n]:[0,1]}var _r=12;function Mr(e,[t,n],r){let o=e.filter(l=>l>=t&&l<=n),i=[...new Set(o)].sort((l,c)=>l-c);if(i.length===0)return ee([t,n],r);if(i.length<=_r&&ci(i))return i;let s=l=>i.reduce((c,u)=>Math.abs(u-l)<Math.abs(c-l)?u:c),a=[];for(let l of ee([t,n],r)){let c=s(l);a[a.length-1]!==c&&a.push(c)}return a}function ci(e){if(e.length<3)return!0;let t=(e[e.length-1]-e[0])/(e.length-1);for(let n=1;n<e.length;n++)if(e[n]-e[n-1]<t*.75)return!1;return!0}function ui(e,t,n,r){let o=e.indexOf(n);return o>=0?t[o]:r(n)}var Er=new WeakMap;function cn(e,t,n){let r=Er.get(e);r||Er.set(e,r=new Map);let o=JSON.stringify([t,n??null]),i=r.get(o);return i||r.set(o,i=fi(e,t,n)),i}function fi(e,t,n){if(t!==""&&ai(e,t)){let s=e.map(a=>k(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:vr(s),label:a=>n===void 0?Ee(a):ii(a,n),ticks:ee}}let r=e.map(s=>$(s,t)),o=t===""?null:li(e,t);if(o){let s=vr(o),a=s[1]-s[0];return{kind:"time",at:l=>o[l]??0,extent:s,label:l=>ui(o,r,l,c=>Cr(c,a)),ticks:(l,c)=>Mr(o,l,c)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>r[Math.round(s)]??"",ticks:(s,a)=>Mr(i,s,a)}}var mi=re.style(H,{series:Y,background:Se,text:ct,grid:ut,marks:rn,labels:on,legend:U},{presets:X}),Or=re.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Yr=[0,100];function vt(e,t=e.xAxis.format){return cn(e.data,e.xField,t)}function hn(e,t=!0){return Qt(e.data,vt(e),e.series,e.stack,t?e.weights:void 0)}function xi(e,t){let n=vt(e,t.format),r=t.range??n.extent;return{...t,range:r,ticks:t.ticks??n.ticks(r,Q-1)}}function yi(e,t){let[n,r]=St(hn(e,!1));if(e.stack==="percent"&&n>=0)return Yr;let o=e.stack!=="none"||(e.style?.area??"none")!=="none";return Te(o?[Math.min(0,n),Math.max(0,r)]:[n,r],t)}function bi(e,t){let n=(t.ticks?.length??Q)-1,r=t.range??yi(e,n),o=t.range!==void 0||e.stack==="percent"&&r===Yr;return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var Ir=new WeakMap;function Je(e){let t=[e.xField,e.xAxis,e.yAxis,e.series,e.stack,e.style?.area],n=Ir.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domains;let r={x:Ke(e.xAxis,o=>xi(e,o)),y:Ke(e.yAxis,o=>bi(e,o))};return Ir.set(e.data,{key:t,domains:r}),r}function Ur(e,t){let[n,r]=e.x.range,[o,i]=e.y.range;return{x:s=>r<=n?0:((s-n)/(r-n)-.5)*t.width,y:s=>i===o?0:((s-o)/(i-o)-.5)*t.height}}var wi={points:[],base:[],values:[]};function Ri(e,t,n,r){let o=hn(e)[n];if(!o)return wi;let i=Ur(t,r),s=([a,l])=>({x:i.x(a),y:i.y(l)});return{points:o.points.map(s),base:o.base?o.base.map(s):[],values:o.points.map(([,a],l)=>a-(o.base?.[l]?.[1]??0))}}function Pr(e){let[t,n]=e.y.range;return un(0,Math.min(t,n),Math.max(t,n))}function Si(e,t){let[n,r]=St(hn(e,!1)),[o,i]=vt(e).extent,s=(a,[l,c])=>a>=Math.min(l,c)-1e-9&&a<=Math.max(l,c)+1e-9;return!(s(n,t.y.range)&&s(r,t.y.range)&&s(o,t.x.range)&&s(i,t.x.range))}function Ai(e,t,n){let{width:r,height:o}=n;return Zt(e.region,{left:-r/2,right:r/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function Dr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function Gr(e){return e!=null&&typeof e=="object"?e:{}}function ki([e,t]){return e<=t?[e,t]:[t,e]}function zr(e,t){let n=ki(e);return{range:n,ticks:ee(n,Math.max(2,t.length)-1)}}function Fr(e,t,n){return{...t.x&&{xAxis:We(e.x,t.x,n)},...t.y&&{yAxis:We(e.y,t.y,n)}}}function Br(e,t,n){let r=e.yAxis.format;if(r!==void 0)return gi(t,r);let o=Ee(t,wt(n));return e.stack==="percent"?`${o}%`:o}function vi(e,t){return Math.max(0,e.weights[t]??1)}function fn(e){let t=mt(e);return{vAxis:t.find(Le.is)??null,hAxis:t.find(Ce.is)??null,lines:t.filter(At.is),legend:t.find(te.is)??null}}function Nr(e,t){let n=t.regionReveal,r=t.region;return n===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:r,regionReveal:n*(1-o)})}function Hr(e,t,n,r,o){let i=fn(n),s=i.lines[r];if(!s)return e.wait(e.duration);let a=i.legend?[i.legend.run(o?"showSeries":"hideSeries",{index:r})]:[];if(t.stack==="none")return e.together([s.run("enter",o?{from:0,to:1}:{from:1,to:0}),...a]);let l=t.series.map((f,h)=>vi(t,h)),c=l[r]??1,u=o?1:0;return e.together([e.animate(f=>{let h=[...l];return h[r]=c+(u-c)*e.ease(f),{weights:h}},{eased:!1}),s.run("hold",{shown:o}),...a])}var dn=pi({key:"lineChart",state:{data:y(()=>[],{kind:"dataset"}),xField:"",series:y(()=>[],{kind:"series"}),stack:re.oneOf(["none","stacked","percent"]),xAxis:re.custom({},{resolve:Me,lerp:Ve}),yAxis:re.custom({},{resolve:Me,lerp:Ve}),style:mi,region:re.custom(null),regionReveal:0,home:re.custom(null,{private:!0}),weights:re.custom([],{private:!0}),clipped:re.boolean(!1,{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Je(e),r,o=()=>ve(r),i=w=>Ri(e,n(),w,o()),s=e.series.map(w=>w.enabled??!0),a=e.style,l=()=>ke(t(),"y"),c=()=>ke(t(),"x"),u=()=>{let w=n().y.ticks;return w.map(b=>Br(e,b,w))},f=a.showYAxis?new Le({range:()=>n().y.range,markers:()=>n().y.ticks,captions:u,axis:l,label:e.yAxis.label??"",width:"hug",height:"fill"}):void 0,h=a.showXAxis?new Ce({range:()=>n().x.range,markers:()=>n().x.ticks,captions:()=>{let w=vt(e);return n().x.ticks.map(b=>w.label(b))},axis:c,label:e.xAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):void 0,d=f&&h?xt({captions:u,count:Je(e).y.ticks.length,text:()=>l().labelStyle,title:e.yAxis.label??"",titleText:()=>l().titleStyle,tickPad:()=>le(l(),"right").tick,titlePad:()=>le(l(),"right").title}):void 0,p=()=>Ai(e,n(),o()),g=()=>1-(1-N)*e.regionReveal,m=e.series.map((w,b)=>new At({points:()=>i(b).points,curve:()=>t().curve,stroke:()=>({weight:t().strokeWidth,fill:P(t(),w,b),align:"center",cap:"round",join:"round"}),dotSize:()=>t().dots?t().dotSize:0,dotFill:()=>P(t(),w,b),enabled:s[b],spotlight:p,dimOpacity:g})),x=e.series.map((w,b)=>new an({points:()=>i(b).points,base:()=>i(b).base,baseline:()=>Ur(n(),o()).y(Pr(n())),curve:()=>t().curve,area:()=>t().area,fill:()=>P(t(),w,b),areaOpacity:()=>t().areaOpacity,progress:()=>m[b].progress,enabled:()=>m[b].enabled,opacity:()=>m[b].opacity,spotlight:p,dimOpacity:g})),R=[];if(a.values!=="none"){let w=a.values==="below";e.series.forEach((b,M)=>{e.data.forEach((z,E)=>{let T=m[M],pe=new di({...Z(()=>ht(t())),text:()=>{let _=i(M).values[E];return _===void 0?"":Br(e,_,n().y.ticks)},x:()=>{let _=(o().width-pe.layoutBounds.width)/2;return un(i(M).points[E]?.x??0,-Math.max(0,_),Math.max(0,_))},y:()=>{let _=i(M).points[E],ae=pe.layoutBounds.height/2+(t().dots?t().dotSize/2:t().strokeWidth/2)+Math.round(W(t().valueText)*.25);return(_?.y??0)+(w?-ae:ae)},opacity:()=>{let _=i(M).points[E];if(!T.enabled||!_)return 0;let ae=Ze(i(M).points,T.progress);return T.opacity*(ae===1/0?1:un((ae-_.x)/24,0,1))}});R.push(pe)})})}let v=a.legend,S=v!=="none"?new te({series:e.series,swatches:()=>e.series.map((w,b)=>P(t(),w,b)),legend:()=>B(t()),flow:v==="right"?"vertical":"horizontal"}):void 0;return r=new hi({clip:()=>e.clipped||Si(e,n()),children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:()=>n().x.ticks,yMarkers:()=>n().y.ticks,xExtent:()=>n().x.range,yExtent:()=>n().y.range,axisStroke:()=>t().axisStroke,xAxisAt:()=>Pr(n()),yAxisAt:()=>n().x.range[0]}),new ln({box:p,stroke:()=>({weight:2,fill:Ue(t().valueText.fill??"white",.7),dash:[14,12],cap:"butt",align:"center"}),fill:()=>Ue(t().valueText.fill??"white",.06),reveal:()=>e.regionReveal}),...x,...m,...R]}),[gt({background:()=>t().background,left:f,ghost:d,plot:r,bottom:h,legend:S,legendAt:v,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:h?K(t()):0,left:h&&!f?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.duration,i=Dr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*D.axes,l=s*D.marks,{legend:c}=r,u=h=>({at:0,duration:0,piece:h}),f=bt(t.style.legend);return G(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...r.lines.map(h=>u(h.to({progress:0}))),...c?[u(c.to({opacity:0,...f}))]:[],...r.vAxis?[{at:0,duration:a,piece:r.vAxis.run("enter",{slide:24})}]:[],...r.hAxis?[{at:0,duration:a,piece:r.hAxis.run("enter",{slide:24})}]:[],...r.lines.map(h=>({at:a,duration:l,piece:h.run("enter")})),...c?[{at:a+l,duration:s*D.legend,piece:c.to({opacity:1,x:0,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(h=>({regionReveal:h}))}]:[],{at:0,duration:o,piece:e.wait(o)}])}},spotlightRegion:{args:{region:Or},easing:he(),run:(e,t)=>{let n=Gr(e.args.region),r=t.regionReveal,o=t.region;return n.x===void 0&&n.y===void 0?Nr(e,t):r<=0||!Dr(t)?e.animate(i=>({region:n,regionReveal:r+(1-r)*i})):e.animate(i=>i<.5?{region:o,regionReveal:r*(1-e.ease(i*2))}:{region:n,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:he(),run:(e,t)=>Nr(e,t)},zoomTo:{args:{region:Or},easing:he(),run:(e,t)=>{let n=Gr(e.args.region);if(!n.x&&!n.y)return e.wait(e.duration);let r=Je(t),o=t.home??r,i={...n.x&&{x:{...r.x,...zr(n.x,r.x.ticks)}},...n.y&&{y:{...r.y,...zr(n.y,r.y.ticks)}}};return e.animate(s=>({home:o,clipped:!0,...Fr(r,i,s)}))}},resetZoom:{args:{},easing:he(),run:(e,t)=>{let n=t.home;if(!n)return e.wait(e.duration);let r=Je(t);return e.animate(o=>({home:null,clipped:o<1,...Fr(r,n,o)}))}},showSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Hr(e,t,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Hr(e,t,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.args.seriesIndex;return e.together([...r.lines.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}}}});import{Rect as zi,Types as oe,clamp as Mn,component2d as Fi,easeOut as Pe}from"@motionscript/sdk";import{formatNumber as Bi}from"@motionscript/sdk/component";import{Rect as pn,Text as Xr,Types as Mt,clamp as Mi,component2d as Ei}from"@motionscript/sdk";import{enterBudget as Ti}from"@motionscript/sdk/component";var Li=24;function Qe(e,t,n){return t<=0?0:-n/2+n/t*(e+.5)}var Et=Ei({key:"categoryAxis",state:{categories:y(()=>[]),axis:Mt.custom(lr),label:"",orientation:Mt.oneOf(["horizontal","vertical"]),dims:y(()=>[]),arrivals:sr()},defaults:{width:"fill",height:"fill"},children:e=>{let t=e.categories.length,n=s=>Mi(e.dims[s]??1,0,1);if(e.orientation==="vertical")return[cr({count:t,axis:()=>e.axis,text:s=>e.categories[s]??"",place:(s,a)=>-Qe(s,e.categories.length,a),arrivals:()=>e.arrivals,opacity:n,label:e.label})];let r=()=>le(e.axis,"top"),o=e.categories.map((s,a)=>{let l=new pn({width:"hug",height:"hug",flow:"freeform",opacity:()=>n(a),x:()=>Qe(a,e.categories.length,l.parent?.layoutBounds.width??0),children:[new Xr({...Z(()=>e.axis.labelStyle),text:s,opacity:()=>Xe(e.arrivals,a).opacity,y:()=>Xe(e.arrivals,a).shift})]});return l}),i=[new pn({width:"fill",height:"hug",padding:()=>({top:r().tick}),children:o})];return e.label!==""&&i.push(new Xr({...Z(()=>e.axis.titleStyle),text:e.label,opacity:()=>Xe(e.arrivals,"label").opacity,y:()=>Xe(e.arrivals,"label").shift})),[new pn({flow:"vertical",gap:()=>r().title,height:"hug",width:"fill",children:i})]},commands:{enter:{args:{stagger:Mt.custom(void 0),slide:Mt.number(Li)},run:(e,t)=>{let{stagger:n,slide:r}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:r},a=[...t.categories.keys(),...i?["label"]:[]],l=e.animate(()=>({arrivals:ar(a,s)}));if(o===0)return l;let{step:c,per:u,caption:f}=Ti(e.duration,o,i,n),h=L(e),d=t.categories.map((g,m)=>({at:m*c,duration:u,piece:jt(e,m,s,h)})),p=i?[{at:(o-1)*c+u,duration:f,piece:jt(e,"label",s,h)}]:[];return e.together([l,G(e,[...d,...p])])}}}});import{Graphics2D as _i,Text as Oi,Types as tt,clamp as wn,component2d as Ii,fillOps as Vr}from"@motionscript/sdk";import{Types as et,fillOps as Ci}from"@motionscript/sdk";function Tt(e,t,n,r=[]){let o=h=>Math.max(0,r[h]??1);if(n!=="stacked"&&n!=="percent")return t.map(h=>{let d=k(e,h.field);return{from:0,to:d,value:d,outer:!0}});let i=t.map((h,d)=>k(e,h.field)*o(d)),s=i.reduce((h,d)=>h+Math.abs(d),0),a=n==="percent"?i.map(h=>s>0?h/s*100:0):i,l=-1,c=-1;a.forEach((h,d)=>{h>0?l=d:h<0&&(c=d)});let u=0,f=0;return a.map((h,d)=>{if(h<0){let g=f;return f+=h,{from:g,to:f,value:h,outer:d===c}}let p=u;return u+=h,{from:p,to:u,value:h,outer:d===l}})}function gn(e,t){return e.map(n=>$(n,t))}function Wr(e,t,n,r){let o=0,i=0;for(let s of e)for(let a of Tt(s,t,n,r))o=Math.min(o,a.from,a.to),i=Math.max(i,a.from,a.to);return o<i?[o,i]:[0,1]}function mn(e,t,n,r,o,i){if(r)return r;let[s,a]=Wr(e,t,n,i);return n==="percent"?[s<0?-100:0,a>0?100:0]:Te([s,a],o)}function xn(e){let t=Ci.resolve(e),n=t[t.length-1];if(n?.type!=="solid")return"white";let[r,o,i]=n.color,s=l=>l<=.03928?l/12.92:((l+.055)/1.055)**2.4;return .2126*s(r)+.7152*s(o)+.0722*s(i)>.4?"#0a0a0a":"white"}var yn={barCornerRadius:et.cornerRadius({topLeft:10,topRight:10,bottomRight:0,bottomLeft:0}),barCornerStyle:et.cornerStyle("rounded"),barWidth:et.number(.7,{min:.05,max:1,step:.05,unit:"%",scale:100}),barGap:et.number(6,{min:0,max:40,step:1,unit:"px"})},bn={values:et.oneOf(["none","end","inside"],{animatable:!1})};var Pi=.6;function Kr(e,t){return e.enabled?wn(e.dims[t]??1,0,1):0}function Rn(e,t){let n=e.bars[t];if(!n)return null;let r=wn(e.growth,0,1);return{base:e.baseline+(n.from-e.baseline)*r,end:e.baseline+(n.to-e.baseline)*r}}function qr(e){return typeof e.fontSize=="number"?e.fontSize:24}function $r(e,t,n){let r=Rn(e,t);if(!r)return 0;if(e.values==="inside")return(r.base+r.end)/2;let o=r.end>=r.base?1:-1;return r.end+o*(qr(e.valueStyle)*.4+n/2)}function Di(e,t,n,r){let o=e.bars[t],i=Rn(e,t);if(!o||!i)return!1;let s=qr(e.valueStyle)*Pi;return Math.abs(i.end-i.base)>=n+s&&o.thickness>=r}var Lt=Ii({key:"chartBars",state:{bars:y(()=>[]),baseline:0,horizontal:!1,fill:tt.custom([],{resolve:Vr.resolve,lerp:Vr.lerp}),cornerRadius:tt.cornerRadius(8),cornerStyle:tt.cornerStyle("rounded"),growth:1,dims:y(()=>[]),values:tt.custom("none"),valueStyle:tt.custom({fontSize:24,fill:"white"}),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.values==="none"?[]:e.bars.map((t,n)=>{let r=new Oi({...Z(()=>({...e.valueStyle,...e.values==="inside"&&{fill:xn(e.fill)}})),text:()=>e.bars[n]?.caption??"",x:()=>e.horizontal?$r(e,n,r.layoutBounds.width):e.bars[n]?.center??0,y:()=>e.horizontal?e.bars[n]?.center??0:$r(e,n,r.layoutBounds.height),opacity:()=>{let o=r.layoutBounds,i=e.horizontal?o.width:o.height,s=e.horizontal?o.height:o.width;return e.values==="inside"&&!Di(e,n,i,s)?0:Kr(e,n)*wn((e.growth-.6)/.4,0,1)}});return r}),load:(e,t)=>C(e,{fills:[t.fill]}),commands:{enter:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))}},render:(e,t)=>{if(t.enabled)for(let n=0;n<t.bars.length;n++){let r=t.bars[n],o=Rn(t,n);if(!o||r.thickness<=0)continue;let i=r.round?0:1,s=Math.abs(o.end-o.base)+i;if(s<=i)continue;let a=o.end>=o.base,l=(o.base+o.end)/2+(a?i:-i)/2,c=Gi(t,r,a,s),u=new _i().rect(t.horizontal?{x:l,y:r.center,width:s,height:r.thickness,...c}:{x:r.center,y:l,width:r.thickness,height:s,...c});u.fill(t.fill),e.draw(u.opacity(Kr(t,n)))}e.children()}});function jr(e,t,n){return t?n?{topLeft:e.bottomLeft,topRight:e.topLeft,bottomRight:e.topRight,bottomLeft:e.bottomRight}:{topLeft:e.topLeft,topRight:e.bottomLeft,bottomRight:e.bottomRight,bottomLeft:e.topRight}:n?e:{topLeft:e.bottomLeft,topRight:e.bottomRight,bottomRight:e.topRight,bottomLeft:e.topLeft}}function Gi(e,t,n,r){let o=t.grounded??!0,i=e.cornerRadius,s=(t.round?1:0)+(o?1:0),a=Math.max(0,Math.min(t.thickness/2,s>1?r/2:r)),l=(u,f)=>f?Math.max(0,Math.min(u,a)):0,c={topLeft:l(i.topLeft,t.round),topRight:l(i.topRight,t.round),bottomRight:l(i.bottomRight,o),bottomLeft:l(i.bottomLeft,o)};return{cornerRadius:jr(c,e.horizontal,n),cornerStyle:jr(e.cornerStyle,e.horizontal,n)}}var Ni=oe.style(H,{series:Y,background:Se,text:ct,grid:ut,marks:yn,labels:bn,legend:U},{presets:X});function Hi(e,t){let n=(t.ticks?.length??Q)-1,r=mn(e.data,e.series,e.stack,t.range,n),o=t.range!==void 0||e.stack==="percent";return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var Zr=new WeakMap;function _t(e){let t=[e.series,e.stack,e.valueAxis],n=Zr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domain;let r=Ke(e.valueAxis,o=>Hi(e,o));return Zr.set(e.data,{key:t,domain:r}),r}function An(e,t,n){let r=e.valueAxis.format;if(r!==void 0)return Bi(n,r);let o=Ee(n,wt(t.ticks));return e.stack==="percent"?`${o}%`:o}function kn(e,t,n){let[r,o]=e.range;return o===r?-t/2:((n-r)/(o-r)-.5)*t}function Sn(e){let[t,n]=e.range;return Mn(0,Math.min(t,n),Math.max(t,n))}function Ct(e,t){return Math.max(0,e.weights[t]??1)}function eo(e,t){return e.orientation==="horizontal"?{along:t.width,across:t.height}:{along:t.height,across:t.width}}function Yi(e,t,n){let r=Qe(t,e.data.length,n);return e.orientation==="horizontal"?-r:r}function Ui(e,t,n){let r=e.series[t];if(!r)return[];let o=_t(e),{along:i,across:s}=eo(e,n),a=e.data.length,c=(a>0?s/a:0)*Mn(e.style.barWidth,0,1),u=e.stack!=="none",f=0;for(let x=0;x<e.series.length;x++)f+=Ct(e,x);let h=c/(f>0?f:1),d=Ct(e,t),p=0;for(let x=0;x<t;x++)p+=Ct(e,x);let g=e.series.length>1?e.style.barGap:0,m=e.style.values;return e.data.map((x,R)=>{let S=Tt(x,e.series,e.stack,e.weights)[t]??{from:0,to:0,value:0,outer:!1},w=Yi(e,R,s),b=-c/2+h*p+h*d/2,M="";return m!=="none"&&S.value!==0&&(!u||m==="inside"||e.stack==="percent"?M=An(e,o,u?S.value:k(x,r.field)):S.outer&&(M=An(e,o,S.to))),{center:u?w:w+(e.orientation==="horizontal"?-b:b),thickness:u?c:Math.max(0,h*d-g),from:kn(o,i,S.from),to:kn(o,i,S.to),round:S.outer,grounded:!u||S.from===0,caption:M}})}function Jr(e){let t=Mn(e.spotlightReveal,0,1),n=e.spotlight;return e.data.map((r,o)=>t<=0||n===o?1:1-(1-N)*t)}function vn(e){let t=mt(e);return{valueAxis:t.find(n=>Le.is(n)||Ce.is(n))??null,categoryAxis:t.find(Et.is)??null,bars:t.filter(Lt.is),legend:t.find(te.is)??null}}function Qr(e,t,n,r,o){let i=vn(n);if(!i.bars[r])return e.wait(e.duration);let s=t.series.map((c,u)=>Ct(t,u)),a=s[r]??1,l=t.series.map((c,u)=>t.showing[u]??c.enabled??!0);return e.together([e.animate(c=>{let u=[...s];u[r]=a+(o-a)*e.ease(c);let f=[...l];return f[r]=o>0||c<1,{weights:u,showing:f}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:r})]:[]])}var En=Fi({key:"barChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),orientation:oe.oneOf(["vertical","horizontal"],{animatable:!1}),stack:oe.oneOf(["none","stacked","percent"]),valueAxis:oe.custom({},{resolve:Me,lerp:Ve}),categoryAxis:oe.custom({},{resolve:Me,lerp:We}),style:Ni,growth:1,spotlight:oe.custom(null),spotlightReveal:0,weights:oe.custom([],{private:!0}),showing:oe.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>_t(e),r,o=()=>ve(r),i=e.style,s=e.orientation==="horizontal",a=gn(e.data,e.categoryField),l=()=>ke(t(),s?"x":"y"),c=()=>ke(t(),s?"y":"x"),u=()=>{let E=n();return E.ticks.map(T=>An(e,E,T))},f=s?i.showXAxis:i.showYAxis,h=s?i.showYAxis:i.showXAxis,d=f?s?new Ce({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):new Le({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",width:"hug",height:"fill"}):void 0,p=h?new Et({categories:a,axis:c,label:e.categoryAxis.label??"",orientation:s?"vertical":"horizontal",dims:()=>Jr(e),width:s?"hug":"fill",height:s?"fill":"hug"}):void 0,g=s?p:d,m=s?d:p,x=s?c:l,R=g&&m?xt({captions:s?()=>a:u,count:s?a.length:_t(e).ticks.length,text:()=>x().labelStyle,title:(s?e.categoryAxis.label:e.valueAxis.label)??"",titleText:()=>x().titleStyle,tickPad:()=>le(x(),"right").tick,titlePad:()=>le(x(),"right").title}):void 0,v=e.series.map((E,T)=>new Lt({bars:()=>Ui(e,T,o()),baseline:()=>kn(n(),eo(e,o()).along,Sn(n())),horizontal:s,fill:()=>P(t(),E,T),cornerRadius:()=>t().barCornerRadius,cornerStyle:()=>t().barCornerStyle,growth:()=>e.growth,dims:()=>Jr(e),values:()=>i.values==="end"&&e.stack==="percent"?"inside":i.values,valueStyle:()=>ht(t()),enabled:()=>e.showing[T]??E.enabled??!0})),S=i.legend,w=S!=="none"?new te({series:e.series,swatches:()=>e.series.map((E,T)=>P(t(),E,T)),legend:()=>B(t()),flow:S==="right"?"vertical":"horizontal"}):void 0,b=e.data.length,M=()=>Array.from({length:Math.max(0,b-1)},(E,T)=>T+1),z=()=>[0,Math.max(1,b)];return r=new zi({children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:s?()=>n().ticks:M,yMarkers:s?M:()=>n().ticks,xExtent:s?()=>n().range:z,yExtent:s?z:()=>n().range,axisStroke:()=>t().axisStroke,xAxisAt:()=>s?0:Sn(n()),yAxisAt:()=>s?Sn(n()):0}),...v]}),[gt({background:()=>t().background,left:g,ghost:R,plot:r,bottom:m,legend:w,legendAt:S,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:s&&m?K(t()):0,left:s&&m&&!g?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:Pe(),run:(e,t,n)=>{let r=vn(n),o=e.duration,i=o*D.axes,s=o*D.marks,{legend:a}=r,l=c=>({at:0,duration:0,piece:c});return G(e,[l(e.animate(()=>({growth:0}))),...a?[l(a.to({opacity:0,...bt(t.style.legend)}))]:[],...r.valueAxis?[{at:0,duration:i,piece:r.valueAxis.run("enter",{slide:24})}]:[],...r.categoryAxis?[{at:0,duration:i,piece:r.categoryAxis.run("enter",{slide:24})}]:[],{at:i,duration:s,piece:e.animate(c=>({growth:c}))},...a?[{at:i+s,duration:o*D.legend,piece:a.to({opacity:1,x:0,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>Qr(e,t,n,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>Qr(e,t,n,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>{let r=vn(n),o=e.args.seriesIndex;return e.together([...r.bars.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}},spotlightCategory:{args:{categoryIndex:oe.number(0,{min:0,step:1})},easing:Pe(),run:(e,t)=>{let n=e.args.categoryIndex;if(n<0||n>=t.data.length)return e.wait(e.duration);let r=t.spotlightReveal;return e.animate(o=>({spotlight:n,spotlightReveal:r+(1-r)*o}))}},clearCategory:{args:{},easing:Pe(),run:(e,t)=>{let n=t.spotlightReveal;if(n===0)return e.wait(e.duration);let r=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:r,spotlightReveal:n*(1-o)})}}}});import{Rect as yo,Types as Ft,clamp as bo,component2d as ss,easeOut as ze}from"@motionscript/sdk";import{Graphics2D as io,PathBuilder as Xi,Rect as _n,Text as De,Types as nt,clamp as ye,component2d as Wi,strokeOps as Vi,textOps as Ge}from"@motionscript/sdk";import{Types as xe}from"@motionscript/sdk";function Tn(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:r.length>0?r[i%r.length]:"white"}))}function Ln(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function to(e){let t=0;for(let n of e)t+=Ln(n);return t}function Ot(e,t){let n=to(e);if(n<=0)return[];let r=[],o=t*Oe;return e.forEach((i,s)=>{let a=Ln(i);if(a<=0)return;let l=a/n,c=o,u=c+l*Math.PI*2;o=u,r.push({index:s,a0:c,a1:u,mid:(c+u)/2,fraction:l})}),r}function It(e,t,n,r){e.sort((s,a)=>a.ideal-s.ideal);let o=n;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=r;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Cn={series:Y,background:lt,text:{labelText:xe.typography({fontSize:28,fontWeight:500,fill:Re}),valueText:xe.typography({fontSize:28,fontWeight:700,fill:Ye}),centerText:xe.typography({fontSize:50,fontWeight:800,fill:Ye}),...Ae},marks:{innerRadius:xe.number(0,{min:0,max:.9,step:.05}),sliceGap:xe.number(3,{min:0,max:40,step:1,unit:"px"}),sliceRadius:xe.number(4,{min:0,max:60,step:1,unit:"px"})},labels:{labelPlacement:xe.oneOf(["inside","outside","none"],{animatable:!1})},legend:U};function Pt(e){return B(e)}function no(e){return{gap:e.sliceGap,holeRadius:e.innerRadius,startAngle:0,selectedGrow:1.08,cornerRadius:e.sliceRadius}}function ro(e){let t=F(e.labelText),n=F(e.valueText);return{textStyle:t,percentStyle:n,insideStyle:{...n,fontSize:Math.round(W(e.valueText)*1.9),fill:"#111113"},leaderStroke:{weight:2,fill:e.labelText.fill??"white"}}}function oo(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Ki={gap:3,holeRadius:0,startAngle:0,selectedGrow:1.08,cornerRadius:4},$i={textStyle:{fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},percentStyle:{fontSize:28,fontWeight:700,textAlign:"center",fill:"#f4f4f5"},insideStyle:{fontSize:52,fontWeight:700,textAlign:"center",fill:"#111113"},leaderStroke:{weight:2,fill:"#a1a1aa"}},ji={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function so(e){let n=ur(e).find(s=>s.type==="solid");if(!n)return"#111113";let[r,o,i]=n.color;return .2126*r+.7152*o+.0722*i>.45?"#111113":"#ffffff"}var ao=12,qi=14,On=.62,Zi=6,lo=34,co=26,uo=8,Ji=.18,Qi=240,es=8,fo=2,po=.44,In=.62,ts=.78,ns=.9,ho=.001,go=26;function de(e,t=go){let n=e.fontSize;return typeof n=="number"?n:t}function rs(e,t,n,r,o,i,s){let a=new Xi,l=t-e,c=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*Qi)),u=A=>A<=0?0:Math.min(o/A,l/2.2),f=(A,I)=>{let we=j(A,I);return{x:we.x+s,y:we.y}},h=n>0,d=e+u(r),p=t-u(r),g=e+u(n),m=t-u(n),x=f(r,d),R=f(r,p),v=Math.max(.001,Math.min(l/2,Math.PI/2)),S=f(o>0?Math.min(o/Math.sin(v),r*.8):0,(e+t)/2),w=h?f(n,g):S,b=h?f(n,m):S,M=h?r-n:r,z=Math.max(0,Math.min(i,M/2.2,(p-d)*r/2.2,h?(m-g)*n/2.2:1/0)),E=z>=.5,T=(A,I,we)=>{let Ne=Math.hypot(I.x-A.x,I.y-A.y)||1,He=Math.min(.5,we/Ne);return{x:A.x+(I.x-A.x)*He,y:A.y+(I.y-A.y)*He}},pe=E?z/Math.max(1,r):0,_=E&&h?z/n:0,ae=(A,I,we)=>{for(let Ne=0;Ne<=c;Ne++){let He=f(A,I+(we-I)*Ne/c);a.lineTo(He.x,He.y)}},at=(A,I)=>{E?a.quadraticCurveTo(A.x,A.y,I.x,I.y):a.lineTo(A.x,A.y)},Kt=f(r,d+pe);if(a.moveTo(Kt.x,Kt.y),ae(r,d+pe,p-pe),at(R,T(R,b,z)),h){let A=T(b,R,z);a.lineTo(A.x,A.y),at(b,f(n,m-_)),ae(n,m-_,g+_),at(w,T(w,x,z))}else a.lineTo(S.x,S.y);let or=T(x,w,E?z:0);return a.lineTo(or.x,or.y),at(x,Kt),a.close(),a}var Dt=class{s;box;constructor(t,n){this.s=t,this.box=n}get arcs(){return Ot(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="outside"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let n=this.outerRadius,r=this.holeRadius,o=r>0?n-r:n*(1-In)*2,i=r>0?(r+n)/2:n*In,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),l=s>ho?o/s:1/0,c=a>ho?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(l,c))}insideGlyphs(t){let n=this.s.labelMode,r=this.s.slices[t.index]?.category.length??0,o=n==="both"||n==="percent"?qt(t.fraction).length:0,i=n==="category"?r:n==="both"?r*po:0;return Math.max(1,o,i)}get insideFont(){let t=de(this.s.label.insideStyle,go*1.9);for(let n of this.arcs){let r=this.insideRoom(n)*ns/(this.insideGlyphs(n)*On);t=Math.min(t,r)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=de(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=de(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*ts/(a*On))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=de(this.s.label.textStyle)*1.25,n=de(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+n+2:this.s.labelMode==="category"?t:n}captionGlyphs(t){let n=this.s.labelMode,r=n==="percent"||n==="both"?4:0,o=n==="category"||n==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(r,o)}get labelGutters(){let t={left:fo,right:fo};if(!this.hasLeaderLabels)return t;let n=de(this.s.label.textStyle)*On;for(let r of this.arcs){let o=lo+co+uo+this.captionGlyphs(r.index)*n+qi,i=Pn(r.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:n}=this.labelGutters;return(t-n)/2}get outerRadius(){let{left:t,right:n}=this.labelGutters,r=Math.min((this.box.width-t-n)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,r/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let n=t<1?t*this.outerRadius:t;return Math.min(n,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+lo}popOf(t){return ye(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let n=this.anchorRadius(t),r=this.holeRadius;return r>0?(r+n)/2:n*In}insideAnchor(t){let n=this.arcs.find(o=>o.index===t);if(n===void 0)return{x:this.centerX,y:0};let r=j(this.bandMidRadius(t),n.mid);return{x:r.x+this.centerX,y:r.y}}get selectionStrength(){let t=0;for(let n=0;n<this.s.slices.length;n++)t=Math.max(t,this.popOf(n));return t}sliceOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let n=this.arcs.find(r=>r.index===t);return qt(n?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let n=this.elbowRadius,r=this.labelRowHeight,o=this.box.height/2-r/2,i=-o,s=this.centerX,a=[],l=[];for(let c of t){let u=Pn(c.mid),f=j(n,c.mid).y;(u>0?a:l).push({index:c.index,side:u,mid:c.mid,ideal:f,y:f})}return It(a,r+ao,o,i),It(l,r+ao,o,i),[...a,...l].map(c=>{let u=j(this.anchorRadius(c.index)+Zi,c.mid),f=Math.sqrt(Math.max(0,n*n-c.y*c.y)),h=s+c.side*Math.max(f,n*Ji),d=s+c.side*(n+co);return{index:c.index,side:c.side,leader:[{x:u.x+s,y:u.y},{x:h,y:c.y},{x:d,y:c.y}],text:{x:d+c.side*uo,y:c.y}}})}placementFor(t){return this.placements().find(n=>n.index===t)}};function Pn(e){return Math.sin(e)>=0?1:-1}var os={width:0,height:0};function is(e){let t=[],n=()=>new Dt(e,t[0]?.parent?.layoutBounds??os),r=o=>{let i=()=>ye(e.labelReveal,0,1)*n().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let f=[];return a&&f.push(new De({...Ge.styleProps(e.label.insideStyle),text:()=>n().percentText(o.index),fill:()=>so(e.slices[o.index]?.fill??"white"),fontSize:()=>n().insideFont})),s&&f.push(new De({...Ge.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fill:()=>so(e.slices[o.index]?.fill??"white"),fontSize:()=>e.labelMode==="category"?n().insideFont:n().insideFont*po})),new _n({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>n().insideAnchor(o.index),children:f})}let l=Pn(o.mid),c=()=>n().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new De({...Ge.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:l>0?"left":"right"})),a&&u.push(new De({...Ge.styleProps(e.label.percentStyle),text:()=>n().percentText(o.index),textAlign:l>0?"left":"right"})),new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:l>0?"centerLeft":"centerRight",opacity:i,centerLeft:l>0?c:void 0,centerRight:l>0?void 0:c,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ot(e.slices,e.ring.startAngle))t.push(r(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new De({...Ge.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new De({...Ge.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(de(e.centerStyle.captionStyle,22)/de(e.centerStyle.labelStyle,46))})),t.push(new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ye(e.centerReveal,0,1)*ye(n().holeRadius/20,0,1),center:()=>({x:n().centerX,y:0}),children:o}))}return t}var Gt=Wi({key:"pieRing",state:{slices:y(()=>[]),ring:nt.custom(Ki),label:nt.custom($i),centerStyle:nt.custom(ji),labelMode:nt.custom("percent"),labelPlacement:nt.custom("outside"),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:ce,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>is(e),load:(e,t)=>C(e,{fills:Ie(t.slices),strokes:[Vi.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=ye(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new Dt(t,e.size),r=n.outerRadius,o=r>0?n.arcs:[];if(o.length>0){let i=ye(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=n.holeRadius,l=Math.max(0,t.ring.gap)/2,c=n.centerX,u=r+n.maxPop+1+Math.abs(c),f=[-u,-u,u,u],h=u*2,d=Ie(t.slices);for(let g of o){let m=Math.min(g.a1,s);if(m<=g.a0)continue;let x=rs(g.a0,m,a,n.anchorRadius(g.index),l,Math.max(0,t.ring.cornerRadius),c),R=new io().path(x.toPathState({centerBounds:f,width:h,height:h}));R.fill(d[g.index]??[]),e.draw(R.opacity(n.sliceOpacity(g.index)))}let p=ye(t.labelReveal,0,1);if(p>.001)for(let g of n.placements())e.draw(new io().line({points:g.leader,radius:es}).stroke(t.label.leaderStroke).opacity(p*n.sliceOpacity(g.index)))}e.children()}});var as=.65,ls=.35,Dn=Ft.number(0,{min:0,step:1});function mo(e){return Tn(e.data,e.categoryField,e.valueField,e.data.map((t,n)=>ft(e.style,n)))}function Fe(e,t){return bo(e.pops[t]??0,0,1)}function cs(e,t){return Fe(e,t)>.5}function us(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Fe(e,n));return e.data.map((n,r)=>ne(t,ce,Fe(e,r)))}function zt(e,t,n){let r=t.data.map((i,s)=>Fe(t,s)),o=t.data.map((i,s)=>bo(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function xo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=yo.is(n)?n.children.find(Gt.is):void 0;if(r)return{ring:r,legend:n.children.find(_e.is)??null}}return null}var Gn=ss({key:"pieChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",style:Ft.style(H,Cn,{presets:X}),labelMode:Ft.custom("percent"),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:Ft.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>mo(e).map(()=>0)},migrate:{style:V("pie")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>mo(e),r=[new Gt({width:"fill",height:"fill",slices:n,ring:()=>no(t()),label:()=>ro(t()),centerStyle:()=>oo(t()),labelMode:e.labelMode,labelPlacement:e.style.labelPlacement,pops:()=>e.pops,dimOpacity:ce,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=new _e({slices:n,legend:()=>Pt(t()),dims:()=>us(e),flow:s?"vertical":"horizontal",align:"center",gap:s?Pt(e.style).itemGap/3:Pt(e.style).itemGap,padding:0});o==="top"?r.unshift(a):r.push(a)}let i=new yo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:ze(),run:(e,t,n)=>{let r=xo(n);if(!r)return e.wait(e.duration);let{ring:o,legend:i}=r,s=e.duration*as,a=e.duration*ls,l=c=>({at:0,duration:0,piece:c});return G(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:ze(),run:(e,t,n)=>xo(n)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:Fe(t,r))}},deselectSlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?0:Fe(t,r))}},selectOnlySlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:0)}},clearSelection:{args:{},easing:ze(),run:(e,t)=>zt(e,t,()=>0)}}});import{Rect as Be,Text as ys,Types as bs,component2d as ws,easeOut as Ut}from"@motionscript/sdk";import{Graphics2D as Xn,Types as Bt,clamp as gs,component2d as ms,fillOps as Eo,strokeOps as Nt}from"@motionscript/sdk";import{Types as q}from"@motionscript/sdk";var Fn={spokeText:q.typography({fontSize:28,fontWeight:500,fill:Re}),...Ae},Bn={gridShape:q.oneOf(["polygon","circle"]),gridLevels:q.number(4,{min:1,max:10,step:1}),gridStroke:q.stroke({weight:2,fill:"white/15"}),spokeStroke:q.stroke({weight:2,fill:"white/15"}),spokeLabels:q.boolean(!0,{animatable:!1})},Nn={strokeWidth:q.number(4,{min:0,max:24,step:1,unit:"px"}),areaOpacity:q.number(.25,{min:0,max:1,step:.05}),dots:q.boolean(!0),dotSize:q.number(10,{min:2,max:40,step:1,unit:"px"})},fs=.55,hs=.58,zn=10,wo=.35;function ie(e,t){let n=e/Math.max(1,t)*Math.PI*2;return{x:Math.sin(n),y:Math.cos(n)}}function Hn(e,t){return e.map(n=>$(n,t))}function Ro(e,t){return t.map(n=>e.map(r=>k(r,n.field)))}var ds=[1,1.2,1.5,2,2.5,3,4,5,6,8,10];function So(e){if(!(e>0))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(ds.find(o=>o>=n-1e-9)??10)*t}function Ao(e,t,n){if(n>t)return{min:t,max:n};let r=t;for(let i of e)for(let s of i)r=Math.max(r,s);let o=So(r-t);return{min:t,max:t+o}}function ko(e,t){let n=t.max-t.min;return n<=0?0:Math.min(1,Math.max(0,(e-t.min)/n))}function Yn(e,t){let{x:n,y:r}=ie(e,t);return n>wo?"centerLeft":n<-wo?"centerRight":r>=0?"bottomCenter":"topCenter"}function vo(e){return e*fs}function ps(e,t){return{width:e.length*t*hs,height:t*1.25}}function Un(e,t,n,r){let o=Math.min(e.width,e.height)/2-zn;if(!r)return Math.max(0,o);let i=vo(n),s=t.length;return t.forEach((a,l)=>{let{x:c,y:u}=ie(l,s),f=ps(a,n),h=Yn(l,s),d=h==="centerLeft"||h==="centerRight"?f.width:f.width/2,p=h==="bottomCenter"||h==="topCenter"?f.height:f.height/2;Math.abs(c)>1e-6&&(o=Math.min(o,(e.width/2-d-zn/2)/Math.abs(c)-i)),Math.abs(u)>1e-6&&(o=Math.min(o,(e.height/2-p-zn/2)/Math.abs(u)-i))}),Math.max(0,o)}function Mo(e,t,n,r){let{x:o,y:i}=ie(e,t),s=n+vo(r);return{x:o*s,y:i*s}}var rt=ms({key:"radarGrid",state:{count:0,radius:0,levels:4,fill:Bt.custom([],{resolve:Eo.resolve,lerp:Eo.lerp}),shape:Bt.custom("polygon"),stroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),spokeStroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),reveal:1},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke,t.spokeStroke]}),render:(e,t)=>{let n=gs(t.reveal,0,1),r=t.radius*n;if(r<=0||n<=0)return;let o=Math.max(0,Math.round(t.count)),i=Math.max(1,Math.round(t.levels)),s=t.shape==="circle"||o<3,a=(l,c)=>{if(s)return l.ellipse({width:c*2,height:c*2});let u=[];for(let f=0;f<o;f++){let h=ie(f,o);u.push({x:h.x*c,y:h.y*c})}return l.line({points:u,closed:!0})};t.fill.length>0&&e.draw(a(new Xn,r).fill(t.fill).opacity(n));for(let l=1;t.stroke.length>0&&l<=i;l++){let c=r*l/i;e.draw(a(new Xn,c).stroke(t.stroke).opacity(n))}if(t.spokeStroke.length!==0)for(let l=0;l<o;l++){let c=ie(l,o);e.draw(new Xn().line({points:[{x:0,y:0},{x:c.x*r,y:c.y*r}]}).stroke(t.spokeStroke).opacity(n))}}});import{Graphics2D as Wn,Types as Ht,clamp as To,component2d as xs,fillOps as Lo,strokeOps as Co}from"@motionscript/sdk";function _o(e,t,n=1){return e.map((r,o)=>{let i=ie(o,e.length),s=t*r*n;return{x:i.x*s,y:i.y*s}})}var Yt=xs({key:"radarSeries",state:{fractions:y(()=>[]),radius:0,fill:Ht.custom([],{resolve:Lo.resolve,lerp:Lo.lerp}),stroke:Ht.custom([],{resolve:Co.resolve,lerp:Co.lerp}),areaOpacity:.25,dots:!0,dotSize:10,progress:1,enabled:!0},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),commands:{enter:{args:{from:Ht.number(0,{min:0,max:1}),to:Ht.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let n=To(t.progress,0,1);if(n<=0||t.radius<=0||t.fractions.length===0)return;let r=_o(t.fractions,t.radius,n);if(r.length>=2){let o=new Wn().line({points:r,closed:!0});t.areaOpacity>0&&t.fill.length>0&&e.draw(o.fill(t.fill).opacity(To(t.areaOpacity,0,1))),t.stroke.length>0&&e.draw(new Wn().line({points:r,closed:!0}).stroke(t.stroke))}if(t.dots&&t.dotSize>0&&t.fill.length>0){let o=new Wn;for(let i of r)o.ellipse({x:i.x,y:i.y,width:t.dotSize,height:t.dotSize});e.draw(o.fill(t.fill))}}});function Po(e){return Ao(Ro(e.data,e.series),e.min,e.max)}function Do(e,t){let n=e.series[t];if(!n)return[];let r=Po(e);return e.data.map(o=>{let i=o[n.field];return ko(typeof i=="number"&&Number.isFinite(i)?i:0,r)})}function Vn(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Be.is(n))continue;let r=n.children.find(o=>Be.is(o)&&o.children.some(rt.is));if(r)return{grid:r.children.find(rt.is),series:r.children.filter(Yt.is),labels:r.children.find(Be.is)??null,legend:n.children.find(te.is)??null}}return null}function Oo(e,t,n,r){let o=Vn(t),i=o?.series[n];return!o||!i?e.wait(e.duration):e.together([i.run("enter",r?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(r?"showSeries":"hideSeries",{index:n})]:[]])}var Io=.3,Kn=ws({key:"radarChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),min:0,max:0,style:bs.style(H,{series:Y,background:Se,text:Fn,grid:Bn,marks:Nn,legend:U},{presets:X})},defaults:{width:"fill",height:"fill"},migrate:{style:V("radar")},allowedChildren:[],children:e=>{let t=()=>e.style,n,r=()=>ve(n),o=()=>Un(r(),Hn(e.data,e.categoryField),W(t().spokeText),t().spokeLabels),i=e.data.length,s=e.series.map(d=>d.enabled??!0),a=new rt({count:()=>e.data.length,radius:o,levels:()=>t().gridLevels,fill:()=>t().gridBackground,shape:()=>t().gridShape,stroke:()=>t().gridStroke,spokeStroke:()=>t().spokeStroke}),l=e.series.map((d,p)=>new Yt({fractions:()=>Do(e,p),radius:o,fill:()=>P(t(),d,p),stroke:()=>{let g=t().strokeWidth;return g>0?{weight:g,fill:P(t(),d,p),align:"center",join:"round"}:[]},areaOpacity:()=>t().areaOpacity,dots:()=>t().dots,dotSize:()=>t().dotSize,enabled:s[p]})),c=[a,...l];if(e.style.spokeLabels){let d=[];for(let p=0;p<i;p++){let g=Yn(p,i),m=g==="centerLeft"?"left":g==="centerRight"?"right":"center",x=()=>Mo(p,i,o(),W(t().spokeText));d.push(new ys({...Z(()=>F(t().spokeText,m)),text:()=>Hn(e.data,e.categoryField)[p]??"",[g]:x}))}c.push(new Be({width:"fill",height:"fill",children:d}))}n=new Be({width:"fill",height:"fill",children:c});let u=[n],f=e.style.legend;if(f!=="none"){let d=f==="right",p=B(e.style),g=new te({series:e.series,swatches:()=>e.series.map((m,x)=>P(t(),m,x)),legend:()=>B(t()),flow:d?"vertical":"horizontal",gap:d?Math.round(p.itemGap/2):p.itemGap,padding:p.padding});f==="top"?u.unshift(g):u.push(g)}let h=new Be({flow:f==="right"?"horizontal":"vertical",width:"fill",height:"fill",gap:24,align:"center",fill:()=>t().background,children:u});return[h]},commands:{enter:{args:{},entrance:!0,easing:Ut(),run:(e,t,n)=>{let r=Vn(n);if(!r)return e.wait(e.duration);let o=e.duration,i=o*D.axes,s=o*D.marks,a=o*D.legend,l=Math.max(1,r.series.length),c=s/(1+Io*(l-1)),{legend:u,labels:f}=r,h=d=>({at:0,duration:0,piece:d});return G(e,[h(r.grid.to({reveal:0})),...r.series.map(d=>h(d.to({progress:0}))),...f?[h(f.to({opacity:0}))]:[],...u?[h(u.to({opacity:0,y:-ir}))]:[],{at:0,duration:i,piece:r.grid.to({reveal:1})},...r.series.map((d,p)=>({at:i+p*c*Io,duration:c,piece:d.to({progress:1})})),...f?[{at:i+s*.6,duration:a+s*.4,piece:f.to({opacity:1})}]:[],...u?[{at:i+s,duration:a,piece:u.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>Oo(e,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>Oo(e,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>{let r=Vn(n);if(!r)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...r.series.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Ko,Types as nr,clamp as $o,component2d as Ps,easeOut as Wt}from"@motionscript/sdk";import{Graphics2D as No,PathBuilder as Ss,Rect as Ho,Text as Qn,Types as ot,clamp as be,component2d as As,fillOps as ks,textOps as er}from"@motionscript/sdk";import{Types as se,clamp as Rs}from"@motionscript/sdk";function $n(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:ft(r,i)}))}function jn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Go(e,t){if(t>0&&Number.isFinite(t))return t;let n=0;for(let r of e)n=Math.max(n,jn(r));return n>0?n:1}function qn(e,t){let n=Go(e,t);return e.map(r=>Rs(jn(r)/n,0,1))}var Zn={series:Y,background:lt,text:{labelText:se.typography({fontSize:28,fontWeight:500,fill:Re}),centerText:se.typography({fontSize:50,fontWeight:800,fill:Ye}),...Ae},marks:{innerRadius:se.number(.3,{min:0,max:.9,step:.05}),ringGap:se.number(8,{min:0,max:60,step:1,unit:"px"}),sweep:se.number(360,{min:30,max:360,step:5,unit:"deg"}),startAngle:se.number(0,{min:-360,max:360,step:5,unit:"deg"}),track:se.fill("white/10"),roundCaps:se.boolean(!0)},labels:{ringLabels:se.boolean(!1)},legend:U};function zo(e){return{innerRadius:e.innerRadius,ringGap:e.ringGap,sweep:e.sweep,startAngle:e.startAngle,track:e.track.length>0,roundCaps:e.roundCaps}}function Jn(e){return B(e)}function Fo(e){return F(e.labelText)}function Bo(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Yo=.12,vs=.12,Ms=4*Oe,Uo=10,Es=.78,Ts=.62,Xo=4,Ls={innerRadius:.3,ringGap:8,sweep:360,startAngle:0,track:!0,roundCaps:!0},Cs={fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},_s={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function it(e,t){return typeof e.fontSize=="number"?e.fontSize:t}var st=class{s;box;constructor(t,n){this.s=t,this.box=n}get count(){return this.s.rows.length}get outerRadius(){return Math.max(0,Math.min(this.box.width,this.box.height)/2-Xo)}get holeRadius(){return be(this.s.marks.innerRadius,0,.9)*this.outerRadius}get thickness(){let t=this.count;return t===0?0:Math.max(0,(this.outerRadius-this.holeRadius-(t-1)*Math.max(0,this.s.marks.ringGap))/t)}ringOuter(t){return this.outerRadius-t*(this.thickness+Math.max(0,this.s.marks.ringGap))}ringMid(t){return this.ringOuter(t)-this.thickness/2}get fractions(){return qn(this.s.rows,this.s.max)}get startRad(){return this.s.marks.startAngle*Oe}get sweepRad(){return be(this.s.marks.sweep,0,360)*Oe}popOf(t){return be(this.s.pops[t]??0,0,1)}get selectionStrength(){let t=0;for(let n=0;n<this.count;n++)t=Math.max(t,this.popOf(n));return t}ringOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}progress(t,n){let r=1+Yo*Math.max(0,this.count-1);return be(n*r-t*Yo,0,1)}get labelFont(){return Math.max(1,Math.min(it(this.s.label,28),this.thickness*.62))}labelAnchor(t){let n=this.startRad,r={x:-Math.cos(n),y:Math.sin(n)},o=j(this.ringMid(t),n),i=r.x<=0?-1:1;return{at:{x:o.x+r.x*Uo,y:o.y+r.y*Uo},side:i}}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=it(t.labelStyle,50),i=this.holeRadius;if(i<=0)return o;let s=it(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*Es/(a*Ts))}};function tr(e,t,n,r,o){let i=new Ss,s=(n+r)/2,a=(r-n)/2,l=o&&s>0?Math.min(a/s,(t-e)/2):0,c=e+l,u=t-l,f=Math.max(2,Math.ceil(Math.abs(u-c)/Ms)),h=(p,g,m,x)=>{for(let R=0;R<=f;R++){let v=j(p,g+(m-g)*R/f);x&&R===0?i.moveTo(v.x,v.y):i.lineTo(v.x,v.y)}},d=(p,g,m)=>{let x=j(s,p),R={x:Math.sin(p),y:Math.cos(p)},v={x:Math.cos(p)*g,y:-Math.sin(p)*g},S=12;for(let w=1;w<S;w++){let b=Math.PI*w/S,M=m?Math.cos(b):-Math.cos(b);i.lineTo(x.x+a*(R.x*M+v.x*Math.sin(b)),x.y+a*(R.y*M+v.y*Math.sin(b)))}};return h(r,c,u,!0),o&&d(u,1,!0),h(n,u,c,!1),o&&d(c,-1,!1),i.close(),i}var Os={width:0,height:0};function Is(e){let t=[],n=()=>new st(e,t[0]?.parent?.layoutBounds??Os),r=n().labelAnchor(0).side;if(e.rows.forEach((o,i)=>{let s=()=>n().labelAnchor(i).at;t.push(new Ho({flow:"vertical",width:"hug",height:"hug",align:r>0?"centerLeft":"centerRight",opacity:()=>e.ringLabels?be(e.labelReveal,0,1)*n().ringOpacity(i):0,centerLeft:r>0?s:void 0,centerRight:r>0?void 0:s,children:[new Qn({...er.styleProps(e.label),text:()=>e.rows[i]?.category??"",textAlign:r>0?"left":"right",fontSize:()=>n().labelFont})]}))}),e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Qn({...er.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Qn({...er.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(it(e.centerStyle.captionStyle,22)/it(e.centerStyle.labelStyle,50))})),t.push(new Ho({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>be(e.centerReveal,0,1),center:{x:0,y:0},children:o}))}return t}var Xt=As({key:"radialRings",state:{rows:y(()=>[]),max:0,marks:ot.custom(Ls),label:ot.custom(Cs),centerStyle:ot.custom(_s),trackFill:ot.fill("white/15"),ringLabels:ot.boolean(!1),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:.25,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Is(e),load:(e,t)=>C(e,{fills:[...Ie(t.rows),ks.resolve(t.trackFill)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=be(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new st(t,e.size),r=n.thickness;if(n.outerRadius>0&&n.count>0&&r>0){let o=n.outerRadius+Xo+1,i={centerBounds:[-o,-o,o,o],width:o*2,height:o*2},s=Ie(t.rows),a=n.fractions,l=n.startRad,c=t.marks.roundCaps,u=[...t.rows.keys()].sort((f,h)=>n.popOf(f)-n.popOf(h));for(let f of u){let h=r*vs*n.popOf(f),d=n.ringOuter(f)+h,p=n.ringOuter(f)-r-h,g=n.ringOpacity(f);t.marks.track&&n.sweepRad>0&&e.draw(new No().path(tr(l,l+n.sweepRad,p,d,c).toPathState(i)).fill(t.trackFill).opacity(g));let m=n.sweepRad*a[f]*n.progress(f,t.growth);m<=1e-4||e.draw(new No().path(tr(l,l+m,p,d,c).toPathState(i)).fill(s[f]??[]).opacity(g))}}e.children()}});var Ds=.7,Gs=.3;function zs(e){return $n(e.data,e.categoryField,e.valueField,e.style)}function Vt(e,t){return $o(e.pops[t]??0,0,1)}function Fs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Vt(e,n));return e.data.map((n,r)=>ne(t,jo,Vt(e,r)))}var jo=Math.max(ce,.25);function Wo(e,t,n){let r=t.data.map((i,s)=>Vt(t,s)),o=t.data.map((i,s)=>$o(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function Vo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=Ko.is(n)?n.children.find(Xt.is):void 0;if(r)return{rings:r,legend:n.children.find(_e.is)??null}}return null}var rr=Ps({key:"radialChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",max:nr.number(0,{min:0,step:1}),style:nr.style(H,Zn,{presets:X}),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:nr.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>e.data.map(()=>0)},migrate:{style:V("radial")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>zs(e),r=[new Xt({width:"fill",height:"fill",rows:n,max:()=>e.max,marks:()=>zo(t()),label:()=>Fo(t()),centerStyle:()=>Bo(t()),trackFill:()=>t().track,ringLabels:()=>t().ringLabels,pops:()=>e.pops,dimOpacity:jo,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=Jn(e.style),l=new _e({slices:n,legend:()=>Jn(t()),dims:()=>Fs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?a.itemGap/3:a.itemGap,padding:0});o==="top"?r.unshift(l):r.push(l)}let i=new Ko({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:Wt(),run:(e,t,n)=>{let r=Vo(n);if(!r)return e.wait(e.duration);let{rings:o,legend:i}=r,s=e.duration*Ds,a=e.duration*Gs,l=c=>({at:0,duration:0,piece:c});return G(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:Wt(),run:(e,t,n)=>Vo(n)?.rings.run("revealCenter")??e.wait(e.duration)},selectRing:{args:{ringIndex:O},easing:Wt(),run:(e,t)=>{let n=e.args.ringIndex;return Wo(e,t,r=>r===n?1:Vt(t,r))}},clearSelection:{args:{},easing:Wt(),run:(e,t)=>Wo(e,t,()=>0)}}});var Bs=[dn,En,Gn,Kn,rr];export{bn as BAR_LABELS,yn as BAR_MARKS,En as BarChart,ut as CARTESIAN_GRID,ct as CARTESIAN_TEXT,lt as CHART_BACKGROUND,Ye as CHART_FOREGROUND,U as CHART_LEGEND,Re as CHART_MUTED,Ns as CHART_PALETTE_DEFAULT,Y as CHART_SERIES,H as CHART_STYLE_FAMILY,X as CHART_STYLE_PRESETS,Et as CategoryAxis,an as ChartArea,Lt as ChartBars,yt as ChartCanvas,te as ChartLegend,At as ChartLine,ln as ChartRegion,Xs as DEFAULT_LEGEND,Q as DEFAULT_MARKERS,lr as DEFAULT_X_AXIS,Us as DEFAULT_Y_AXIS,Oe as DEG,me as EMPTY_REGION_BOX,D as ENTER_SHARE,_r as EVERY_SAMPLE,Se as GRID_BACKGROUND,Ce as HorizontalAxis,ir as LEGEND_SLIDE,Ae as LEGEND_TEXT,on as LINE_LABELS,rn as LINE_MARKS,dn as LineChart,Bs as NODES,ce as PIE_SPOTLIGHT_DIM,Cn as PIE_STYLE_GROUPS,Gn as PieChart,_e as PieLegend,Gt as PieRing,Bn as RADAR_GRID,Nn as RADAR_MARKS,Fn as RADAR_TEXT,Zn as RADIAL_STYLE_GROUPS,Kn as RadarChart,rt as RadarGrid,Yt as RadarSeries,rr as RadialChart,st as RadialGeometry,Xt as RadialRings,O as SERIES_ARG,N as SPOTLIGHT_DIM,Le as VerticalAxis,br as areaFill,ar as armed,jt as arrival,Xe as arrivalOf,sr as arrivalsEntry,J as asParts,ke as axisConfigOf,le as axisPads,tr as bandPath,gn as barCategories,_t as barChartDomain,Tt as barSpans,Wr as barValueExtent,G as beats,Z as boundText,cr as captionColumn,gt as cartesianFrame,mt as chartViews,nn as clipPolygonToBox,Jt as clipPolylineToBox,xt as columnGhost,en as curvePoints,tn as cutAt,Ue as fade,Un as fitRadius,Cr as formatInstant,Ee as formatMarker,qt as formatPercent,L as frameEase,dt as frameGap,y as fresh,ue as hasRegion,pt as headroom,xn as inkOn,cs as isSliceSelected,ve as laidOutSize,bt as legendAway,B as legendConfigOf,We as lerpAxisDomain,Ve as lerpAxisEntry,Je as lineChartDomains,C as loadPaints,Ws as markerCaption,wt as markerStep,Hs as markerText,ee as markerValues,V as migrateChartStyle,So as niceCeil,Te as niceRange,Rt as niceTicks,k as num,Ys as numericFields,K as overhang,ft as paletteFill,Lr as parseInstant,Ot as pieArcs,F as placedText,Do as radarFractions,Po as radarScale,qn as radialFractions,Go as radialMax,It as relaxLabels,Me as resolveAxisDomain,mn as resolveBarScale,Tn as resolvePieSlices,$n as resolveRadialRows,Zt as resolveRegionBox,cn as resolveXScale,Qo as resolveYScale,ur as resolvedFill,Ie as ringFills,j as ringPoint,jn as rowValue,$t as rule,ne as selectionFade,P as seriesFill,Jo as seriesPoints,_o as seriesVertices,Ke as settleAxisDomain,W as sizeOf,to as sliceTotal,Ln as sliceValue,Qe as slotCentre,ie as spokeDirection,St as stackExtent,Qt as stackSeries,$ as text,Ze as traceX,ht as valueText,pr as yExtent};
|
|
1
|
+
import{$ as Hs,A as ke,B as Z,C as xt,D as Ye,E as y,F as J,G as O,H as C,I as $t,J as yt,K as or,L as bt,M as Q,N as G,O as L,P as D,Q as ir,R as Ue,S as sr,T as jt,U as ve,V as Xe,W as We,X as Ve,Y as N,Z as k,_ as $,a as H,aa as ar,b as Bs,ba as Ys,c as He,ca as Us,d as Re,da as Me,e as Y,ea as wt,f as at,fa as qt,g as Se,ga as ee,h as lt,ha as Ee,i as ct,ia as Rt,j as ut,ja as te,k as U,ka as Xs,l as X,la as le,m as ft,ma as lr,n as P,na as Te,o as W,oa as Le,p as F,pa as Ce,q as Ns,qa as _e,r as ht,ra as ne,s as Ae,sa as j,t as B,ta as ce,u as V,ua as cr,v as dt,va as Oe,w as pt,x as K,y as gt,z as mt}from"./chunks/chunk-FJHNBNPQ.js";import{Rect as fi,Text as hi,Types as re,clamp as un,component2d as di,easeOut as he}from"@motionscript/sdk";import{formatNumber as pi}from"@motionscript/sdk/component";import{Graphics2D as Ke,Types as fe,clamp as $e,component2d as mr,fillOps as je,strokeOps as pr}from"@motionscript/sdk";import{Types as ge}from"@motionscript/sdk";var me={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function ue(e){return e.right>e.left&&e.top>e.bottom}function Zt(e,t,n,r){if(!e||e.x===void 0&&e.y===void 0)return me;let o=(f,[h,d],p,g)=>{if(f===void 0||d<=h)return[p,g,!1];let m=Math.min(f[0],f[1]),x=Math.max(f[0],f[1]),R=v=>p+(v-h)/(d-h)*(g-p);return[Math.max(p,Math.min(g,R(m))),Math.max(p,Math.min(g,R(x))),!0]},[i,s,a]=o(e.x,n,t.left,t.right),[l,c,u]=o(e.y,r,t.bottom,t.top);return{left:i,right:s,bottom:l,top:c,xBounded:a,yBounded:u}}function Jt(e,t){if(e.length<2||!ue(t))return[];let n=[],r=[];for(let o=1;o<e.length;o++){let i=qo(e[o-1],e[o],t);if(!i){r.length>=2&&n.push(r),r=[];continue}let[s,a]=i;r.length>0&&jo(r[r.length-1],s)?r.push(a):(r.length>=2&&n.push(r),r=[s,a])}return r.length>=2&&n.push(r),n}function jo(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function qo(e,t,n){let r=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-r,e.x-n.left],[r,n.right-e.x],[-o,e.y-n.bottom],[o,n.top-e.y]];for(let[l,c]of a){if(l===0){if(c<0)return null;continue}let u=c/l;if(l<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*r,y:e.y+i*o},{x:e.x+s*r,y:e.y+s*o}]}function Zo(e,t,n){return e.map((r,o)=>[t.at(o),k(r,n.field)]).sort((r,o)=>r[0]-o[0])}function dr(e,t){let n=1/0,r=-1/0;for(let o of e)for(let i of t){let s=k(o,i.field);s<n&&(n=s),s>r&&(r=s)}return n<=r?[n,r]:[0,1]}function Jo(e,t,n,r){return n??Ee(dr(e,t),r)}function Qt(e,t,n,r,o=[]){let i=e.map((c,u)=>u).sort((c,u)=>t.at(c)-t.at(u));if(r!=="stacked"&&r!=="percent")return n.map(c=>({points:i.map(u=>[t.at(u),k(e[u],c.field)]),base:null}));let s=c=>Math.max(0,o[c]??1),a=i.map(c=>n.reduce((u,f,h)=>u+Math.abs(k(e[c],f.field)*s(h)),0)),l=i.map(()=>0);return n.map((c,u)=>{let f=i.map((d,p)=>[t.at(d),l[p]]);return{points:i.map((d,p)=>{let g=k(e[d],c.field)*s(u);return l[p]+=r==="percent"?a[p]>0?g/a[p]*100:0:g,[t.at(d),l[p]]}),base:f}})}function St(e){let t=1/0,n=-1/0;for(let{points:r,base:o}of e)for(let[,i]of[...r,...o??[]])i<t&&(t=i),i>n&&(n=i);return t<=n?[t,n]:[0,1]}var ur=16;function en(e,t){if(t==="step"){let o=e.length>0?[e[0]]:[];for(let i=1;i<e.length;i++){let s=(e[i-1].x+e[i].x)/2;o.push({x:s,y:e[i-1].y},{x:s,y:e[i].y},e[i])}return o}if(t!=="smooth"||e.length<3)return[...e];let n=Qo(e),r=[e[0]];for(let o=1;o<e.length;o++){let i=e[o-1],s=e[o],a=(s.x-i.x)/3,l={x:i.x+a,y:i.y+a*n[o-1]},c={x:s.x-a,y:s.y-a*n[o]};for(let u=1;u<=ur;u++){let f=u/ur,h=1-f;r.push({x:h*h*h*i.x+3*h*h*f*l.x+3*h*f*f*c.x+f*f*f*s.x,y:h*h*h*i.y+3*h*h*f*l.y+3*h*f*f*c.y+f*f*f*s.y})}}return r}function Qo(e){let t=e.length,n=o=>{let i=e[o+1].x-e[o].x;return i===0?0:(e[o+1].y-e[o].y)/i},r=new Array(t).fill(0);for(let o=1;o<t-1;o++){let i=e[o].x-e[o-1].x,s=e[o+1].x-e[o].x,a=n(o-1),l=n(o),c=i+s===0?0:(a*s+l*i)/(i+s);r[o]=(Math.sign(a)+Math.sign(l))*Math.min(Math.abs(a),Math.abs(l),.5*Math.abs(c))||0}return r[0]=fr(n(0),r[1]),r[t-1]=fr(n(t-2),r[t-2]),r}function fr(e,t){let n=(3*e-t)/2;return e===0||Math.sign(n)!==Math.sign(e)?0:Math.abs(n)>3*Math.abs(e)?3*e:n}function tn(e,t){if(e.length===0||t<e[0].x)return[];let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.x<=t){n.push(o);continue}let i=e[r-1];i&&o.x>i.x&&n.push({x:t,y:i.y+(o.y-i.y)*(t-i.x)/(o.x-i.x)});break}return n}function nn(e,t){if(e.length<3||!ue(t))return[];let n=[o=>o.x-t.left,o=>t.right-o.x,o=>o.y-t.bottom,o=>t.top-o.y],r=[...e];for(let o of n){let i=r;r=[];for(let s=0;s<i.length;s++){let a=i[s],l=i[(s+i.length-1)%i.length],c=o(a),u=o(l);c>=0?(u<0&&r.push(hr(l,a,u,c)),r.push(a)):u>=0&&r.push(hr(l,a,u,c))}if(r.length===0)return[]}return r}function hr(e,t,n,r){let o=n/(n-r);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}var rn={strokeWidth:ge.number(4,{min:0,max:24,step:.5,unit:"px"}),curve:ge.oneOf(["smooth","linear","step"]),dots:ge.boolean(!1),dotSize:ge.number(12,{min:0,max:48,step:1,unit:"px"}),area:ge.oneOf(["none","solid","gradient"]),areaOpacity:ge.number(.4,{min:0,max:1,step:.05})},on={values:ge.oneOf(["none","above","below"],{animatable:!1}),...lt};function qe(e,t){if(e.length===0)return 0;let n=e[0].x,r=e[e.length-1].x;return t>=1?1/0:n+(r-n)*t}function sn(e,t,n){let r=en(e,t);return n>=1?r:tn(r,qe(e,n))}var xr=()=>fe.custom("smooth");function ei(e){return[...e.map((t,n)=>({type:n===0?"M":"L",x:t.x,y:t.y})),{type:"Z"}]}function ti(e,t,n,r){if(t.length<3||r<=0)return;let{width:o,height:i}=e.size,s=[-o/2,-i/2,o/2,i/2];e.draw(new Ke().path({data:ei(t),centerBounds:s}).fill(n).opacity(r))}var At=mr({key:"chartLine",state:{points:y(()=>[]),curve:xr(),stroke:fe.custom([],{resolve:pr.resolve,lerp:pr.lerp}),dotSize:0,dotFill:fe.custom([],{resolve:je.resolve,lerp:je.lerp}),progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.dotFill],strokes:[t.stroke]}),commands:{enter:{args:{from:fe.number(0,{min:0,max:1}),to:fe.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}},hold:{args:{shown:fe.boolean(!0)},run:e=>{let{shown:t}=e.args;return e.animate(n=>({progress:1,enabled:t||n<1}),{eased:!1})}}},render:(e,t)=>{if(!t.enabled)return;let n=t.points,r=$e(t.progress,0,1);if(n.length===0||r<=0)return;let o=t.spotlight,i=ue(o),s=$e(t.dimOpacity,0,1),a=t.stroke,l=a[0]?.weight??0,c=sn(n,t.curve,r);if(c.length>=2&&l>0){let m=t.curve==="linear"?l*2:0;if(e.draw(new Ke().line({points:c,radius:m}).stroke(a).opacity(i?s:1)),i)for(let x of Jt(c,o))e.draw(new Ke().line({points:x,radius:m}).stroke(a))}let u=t.dotSize;if(u<=0)return;let f=qe(n,r),h=new Ke,d=new Ke,p=!1,g=!1;for(let m of n){let x=f===1/0?1:$e((f-m.x)/(u*2),0,1);if(x<=0)continue;let R=!i||m.x>=o.left&&m.x<=o.right&&m.y>=o.bottom&&m.y<=o.top;(R?h:d).ellipse({x:m.x,y:m.y,width:u*x,height:u*x}),R?p=!0:g=!0}g&&e.draw(d.fill(t.dotFill).opacity(s)),p&&e.draw(h.fill(t.dotFill))}}),an=mr({key:"chartArea",state:{points:y(()=>[]),base:y(()=>[]),baseline:0,curve:xr(),area:fe.custom("solid"),fill:fe.custom([],{resolve:je.resolve,lerp:je.lerp}),areaOpacity:.4,progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.fill]}),render:(e,t)=>{let n=t.points,r=$e(t.progress,0,1);if(!t.enabled||t.area==="none"||n.length<2||r<=0||t.fill.length===0)return;let o=c=>{let u=sn(n,t.curve,c);if(u.length<2)return[];let f=t.base.length===n.length?sn(t.base,t.curve,c):[{x:u[0].x,y:t.baseline},{x:u[u.length-1].x,y:t.baseline}];return[...u,...[...f].reverse()]},i=gr(o(1)),s=(c,u)=>ti(e,c,yr(t.fill,t.area,t.areaOpacity,i,gr(c)),u),a=o(r),l=t.spotlight;if(!ue(l)){s(a,1);return}s(a,$e(t.dimOpacity,0,1)),s(nn(a,l),1)}});function gr(e){let t=-1/0,n=1/0;for(let r of e)r.y>t&&(t=r.y),r.y<n&&(n=r.y);return{top:t,bottom:n}}function yr(e,t,n,r,o){let i=e[e.length-1];if(t!=="gradient"||i?.type!=="solid"||!(o.top>o.bottom))return Ye(e,n);let[s,a,l,c]=i.color,u=(o.top+o.bottom)/2,f=(o.top-o.bottom)/2;return je.resolve({type:"linear-gradient",colors:[[s,a,l,c*n],[s,a,l,c*n*.04]],start:{x:0,y:(r.top-u)/f},end:{x:0,y:(r.bottom-u)/f}})}import{Graphics2D as ni,Types as br,component2d as ri,fillOps as wr,strokeOps as Rr}from"@motionscript/sdk";var ln=ri({key:"chartRegion",state:{box:y(()=>me),stroke:br.custom({weight:2,fill:"white/70",dash:[14,12],cap:"butt",align:"center"},{resolve:Rr.resolve,lerp:Rr.lerp}),fill:br.custom("white/6",{resolve:wr.resolve,lerp:wr.lerp}),reveal:0},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let n=t.box;if(!ue(n))return;let r=Math.max(0,Math.min(1,t.reveal));if(r<=0)return;let o=n.right-n.left,i=n.top-n.bottom,s=(n.left+n.right)/2,a=(n.bottom+n.top)/2;if(t.fill.length>0&&e.draw(new ni().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(r)),t.stroke.length!==0){if(n.xBounded){let l=i/2*r;for(let c of[n.left,n.right])$t(e,{x:c,y:a-l},{x:c,y:a+l},t.stroke,r)}if(n.yBounded){let l=o/2*r;for(let c of[n.bottom,n.top])$t(e,{x:s-l,y:c},{x:s+l,y:c},t.stroke,r)}}}});import{formatNumber as oi}from"@motionscript/sdk/component";var kt=864e5,Er=["january","february","march","april","may","june","july","august","september","october","november","december"],Sr=2024;function Ar(e){return e.length<3?-1:Er.findIndex(t=>t.startsWith(e))}function ii(e,t){let n=Date.UTC(e,0,4),r=(new Date(n).getUTCDay()+6)%7;return n-r*kt+(t-1)*7*kt}function Tr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let n=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(n){let s=Number(n[2]),a=n[3]===void 0?1:Number(n[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(n[1]),s-1,a)}let r=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(r){let s=Number(r[2]);return s<1||s>53?null:ii(r[1]===void 0?Sr:Number(r[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=Ar(o[2]);if(s>=0){let a=o[1]??o[3],l=a===void 0?Sr:Number(a);return Date.UTC(l,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=Ar(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function Lr(e,t){let n=new Date(e),r=n.getUTCFullYear(),o=Er[n.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*kt?String(r):t>60*kt?`${i} ${r}`:`${i} ${n.getUTCDate()}`}function si(e,t){let n=!1;for(let r of e){let o=r[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;n=!0}}return n}function ai(e,t){let n=[],r=!1;for(let s of e){let a=s[t];if(a==null||a===""){n.push(null);continue}let l=Tr(a);if(l===null)return null;n.push(l),r=!0}if(!r)return null;let i=n.find(s=>s!==null);return n.map(s=>s===null?i:i=s)}function kr(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t<=n?[t,n]:[0,1]}var Cr=12;function vr(e,[t,n],r){let o=e.filter(l=>l>=t&&l<=n),i=[...new Set(o)].sort((l,c)=>l-c);if(i.length===0)return ee([t,n],r);if(i.length<=Cr&&li(i))return i;let s=l=>i.reduce((c,u)=>Math.abs(u-l)<Math.abs(c-l)?u:c),a=[];for(let l of ee([t,n],r)){let c=s(l);a[a.length-1]!==c&&a.push(c)}return a}function li(e){if(e.length<3)return!0;let t=(e[e.length-1]-e[0])/(e.length-1);for(let n=1;n<e.length;n++)if(e[n]-e[n-1]<t*.75)return!1;return!0}function ci(e,t,n,r){let o=e.indexOf(n);return o>=0?t[o]:r(n)}var Mr=new WeakMap;function cn(e,t,n){let r=Mr.get(e);r||Mr.set(e,r=new Map);let o=JSON.stringify([t,n??null]),i=r.get(o);return i||r.set(o,i=ui(e,t,n)),i}function ui(e,t,n){if(t!==""&&si(e,t)){let s=e.map(a=>k(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:kr(s),label:a=>n===void 0?Me(a):oi(a,n),ticks:ee}}let r=e.map(s=>$(s,t)),o=t===""?null:ai(e,t);if(o){let s=kr(o),a=s[1]-s[0];return{kind:"time",at:l=>o[l]??0,extent:s,label:l=>ci(o,r,l,c=>Lr(c,a)),ticks:(l,c)=>vr(o,l,c)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>r[Math.round(s)]??"",ticks:(s,a)=>vr(i,s,a)}}var gi=re.style(H,{series:Y,background:Se,grid:ct,axes:ut,marks:rn,labels:on,legend:U},{presets:X}),_r=re.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Hr=[0,100];function vt(e,t=e.xAxis.format){return cn(e.data,e.xField,t)}function hn(e,t=!0){return Qt(e.data,vt(e),e.series,e.stack,t?e.weights:void 0)}function mi(e,t){let n=vt(e,t.format),r=t.range??n.extent;return{...t,range:r,ticks:t.ticks??n.ticks(r,Q-1)}}function xi(e,t){let[n,r]=St(hn(e,!1));if(e.stack==="percent"&&n>=0)return Hr;let o=e.stack!=="none"||(e.style?.area??"none")!=="none";return Ee(o?[Math.min(0,n),Math.max(0,r)]:[n,r],t)}function yi(e,t){let n=(t.ticks?.length??Q)-1,r=t.range??xi(e,n),o=t.range!==void 0||e.stack==="percent"&&r===Hr;return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var Or=new WeakMap;function Ze(e){let t=[e.xField,e.xAxis,e.yAxis,e.series,e.stack,e.style?.area],n=Or.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domains;let r={x:Ve(e.xAxis,o=>mi(e,o)),y:Ve(e.yAxis,o=>yi(e,o))};return Or.set(e.data,{key:t,domains:r}),r}function Yr(e,t){let[n,r]=e.x.range,[o,i]=e.y.range;return{x:s=>r<=n?0:((s-n)/(r-n)-.5)*t.width,y:s=>i===o?0:((s-o)/(i-o)-.5)*t.height}}var bi={points:[],base:[],values:[]};function wi(e,t,n,r){let o=hn(e)[n];if(!o)return bi;let i=Yr(t,r),s=([a,l])=>({x:i.x(a),y:i.y(l)});return{points:o.points.map(s),base:o.base?o.base.map(s):[],values:o.points.map(([,a],l)=>a-(o.base?.[l]?.[1]??0))}}function Ir(e){let[t,n]=e.y.range;return un(0,Math.min(t,n),Math.max(t,n))}function Ri(e,t){let[n,r]=St(hn(e,!1)),[o,i]=vt(e).extent,s=(a,[l,c])=>a>=Math.min(l,c)-1e-9&&a<=Math.max(l,c)+1e-9;return!(s(n,t.y.range)&&s(r,t.y.range)&&s(o,t.x.range)&&s(i,t.x.range))}function Si(e,t,n){let{width:r,height:o}=n;return Zt(e.region,{left:-r/2,right:r/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function Pr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function Gr(e){return e!=null&&typeof e=="object"?e:{}}function Ai([e,t]){return e<=t?[e,t]:[t,e]}function Dr(e,t){let n=Ai(e);return{range:n,ticks:ee(n,Math.max(2,t.length)-1)}}function zr(e,t,n){return{...t.x&&{xAxis:Xe(e.x,t.x,n)},...t.y&&{yAxis:Xe(e.y,t.y,n)}}}function Fr(e,t,n){let r=e.yAxis.format;if(r!==void 0)return pi(t,r);let o=Me(t,wt(n));return e.stack==="percent"?`${o}%`:o}function ki(e,t){return Math.max(0,e.weights[t]??1)}function fn(e){let t=mt(e);return{vAxis:t.find(Te.is)??null,hAxis:t.find(Le.is)??null,lines:t.filter(At.is),legend:t.find(te.is)??null}}function Br(e,t){let n=t.regionReveal,r=t.region;return n===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:r,regionReveal:n*(1-o)})}function Nr(e,t,n,r,o){let i=fn(n),s=i.lines[r];if(!s)return e.wait(e.duration);let a=i.legend?[i.legend.run(o?"showSeries":"hideSeries",{index:r})]:[];if(t.stack==="none")return e.together([s.run("enter",o?{from:0,to:1}:{from:1,to:0}),...a]);let l=t.series.map((f,h)=>ki(t,h)),c=l[r]??1,u=o?1:0;return e.together([e.animate(f=>{let h=[...l];return h[r]=c+(u-c)*e.ease(f),{weights:h}},{eased:!1}),s.run("hold",{shown:o}),...a])}var dn=di({key:"lineChart",state:{data:y(()=>[],{kind:"dataset"}),xField:"",series:y(()=>[],{kind:"series"}),stack:re.oneOf(["none","stacked","percent"]),xAxis:re.custom({},{resolve:ve,lerp:We}),yAxis:re.custom({},{resolve:ve,lerp:We}),style:gi,region:re.custom(null),regionReveal:0,home:re.custom(null,{private:!0}),weights:re.custom([],{private:!0}),clipped:re.boolean(!1,{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ze(e),r,o=()=>ke(r),i=w=>wi(e,n(),w,o()),s=e.series.map(w=>w.enabled??!0),a=e.style,l=()=>Ae(t(),"y"),c=()=>Ae(t(),"x"),u=()=>{let w=n().y.ticks;return w.map(b=>Fr(e,b,w))},f=a.showYAxis?new Te({range:()=>n().y.range,markers:()=>n().y.ticks,captions:u,axis:l,label:e.yAxis.label??"",width:"hug",height:"fill"}):void 0,h=a.showXAxis?new Le({range:()=>n().x.range,markers:()=>n().x.ticks,captions:()=>{let w=vt(e);return n().x.ticks.map(b=>w.label(b))},axis:c,label:e.xAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):void 0,d=f&&h?xt({captions:u,count:Ze(e).y.ticks.length,text:()=>l().labelStyle,title:e.yAxis.label??"",titleText:()=>l().titleStyle,tickPad:()=>le(l(),"right").tick,titlePad:()=>le(l(),"right").title}):void 0,p=()=>Si(e,n(),o()),g=()=>1-(1-N)*e.regionReveal,m=e.series.map((w,b)=>new At({points:()=>i(b).points,curve:()=>t().curve,stroke:()=>({weight:t().strokeWidth,fill:P(t(),w,b),align:"center",cap:"round",join:"round"}),dotSize:()=>t().dots?t().dotSize:0,dotFill:()=>P(t(),w,b),enabled:s[b],spotlight:p,dimOpacity:g})),x=e.series.map((w,b)=>new an({points:()=>i(b).points,base:()=>i(b).base,baseline:()=>Yr(n(),o()).y(Ir(n())),curve:()=>t().curve,area:()=>t().area,fill:()=>P(t(),w,b),areaOpacity:()=>t().areaOpacity,progress:()=>m[b].progress,enabled:()=>m[b].enabled,opacity:()=>m[b].opacity,spotlight:p,dimOpacity:g})),R=[];if(a.values!=="none"){let w=a.values==="below";e.series.forEach((b,M)=>{e.data.forEach((z,E)=>{let T=m[M],pe=new hi({...Z(()=>ht(t())),text:()=>{let _=i(M).values[E];return _===void 0?"":Fr(e,_,n().y.ticks)},x:()=>{let _=(o().width-pe.layoutBounds.width)/2;return un(i(M).points[E]?.x??0,-Math.max(0,_),Math.max(0,_))},y:()=>{let _=i(M).points[E],ae=pe.layoutBounds.height/2+(t().dots?t().dotSize/2:t().strokeWidth/2)+Math.round(W(t().valueText)*.25);return(_?.y??0)+(w?-ae:ae)},opacity:()=>{let _=i(M).points[E];if(!T.enabled||!_)return 0;let ae=qe(i(M).points,T.progress);return T.opacity*(ae===1/0?1:un((ae-_.x)/24,0,1))}});R.push(pe)})})}let v=a.legend,S=v!=="none"?new te({series:e.series,swatches:()=>e.series.map((w,b)=>P(t(),w,b)),legend:()=>B(t()),flow:v==="right"?"vertical":"horizontal"}):void 0;return r=new fi({clip:()=>e.clipped||Ri(e,n()),children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:()=>n().x.ticks,yMarkers:()=>n().y.ticks,xExtent:()=>n().x.range,yExtent:()=>n().y.range,axisStroke:()=>t().axisStroke,xAxisAt:()=>Ir(n()),yAxisAt:()=>n().x.range[0]}),new ln({box:p,stroke:()=>({weight:2,fill:Ye(t().valueText.fill??"white",.7),dash:[14,12],cap:"butt",align:"center"}),fill:()=>Ye(t().valueText.fill??"white",.06),reveal:()=>e.regionReveal}),...x,...m,...R]}),[gt({background:()=>t().background,left:f,ghost:d,plot:r,bottom:h,legend:S,legendAt:v,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:h?K(t()):0,left:h&&!f?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.duration,i=Pr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*G.axes,l=s*G.marks,{legend:c}=r,u=h=>({at:0,duration:0,piece:h}),f=bt(t.style.legend);return D(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...r.lines.map(h=>u(h.to({progress:0}))),...c?[u(c.to({opacity:0,...f}))]:[],...r.vAxis?[{at:0,duration:a,piece:r.vAxis.run("enter",{slide:24})}]:[],...r.hAxis?[{at:0,duration:a,piece:r.hAxis.run("enter",{slide:24})}]:[],...r.lines.map(h=>({at:a,duration:l,piece:h.run("enter")})),...c?[{at:a+l,duration:s*G.legend,piece:c.to({opacity:1,x:0,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(h=>({regionReveal:h}))}]:[],{at:0,duration:o,piece:e.wait(o)}])}},spotlightRegion:{args:{region:_r},easing:he(),run:(e,t)=>{let n=Gr(e.args.region),r=t.regionReveal,o=t.region;return n.x===void 0&&n.y===void 0?Br(e,t):r<=0||!Pr(t)?e.animate(i=>({region:n,regionReveal:r+(1-r)*i})):e.animate(i=>i<.5?{region:o,regionReveal:r*(1-e.ease(i*2))}:{region:n,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:he(),run:(e,t)=>Br(e,t)},zoomTo:{args:{region:_r},easing:he(),run:(e,t)=>{let n=Gr(e.args.region);if(!n.x&&!n.y)return e.wait(e.duration);let r=Ze(t),o=t.home??r,i={...n.x&&{x:{...r.x,...Dr(n.x,r.x.ticks)}},...n.y&&{y:{...r.y,...Dr(n.y,r.y.ticks)}}};return e.animate(s=>({home:o,clipped:!0,...zr(r,i,s)}))}},resetZoom:{args:{},easing:he(),run:(e,t)=>{let n=t.home;if(!n)return e.wait(e.duration);let r=Ze(t);return e.animate(o=>({home:null,clipped:o<1,...zr(r,n,o)}))}},showSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Nr(e,t,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Nr(e,t,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.args.seriesIndex;return e.together([...r.lines.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}}}});import{Rect as Di,Types as oe,clamp as Mn,component2d as zi,easeOut as Ie}from"@motionscript/sdk";import{formatNumber as Fi}from"@motionscript/sdk/component";import{Rect as pn,Text as Ur,Types as Mt,clamp as vi,component2d as Mi}from"@motionscript/sdk";import{enterBudget as Ei}from"@motionscript/sdk/component";var Ti=24;function Je(e,t,n){return t<=0?0:-n/2+n/t*(e+.5)}var Et=Mi({key:"categoryAxis",state:{categories:y(()=>[]),axis:Mt.custom(ar),label:"",orientation:Mt.oneOf(["horizontal","vertical"]),dims:y(()=>[]),arrivals:ir()},defaults:{width:"fill",height:"fill"},children:e=>{let t=e.categories.length,n=s=>vi(e.dims[s]??1,0,1);if(e.orientation==="vertical")return[lr({count:t,axis:()=>e.axis,text:s=>e.categories[s]??"",place:(s,a)=>-Je(s,e.categories.length,a),arrivals:()=>e.arrivals,opacity:n,label:e.label})];let r=()=>le(e.axis,"top"),o=e.categories.map((s,a)=>{let l=new pn({width:"hug",height:"hug",flow:"freeform",opacity:()=>n(a),x:()=>Je(a,e.categories.length,l.parent?.layoutBounds.width??0),children:[new Ur({...Z(()=>e.axis.labelStyle),text:s,opacity:()=>Ue(e.arrivals,a).opacity,y:()=>Ue(e.arrivals,a).shift})]});return l}),i=[new pn({width:"fill",height:"hug",padding:()=>({top:r().tick}),children:o})];return e.label!==""&&i.push(new Ur({...Z(()=>e.axis.titleStyle),text:e.label,opacity:()=>Ue(e.arrivals,"label").opacity,y:()=>Ue(e.arrivals,"label").shift})),[new pn({flow:"vertical",gap:()=>r().title,height:"hug",width:"fill",children:i})]},commands:{enter:{args:{stagger:Mt.custom(void 0),slide:Mt.number(Ti)},run:(e,t)=>{let{stagger:n,slide:r}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:r},a=[...t.categories.keys(),...i?["label"]:[]],l=e.animate(()=>({arrivals:sr(a,s)}));if(o===0)return l;let{step:c,per:u,caption:f}=Ei(e.duration,o,i,n),h=L(e),d=t.categories.map((g,m)=>({at:m*c,duration:u,piece:jt(e,m,s,h)})),p=i?[{at:(o-1)*c+u,duration:f,piece:jt(e,"label",s,h)}]:[];return e.together([l,D(e,[...d,...p])])}}}});import{Graphics2D as Ci,Text as _i,Types as et,clamp as wn,component2d as Oi,fillOps as Wr}from"@motionscript/sdk";import{Types as Qe,fillOps as Li}from"@motionscript/sdk";function Tt(e,t,n,r=[]){let o=h=>Math.max(0,r[h]??1);if(n!=="stacked"&&n!=="percent")return t.map(h=>{let d=k(e,h.field);return{from:0,to:d,value:d,outer:!0}});let i=t.map((h,d)=>k(e,h.field)*o(d)),s=i.reduce((h,d)=>h+Math.abs(d),0),a=n==="percent"?i.map(h=>s>0?h/s*100:0):i,l=-1,c=-1;a.forEach((h,d)=>{h>0?l=d:h<0&&(c=d)});let u=0,f=0;return a.map((h,d)=>{if(h<0){let g=f;return f+=h,{from:g,to:f,value:h,outer:d===c}}let p=u;return u+=h,{from:p,to:u,value:h,outer:d===l}})}function gn(e,t){return e.map(n=>$(n,t))}function Xr(e,t,n,r){let o=0,i=0;for(let s of e)for(let a of Tt(s,t,n,r))o=Math.min(o,a.from,a.to),i=Math.max(i,a.from,a.to);return o<i?[o,i]:[0,1]}function mn(e,t,n,r,o,i){if(r)return r;let[s,a]=Xr(e,t,n,i);return n==="percent"?[s<0?-100:0,a>0?100:0]:Ee([s,a],o)}function xn(e){let t=Li.resolve(e),n=t[t.length-1];if(n?.type!=="solid")return"white";let[r,o,i]=n.color,s=l=>l<=.03928?l/12.92:((l+.055)/1.055)**2.4;return .2126*s(r)+.7152*s(o)+.0722*s(i)>.4?"#0a0a0a":"white"}var yn={barCornerRadius:Qe.cornerRadius({topLeft:10,topRight:10,bottomRight:0,bottomLeft:0}),barCornerStyle:Qe.cornerStyle("rounded"),barWidth:Qe.number(.7,{min:.05,max:1,step:.05,unit:"%",scale:100}),barGap:Qe.number(6,{min:0,max:40,step:1,unit:"px"})},bn={values:Qe.oneOf(["none","end","inside"],{animatable:!1}),...lt};var Ii=.6;function Vr(e,t){return e.enabled?wn(e.dims[t]??1,0,1):0}function Rn(e,t){let n=e.bars[t];if(!n)return null;let r=wn(e.growth,0,1);return{base:e.baseline+(n.from-e.baseline)*r,end:e.baseline+(n.to-e.baseline)*r}}function jr(e){return typeof e.fontSize=="number"?e.fontSize:24}function Kr(e,t,n){let r=Rn(e,t);if(!r)return 0;if(e.values==="inside")return(r.base+r.end)/2;let o=r.end>=r.base?1:-1;return r.end+o*(jr(e.valueStyle)*.4+n/2)}function Pi(e,t,n,r){let o=e.bars[t],i=Rn(e,t);if(!o||!i)return!1;let s=jr(e.valueStyle)*Ii;return Math.abs(i.end-i.base)>=n+s&&o.thickness>=r}var Lt=Oi({key:"chartBars",state:{bars:y(()=>[]),baseline:0,horizontal:!1,fill:et.custom([],{resolve:Wr.resolve,lerp:Wr.lerp}),cornerRadius:et.cornerRadius(8),cornerStyle:et.cornerStyle("rounded"),growth:1,dims:y(()=>[]),values:et.custom("none"),valueStyle:et.custom({fontSize:24,fill:"white"}),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.values==="none"?[]:e.bars.map((t,n)=>{let r=new _i({...Z(()=>({...e.valueStyle,...e.values==="inside"&&{fill:xn(e.fill)}})),text:()=>e.bars[n]?.caption??"",x:()=>e.horizontal?Kr(e,n,r.layoutBounds.width):e.bars[n]?.center??0,y:()=>e.horizontal?e.bars[n]?.center??0:Kr(e,n,r.layoutBounds.height),opacity:()=>{let o=r.layoutBounds,i=e.horizontal?o.width:o.height,s=e.horizontal?o.height:o.width;return e.values==="inside"&&!Pi(e,n,i,s)?0:Vr(e,n)*wn((e.growth-.6)/.4,0,1)}});return r}),load:(e,t)=>C(e,{fills:[t.fill]}),commands:{enter:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))}},render:(e,t)=>{if(t.enabled)for(let n=0;n<t.bars.length;n++){let r=t.bars[n],o=Rn(t,n);if(!o||r.thickness<=0)continue;let i=r.round?0:1,s=Math.abs(o.end-o.base)+i;if(s<=i)continue;let a=o.end>=o.base,l=(o.base+o.end)/2+(a?i:-i)/2,c=Gi(t,r,a,s),u=new Ci().rect(t.horizontal?{x:l,y:r.center,width:s,height:r.thickness,...c}:{x:r.center,y:l,width:r.thickness,height:s,...c});u.fill(t.fill),e.draw(u.opacity(Vr(t,n)))}e.children()}});function $r(e,t,n){return t?n?{topLeft:e.bottomLeft,topRight:e.topLeft,bottomRight:e.topRight,bottomLeft:e.bottomRight}:{topLeft:e.topLeft,topRight:e.bottomLeft,bottomRight:e.bottomRight,bottomLeft:e.topRight}:n?e:{topLeft:e.bottomLeft,topRight:e.bottomRight,bottomRight:e.topRight,bottomLeft:e.topLeft}}function Gi(e,t,n,r){let o=t.grounded??!0,i=e.cornerRadius,s=(t.round?1:0)+(o?1:0),a=Math.max(0,Math.min(t.thickness/2,s>1?r/2:r)),l=(u,f)=>f?Math.max(0,Math.min(u,a)):0,c={topLeft:l(i.topLeft,t.round),topRight:l(i.topRight,t.round),bottomRight:l(i.bottomRight,o),bottomLeft:l(i.bottomLeft,o)};return{cornerRadius:$r(c,e.horizontal,n),cornerStyle:$r(e.cornerStyle,e.horizontal,n)}}var Bi=oe.style(H,{series:Y,background:Se,grid:ct,axes:ut,marks:yn,labels:bn,legend:U},{presets:X});function Ni(e,t){let n=(t.ticks?.length??Q)-1,r=mn(e.data,e.series,e.stack,t.range,n),o=t.range!==void 0||e.stack==="percent";return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var qr=new WeakMap;function _t(e){let t=[e.series,e.stack,e.valueAxis],n=qr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domain;let r=Ve(e.valueAxis,o=>Ni(e,o));return qr.set(e.data,{key:t,domain:r}),r}function An(e,t,n){let r=e.valueAxis.format;if(r!==void 0)return Fi(n,r);let o=Me(n,wt(t.ticks));return e.stack==="percent"?`${o}%`:o}function kn(e,t,n){let[r,o]=e.range;return o===r?-t/2:((n-r)/(o-r)-.5)*t}function Sn(e){let[t,n]=e.range;return Mn(0,Math.min(t,n),Math.max(t,n))}function Ct(e,t){return Math.max(0,e.weights[t]??1)}function Qr(e,t){return e.orientation==="horizontal"?{along:t.width,across:t.height}:{along:t.height,across:t.width}}function Hi(e,t,n){let r=Je(t,e.data.length,n);return e.orientation==="horizontal"?-r:r}function Yi(e,t,n){let r=e.series[t];if(!r)return[];let o=_t(e),{along:i,across:s}=Qr(e,n),a=e.data.length,c=(a>0?s/a:0)*Mn(e.style.barWidth,0,1),u=e.stack!=="none",f=0;for(let x=0;x<e.series.length;x++)f+=Ct(e,x);let h=c/(f>0?f:1),d=Ct(e,t),p=0;for(let x=0;x<t;x++)p+=Ct(e,x);let g=e.series.length>1?e.style.barGap:0,m=e.style.values;return e.data.map((x,R)=>{let S=Tt(x,e.series,e.stack,e.weights)[t]??{from:0,to:0,value:0,outer:!1},w=Hi(e,R,s),b=-c/2+h*p+h*d/2,M="";return m!=="none"&&S.value!==0&&(!u||m==="inside"||e.stack==="percent"?M=An(e,o,u?S.value:k(x,r.field)):S.outer&&(M=An(e,o,S.to))),{center:u?w:w+(e.orientation==="horizontal"?-b:b),thickness:u?c:Math.max(0,h*d-g),from:kn(o,i,S.from),to:kn(o,i,S.to),round:S.outer,grounded:!u||S.from===0,caption:M}})}function Zr(e){let t=Mn(e.spotlightReveal,0,1),n=e.spotlight;return e.data.map((r,o)=>t<=0||n===o?1:1-(1-N)*t)}function vn(e){let t=mt(e);return{valueAxis:t.find(n=>Te.is(n)||Le.is(n))??null,categoryAxis:t.find(Et.is)??null,bars:t.filter(Lt.is),legend:t.find(te.is)??null}}function Jr(e,t,n,r,o){let i=vn(n);if(!i.bars[r])return e.wait(e.duration);let s=t.series.map((c,u)=>Ct(t,u)),a=s[r]??1,l=t.series.map((c,u)=>t.showing[u]??c.enabled??!0);return e.together([e.animate(c=>{let u=[...s];u[r]=a+(o-a)*e.ease(c);let f=[...l];return f[r]=o>0||c<1,{weights:u,showing:f}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:r})]:[]])}var En=zi({key:"barChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),orientation:oe.oneOf(["vertical","horizontal"],{animatable:!1}),stack:oe.oneOf(["none","stacked","percent"]),valueAxis:oe.custom({},{resolve:ve,lerp:We}),categoryAxis:oe.custom({},{resolve:ve,lerp:Xe}),style:Bi,growth:1,spotlight:oe.custom(null),spotlightReveal:0,weights:oe.custom([],{private:!0}),showing:oe.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>_t(e),r,o=()=>ke(r),i=e.style,s=e.orientation==="horizontal",a=gn(e.data,e.categoryField),l=()=>Ae(t(),s?"x":"y"),c=()=>Ae(t(),s?"y":"x"),u=()=>{let E=n();return E.ticks.map(T=>An(e,E,T))},f=s?i.showXAxis:i.showYAxis,h=s?i.showYAxis:i.showXAxis,d=f?s?new Le({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):new Te({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",width:"hug",height:"fill"}):void 0,p=h?new Et({categories:a,axis:c,label:e.categoryAxis.label??"",orientation:s?"vertical":"horizontal",dims:()=>Zr(e),width:s?"hug":"fill",height:s?"fill":"hug"}):void 0,g=s?p:d,m=s?d:p,x=s?c:l,R=g&&m?xt({captions:s?()=>a:u,count:s?a.length:_t(e).ticks.length,text:()=>x().labelStyle,title:(s?e.categoryAxis.label:e.valueAxis.label)??"",titleText:()=>x().titleStyle,tickPad:()=>le(x(),"right").tick,titlePad:()=>le(x(),"right").title}):void 0,v=e.series.map((E,T)=>new Lt({bars:()=>Yi(e,T,o()),baseline:()=>kn(n(),Qr(e,o()).along,Sn(n())),horizontal:s,fill:()=>P(t(),E,T),cornerRadius:()=>t().barCornerRadius,cornerStyle:()=>t().barCornerStyle,growth:()=>e.growth,dims:()=>Zr(e),values:()=>i.values==="end"&&e.stack==="percent"?"inside":i.values,valueStyle:()=>ht(t()),enabled:()=>e.showing[T]??E.enabled??!0})),S=i.legend,w=S!=="none"?new te({series:e.series,swatches:()=>e.series.map((E,T)=>P(t(),E,T)),legend:()=>B(t()),flow:S==="right"?"vertical":"horizontal"}):void 0,b=e.data.length,M=()=>Array.from({length:Math.max(0,b-1)},(E,T)=>T+1),z=()=>[0,Math.max(1,b)];return r=new Di({children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:s?()=>n().ticks:M,yMarkers:s?M:()=>n().ticks,xExtent:s?()=>n().range:z,yExtent:s?z:()=>n().range,axisStroke:()=>t().axisStroke,xAxisAt:()=>s?0:Sn(n()),yAxisAt:()=>s?Sn(n()):0}),...v]}),[gt({background:()=>t().background,left:g,ghost:R,plot:r,bottom:m,legend:w,legendAt:S,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:s&&m?K(t()):0,left:s&&m&&!g?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:Ie(),run:(e,t,n)=>{let r=vn(n),o=e.duration,i=o*G.axes,s=o*G.marks,{legend:a}=r,l=c=>({at:0,duration:0,piece:c});return D(e,[l(e.animate(()=>({growth:0}))),...a?[l(a.to({opacity:0,...bt(t.style.legend)}))]:[],...r.valueAxis?[{at:0,duration:i,piece:r.valueAxis.run("enter",{slide:24})}]:[],...r.categoryAxis?[{at:0,duration:i,piece:r.categoryAxis.run("enter",{slide:24})}]:[],{at:i,duration:s,piece:e.animate(c=>({growth:c}))},...a?[{at:i+s,duration:o*G.legend,piece:a.to({opacity:1,x:0,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Ie(),run:(e,t,n)=>Jr(e,t,n,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:O},easing:Ie(),run:(e,t,n)=>Jr(e,t,n,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:O},easing:Ie(),run:(e,t,n)=>{let r=vn(n),o=e.args.seriesIndex;return e.together([...r.bars.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}},spotlightCategory:{args:{categoryIndex:oe.number(0,{min:0,step:1})},easing:Ie(),run:(e,t)=>{let n=e.args.categoryIndex;if(n<0||n>=t.data.length)return e.wait(e.duration);let r=t.spotlightReveal;return e.animate(o=>({spotlight:n,spotlightReveal:r+(1-r)*o}))}},clearCategory:{args:{},easing:Ie(),run:(e,t)=>{let n=t.spotlightReveal;if(n===0)return e.wait(e.duration);let r=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:r,spotlightReveal:n*(1-o)})}}}});import{Rect as xo,Types as Ft,clamp as yo,component2d as is,easeOut as De}from"@motionscript/sdk";import{Graphics2D as oo,PathBuilder as Ui,Rect as _n,Text as Pe,Types as tt,clamp as ye,component2d as Xi,strokeOps as Wi,textOps as Ge}from"@motionscript/sdk";import{Types as xe}from"@motionscript/sdk";function Tn(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:r.length>0?r[i%r.length]:"white"}))}function Ln(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function eo(e){let t=0;for(let n of e)t+=Ln(n);return t}function Ot(e,t){let n=eo(e);if(n<=0)return[];let r=[],o=t*_e;return e.forEach((i,s)=>{let a=Ln(i);if(a<=0)return;let l=a/n,c=o,u=c+l*Math.PI*2;o=u,r.push({index:s,a0:c,a1:u,mid:(c+u)/2,fraction:l})}),r}function It(e,t,n,r){e.sort((s,a)=>a.ideal-s.ideal);let o=n;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=r;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Cn={series:Y,background:at,marks:{innerRadius:xe.number(0,{min:0,max:.9,step:.05}),sliceGap:xe.number(3,{min:0,max:40,step:1,unit:"px"}),sliceRadius:xe.number(4,{min:0,max:60,step:1,unit:"px"})},labels:{labelPlacement:xe.oneOf(["inside","outside","none"],{animatable:!1}),labelText:xe.typography({fontSize:28,fontWeight:500,fill:Re}),valueText:xe.typography({fontSize:28,fontWeight:700,fill:He}),centerText:xe.typography({fontSize:50,fontWeight:800,fill:He})},legend:U};function Pt(e){return B(e)}function to(e){return{gap:e.sliceGap,holeRadius:e.innerRadius,startAngle:0,selectedGrow:1.08,cornerRadius:e.sliceRadius}}function no(e){let t=F(e.labelText),n=F(e.valueText);return{textStyle:t,percentStyle:n,insideStyle:{...n,fontSize:Math.round(W(e.valueText)*1.9),fill:"#111113"},leaderStroke:{weight:2,fill:e.labelText.fill??"white"}}}function ro(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Vi={gap:3,holeRadius:0,startAngle:0,selectedGrow:1.08,cornerRadius:4},Ki={textStyle:{fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},percentStyle:{fontSize:28,fontWeight:700,textAlign:"center",fill:"#f4f4f5"},insideStyle:{fontSize:52,fontWeight:700,textAlign:"center",fill:"#111113"},leaderStroke:{weight:2,fill:"#a1a1aa"}},$i={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function io(e){let n=cr(e).find(s=>s.type==="solid");if(!n)return"#111113";let[r,o,i]=n.color;return .2126*r+.7152*o+.0722*i>.45?"#111113":"#ffffff"}var so=12,ji=14,On=.62,qi=6,ao=34,lo=26,co=8,Zi=.18,Ji=240,Qi=8,uo=2,ho=.44,In=.62,es=.78,ts=.9,fo=.001,po=26;function de(e,t=po){let n=e.fontSize;return typeof n=="number"?n:t}function ns(e,t,n,r,o,i,s){let a=new Ui,l=t-e,c=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*Ji)),u=A=>A<=0?0:Math.min(o/A,l/2.2),f=(A,I)=>{let we=j(A,I);return{x:we.x+s,y:we.y}},h=n>0,d=e+u(r),p=t-u(r),g=e+u(n),m=t-u(n),x=f(r,d),R=f(r,p),v=Math.max(.001,Math.min(l/2,Math.PI/2)),S=f(o>0?Math.min(o/Math.sin(v),r*.8):0,(e+t)/2),w=h?f(n,g):S,b=h?f(n,m):S,M=h?r-n:r,z=Math.max(0,Math.min(i,M/2.2,(p-d)*r/2.2,h?(m-g)*n/2.2:1/0)),E=z>=.5,T=(A,I,we)=>{let Be=Math.hypot(I.x-A.x,I.y-A.y)||1,Ne=Math.min(.5,we/Be);return{x:A.x+(I.x-A.x)*Ne,y:A.y+(I.y-A.y)*Ne}},pe=E?z/Math.max(1,r):0,_=E&&h?z/n:0,ae=(A,I,we)=>{for(let Be=0;Be<=c;Be++){let Ne=f(A,I+(we-I)*Be/c);a.lineTo(Ne.x,Ne.y)}},st=(A,I)=>{E?a.quadraticCurveTo(A.x,A.y,I.x,I.y):a.lineTo(A.x,A.y)},Kt=f(r,d+pe);if(a.moveTo(Kt.x,Kt.y),ae(r,d+pe,p-pe),st(R,T(R,b,z)),h){let A=T(b,R,z);a.lineTo(A.x,A.y),st(b,f(n,m-_)),ae(n,m-_,g+_),st(w,T(w,x,z))}else a.lineTo(S.x,S.y);let rr=T(x,w,E?z:0);return a.lineTo(rr.x,rr.y),st(x,Kt),a.close(),a}var Gt=class{s;box;constructor(t,n){this.s=t,this.box=n}get arcs(){return Ot(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="outside"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let n=this.outerRadius,r=this.holeRadius,o=r>0?n-r:n*(1-In)*2,i=r>0?(r+n)/2:n*In,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),l=s>fo?o/s:1/0,c=a>fo?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(l,c))}insideGlyphs(t){let n=this.s.labelMode,r=this.s.slices[t.index]?.category.length??0,o=n==="both"||n==="percent"?qt(t.fraction).length:0,i=n==="category"?r:n==="both"?r*ho:0;return Math.max(1,o,i)}get insideFont(){let t=de(this.s.label.insideStyle,po*1.9);for(let n of this.arcs){let r=this.insideRoom(n)*ts/(this.insideGlyphs(n)*On);t=Math.min(t,r)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=de(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=de(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*es/(a*On))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=de(this.s.label.textStyle)*1.25,n=de(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+n+2:this.s.labelMode==="category"?t:n}captionGlyphs(t){let n=this.s.labelMode,r=n==="percent"||n==="both"?4:0,o=n==="category"||n==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(r,o)}get labelGutters(){let t={left:uo,right:uo};if(!this.hasLeaderLabels)return t;let n=de(this.s.label.textStyle)*On;for(let r of this.arcs){let o=ao+lo+co+this.captionGlyphs(r.index)*n+ji,i=Pn(r.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:n}=this.labelGutters;return(t-n)/2}get outerRadius(){let{left:t,right:n}=this.labelGutters,r=Math.min((this.box.width-t-n)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,r/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let n=t<1?t*this.outerRadius:t;return Math.min(n,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+ao}popOf(t){return ye(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let n=this.anchorRadius(t),r=this.holeRadius;return r>0?(r+n)/2:n*In}insideAnchor(t){let n=this.arcs.find(o=>o.index===t);if(n===void 0)return{x:this.centerX,y:0};let r=j(this.bandMidRadius(t),n.mid);return{x:r.x+this.centerX,y:r.y}}get selectionStrength(){let t=0;for(let n=0;n<this.s.slices.length;n++)t=Math.max(t,this.popOf(n));return t}sliceOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let n=this.arcs.find(r=>r.index===t);return qt(n?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let n=this.elbowRadius,r=this.labelRowHeight,o=this.box.height/2-r/2,i=-o,s=this.centerX,a=[],l=[];for(let c of t){let u=Pn(c.mid),f=j(n,c.mid).y;(u>0?a:l).push({index:c.index,side:u,mid:c.mid,ideal:f,y:f})}return It(a,r+so,o,i),It(l,r+so,o,i),[...a,...l].map(c=>{let u=j(this.anchorRadius(c.index)+qi,c.mid),f=Math.sqrt(Math.max(0,n*n-c.y*c.y)),h=s+c.side*Math.max(f,n*Zi),d=s+c.side*(n+lo);return{index:c.index,side:c.side,leader:[{x:u.x+s,y:u.y},{x:h,y:c.y},{x:d,y:c.y}],text:{x:d+c.side*co,y:c.y}}})}placementFor(t){return this.placements().find(n=>n.index===t)}};function Pn(e){return Math.sin(e)>=0?1:-1}var rs={width:0,height:0};function os(e){let t=[],n=()=>new Gt(e,t[0]?.parent?.layoutBounds??rs),r=o=>{let i=()=>ye(e.labelReveal,0,1)*n().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let f=[];return a&&f.push(new Pe({...Ge.styleProps(e.label.insideStyle),text:()=>n().percentText(o.index),fill:()=>io(e.slices[o.index]?.fill??"white"),fontSize:()=>n().insideFont})),s&&f.push(new Pe({...Ge.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fill:()=>io(e.slices[o.index]?.fill??"white"),fontSize:()=>e.labelMode==="category"?n().insideFont:n().insideFont*ho})),new _n({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>n().insideAnchor(o.index),children:f})}let l=Pn(o.mid),c=()=>n().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new Pe({...Ge.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:l>0?"left":"right"})),a&&u.push(new Pe({...Ge.styleProps(e.label.percentStyle),text:()=>n().percentText(o.index),textAlign:l>0?"left":"right"})),new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:l>0?"centerLeft":"centerRight",opacity:i,centerLeft:l>0?c:void 0,centerRight:l>0?void 0:c,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ot(e.slices,e.ring.startAngle))t.push(r(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Pe({...Ge.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Pe({...Ge.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(de(e.centerStyle.captionStyle,22)/de(e.centerStyle.labelStyle,46))})),t.push(new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ye(e.centerReveal,0,1)*ye(n().holeRadius/20,0,1),center:()=>({x:n().centerX,y:0}),children:o}))}return t}var Dt=Xi({key:"pieRing",state:{slices:y(()=>[]),ring:tt.custom(Vi),label:tt.custom(Ki),centerStyle:tt.custom($i),labelMode:tt.custom("percent"),labelPlacement:tt.custom("outside"),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:ce,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>os(e),load:(e,t)=>C(e,{fills:Oe(t.slices),strokes:[Wi.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=ye(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new Gt(t,e.size),r=n.outerRadius,o=r>0?n.arcs:[];if(o.length>0){let i=ye(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=n.holeRadius,l=Math.max(0,t.ring.gap)/2,c=n.centerX,u=r+n.maxPop+1+Math.abs(c),f=[-u,-u,u,u],h=u*2,d=Oe(t.slices);for(let g of o){let m=Math.min(g.a1,s);if(m<=g.a0)continue;let x=ns(g.a0,m,a,n.anchorRadius(g.index),l,Math.max(0,t.ring.cornerRadius),c),R=new oo().path(x.toPathState({centerBounds:f,width:h,height:h}));R.fill(d[g.index]??[]),e.draw(R.opacity(n.sliceOpacity(g.index)))}let p=ye(t.labelReveal,0,1);if(p>.001)for(let g of n.placements())e.draw(new oo().line({points:g.leader,radius:Qi}).stroke(t.label.leaderStroke).opacity(p*n.sliceOpacity(g.index)))}e.children()}});var ss=.65,as=.35,Gn=Ft.number(0,{min:0,step:1});function go(e){return Tn(e.data,e.categoryField,e.valueField,e.data.map((t,n)=>ft(e.style,n)))}function ze(e,t){return yo(e.pops[t]??0,0,1)}function ls(e,t){return ze(e,t)>.5}function cs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ze(e,n));return e.data.map((n,r)=>ne(t,ce,ze(e,r)))}function zt(e,t,n){let r=t.data.map((i,s)=>ze(t,s)),o=t.data.map((i,s)=>yo(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function mo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=xo.is(n)?n.children.find(Dt.is):void 0;if(r)return{ring:r,legend:n.children.find(Ce.is)??null}}return null}var Dn=is({key:"pieChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",style:Ft.style(H,Cn,{presets:X}),labelMode:Ft.custom("percent"),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:Ft.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>go(e).map(()=>0)},migrate:{style:V("pie")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>go(e),r=[new Dt({width:"fill",height:"fill",slices:n,ring:()=>to(t()),label:()=>no(t()),centerStyle:()=>ro(t()),labelMode:e.labelMode,labelPlacement:e.style.labelPlacement,pops:()=>e.pops,dimOpacity:ce,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=new Ce({slices:n,legend:()=>Pt(t()),dims:()=>cs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?Pt(e.style).itemGap/3:Pt(e.style).itemGap,padding:0});o==="top"?r.unshift(a):r.push(a)}let i=new xo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:De(),run:(e,t,n)=>{let r=mo(n);if(!r)return e.wait(e.duration);let{ring:o,legend:i}=r,s=e.duration*ss,a=e.duration*as,l=c=>({at:0,duration:0,piece:c});return D(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:De(),run:(e,t,n)=>mo(n)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Gn},easing:De(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:ze(t,r))}},deselectSlice:{args:{sliceIndex:Gn},easing:De(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?0:ze(t,r))}},selectOnlySlice:{args:{sliceIndex:Gn},easing:De(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:0)}},clearSelection:{args:{},easing:De(),run:(e,t)=>zt(e,t,()=>0)}}});import{Rect as Fe,Text as xs,Types as ys,component2d as bs,easeOut as Ut}from"@motionscript/sdk";import{Graphics2D as Un,Types as Bt,clamp as ps,component2d as gs,fillOps as Mo,strokeOps as Nt}from"@motionscript/sdk";import{Types as q}from"@motionscript/sdk";var Fn={gridShape:q.oneOf(["polygon","circle"]),gridLevels:q.number(4,{min:1,max:10,step:1}),gridStroke:q.stroke({weight:2,fill:"white/15"}),spokeStroke:q.stroke({weight:2,fill:"white/15"}),spokeLabels:q.boolean(!0,{animatable:!1}),spokeText:q.typography({fontSize:28,fontWeight:500,fill:Re})},Bn={strokeWidth:q.number(4,{min:0,max:24,step:1,unit:"px"}),areaOpacity:q.number(.25,{min:0,max:1,step:.05}),dots:q.boolean(!0),dotSize:q.number(10,{min:2,max:40,step:1,unit:"px"})},us=.55,fs=.58,zn=10,bo=.35;function ie(e,t){let n=e/Math.max(1,t)*Math.PI*2;return{x:Math.sin(n),y:Math.cos(n)}}function Nn(e,t){return e.map(n=>$(n,t))}function wo(e,t){return t.map(n=>e.map(r=>k(r,n.field)))}var hs=[1,1.2,1.5,2,2.5,3,4,5,6,8,10];function Ro(e){if(!(e>0))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(hs.find(o=>o>=n-1e-9)??10)*t}function So(e,t,n){if(n>t)return{min:t,max:n};let r=t;for(let i of e)for(let s of i)r=Math.max(r,s);let o=Ro(r-t);return{min:t,max:t+o}}function Ao(e,t){let n=t.max-t.min;return n<=0?0:Math.min(1,Math.max(0,(e-t.min)/n))}function Hn(e,t){let{x:n,y:r}=ie(e,t);return n>bo?"centerLeft":n<-bo?"centerRight":r>=0?"bottomCenter":"topCenter"}function ko(e){return e*us}function ds(e,t){return{width:e.length*t*fs,height:t*1.25}}function Yn(e,t,n,r){let o=Math.min(e.width,e.height)/2-zn;if(!r)return Math.max(0,o);let i=ko(n),s=t.length;return t.forEach((a,l)=>{let{x:c,y:u}=ie(l,s),f=ds(a,n),h=Hn(l,s),d=h==="centerLeft"||h==="centerRight"?f.width:f.width/2,p=h==="bottomCenter"||h==="topCenter"?f.height:f.height/2;Math.abs(c)>1e-6&&(o=Math.min(o,(e.width/2-d-zn/2)/Math.abs(c)-i)),Math.abs(u)>1e-6&&(o=Math.min(o,(e.height/2-p-zn/2)/Math.abs(u)-i))}),Math.max(0,o)}function vo(e,t,n,r){let{x:o,y:i}=ie(e,t),s=n+ko(r);return{x:o*s,y:i*s}}var nt=gs({key:"radarGrid",state:{count:0,radius:0,levels:4,fill:Bt.custom([],{resolve:Mo.resolve,lerp:Mo.lerp}),shape:Bt.custom("polygon"),stroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),spokeStroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),reveal:1},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke,t.spokeStroke]}),render:(e,t)=>{let n=ps(t.reveal,0,1),r=t.radius*n;if(r<=0||n<=0)return;let o=Math.max(0,Math.round(t.count)),i=Math.max(1,Math.round(t.levels)),s=t.shape==="circle"||o<3,a=(l,c)=>{if(s)return l.ellipse({width:c*2,height:c*2});let u=[];for(let f=0;f<o;f++){let h=ie(f,o);u.push({x:h.x*c,y:h.y*c})}return l.line({points:u,closed:!0})};t.fill.length>0&&e.draw(a(new Un,r).fill(t.fill).opacity(n));for(let l=1;t.stroke.length>0&&l<=i;l++){let c=r*l/i;e.draw(a(new Un,c).stroke(t.stroke).opacity(n))}if(t.spokeStroke.length!==0)for(let l=0;l<o;l++){let c=ie(l,o);e.draw(new Un().line({points:[{x:0,y:0},{x:c.x*r,y:c.y*r}]}).stroke(t.spokeStroke).opacity(n))}}});import{Graphics2D as Xn,Types as Ht,clamp as Eo,component2d as ms,fillOps as To,strokeOps as Lo}from"@motionscript/sdk";function Co(e,t,n=1){return e.map((r,o)=>{let i=ie(o,e.length),s=t*r*n;return{x:i.x*s,y:i.y*s}})}var Yt=ms({key:"radarSeries",state:{fractions:y(()=>[]),radius:0,fill:Ht.custom([],{resolve:To.resolve,lerp:To.lerp}),stroke:Ht.custom([],{resolve:Lo.resolve,lerp:Lo.lerp}),areaOpacity:.25,dots:!0,dotSize:10,progress:1,enabled:!0},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),commands:{enter:{args:{from:Ht.number(0,{min:0,max:1}),to:Ht.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let n=Eo(t.progress,0,1);if(n<=0||t.radius<=0||t.fractions.length===0)return;let r=Co(t.fractions,t.radius,n);if(r.length>=2){let o=new Xn().line({points:r,closed:!0});t.areaOpacity>0&&t.fill.length>0&&e.draw(o.fill(t.fill).opacity(Eo(t.areaOpacity,0,1))),t.stroke.length>0&&e.draw(new Xn().line({points:r,closed:!0}).stroke(t.stroke))}if(t.dots&&t.dotSize>0&&t.fill.length>0){let o=new Xn;for(let i of r)o.ellipse({x:i.x,y:i.y,width:t.dotSize,height:t.dotSize});e.draw(o.fill(t.fill))}}});function Io(e){return So(wo(e.data,e.series),e.min,e.max)}function Po(e,t){let n=e.series[t];if(!n)return[];let r=Io(e);return e.data.map(o=>{let i=o[n.field];return Ao(typeof i=="number"&&Number.isFinite(i)?i:0,r)})}function Wn(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Fe.is(n))continue;let r=n.children.find(o=>Fe.is(o)&&o.children.some(nt.is));if(r)return{grid:r.children.find(nt.is),series:r.children.filter(Yt.is),labels:r.children.find(Fe.is)??null,legend:n.children.find(te.is)??null}}return null}function _o(e,t,n,r){let o=Wn(t),i=o?.series[n];return!o||!i?e.wait(e.duration):e.together([i.run("enter",r?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(r?"showSeries":"hideSeries",{index:n})]:[]])}var Oo=.3,Vn=bs({key:"radarChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),min:0,max:0,style:ys.style(H,{series:Y,background:Se,grid:Fn,marks:Bn,legend:U},{presets:X})},defaults:{width:"fill",height:"fill"},migrate:{style:V("radar")},allowedChildren:[],children:e=>{let t=()=>e.style,n,r=()=>ke(n),o=()=>Yn(r(),Nn(e.data,e.categoryField),W(t().spokeText),t().spokeLabels),i=e.data.length,s=e.series.map(d=>d.enabled??!0),a=new nt({count:()=>e.data.length,radius:o,levels:()=>t().gridLevels,fill:()=>t().gridBackground,shape:()=>t().gridShape,stroke:()=>t().gridStroke,spokeStroke:()=>t().spokeStroke}),l=e.series.map((d,p)=>new Yt({fractions:()=>Po(e,p),radius:o,fill:()=>P(t(),d,p),stroke:()=>{let g=t().strokeWidth;return g>0?{weight:g,fill:P(t(),d,p),align:"center",join:"round"}:[]},areaOpacity:()=>t().areaOpacity,dots:()=>t().dots,dotSize:()=>t().dotSize,enabled:s[p]})),c=[a,...l];if(e.style.spokeLabels){let d=[];for(let p=0;p<i;p++){let g=Hn(p,i),m=g==="centerLeft"?"left":g==="centerRight"?"right":"center",x=()=>vo(p,i,o(),W(t().spokeText));d.push(new xs({...Z(()=>F(t().spokeText,m)),text:()=>Nn(e.data,e.categoryField)[p]??"",[g]:x}))}c.push(new Fe({width:"fill",height:"fill",children:d}))}n=new Fe({width:"fill",height:"fill",children:c});let u=[n],f=e.style.legend;if(f!=="none"){let d=f==="right",p=B(e.style),g=new te({series:e.series,swatches:()=>e.series.map((m,x)=>P(t(),m,x)),legend:()=>B(t()),flow:d?"vertical":"horizontal",gap:d?Math.round(p.itemGap/2):p.itemGap,padding:p.padding});f==="top"?u.unshift(g):u.push(g)}let h=new Fe({flow:f==="right"?"horizontal":"vertical",width:"fill",height:"fill",gap:24,align:"center",fill:()=>t().background,children:u});return[h]},commands:{enter:{args:{},entrance:!0,easing:Ut(),run:(e,t,n)=>{let r=Wn(n);if(!r)return e.wait(e.duration);let o=e.duration,i=o*G.axes,s=o*G.marks,a=o*G.legend,l=Math.max(1,r.series.length),c=s/(1+Oo*(l-1)),{legend:u,labels:f}=r,h=d=>({at:0,duration:0,piece:d});return D(e,[h(r.grid.to({reveal:0})),...r.series.map(d=>h(d.to({progress:0}))),...f?[h(f.to({opacity:0}))]:[],...u?[h(u.to({opacity:0,y:-or}))]:[],{at:0,duration:i,piece:r.grid.to({reveal:1})},...r.series.map((d,p)=>({at:i+p*c*Oo,duration:c,piece:d.to({progress:1})})),...f?[{at:i+s*.6,duration:a+s*.4,piece:f.to({opacity:1})}]:[],...u?[{at:i+s,duration:a,piece:u.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>_o(e,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>_o(e,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>{let r=Wn(n);if(!r)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...r.series.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Vo,Types as tr,clamp as Ko,component2d as Is,easeOut as Wt}from"@motionscript/sdk";import{Graphics2D as Bo,PathBuilder as Rs,Rect as No,Text as Jn,Types as rt,clamp as be,component2d as Ss,fillOps as As,textOps as Qn}from"@motionscript/sdk";import{Types as se,clamp as ws}from"@motionscript/sdk";function Kn(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:ft(r,i)}))}function $n(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Go(e,t){if(t>0&&Number.isFinite(t))return t;let n=0;for(let r of e)n=Math.max(n,$n(r));return n>0?n:1}function jn(e,t){let n=Go(e,t);return e.map(r=>ws($n(r)/n,0,1))}var qn={series:Y,background:at,marks:{innerRadius:se.number(.3,{min:0,max:.9,step:.05}),ringGap:se.number(8,{min:0,max:60,step:1,unit:"px"}),sweep:se.number(360,{min:30,max:360,step:5,unit:"deg"}),startAngle:se.number(0,{min:-360,max:360,step:5,unit:"deg"}),track:se.fill("white/10"),roundCaps:se.boolean(!0)},labels:{ringLabels:se.boolean(!1),labelText:se.typography({fontSize:28,fontWeight:500,fill:Re}),centerText:se.typography({fontSize:50,fontWeight:800,fill:He})},legend:U};function Do(e){return{innerRadius:e.innerRadius,ringGap:e.ringGap,sweep:e.sweep,startAngle:e.startAngle,track:e.track.length>0,roundCaps:e.roundCaps}}function Zn(e){return B(e)}function zo(e){return F(e.labelText)}function Fo(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Ho=.12,ks=.12,vs=4*_e,Yo=10,Ms=.78,Es=.62,Uo=4,Ts={innerRadius:.3,ringGap:8,sweep:360,startAngle:0,track:!0,roundCaps:!0},Ls={fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},Cs={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function ot(e,t){return typeof e.fontSize=="number"?e.fontSize:t}var it=class{s;box;constructor(t,n){this.s=t,this.box=n}get count(){return this.s.rows.length}get outerRadius(){return Math.max(0,Math.min(this.box.width,this.box.height)/2-Uo)}get holeRadius(){return be(this.s.marks.innerRadius,0,.9)*this.outerRadius}get thickness(){let t=this.count;return t===0?0:Math.max(0,(this.outerRadius-this.holeRadius-(t-1)*Math.max(0,this.s.marks.ringGap))/t)}ringOuter(t){return this.outerRadius-t*(this.thickness+Math.max(0,this.s.marks.ringGap))}ringMid(t){return this.ringOuter(t)-this.thickness/2}get fractions(){return jn(this.s.rows,this.s.max)}get startRad(){return this.s.marks.startAngle*_e}get sweepRad(){return be(this.s.marks.sweep,0,360)*_e}popOf(t){return be(this.s.pops[t]??0,0,1)}get selectionStrength(){let t=0;for(let n=0;n<this.count;n++)t=Math.max(t,this.popOf(n));return t}ringOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}progress(t,n){let r=1+Ho*Math.max(0,this.count-1);return be(n*r-t*Ho,0,1)}get labelFont(){return Math.max(1,Math.min(ot(this.s.label,28),this.thickness*.62))}labelAnchor(t){let n=this.startRad,r={x:-Math.cos(n),y:Math.sin(n)},o=j(this.ringMid(t),n),i=r.x<=0?-1:1;return{at:{x:o.x+r.x*Yo,y:o.y+r.y*Yo},side:i}}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=ot(t.labelStyle,50),i=this.holeRadius;if(i<=0)return o;let s=ot(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*Ms/(a*Es))}};function er(e,t,n,r,o){let i=new Rs,s=(n+r)/2,a=(r-n)/2,l=o&&s>0?Math.min(a/s,(t-e)/2):0,c=e+l,u=t-l,f=Math.max(2,Math.ceil(Math.abs(u-c)/vs)),h=(p,g,m,x)=>{for(let R=0;R<=f;R++){let v=j(p,g+(m-g)*R/f);x&&R===0?i.moveTo(v.x,v.y):i.lineTo(v.x,v.y)}},d=(p,g,m)=>{let x=j(s,p),R={x:Math.sin(p),y:Math.cos(p)},v={x:Math.cos(p)*g,y:-Math.sin(p)*g},S=12;for(let w=1;w<S;w++){let b=Math.PI*w/S,M=m?Math.cos(b):-Math.cos(b);i.lineTo(x.x+a*(R.x*M+v.x*Math.sin(b)),x.y+a*(R.y*M+v.y*Math.sin(b)))}};return h(r,c,u,!0),o&&d(u,1,!0),h(n,u,c,!1),o&&d(c,-1,!1),i.close(),i}var _s={width:0,height:0};function Os(e){let t=[],n=()=>new it(e,t[0]?.parent?.layoutBounds??_s),r=n().labelAnchor(0).side;if(e.rows.forEach((o,i)=>{let s=()=>n().labelAnchor(i).at;t.push(new No({flow:"vertical",width:"hug",height:"hug",align:r>0?"centerLeft":"centerRight",opacity:()=>e.ringLabels?be(e.labelReveal,0,1)*n().ringOpacity(i):0,centerLeft:r>0?s:void 0,centerRight:r>0?void 0:s,children:[new Jn({...Qn.styleProps(e.label),text:()=>e.rows[i]?.category??"",textAlign:r>0?"left":"right",fontSize:()=>n().labelFont})]}))}),e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Jn({...Qn.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Jn({...Qn.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(ot(e.centerStyle.captionStyle,22)/ot(e.centerStyle.labelStyle,50))})),t.push(new No({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>be(e.centerReveal,0,1),center:{x:0,y:0},children:o}))}return t}var Xt=Ss({key:"radialRings",state:{rows:y(()=>[]),max:0,marks:rt.custom(Ts),label:rt.custom(Ls),centerStyle:rt.custom(Cs),trackFill:rt.fill("white/15"),ringLabels:rt.boolean(!1),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:.25,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Os(e),load:(e,t)=>C(e,{fills:[...Oe(t.rows),As.resolve(t.trackFill)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=be(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new it(t,e.size),r=n.thickness;if(n.outerRadius>0&&n.count>0&&r>0){let o=n.outerRadius+Uo+1,i={centerBounds:[-o,-o,o,o],width:o*2,height:o*2},s=Oe(t.rows),a=n.fractions,l=n.startRad,c=t.marks.roundCaps,u=[...t.rows.keys()].sort((f,h)=>n.popOf(f)-n.popOf(h));for(let f of u){let h=r*ks*n.popOf(f),d=n.ringOuter(f)+h,p=n.ringOuter(f)-r-h,g=n.ringOpacity(f);t.marks.track&&n.sweepRad>0&&e.draw(new Bo().path(er(l,l+n.sweepRad,p,d,c).toPathState(i)).fill(t.trackFill).opacity(g));let m=n.sweepRad*a[f]*n.progress(f,t.growth);m<=1e-4||e.draw(new Bo().path(er(l,l+m,p,d,c).toPathState(i)).fill(s[f]??[]).opacity(g))}}e.children()}});var Ps=.7,Gs=.3;function Ds(e){return Kn(e.data,e.categoryField,e.valueField,e.style)}function Vt(e,t){return Ko(e.pops[t]??0,0,1)}function zs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Vt(e,n));return e.data.map((n,r)=>ne(t,$o,Vt(e,r)))}var $o=Math.max(ce,.25);function Xo(e,t,n){let r=t.data.map((i,s)=>Vt(t,s)),o=t.data.map((i,s)=>Ko(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function Wo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=Vo.is(n)?n.children.find(Xt.is):void 0;if(r)return{rings:r,legend:n.children.find(Ce.is)??null}}return null}var nr=Is({key:"radialChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",max:tr.number(0,{min:0,step:1}),style:tr.style(H,qn,{presets:X}),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:tr.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>e.data.map(()=>0)},migrate:{style:V("radial")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ds(e),r=[new Xt({width:"fill",height:"fill",rows:n,max:()=>e.max,marks:()=>Do(t()),label:()=>zo(t()),centerStyle:()=>Fo(t()),trackFill:()=>t().track,ringLabels:()=>t().ringLabels,pops:()=>e.pops,dimOpacity:$o,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=Zn(e.style),l=new Ce({slices:n,legend:()=>Zn(t()),dims:()=>zs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?a.itemGap/3:a.itemGap,padding:0});o==="top"?r.unshift(l):r.push(l)}let i=new Vo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:Wt(),run:(e,t,n)=>{let r=Wo(n);if(!r)return e.wait(e.duration);let{rings:o,legend:i}=r,s=e.duration*Ps,a=e.duration*Gs,l=c=>({at:0,duration:0,piece:c});return D(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:Wt(),run:(e,t,n)=>Wo(n)?.rings.run("revealCenter")??e.wait(e.duration)},selectRing:{args:{ringIndex:O},easing:Wt(),run:(e,t)=>{let n=e.args.ringIndex;return Xo(e,t,r=>r===n?1:Vt(t,r))}},clearSelection:{args:{},easing:Wt(),run:(e,t)=>Xo(e,t,()=>0)}}});var Fs=[dn,En,Dn,Vn,nr];export{bn as BAR_LABELS,yn as BAR_MARKS,En as BarChart,ut as CARTESIAN_AXES,ct as CARTESIAN_GRID,at as CHART_BACKGROUND,He as CHART_FOREGROUND,U as CHART_LEGEND,Re as CHART_MUTED,Bs as CHART_PALETTE_DEFAULT,Y as CHART_SERIES,H as CHART_STYLE_FAMILY,X as CHART_STYLE_PRESETS,Et as CategoryAxis,an as ChartArea,Lt as ChartBars,yt as ChartCanvas,te as ChartLegend,At as ChartLine,ln as ChartRegion,Us as DEFAULT_LEGEND,Q as DEFAULT_MARKERS,ar as DEFAULT_X_AXIS,Ys as DEFAULT_Y_AXIS,_e as DEG,me as EMPTY_REGION_BOX,G as ENTER_SHARE,Cr as EVERY_SAMPLE,Se as GRID_BACKGROUND,Le as HorizontalAxis,or as LEGEND_SLIDE,on as LINE_LABELS,rn as LINE_MARKS,dn as LineChart,Fs as NODES,ce as PIE_SPOTLIGHT_DIM,Cn as PIE_STYLE_GROUPS,Dn as PieChart,Ce as PieLegend,Dt as PieRing,Fn as RADAR_GRID,Bn as RADAR_MARKS,qn as RADIAL_STYLE_GROUPS,Vn as RadarChart,nt as RadarGrid,Yt as RadarSeries,nr as RadialChart,it as RadialGeometry,Xt as RadialRings,O as SERIES_ARG,N as SPOTLIGHT_DIM,lt as VALUE_TEXT,Te as VerticalAxis,yr as areaFill,sr as armed,jt as arrival,Ue as arrivalOf,ir as arrivalsEntry,J as asParts,Ae as axisConfigOf,le as axisPads,er as bandPath,gn as barCategories,_t as barChartDomain,Tt as barSpans,Xr as barValueExtent,D as beats,Z as boundText,lr as captionColumn,gt as cartesianFrame,mt as chartViews,nn as clipPolygonToBox,Jt as clipPolylineToBox,xt as columnGhost,en as curvePoints,tn as cutAt,Ye as fade,Yn as fitRadius,Lr as formatInstant,Me as formatMarker,qt as formatPercent,L as frameEase,dt as frameGap,y as fresh,ue as hasRegion,pt as headroom,xn as inkOn,ls as isSliceSelected,ke as laidOutSize,bt as legendAway,B as legendConfigOf,Xe as lerpAxisDomain,We as lerpAxisEntry,Ze as lineChartDomains,C as loadPaints,Xs as markerCaption,wt as markerStep,Ns as markerText,ee as markerValues,V as migrateChartStyle,Ro as niceCeil,Ee as niceRange,Rt as niceTicks,k as num,Hs as numericFields,K as overhang,ft as paletteFill,Tr as parseInstant,Ot as pieArcs,F as placedText,Po as radarFractions,Io as radarScale,jn as radialFractions,Go as radialMax,It as relaxLabels,ve as resolveAxisDomain,mn as resolveBarScale,Tn as resolvePieSlices,Kn as resolveRadialRows,Zt as resolveRegionBox,cn as resolveXScale,Jo as resolveYScale,cr as resolvedFill,Oe as ringFills,j as ringPoint,$n as rowValue,$t as rule,ne as selectionFade,P as seriesFill,Zo as seriesPoints,Co as seriesVertices,Ve as settleAxisDomain,W as sizeOf,eo as sliceTotal,Ln as sliceValue,Je as slotCentre,ie as spokeDirection,St as stackExtent,Qt as stackSeries,$ as text,qe as traceX,ht as valueText,dr as yExtent};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|