pymations 0.1.0 → 0.2.0

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/engine/anim.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /* Pymations engine (MIT licence, John Wylie). Built from engine/src. Loads KaTeX and opentype.js beside it. */
2
- (()=>{var ft=[1,0,0,1,0,0];function Y(t,n){return[t[0]*n[0]+t[2]*n[1],t[1]*n[0]+t[3]*n[1],t[0]*n[2]+t[2]*n[3],t[1]*n[2]+t[3]*n[3],t[0]*n[4]+t[2]*n[5]+t[4],t[1]*n[4]+t[3]*n[5]+t[5]]}function yt(t,n){return[t[0]*n[0]+t[2]*n[1]+t[4],t[1]*n[0]+t[3]*n[1]+t[5]]}function xe(t){let n=t[0]*t[3]-t[1]*t[2]||1e-12,e=t[3]/n,r=-t[1]/n,o=-t[2]/n,s=t[0]/n;return[e,r,o,s,-(e*t[4]+o*t[5]),-(r*t[4]+s*t[5])]}function Z(t,n){return[1,0,0,1,t,n]}function St(t,n,e){return[t,0,0,n,e[0]-t*e[0],e[1]-n*e[1]]}function te(t,n){let e=Math.cos(t),r=Math.sin(t);return[e,r,-r,e,n[0]-e*n[0]+r*n[1],n[1]-r*n[0]-e*n[1]]}function de(t,n,e){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e,t[2]+(n[2]-t[2])*e,t[3]+(n[3]-t[3])*e,t[4]+(n[4]-t[4])*e,t[5]+(n[5]-t[5])*e]}function un(t){return Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))||1e-9}var _t=Math.PI*2;function Ct(t,n,e){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e]}function ia(t,n){return Math.hypot(n[0]-t[0],n[1]-t[1])}function mn(t,n,e){t.push(Ct(n,e,1/3),Ct(n,e,2/3),[e[0],e[1]])}function dt(t,n){let e=[[t[0],t[1]]];return mn(e,t,n),{points:e,closed:!1}}function ot(t,n){if(!t.length)return{points:[[0,0]],closed:!1};let e=[[t[0][0],t[0][1]]];for(let r=1;r<t.length;r++)mn(e,t[r-1],t[r]);return n&&t.length>1&&mn(e,t[t.length-1],t[0]),{points:e,closed:n}}function It(t,n,e,r,o,s=!1,a=0){let i=a>0?a:Math.max(1,Math.ceil(Math.abs(o)/(_t/8)-1e-9)),c=o/i,u=4/3*Math.tan(c/4),f=m=>[t[0]+n*Math.cos(m),t[1]+e*Math.sin(m)],l=[f(r)];for(let m=0;m<i;m++){let h=r+c*m,p=h+c,d=f(h),g=f(p);l.push([d[0]-u*n*Math.sin(h),d[1]+u*e*Math.cos(h)],[g[0]+u*n*Math.sin(p),g[1]-u*e*Math.cos(p)],g)}return s&&(l[l.length-1]=[l[0][0],l[0][1]]),{points:l,closed:s}}function ee(t,n){return It(t,n,n,0,_t,!0)}function Ge(t,n,e){if(e=Math.max(0,Math.min(e,t/2,n/2)),e<=1e-9)return ot(pe(t,n),!0);let r=t/2,o=n/2,s=[],a=(i,c,u)=>{let f=It([i,c],e,e,u,Math.PI/2,!1,1);s.length?(mn(s,s[s.length-1],f.points[0]),s.push(...f.points.slice(1))):s.push(...f.points)};return a(r-e,o-e,0),a(-r+e,o-e,Math.PI/2),a(-r+e,-o+e,Math.PI),a(r-e,-o+e,Math.PI*1.5),mn(s,s[s.length-1],s[0]),s[s.length-1]=[s[0][0],s[0][1]],{points:s,closed:!0}}function pe(t,n){return[[t/2,n/2],[-t/2,n/2],[-t/2,-n/2],[t/2,-n/2]]}function mr(t,n,e){let r=[];for(let o=0;o<t;o++){let s=e+_t*o/t;r.push([n*Math.cos(s),n*Math.sin(s)])}return r}function po(t,n,e,r){let o=[];for(let s=0;s<2*t;s++){let a=r+Math.PI*s/t,i=s%2?e:n;o.push([i*Math.cos(a),i*Math.sin(a)])}return o}function fn(t,n){let e=t.length;if(e<3)return ot(t,n);let r=a=>n?t[(a%e+e)%e]:t[Math.max(0,Math.min(e-1,a))],o=[[t[0][0],t[0][1]]],s=n?e:e-1;for(let a=0;a<s;a++){let i=r(a-1),c=r(a),u=r(a+1),f=r(a+2);o.push([c[0]+(u[0]-i[0])/6,c[1]+(u[1]-i[1])/6],[u[0]-(f[0]-c[0])/6,u[1]-(f[1]-c[1])/6],[u[0],u[1]])}return{points:o,closed:n}}function zt(t,n){return t.map(e=>({points:e.points.map(r=>yt(n,r)),closed:e.closed}))}function hn(t,n){let e=1/0,r=1/0,o=-1/0,s=-1/0;for(let a of t)for(let i of a.points){let c=n?n[0]*i[0]+n[2]*i[1]+n[4]:i[0],u=n?n[1]*i[0]+n[3]*i[1]+n[5]:i[1];c<e&&(e=c),c>o&&(o=c),u<r&&(r=u),u>s&&(s=u)}return e===1/0?null:[e,r,o,s]}function dn(t,n){return t?n?[Math.min(t[0],n[0]),Math.min(t[1],n[1]),Math.max(t[2],n[2]),Math.max(t[3],n[3])]:t:n}function bo(t,n,e,r,o){let s=1-o,a=s*s*s,i=3*s*s*o,c=3*s*o*o,u=o*o*o;return[a*t[0]+i*n[0]+c*e[0]+u*r[0],a*t[1]+i*n[1]+c*e[1]+u*r[1]]}function go(t,n,e,r,o,s){let[a,i,c,u]=ca(t,n,e,r,s);if(o>0){let f=s>0?o/s:0;[a,i,c,u]=ua(a,i,c,u,f)}return[a,i,c,u]}function ca(t,n,e,r,o){let s=Ct(t,n,o),a=Ct(n,e,o),i=Ct(e,r,o),c=Ct(s,a,o),u=Ct(a,i,o),f=Ct(c,u,o);return[t,s,c,f]}function ua(t,n,e,r,o){let s=Ct(t,n,o),a=Ct(n,e,o),i=Ct(e,r,o),c=Ct(s,a,o),u=Ct(a,i,o);return[Ct(c,u,o),u,i,r]}var ln=12,fo=new WeakMap;function fr(t){let n=fo.get(t);if(n)return n;let e=[],r=0;return t.forEach((o,s)=>{let a=o.points;for(let i=0;i+3<a.length;i+=3){let c=new Float64Array(ln+1),u=a[i],f=0;for(let l=1;l<=ln;l++){let m=bo(a[i],a[i+1],a[i+2],a[i+3],l/ln);f+=ia(u,m),c[l]=f,u=m}e.push({sub:s,i,len:f,cum:c}),r+=f}}),n={segs:e,total:r},fo.set(t,n),n}function hr(t){return fr(t).total}function ur(t,n){if(n<=0)return 0;if(n>=t.len)return 1;let e=t.cum,r=1;for(;r<ln&&e[r]<n;)r++;let o=e[r]-e[r-1]||1;return(r-1+(n-e[r-1])/o)/ln}function Fe(t,n,e){if(n<=0&&e>=1)return t;if(e<=n)return[];let r=fr(t),o=r.total;if(o<=1e-12)return e>=1?t:[];let s=n*o,a=e*o,i=[],c=0,u=null,f=-1,l=!0;for(let m of r.segs){let h=c+m.len,p=t[m.sub].points;m.sub!==f&&(u&&i.push({points:u,closed:l&&t[f].closed}),u=null,f=m.sub,l=!0);let d=Math.max(s,c),g=Math.min(a,h);if(g>d||m.len===0&&c>=s&&c<=a){(d>c+1e-12||g<h-1e-12)&&(l=!1);let w=ur(m,d-c),M=ur(m,g-c),S=w<=0&&M>=1?[p[m.i],p[m.i+1],p[m.i+2],p[m.i+3]]:go(p[m.i],p[m.i+1],p[m.i+2],p[m.i+3],w,M);u||(u=[S[0]]),u.push(S[1],S[2],S[3])}else l=!1;c=h}return u&&i.push({points:u,closed:l&&t[f].closed}),i}function we(t,n){var s;let e=fr(t);if(!e.segs.length){let a=(s=t[0])==null?void 0:s.points[0];return a?[a[0],a[1]]:[0,0]}let r=Math.max(0,Math.min(1,n))*e.total,o=0;for(let a of e.segs){if(r<=o+a.len||a===e.segs[e.segs.length-1]){let i=t[a.sub].points;return bo(i[a.i],i[a.i+1],i[a.i+2],i[a.i+3],ur(a,r-o))}o+=a.len}return[0,0]}function yo(t,n,e){let r=hr(t),o=Math.max(2,Math.ceil(r/Math.max(1e-6,n)*e)),s=e/o,i=t.length===1&&t[0].closed?1/o:(1-s)/(o-1),c=[];for(let u=0;u<o;u++){let f=u*i;for(let l of Fe(t,f,Math.min(1,f+s)))c.push({points:l.points,closed:!1})}return c}function lr(t){return Math.max(0,(t.points.length-1)/3)}function ho(t,n){let e=lr(t);if(e===n)return t;let r=t.points;if(e===0){let a=r[0]||[0,0],i=[a];for(let c=0;c<n;c++)i.push(a,a,a);return{points:i,closed:t.closed}}let o=new Array(e).fill(0);for(let a=0;a<n;a++)o[Math.floor(a*e/n)]++;let s=[r[0]];for(let a=0;a<e;a++){let i=o[a],c=r[3*a],u=r[3*a+1],f=r[3*a+2],l=r[3*a+3];if(i<=1){s.push(u,f,l);continue}for(let m=0;m<i;m++){let h=go(c,u,f,l,m/i,(m+1)/i);s.push(h[1],h[2],h[3])}}return{points:s,closed:t.closed}}function _o(t,n,e,r){let o=t.length?t:[{points:[e],closed:!1}],s=n.length?n:[{points:[r],closed:!1}],a=Math.max(o.length,s.length),i=[],c=[],u=(f,l)=>{if(l<f.length)return f[l];let m=f[f.length-1].points;return{points:[m[m.length-1]],closed:!1}};for(let f=0;f<a;f++){let l=u(o,f),m=u(s,f),h=Math.max(lr(l),lr(m),1);i.push(ho(l,h)),c.push(ho(m,h))}return[i,c]}function dr(t,n,e){if(e<=0)return t;if(e>=1)return n;let r=new Array(t.length);for(let o=0;o<t.length;o++){let s=t[o].points,a=n[o].points,i=new Array(s.length);for(let c=0;c<s.length;c++)i[c]=[s[c][0]+(a[c][0]-s[c][0])*e,s[c][1]+(a[c][1]-s[c][1])*e];r[o]={points:i,closed:e<.5?t[o].closed:n[o].closed}}return r}var Ut=0,Ht=class t{constructor(n,e,r){this.shared=!1;this.mobs=n||new Map,this.display=e||[],this.ids=r||{n:-1}}snapshot(){return this.shared=!0,{mobs:this.mobs,display:this.display}}fork(){this.shared=!0;let n=new t(this.mobs,this.display,this.ids);return n.shared=!0,n}own(){this.shared&&(this.mobs=new Map(this.mobs),this.display=this.display.slice(),this.shared=!1)}has(n){return this.mobs.has(n)}get(n){let e=this.mobs.get(n);if(!e)throw new Error(n===Ut?"no camera frame":`that object does not exist (#${n})`);return e}set(n){this.own(),this.mobs.set(n.id,n)}update(n,e){this.set({...this.get(n),...e})}setDisplay(n){this.own(),this.display=n}newId(){return this.ids.n--}};function ne(t){return t.paths.length>0||!!t.text||!!t.image}function st(t,n,e=[],r){let o=t.mobs.get(n);if(!o||(r=r||new Set,r.has(n)))return e;r.add(n),e.push(n);for(let s of o.children)st(t,s,e,r);return e}function et(t,n){return st(t,n).filter(e=>ne(t.mobs.get(e)))}function pr(t,n=t.m){let e=t.paths.length?hn(t.paths,n):null,r=t.text||t.image;if(r){let{w:o,h:s}=r;e=dn(e,hn([{points:[[-o/2,-s/2],[o/2,-s/2],[o/2,s/2],[-o/2,s/2]],closed:!0}],n))}return e}function $(t,n){let e=null;for(let r of st(t,n))e=dn(e,pr(t.mobs.get(r)));if(!e){let r=t.mobs.get(n),o=r?yt(r.m,[0,0]):[0,0];return[o[0],o[1],o[0],o[1]]}return e}function at(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function Et(t,n){let e=(r,o,s)=>s>1e-9?o:s<-1e-9?r:(r+o)/2;return[e(t[0],t[2],n[0]),e(t[1],t[3],n[1])]}function pt(t,n){return at($(t,n))}function At(t,n,e){for(let r of st(t,n)){let o=t.get(r);t.set({...o,m:Y(e,o.m)})}}function vt(t,n,e){for(let r of st(t,n)){let o=t.get(r);t.set({...o,style:e(o.style,o)})}}function Me(t,n,e){let r=t.get(n),o=e!=null?e:t.newId(),s=r.children.map(a=>Me(t,a));return t.set({...r,id:o,children:s,data:r.data?{...r.data}:void 0}),o}function Re(t,n,e){if(n===e)return;let r=t.get(e),o=t.has(n)?t.get(n).children:[],s=o.length&&o.length===r.children.length?o.map((a,i)=>(Re(t,a,r.children[i]),a)):r.children.map(a=>Me(t,a));t.set({...r,id:n,children:s,data:r.data?{...r.data}:void 0})}function Lt(t,n){let e=new Set(n),r=t.display.filter(o=>!e.has(o));for(let o of n)o!==Ut&&!r.includes(o)&&r.push(o);t.setDisplay(r)}function oe(t,n){let e=t.display.slice();for(let r of n){let o=[];for(let s of e)s!==r&&o.push(...xo(t,s,r));e=o}t.setDisplay(e)}function xo(t,n,e){if(n===e)return[];if(!st(t,n).includes(e))return[n];let r=[];for(let o of t.get(n).children)r.push(...xo(t,o,e));return r}function br(t,n){for(let e of t.display)if(e===n||st(t,e).includes(n))return!0;return!1}function H(t,n,e,r=[],o){return{id:t,kind:n,paths:r,m:ft,children:[],style:e,z:0,...o}}var Tt={BLACK:"#000000",BLUE:"#58C4DD",BLUE_A:"#C7E9F1",BLUE_B:"#9CDCEB",BLUE_C:"#58C4DD",BLUE_D:"#29ABCA",BLUE_E:"#236B8E",DARKER_GRAY:"#222222",DARKER_GREY:"#222222",DARK_BLUE:"#236B8E",DARK_BROWN:"#8B4513",DARK_GRAY:"#444444",DARK_GREY:"#444444",GOLD:"#F0AC5F",GOLD_A:"#F7C797",GOLD_B:"#F9B775",GOLD_C:"#F0AC5F",GOLD_D:"#E1A158",GOLD_E:"#C78D46",GRAY:"#888888",GRAY_A:"#DDDDDD",GRAY_B:"#BBBBBB",GRAY_BROWN:"#736357",GRAY_C:"#888888",GRAY_D:"#444444",GRAY_E:"#222222",GREEN:"#83C167",GREEN_A:"#C9E2AE",GREEN_B:"#A6CF8C",GREEN_C:"#83C167",GREEN_D:"#77B05D",GREEN_E:"#699C52",GREY:"#888888",GREY_A:"#DDDDDD",GREY_B:"#BBBBBB",GREY_BROWN:"#736357",GREY_C:"#888888",GREY_D:"#444444",GREY_E:"#222222",LIGHTER_GRAY:"#DDDDDD",LIGHTER_GREY:"#DDDDDD",LIGHT_BROWN:"#CD853F",LIGHT_GRAY:"#BBBBBB",LIGHT_GREY:"#BBBBBB",LIGHT_PINK:"#DC75CD",LOGO_BLACK:"#343434",LOGO_BLUE:"#525893",LOGO_GREEN:"#87C2A5",LOGO_RED:"#E07A5F",LOGO_WHITE:"#ECE7E2",MAROON:"#C55F73",MAROON_A:"#ECABC1",MAROON_B:"#EC92AB",MAROON_C:"#C55F73",MAROON_D:"#A24D61",MAROON_E:"#94424F",ORANGE:"#FF862F",PINK:"#D147BD",PURE_BLUE:"#0000FF",PURE_CYAN:"#00FFFF",PURE_GREEN:"#00FF00",PURE_MAGENTA:"#FF00FF",PURE_RED:"#FF0000",PURE_YELLOW:"#FFFF00",PURPLE:"#9A72AC",PURPLE_A:"#CAA3E8",PURPLE_B:"#B189C6",PURPLE_C:"#9A72AC",PURPLE_D:"#715582",PURPLE_E:"#644172",RED:"#FC6255",RED_A:"#F7A1A3",RED_B:"#FF8080",RED_C:"#FC6255",RED_D:"#E65A4C",RED_E:"#CF5044",TEAL:"#5CD0B3",TEAL_A:"#ACEAD7",TEAL_B:"#76DDC0",TEAL_C:"#5CD0B3",TEAL_D:"#55C1A7",TEAL_E:"#49A88F",WHITE:"#FFFFFF",YELLOW:"#F7D96F",YELLOW_A:"#FFF1B6",YELLOW_B:"#FFEA94",YELLOW_C:"#F7D96F",YELLOW_D:"#F4D345",YELLOW_E:"#E8C11C"},lt="#FFFFFF",Ce="#F7D96F",pn="#FFFF00",wo=["#003F5C","#58508D","#BC5090","#FF6361","#FFA600"],Fn=new Map;function Rn(t){let n=Fn.get(t);if(n!==void 0)return n;let e=t.trim();Tt[e.toUpperCase()]&&(e=Tt[e.toUpperCase()]);let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e);if(r){let o=parseInt(r[1],16);n=[o>>16&255,o>>8&255,o&255]}else(r=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e))?n=[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)]:n=null;return Fn.size>2e3&&Fn.clear(),Fn.set(t,n),n}function Q(t,n){if(typeof t=="string"){let e=t.toUpperCase();return Tt[e]?Tt[e]:t}if(Array.isArray(t)&&t.length>=3){let e=t.some(r=>Number(r)>1)?1:255;return Mo([Number(t[0])*e,Number(t[1])*e,Number(t[2])*e])}return n}function Mo(t){let n=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return"#"+n(t[0])+n(t[1])+n(t[2])}function Ie(t,n,e){if(t===n||e<=0)return t;if(e>=1)return n;let r=Rn(t),o=Rn(n);if(!r||!o)return e<.5?t:n;let s=(a,i)=>Math.floor(a+(i-a)*e+1e-6);return Mo([s(r[0],o[0]),s(r[1],o[1]),s(r[2],o[2])])}var la={"normal|normal":"LiberationSans-Regular.ttf","bold|normal":"LiberationSans-Bold.ttf","normal|italic":"LiberationSans-Italic.ttf","bold|italic":"LiberationSans-BoldItalic.ttf","serif:normal|normal":"KaTeX_Main-Regular.ttf","serif:bold|normal":"KaTeX_Main-Bold.ttf","serif:normal|italic":"KaTeX_Main-Italic.ttf","serif:bold|italic":"KaTeX_Main-BoldItalic.ttf","mono:normal|normal":"KaTeX_Typewriter-Regular.ttf","mono:bold|normal":"KaTeX_Typewriter-Regular.ttf","mono:normal|italic":"KaTeX_Typewriter-Regular.ttf","mono:bold|italic":"KaTeX_Typewriter-Regular.ttf"};function ma(t){let n=String(t||"");return/\.(ttf|otf|woff2?)(\?|#|$)/i.test(n)||/^(blob:|data:|https?:)/.test(n)}function fa(t){let n=String(t||"").toLowerCase();return/mono|courier|consol|menlo|typewriter|code/.test(n)?"mono":/serif/.test(n)&&!/sans/.test(n)||/times|georgia|garamond|roman|palatino|baskerville|cambria|book/.test(n)?"serif":"sans"}function ke(t,n,e){if(e&&ma(e))return"url:"+String(e);let r=String(t||"normal").toLowerCase(),o=String(n||"normal").toLowerCase(),s=r==="bold"||r==="heavy"||r==="ultrabold"||r==="semibold"||Number(r)>=600,a=o==="italic"||o==="oblique",i=e?fa(e):"sans";return`${i==="sans"?"":i+":"}${s?"bold":"normal"}|${a?"italic":"normal"}`}function Po(t){return t.startsWith("url:")?`"${So(t)}", "Liberation Sans", Arial, sans-serif`:t.startsWith("mono:")?'Menlo, Consolas, "Liberation Mono", monospace':t.startsWith("serif:")?'"KaTeX_Main", "Times New Roman", serif':'"Liberation Sans", Arial, sans-serif'}function So(t){let n=0;for(let e of t)n=n*31+e.charCodeAt(0)|0;return"pymations-font-"+(n>>>0).toString(36)}var gr=null;function ha(t,n){let e=globalThis;return e[n]?Promise.resolve(e[n]):typeof document=="undefined"?Promise.reject(new Error("no document to load "+t)):new Promise((r,o)=>{let s=t.slice(t.lastIndexOf("/")+1),a=Array.from(document.scripts).find(u=>u.src&&u.src.split("?")[0].endsWith("/"+s))||null,i=a||document.createElement("script"),c=()=>e[n]?r(e[n]):o(new Error(n+" did not load"));i.addEventListener("load",c),i.addEventListener("error",()=>o(new Error("could not load "+t))),a||(i.src=t,i.async=!0,i.dataset.cirSrc=t,document.head.appendChild(i))})}var Cn=class{constructor(n){this.base=n;this.fonts=new Map;this.loading=new Map;this.cache=new Map;this.chars=new Map}font(n){return this.fonts.get(n)}load(n){if(this.fonts.has(n))return Promise.resolve(this.fonts.get(n));let e=this.loading.get(n);return e||(e=this.fetchFont(n).then(r=>(this.fonts.set(n,r),r),()=>(this.fonts.set(n,null),null)),this.loading.set(n,e),e)}async fetchFont(n){if(!this.base||typeof fetch=="undefined")return null;gr||(gr=ha(this.base+"opentype.min.js","opentype"));let e=await gr,r=n.startsWith("url:")?n.slice(4):this.base+"fonts/"+la[n],o=await fetch(r);if(!o.ok)throw new Error("font "+o.status);let s=await o.arrayBuffer();if(n.startsWith("url:")&&typeof FontFace!="undefined"&&typeof document!="undefined")try{let a=new FontFace(So(n),s.slice(0));await a.load(),document.fonts.add(a)}catch(a){}return e.parse(s)}glyph(n,e,r){let o=`${r}|${e}|${n}`,s=this.chars.get(o);if(s!==void 0)return s;let a=this.fonts.get(r);if(!a)return null;let i=e/a.unitsPerEm,c=a.charToGlyph(n),u=n.trim()?ko(c.path.commands,i,0,0):[],f=1/0,l=-1/0,m=1/0,h=-1/0;for(let p of u)for(let d of p.points)f=Math.min(f,d[1]),l=Math.max(l,d[1]),m=Math.min(m,d[0]),h=Math.max(h,d[0]);return s={paths:u,advance:c.advanceWidth*i,box:u.length?[m,f,h,l]:null},this.chars.size>4e3&&this.chars.clear(),this.chars.set(o,s),s}outline(n,e,r,o=1.2,s=0){let a=`${r}|${e}|${o}|${s}|${n}`;if(this.cache.has(a))return this.cache.get(a);let i=this.fonts.get(r);if(!i)return null;let c=e/i.unitsPerEm,u=[],f=n.split(`
3
- `),l=0;f.forEach((S,b)=>{let _=0,x=-b*o*e,P=null;for(let k of Array.from(S)){let v=i.charToGlyph(k);P&&(_+=i.getKerningValue(P,v)*c),k.trim()&&u.push({char:k,paths:ko(v.path.commands,c,_,x)}),_+=v.advanceWidth*c+s,P=v}l=Math.max(l,_)});let m=1/0,h=1/0,p=-1/0,d=-1/0;for(let S of u)for(let b of S.paths)for(let _ of b.points)_[0]<m&&(m=_[0]),_[0]>p&&(p=_[0]),_[1]<h&&(h=_[1]),_[1]>d&&(d=_[1]);m===1/0&&(m=0,p=l,h=0,d=0);let g=(m+p)/2,w=(h+d)/2;for(let S of u)S.paths=S.paths.map(b=>({points:b.points.map(_=>[_[0]-g,_[1]-w]),closed:b.closed}));let M={glyphs:u,width:p-m,height:d-h};return this.cache.size>500&&this.cache.clear(),this.cache.set(a,M),M}};function ko(t,n,e,r){let o=[],s=null,a=(f,l)=>[e+f*n,r+l*n],i=()=>s[s.length-1],c=f=>{let l=i();s.push([l[0]+(f[0]-l[0])/3,l[1]+(f[1]-l[1])/3],[l[0]+2*(f[0]-l[0])/3,l[1]+2*(f[1]-l[1])/3],f)},u=f=>{s&&s.length>1&&o.push({points:s,closed:f}),s=null};for(let f of t)switch(f.type){case"M":u(!1),s=[a(f.x,f.y)];break;case"L":s&&c(a(f.x,f.y));break;case"Q":{if(!s)break;let l=i(),m=a(f.x1,f.y1),h=a(f.x,f.y);s.push([l[0]+2/3*(m[0]-l[0]),l[1]+2/3*(m[1]-l[1])],[h[0]+2/3*(m[0]-h[0]),h[1]+2/3*(m[1]-h[1])],h);break}case"C":s&&s.push(a(f.x1,f.y1),a(f.x2,f.y2),a(f.x,f.y));break;case"Z":{if(!s)break;let l=s[0],m=i();(Math.abs(l[0]-m[0])>1e-9||Math.abs(l[1]-m[1])>1e-9)&&c([l[0],l[1]]),u(!0);break}}return u(!1),o}function Xe(t){return t/48*.65}var Ao=Tt.RED,In=Tt.BLUE,yr=Tt.BLUE_D,da="#000000";function U(t,n={}){var a,i,c,u;let e=t.color!=null?Q(t.color,lt):null,r=t.stroke_color!=null?Q(t.stroke_color,lt):(a=e!=null?e:n.color)!=null?a:lt,o=t.fill_color!=null?Q(t.fill_color,lt):(i=e!=null?e:n.color)!=null?i:lt,s=t.opacity!=null?y(t.opacity,1):1;return{sc:r,fc:o,sw:y(t.stroke_width,(c=n.sw)!=null?c:4),so:y(t.stroke_opacity,1)*s,fo:y(t.fill_opacity,(u=n.fo)!=null?u:0)*s}}function Yt(t,n,e){return n==null?e:it(t.w,n)}function Eo(t,n,e){let r=null,o=-1/0;for(let s of st(t.w,n)){let a=t.w.get(s);for(let i of zt(a.paths,a.m)){let c=i.points;for(let u=0;u+3<c.length;u+=3)for(let f=0;f<=8;f++){let l=f/8,m=1-l,h=m*m*m*c[u][0]+3*m*m*l*c[u+1][0]+3*m*l*l*c[u+2][0]+l*l*l*c[u+3][0],p=m*m*m*c[u][1]+3*m*m*l*c[u+1][1]+3*m*l*l*c[u+2][1]+l*l*l*c[u+3][1],d=h*e[0]+p*e[1];d>o&&(o=d,r=[h,p])}}}return r||at($(t.w,n))}function Le(t,n,e){let r=(i,c)=>i==null?c:Ft(i)?at($(t.w,W(t.w,i))):it(t.w,i),o=r(n,[-1,0]),s=r(e,[1,0]),a=[s[0]-o[0],s[1]-o[1]];return Ft(n)&&(o=Eo(t,W(t.w,n),a)),Ft(e)&&(s=Eo(t,W(t.w,e),[-a[0],-a[1]])),[o,s]}function X(t,n,e,r,o,s,a){let i=H(n,e,o,s,{z:y(r.z_index,0),...a});return t.w.set(i),i}function _r(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1]);if(r<=2*e||e<=0)return[t,n];let o=(n[0]-t[0])/r,s=(n[1]-t[1])/r;return[[t[0]+o*e,t[1]+s*e],[n[0]-o*e,n[1]-s*e]]}function Ue(t,n,e,r,o){let s=t[0]-n*r,a=t[1]-e*r,i=-e*o/2,c=n*o/2;return[ot([t,[s+i,a+c],[s-i,a-c]],!0)]}function bn(t,n,e,r,o,s,a,i){let[c,u]=_r(o,s,a),f=Math.hypot(u[0]-c[0],u[1]-c[1])||1e-9,l=(u[0]-c[0])/f,m=(u[1]-c[1])/f,h=Math.min(y(r.tip_length,.35),y(r.max_tip_length_to_length_ratio,.25)*f),p=i?Math.max(0,f-2*h):f,d=Math.min(y(r.stroke_width,6),y(r.max_stroke_width_to_length_ratio,5)*p),g=U({...r,stroke_width:d},{sw:6}),w=i?[c[0]+l*h,c[1]+m*h]:c,M=[u[0]-l*h,u[1]-m*h],S={...g,fc:g.sc,fo:1,sw:0},b=[],_=t.w.newId();if(t.w.set(H(_,"tip",S,Ue(u,l,m,h,h))),b.push(_),i){let x=t.w.newId();t.w.set(H(x,"tip",S,Ue(c,-l,-m,h,h))),b.push(x)}X(t,n,e,r,g,[dt(w,M)],{children:b,data:{start:c,end:u}})}function Bn(t,n,e=!1){let o=(n>0?t.toFixed(n):String(Math.round(t))).replace(/^-/,"\u2212");return e&&t>=0?"+"+o:o}function ae(t,n,e,r,o){let s=ke(r.weight,r.slant,r.font);if(t.text.font(s)===void 0)return t.text.load(s).then(()=>ae(t,n,e,r,o));let a=Xe(y(r.font_size,48)),i=U(r,{sw:0,fo:1}),c=t.text.outline(o,a,s,y(r.line_spacing,1.2),y(r.letter_spacing,0)*a);if(!c){let m=o.split(`
4
- `),h=Math.max(...m.map(w=>w.length))*a*.55,p=m.length*a*.75,[d,g]=s.replace(/^[a-z]+:/,"").split("|");X(t,n,e,r,i,[],{text:{str:o,em:a,weight:s.startsWith("url:")?"normal":d,slant:s.startsWith("url:")?"normal":g,w:h,h:p,family:s},data:{text:o}});return}let u=c.glyphs.map(()=>null),f=r.t2c||r.text_to_color_map;if(f&&typeof f=="object"){let m=Array.from(o).filter(h=>h.trim()).join("");for(let h of Object.keys(f)){let p=Array.from(h).filter(g=>g.trim()).join("");if(!p)continue;let d=m.indexOf(p);for(;d>=0;){for(let g=d;g<d+Array.from(p).length&&g<u.length;g++)u[g]=Q(f[h],lt);d=m.indexOf(p,d+1)}}}let l=c.glyphs.map((m,h)=>{let p=t.w.newId(),d=u[h];return t.w.set(H(p,"glyph",d?{...i,sc:d,fc:d}:i,m.paths,{data:{char:m.char}})),p});X(t,n,e,r,i,[],{children:l,data:{text:o}})}function yn(t,n,e,r,o){var h,p;let s=(p=(h=r.parts)!=null?h:r.tex_strings)!=null?p:r.tex!=null?[r.tex]:[];Array.isArray(s)||(s=[String(s)]),s=s.map(String);let a=y(r.font_size,48),i=r.arg_separator!=null?String(r.arg_separator):o==="math"?" ":"",c=r.tex_environment!=null?String(r.tex_environment):r.environment!=null?String(r.environment):void 0,u=`${o}|${a}|${i}|${c!=null?c:""}|${s.join("")}`,f=d=>{let g=U(r,{sw:0,fo:1}),w=d.parts.map((M,S)=>{var x;let b=t.w.newId(),_=M.map(P=>{let k=t.w.newId();return t.w.set(H(k,"glyph",g,P)),k});return t.w.set(H(b,"tex_part",g,[],{children:_,data:{tex:(x=s[S])!=null?x:""}})),b});X(t,n,e,r,g,[],{children:w,data:{tex:s.join(i),parts:s}})},l=t.texCache.get(u);if(l&&!(l instanceof Promise))return f(l);if(!t.tex)throw new Error("MathTex is not available in this preview");let m=l||t.tex({tex:s.join(i),mode:o,parts:s,fontSize:a,...c?{environment:c}:{}});return t.texCache.set(u,m),m.then(d=>{t.texCache.set(u,d),f(d)},d=>{throw t.texCache.delete(u),d})}function xr(t,n){return Array.isArray(t)?[y(t[0],n[0]),y(t[1],n[1]),y(t[2],1)]:n}function vo(t){let n=[],[e,r,o]=t;if(o<=0)return n;let s=Math.floor((r-e)/o+1e-9);for(let a=0;a<=s&&a<1e3;a++)n.push(+(e+a*o).toFixed(10));return n}function Ln(t,n,e,r,o){let s=[];if(r<=0)return s;let a=1e-9,i=Math.ceil((t-e)/r-a),c=Math.floor((n-e)/r+a);for(let u=i;u<=c&&s.length<2e3;u++){let f=+(e+u*r).toFixed(10);!o&&(Math.abs(f-t)<a||Math.abs(f-n)<a)||s.push(f)}return s}function pa(t){let n=String(+t.toFixed(6)),e=n.indexOf(".");return e<0?0:Math.min(3,n.length-e-1)}function wr(t,n){var r,o,s,a,i,c,u,f,l,m,h,p,d,g,w,M;let e=y((r=t.tip_height)!=null?r:t.tip_length,.35);return{color:Q((a=(s=(o=t.color)!=null?o:t.stroke_color)!=null?s:n.color)!=null?a:lt,lt),sw:y(t.stroke_width,(i=n.sw)!=null?i:2),tip:(u=(c=t.include_tip)!=null?c:n.tip)!=null?u:!1,tipLen:e,tipWidth:y(t.tip_width,e),ticks:(l=(f=t.include_ticks)!=null?f:n.ticks)!=null?l:!0,tickSize:y(t.tick_size,.1),numbers:(h=(m=t.include_numbers)!=null?m:n.numbers)!=null?h:!1,fontSize:y(t.font_size,(p=n.fontSize)!=null?p:36),exclude:((g=(d=t.numbers_to_exclude)!=null?d:n.exclude)!=null?g:[]).map(Number),numberBuff:y(t.line_to_number_buff,(w=n.numberBuff)!=null?w:.25),labelDir:Array.isArray(t.label_direction)?[Number(t.label_direction[0]),Number(t.label_direction[1])]:(M=n.labelDir)!=null?M:[0,-1]}}function Mr(t,n,e,r,o,s,a=[]){let i=o(e[0]),c=o(e[1]),u={sc:r.color,fc:r.color,sw:r.sw,so:1,fo:0},f=[],l=-s[1],m=s[0],h=d=>a.some(g=>Math.abs(g-d)<1e-9);if(r.ticks){let d=vo(e).filter(w=>!h(w)).map(w=>{let M=o(w),S=t.w.newId();return t.w.set(H(S,"tick",u,[dt([M[0]-l*r.tickSize,M[1]-m*r.tickSize],[M[0]+l*r.tickSize,M[1]+m*r.tickSize])])),S}),g=t.w.newId();t.w.set(H(g,"group",u,[],{children:d})),f.push(g)}let p=c;if(r.tip){let d=t.w.newId();t.w.set(H(d,"tip",{...u,fo:1,sw:0},Ue(c,s[0],s[1],r.tipLen,r.tipWidth))),f.push(d),p=[c[0]-s[0]*r.tipLen,c[1]-s[1]*r.tipLen]}if(r.numbers){let d=pa(e[2]),g=vo(e).filter(S=>!r.exclude.some(b=>Math.abs(b-S)<1e-9)&&!(r.tip&&Math.abs(S-e[1])<1e-9)),w=t.w.newId(),M=g.map(S=>{let b=t.w.newId();ae(t,b,"text",{font_size:r.fontSize,color:r.color},Bn(S,d));let _=o(S),x=$(t.w,b),P=r.labelDir,k=(x[2]-x[0])/2,v=(x[3]-x[1])/2,C=_[0]+P[0]*(r.numberBuff+k),F=_[1]+P[1]*(r.numberBuff+v);return Oe(t.w,b,Z(C-(x[0]+x[2])/2,F-(x[1]+x[3])/2)),b});t.w.set(H(w,"group",u,[],{children:M})),f.push(w)}t.w.set(H(n,"number_line",u,[dt(i,p)],{children:f,data:{start:i,end:c}}))}function Oe(t,n,e){for(let r of st(t,n)){let o=t.get(r);t.set({...o,m:Y(e,o.m)})}}function To(t){return t[0]>0?t[0]:t[1]<0?t[1]:0}function ba(...t){return t.some(n=>n&&n.include_numbers)}function Ye(t,n,e,r){var C,F,T,I,B;let o=e==="number_plane",s=r.axis_config||{},a={...s,...r.x_axis_config||{}},i={...s,...r.y_axis_config||{}};if(r.include_numbers!=null&&((C=a.include_numbers)!=null||(a.include_numbers=r.include_numbers),(F=i.include_numbers)!=null||(i.include_numbers=r.include_numbers)),ba(a,i)){let L=ke("normal","normal");if(t.text.font(L)===void 0)return t.text.load(L).then(()=>Ye(t,n,e,r))}let c=t.fw,u=t.fh,f=xr(r.x_range,o?[-c/2,c/2,1]:[-Math.round(c/2),Math.round(c/2),1]),l=xr(r.y_range,[-u/2,u/2,1]),m=y(r.x_length,o?f[1]-f[0]:Math.round(c)-2),h=y(r.y_length,o?l[1]-l[0]:Math.round(u)-2),p={x0:f[0],y0:l[0],sx:m/(f[1]-f[0]||1),sy:h/(l[1]-l[0]||1),ox:-m/2,oy:-h/2},d=(L,D)=>Nt(p,L,D),g=r.color!=null?Q(r.color,lt):void 0,w=(T=r.tips)!=null?T:!o,M=o?{color:g!=null?g:lt,sw:2,tip:!1,ticks:!1,numberBuff:.1,fontSize:24,labelDir:[1,-1]}:{color:g!=null?g:lt,sw:2,tip:w,exclude:[0]},S=wr(a,{...M}),b=wr(i,{...M,labelDir:o?[1,-1]:[-1,0]}),_=To(l),x=To(f),P=[];if(o){let L=r.background_line_style||{},D={sc:Q((B=(I=L.stroke_color)!=null?I:L.color)!=null?B:yr,yr),fc:yr,sw:y(L.stroke_width,2),so:y(L.stroke_opacity,1),fo:0},j=(wt,Jt)=>[...wt.map(Qt=>dt(d(Qt,l[0]),d(Qt,l[1]))),...Jt.map(Qt=>dt(d(f[0],Qt),d(f[1],Qt)))],J=t.w.newId(),ut=t.w.newId(),G=Ln(f[0],f[1],x,f[2],!1),ct=Ln(l[0],l[1],_,l[2],!1);t.w.set(H(J,"background_lines",D,j(G,ct)));let ht=Math.round(y(r.faded_line_ratio,1)),Kt=[];if(ht>1){let wt=(Jt,Qt)=>Jt.filter(Gt=>!Qt.some(ye=>Math.abs(ye-Gt)<1e-9));Kt=j(wt(Ln(f[0],f[1],x,f[2]/ht,!0),G),wt(Ln(l[0],l[1],_,l[2]/ht,!0),ct))}t.w.set(H(ut,"faded_lines",{...D,sw:D.sw/2,so:D.so*.5},Kt)),P.push(J,ut)}let k=t.w.newId(),v=t.w.newId();Mr(t,k,f,S,L=>d(L,_),[1,0],o?[]:[x,...S.tip?[f[1]]:[]]),Mr(t,v,l,b,L=>d(x,L),[0,1],o?[]:[_,...b.tip?[l[1]]:[]]),t.w.update(k,{data:{...t.w.get(k).data,axes:{...p,sy:0,oy:d(0,_)[1],y0:0}}}),t.w.update(v,{data:{...t.w.get(v).data,axes:{x0:l[0],y0:0,sx:0,sy:p.sy,ox:d(x,0)[0],oy:p.oy}}}),P.push(k,v),X(t,n,e,r,{sc:lt,fc:lt,sw:2,so:1,fo:0},[],{children:P,data:{axes:p,props:r}})}function Lo(t,n,e){if(e.include_numbers){let i=ke("normal","normal");if(t.text.font(i)===void 0)return t.text.load(i).then(()=>Lo(t,n,e))}let r=xr(e.x_range,[-7,7,1]),o=y(e.length,y(e.unit_size,1)*(r[1]-r[0])),s={x0:r[0],y0:0,sx:o/(r[1]-r[0]||1),sy:0,ox:-o/2,oy:0},a=wr(e,{color:e.color!=null?Q(e.color,lt):lt,sw:2,tip:!1});Mr(t,n,r,a,i=>Nt(s,i,0),[1,0]),t.w.update(n,{z:y(e.z_index,0),data:{...t.w.get(n).data,axes:s}})}function ga(t,n,e){var l;let r=null,o;if(e.axes!=null){let m=t.w.get(W(t.w,e.axes));if(r=(l=m.data)==null?void 0:l.axes,!r)throw new Error("plot needs Axes, a NumberPlane or a NumberLine");o=m.m}let s=[],a=[],i=m=>{let h=[],p=[];for(let d of m){if(!(Array.isArray(d)&&Number.isFinite(Number(d[0]))&&Number.isFinite(Number(d[1])))){h.length&&(s.push(h),a.push(p)),h=[],p=[];continue}let w=Number(d[0]),M=Number(d[1]);h.push(r?Nt(r,w,M):[w,M]),p.push([w,M])}h.length&&(s.push(h),a.push(p))};if(Array.isArray(e.segments))for(let m of e.segments)i(m);else i(e.points||[]);let c=e.use_smoothing!==!1&&e.smooth!==!1,u=!!e.closed,f=s.filter(m=>m.length>=2).map(m=>c?fn(m,u):ot(m,u));Array.isArray(e.color)&&typeof e.color[0]=="string"&&(e={...e,color:e.color[0]}),X(t,n,"graph",e,U(e,{color:Ce}),f,{...o?{m:o}:{},data:{...r?{axes:r}:{},samples:a}})}var On=null;function Oo(t){On=t}var He=new Map;function re(t){let n=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of t)for(let a of s.points)a[0]<n&&(n=a[0]),a[0]>r&&(r=a[0]),a[1]<e&&(e=a[1]),a[1]>o&&(o=a[1]);return[n,e,r,o]}function Nn(t,n,e){return t.map(r=>({closed:r.closed,points:r.points.map(o=>[o[0]-n,o[1]-e])}))}async function ya(t,n){let e=d=>t({tex:d,mode:"math",parts:[d],fontSize:n}).then(g=>g.parts.flat()),[r,o,s,a,i]=await Promise.all([e("0123456789"),e("0.0"),e("-0"),e("+0"),e("0{,}0")]),c=new Map;if(r.length!==10)throw new Error("unexpected digit layout");let u=r.map(re),f=d=>(d[0]+d[2])/2,l=(f(u[9])-f(u[0]))/9,m=u[0][1];r.forEach((d,g)=>{let w=f(u[g])-l/2,M=Nn(d,w,m);c.set(String(g),{paths:M,advance:l,box:re(M)})});let h=(d,g)=>{if(d.length!==3)return;let w=re(d[0]),M=re(d[2]),S=f(w)+l/2,b=f(M)-l/2,_=Nn(d[1],S,w[1]);c.set(g,{paths:_,advance:b-S,box:re(_)})};h(o,"."),h(i,",");let p=(d,g)=>{if(d.length!==2)return;let w=re(d[0]),M=re(d[1]),S=w[0],b=f(M)-l/2,_=Nn(d[0],S,M[1]);c.set(g,{paths:_,advance:b-S,box:re(_)})};return p(s,"-"),p(s,"\u2212"),p(a,"+"),c}function _a(t,n){let e=He.get(n);if(e)return e;if(!t||!t.tex)return null;let r=ya(t.tex,n).then(o=>(He.set(n,o),o),()=>(He.delete(n),null));return He.set(n,r),r}function Sr(t,n){let e=Bn(n,t.places,t.sign);if(t.commas){let[o,s]=e.split(".");e=o.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(s!=null?"."+s:"")}let r=Array.from(e);return t.ellipsis&&r.push("\\ldots"),t.unit&&r.push(t.unit),r}function Ar(t,n){return Sr(t,n).map(e=>e==="\\ldots"?"\u2026":e).join("")}function kr(t,n){if(t.src==="tex"){let o=He.get(t.fontSize);if(o&&!(o instanceof Promise)){let s=o.get(n)||(n==="\u2212"?o.get("-"):null);if(s)return s}}if(!On)return null;if(n.length===1||Array.from(n).length===1)return On.glyph(n,t.em,t.key);let e=[],r=0;for(let o of Array.from(n==="\\ldots"?"\u2026":n.replace(/\\text\{([^}]*)\}/g,"$1"))){let s=On.glyph(o,t.em,t.key);if(!s)return null;e.push(...s.paths.map(a=>({closed:a.closed,points:a.points.map(i=>[i[0]+r,i[1]])}))),r+=s.advance}return{paths:e,advance:r,box:e.length?re(e):null}}var No=t=>.048*(t.fontSize/48);function Bo(t,n,e,r,o){let s=Sr(e,e.value),a=s.map(f=>kr(e,f));if(a.some(f=>!f)){let f=Ar(e,e.value),l=f.length*e.em*.55;return{children:[],text:{str:f,em:e.em,weight:e.key.split("|")[0],slant:e.key.split("|")[1],w:l,h:e.em*.75}}}let i=e.left,c=No(e),u=[];return s.forEach((f,l)=>{let m=a[l];if(!m.paths.length||!m.box){i+=m.advance;return}let h=i-m.box[0],p=t.newId();t.set(H(p,"glyph",r,m.paths,{m:Y(o,Z(h,-e.mid)),data:{char:f}})),u.push(p),i+=m.box[2]-m.box[0]+c}),{children:u}}function xa(t,n,e){let r=He.get(n);if(!(!r||r instanceof Promise||r.has(e)||!t.tex))return t.tex({tex:e,mode:"math",parts:[e],fontSize:n}).then(o=>{let s=o.parts.flat().flat();if(!s.length)return;let a=re(s),i=Nn(s,a[0],a[1]);r.set(e,{paths:i,advance:a[2]-a[0],box:re(i)})},()=>{})}function gn(t,n,e,r){var w;let o=ke(r.weight,r.slant);if(t.text.font(o)===void 0)return t.text.load(o).then(()=>gn(t,n,e,r));let s=y(r.font_size,48),a=_a(t,s);if(a instanceof Promise)return a.then(()=>gn(t,n,e,r));let i=r.unit!=null&&r.unit!==""?String(r.unit):"";for(let M of[i,r.show_ellipsis?"\\ldots":""]){if(!M)continue;let S=xa(t,s,M);if(S)return S.then(()=>gn(t,n,e,r))}let c=r.num_decimal_places!=null?y(r.num_decimal_places,2):e==="integer"?0:2,u=Xe(s),f={value:y((w=r.number)!=null?w:r.value,0),places:c,sign:!!r.include_sign,unit:a?i:i.replace(/^\^\\circ$/,"\xB0").replace(/\\circ/g,"\xB0").replace(/\\text\{([^}]*)\}/g,"$1"),em:u,key:o,left:0,mid:0,text:"",src:a?"tex":"text",fontSize:s,commas:r.group_with_commas!==!1,ellipsis:!!r.show_ellipsis},l=kr(f,"0");f.mid=l&&l.box?(l.box[1]+l.box[3])/2:u*.35;let m=0,h=0;for(let M of Sr(f,f.value)){let S=kr(f,M);S&&S.box&&(m+=S.box[2]-S.box[0],h++)}m+=Math.max(0,h-1)*No(f),f.left=-m/2,f.text=Ar(f,f.value);let p=U(r,{sw:0,fo:1}),{children:d,text:g}=Bo(t.w,n,f,p,ft);X(t,n,e,r,p,[],{children:d,text:g,data:{...f,number:!0}})}function Vt(t,n,e){let r=t.get(n),o=r.data;if(!o||!o.number){t.update(n,{data:{...r.data||{},value:e}});return}if(o.value===e&&!r.text)return;let s={...o,value:e},a=r.children.length?t.get(r.children[0]).style:r.style,{children:i,text:c}=Bo(t,n,s,a,r.m);s.text=Ar(o,e),t.set({...r,children:i,text:c,data:s})}function Do(t){return!!(t.data&&t.data.number)}var Pr=null;function Wo(t){Pr=t}function Fo(t,n,e,r,o,s){for(let a=s.length?1:0;a<=o;a++){let i=a/o,c=1-i;s.push([c*c*c*t[0]+3*c*c*i*n[0]+3*c*i*i*e[0]+i*i*i*r[0],c*c*c*t[1]+3*c*c*i*n[1]+3*c*i*i*e[1]+i*i*i*r[1]])}}var jo=.273;function wa(t){let e=Math.min(.18,t/4),r=t/2,o=[];Fo([-r,0],[-r,-.25*.45],[-r+e*.3,-.25/2],[-r+e,-.25/2],16,o),o.push([-e,-.25/2]);let s=[];Fo([-e,-.25/2],[-e*.3,-.25/2],[0,-.25*.55],[0,-.25],16,s),o.push(...s.slice(1));let a=[...o,...o.slice(0,-1).reverse().map(g=>[-g[0],g[1]])],i=a.length,c=[],u=[];for(let g=0;g<i;g++){let w=a[Math.max(0,g-1)],M=a[Math.min(i-1,g+1)],S=M[0]-w[0],b=M[1]-w[1],_=Math.hypot(S,b)||1;S/=_,b/=_;let x=g/(i-1),P=.016+.045*Math.sin(Math.PI*((x<=.5?x:1-x)*2));c.push([a[g][0]-b*P/2,a[g][1]+S*P/2]),u.push([a[g][0]+b*P/2,a[g][1]-S*P/2])}let f=[...c,...u.reverse()],l=-1/0,m=1/0,h=0;for(let g of f)l=Math.max(l,g[1]),m=Math.min(m,g[1]),h=Math.max(h,Math.abs(g[0]));let p=jo/(l-m||1),d=r/(h||1);return[ot(f.map(g=>[g[0]*d,(g[1]-l)*p]),!0)]}function Ve(t,n,e){let r=Array.isArray(n)?n:[n],o=null;for(let s of r)for(let a of st(t,W(t,s))){let i=t.get(a);(i.paths.length||i.text)&&(o=dn(o,pr(i,e?Y(e,i.m):i.m)))}return o||[0,0,0,0]}function Ma(t,n,e){var m;let r=t.w,o=e.direction?it(r,e.direction):[0,-1],s=Math.atan2(o[1],o[0])+Math.PI/2,a=y(e.buff,.2),i=te(-s,[0,0]),c=(m=e.target)!=null?m:e.mobject,u;if(c!=null)u=Ve(r,c,i);else{let h=yt(i,Yt(t,e.start,[-1,0])),p=yt(i,Yt(t,e.end,[1,0]));u=[Math.min(h[0],p[0]),Math.min(h[1],p[1]),Math.max(h[0],p[0]),Math.max(h[1],p[1])]}let f=u[2]-u[0],l=Y(te(s,[0,0]),Z((u[0]+u[2])/2,u[1]-a));X(t,n,"brace",e,U(e,{sw:0,fo:1}),wa(Math.max(f,.1)),{m:l,data:{tip:[0,-jo],start:[-f/2,0],end:[f/2,0]}})}function Ro(t,n){if(Array.isArray(t))return[y(t[0],n),y(t[1],n)];let e=y(t,n);return[e,e]}function se(t,n={},e){return(r,o,s,a)=>{let i=e?e(s,r):null;X(r,o,a,s,U(s,n),t(s,r),i?{m:Z(i[0],i[1])}:void 0)}}var Co=(t,n)=>t.arc_center!=null?Yt(n,t.arc_center,[0,0]):null;function Io(t,n){var r,o;return((o=(r=n.vertices)!=null?r:n.points)!=null?o:[]).map(s=>it(t.w,s))}var Er={circle:se(t=>[ee([0,0],y(t.radius,1))],{color:Ao},Co),dot:se(t=>[ee([0,0],y(t.radius,.08))],{sw:0,fo:1},(t,n)=>Yt(n,t.point,[0,0])),point:se(()=>[],{},(t,n)=>{var e;return Yt(n,(e=t.location)!=null?e:t.point,[0,0])}),square:se(t=>[ot(pe(y(t.side_length,2),y(t.side_length,2)),!0)]),rectangle:se(t=>[ot(pe(y(t.width,4),y(t.height,2)),!0)]),rounded_rectangle:se(t=>[Ge(y(t.width,4),y(t.height,2),y(t.corner_radius,.5))]),ellipse:se(t=>[It([0,0],y(t.width,2)/2,y(t.height,1)/2,0,_t,!0)],{color:Ao},Co),arc:(t,n,e,r)=>{let o=Yt(t,e.arc_center,[0,0]);X(t,n,r,e,U(e),[It(o,y(e.radius,1),y(e.radius,1),y(e.start_angle,0),y(e.angle,_t/4),!1,8)])},annulus:(t,n,e,r)=>{let o=Yt(t,e.arc_center,[0,0]),s=y(e.inner_radius,1),a=y(e.outer_radius,2);X(t,n,r,e,U(e,{sw:0,fo:1}),[It(o,a,a,0,_t,!0),It(o,s,s,0,-_t,!0)])},triangle:se(t=>[ot(mr(3,y(t.radius,1),y(t.start_angle,Math.PI/2)),!0)],{color:In}),regular_polygon:se(t=>{let n=Math.max(3,Math.round(y(t.n,6)));return[ot(mr(n,y(t.radius,1),y(t.start_angle,n%2?Math.PI/2:0)),!0)]},{color:In}),star:se(t=>{let n=Math.max(2,Math.round(y(t.n,5))),e=y(t.outer_radius,1),r=y(t.density,2),o=t.inner_radius!=null?y(t.inner_radius,.4):e*Math.cos(Math.PI*r/n)/Math.cos(Math.PI*(r-1)/n);return[ot(po(n,e,o,y(t.start_angle,Math.PI/2)),!0)]},{color:In}),polygon:(t,n,e,r)=>{X(t,n,r,e,U(e,{color:In}),[ot(Io(t,e),!0)])},polyline:(t,n,e,r)=>{X(t,n,r,e,U(e),[ot(Io(t,e),!1)])},vmobject:(t,n,e,r)=>{var c;let o=Array.isArray(e.subpaths)?e.subpaths:[e.points||[]],s=(c=e.mode)!=null?c:e.smooth?"smooth":"corners",a=!!e.closed,i=o.map(u=>{let f=u.map(l=>it(t.w,l));return s==="bezier"?{points:f,closed:a}:s==="smooth"?fn(f,a):ot(f,a)}).filter(u=>u.points.length);X(t,n,r,e,U(e),i)},line:(t,n,e,r)=>{let[o,s]=_r(...Le(t,e.start,e.end),y(e.buff,0));X(t,n,r,e,U(e),[dt(o,s)],{data:{start:o,end:s}})},dashed_line:(t,n,e,r)=>{let[o,s]=_r(...Le(t,e.start,e.end),y(e.buff,0)),a=U(e),i=yo([dt(o,s)],y(e.dash_length,.05),y(e.dashed_ratio,.5)).map(c=>{let u=t.w.newId();return t.w.set(H(u,"dash",a,[c])),u});X(t,n,r,e,a,[],{children:i,data:{start:o,end:s}})},arrow:(t,n,e,r)=>bn(t,n,r,e,...Le(t,e.start,e.end),y(e.buff,.25),!1),double_arrow:(t,n,e,r)=>bn(t,n,r,e,...Le(t,e.start,e.end),y(e.buff,.25),!0),vector:(t,n,e,r)=>bn(t,n,r,e,[0,0],Yt(t,e.direction,[1,0]),y(e.buff,0),!1),group:(t,n,e,r)=>{let o=(e.children||[]).map(s=>W(t.w,s));X(t,n,r,e,U(e),[],{children:o})},text:(t,n,e,r)=>{var o;return ae(t,n,r,e,String((o=e.text)!=null?o:""))},decimal_number:(t,n,e,r)=>gn(t,n,r,e),value_tracker:(t,n,e,r)=>{X(t,n,r,e,U(e),[],{data:{value:y(e.value,0)}})},variable:(t,n,e,r)=>{var m,h,p;let o=ke("normal","normal");if(t.text.font(o)===void 0)return t.text.load(o).then(()=>Er.variable(t,n,e,r));let s=t.w.newId(),a=t.w.newId(),i=typeof e.var=="number"?e.var:e.var!=null?Number((h=(m=t.w.get(W(t.w,e.var)).data)==null?void 0:m.value)!=null?h:0):y(e.value,0);ae(t,s,"text",{font_size:e.font_size,color:e.color},`${(p=e.label)!=null?p:"x"} =`),gn(t,a,"decimal_number",{number:i,num_decimal_places:e.num_decimal_places,font_size:e.font_size,color:e.color}),X(t,n,r,e,U(e),[],{children:[s,a]});let c=t.w.get(n).children,u=$(t.w,c[0]),f=$(t.w,c[1]);Oe(t.w,c[1],Z(u[2]+.2-f[0],(u[1]+u[3])/2-(f[1]+f[3])/2));let l=at($(t.w,n));Oe(t.w,n,Z(-l[0],-l[1]))},traced_path:(t,n,e,r)=>{var o;X(t,n,r,e,U(e,{sw:y(e.stroke_width,2)}),[],{data:{trace:{point:(o=e.point)!=null?o:e.traced_point,dissipating:e.dissipating_time!=null?y(e.dissipating_time,0):null}}})},pyctures_canvas:(t,n,e,r)=>{var f,l;let o=y(e.width,4),s=y(e.height,3),a=Math.max(1,Math.round(y((f=e.px_width)!=null?f:e.pixel_width,o*100))),i=Math.max(1,Math.round(y((l=e.px_height)!=null?l:e.pixel_height,s*100))),c=e.canvas&&typeof e.canvas=="object"?e.canvas:Pr?Pr(a,i):null,u=e.point!=null?Yt(t,e.point,[0,0]):null;X(t,n,r,e,U({fill_opacity:1,...e},{sw:0}),[],{image:{src:c,w:o,h:s,fullW:o,fullH:s,live:!0},...u?{m:Z(u[0],u[1])}:{},data:{pxW:a,pxH:i}})},mathtex:(t,n,e,r)=>yn(t,n,r,e,"math"),tex:(t,n,e,r)=>yn(t,n,r,e,"text"),axes:(t,n,e,r)=>Ye(t,n,r,e),number_plane:(t,n,e,r)=>Ye(t,n,r,e),number_line:(t,n,e)=>Lo(t,n,e),graph:(t,n,e)=>ga(t,n,e),brace:(t,n,e)=>Ma(t,n,e),surrounding_rectangle:(t,n,e,r)=>{var u;let o=Ve(t.w,(u=e.target)!=null?u:e.mobject),[s,a]=Ro(e.buff,.1),i=o[2]-o[0]+2*s,c=o[3]-o[1]+2*a;X(t,n,r,e,U(e,{color:pn}),[Ge(i,c,y(e.corner_radius,0))],{m:Z((o[0]+o[2])/2,(o[1]+o[3])/2)})},background_rectangle:(t,n,e,r)=>{var u;let o=Ve(t.w,(u=e.target)!=null?u:e.mobject),[s,a]=Ro(e.buff,0),i=o[2]-o[0]+2*s,c=o[3]-o[1]+2*a;X(t,n,r,e,U({fill_opacity:.75,stroke_opacity:0,...e},{color:da,sw:0}),[ot(pe(i,c),!0)],{m:Z((o[0]+o[2])/2,(o[1]+o[3])/2)})}},ka={vgroup:"group",v_group:"group",mobject:"group",v_mobject:"vmobject",math_tex:"mathtex",integer:"decimal_number",regular_polygram:"regular_polygon",surrounding_rect:"surrounding_rectangle",round_rectangle:"rounded_rectangle",plot:"graph",parametric_function:"graph"};function Pa(t){let n=String(t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase();return ka[n]||n}var zo=()=>[...Object.keys(Er),...Object.keys(vr)];function _n(t,n,e,r){let o=Pa(e),s=Er[o]||vr[o];if(!s)throw new Error(`the animation layer cannot make "${e}" yet`);return s(t,n,Ot(r,[]),String(e).toLowerCase()==="integer"?"integer":o)}var Xt=(t,n,e)=>[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e],be=class{constructor(){this.subpaths=[];this.cur=null;this.start=[0,0]}get current(){return this.cur?this.cur[this.cur.length-1]:this.start}moveTo(n){this.flush(!1),this.cur=[n],this.start=n}lineTo(n){let e=this.ensure();this.cur.push(Xt(e,n,1/3),Xt(e,n,2/3),n)}quadTo(n,e){let r=this.ensure();this.cur.push(Xt(r,n,2/3),Xt(e,n,2/3),e)}cubicTo(n,e,r){this.ensure(),this.cur.push(n,e,r)}close(){if(!this.cur)return;let n=this.cur[this.cur.length-1];(n[0]!==this.start[0]||n[1]!==this.start[1])&&this.lineTo(this.start),this.flush(!0)}finish(){return this.flush(!1),this.subpaths}ensure(){return this.cur||(this.cur=[this.start]),this.cur[this.cur.length-1]}flush(n){this.cur&&this.cur.length>1&&this.subpaths.push({points:this.cur,closed:n}),this.cur=null}};function Ko(t,n,e,r,o,s,a){if(t[0]===a[0]&&t[1]===a[1])return[];if(n=Math.abs(n),e=Math.abs(e),n===0||e===0)return[Xt(t,a,1/3),Xt(t,a,2/3),a];let i=r*Math.PI/180,c=Math.cos(i),u=Math.sin(i),f=(t[0]-a[0])/2,l=(t[1]-a[1])/2,m=c*f+u*l,h=-u*f+c*l,p=m*m/(n*n)+h*h/(e*e);if(p>1){let L=Math.sqrt(p);n*=L,e*=L}let d=n*n*e*e-n*n*h*h-e*e*m*m,g=n*n*h*h+e*e*m*m,w=Math.sqrt(Math.max(0,d/g));o===s&&(w=-w);let M=w*n*h/e,S=-w*e*m/n,b=c*M-u*S+(t[0]+a[0])/2,_=u*M+c*S+(t[1]+a[1])/2,x=(L,D,j,J)=>Math.atan2(L*J-D*j,L*j+D*J),P=x(1,0,(m-M)/n,(h-S)/e),k=x((m-M)/n,(h-S)/e,(-m-M)/n,(-h-S)/e);!s&&k>0&&(k-=2*Math.PI),s&&k<0&&(k+=2*Math.PI);let v=Math.max(1,Math.ceil(Math.abs(k)/(Math.PI/2)-1e-9)),C=k/v,F=4/3*Math.tan(C/4),T=(L,D)=>[c*n*L-u*e*D+b,u*n*L+c*e*D+_],I=[],B=P;for(let L=0;L<v;L++){let D=Math.cos(B),j=Math.sin(B),J=B+C,ut=Math.cos(J),G=Math.sin(J);I.push(T(D-F*j,j+F*D),T(ut+F*G,G-F*ut)),I.push(L===v-1?a:T(ut,G)),B=J}return I}function Sa(t,n){return[t[0]*n[0]+t[2]*n[1]+t[4],t[1]*n[0]+t[3]*n[1]+t[5]]}function Go(t,n){return t.map(e=>({closed:e.closed,points:e.points.map(r=>Sa(n,r))}))}function Ho(t,n,e,r){let[o,s,a,i]=t,c=a?n/a:1,u=i?e/i:1,f=(r||"xMidYMid meet").trim().split(/\s+/),l=f[0]||"xMidYMid";l!=="none"&&(c=u=f[1]==="slice"?Math.max(c,u):Math.min(c,u));let m=-o*c,h=-s*u;if(l!=="none"){let p=l.includes("xMid")?.5:l.includes("xMax")?1:0,d=l.includes("YMid")?.5:l.includes("YMax")?1:0;m+=(n-a*c)*p,h+=(e-i*u)*d}return[c,0,0,u,m,h]}function $o(t,n,e,r,o){let s=Xt(t,n,o),a=Xt(n,e,o),i=Xt(e,r,o),c=Xt(s,a,o),u=Xt(a,i,o),f=Xt(c,u,o);return[[t,s,c,f],[f,u,i,r]]}function Dn(t,n,e,r,o){let s=1-o,a=s*s*s,i=3*s*s*o,c=3*s*o*o,u=o*o*o;return[a*t[0]+i*n[0]+c*e[0]+u*r[0],a*t[1]+i*n[1]+c*e[1]+u*r[1]]}function Aa(t,n,e){let r=t;return e<1&&(r=$o(r[0],r[1],r[2],r[3],e)[0]),n>0&&(r=$o(r[0],r[1],r[2],r[3],n/e)[1]),r}function Ea(t,n){var m;let e=t.points,r=(e.length-1)/3;if(r<1)return null;let o=!0,s=!0;for(let h of e)n(h)>=0?s=!1:o=!1;if(o)return t;if(s)return null;let a=[];for(let h=0;h<r;h++){let p=e.slice(h*3,h*3+4),d=[0],g=24,w=0,M=n(p[0]);for(let S=1;S<=g;S++){let b=S/g,_=n(Dn(p[0],p[1],p[2],p[3],b));if(M<0!=_<0){let x=w,P=b,k=M;for(let v=0;v<40;v++){let C=(x+P)/2,F=n(Dn(p[0],p[1],p[2],p[3],C));F<0==k<0?(x=C,k=F):P=C}d.push((x+P)/2)}w=b,M=_}d.push(1);for(let S=0;S<d.length-1;S++){let b=d[S],_=d[S+1];if(_-b<1e-9)continue;let x=Aa(p,b,_),P=Dn(p[0],p[1],p[2],p[3],(b+_)/2);a.push({seg:x,inside:n(P)>=0})}}let i=a.findIndex((h,p)=>h.inside&&!a[(p-1+a.length)%a.length].inside);i<0&&(i=0);let c=a.slice(i).concat(a.slice(0,i)),u=new be,f=!1,l=!1;for(let h of c){if(!h.inside){l=!0;continue}f?l&&u.lineTo(h.seg[0]):(u.moveTo(h.seg[0]),f=!0),l=!1,u.cubicTo(h.seg[1],h.seg[2],h.seg[3])}return f?(u.close(),(m=u.finish()[0])!=null?m:null):null}function Uo(t,n){let e=[o=>o[0]-n.x0,o=>n.x1-o[0],o=>o[1]-n.y0,o=>n.y1-o[1]],r=[];for(let o of t){let s=o;for(let a of e){if(!s)break;s=Ea(s,a)}s&&r.push(s)}return r}function Wn(t){let n=1/0,e=1/0,r=-1/0,o=-1/0,s=a=>{a[0]<n&&(n=a[0]),a[0]>r&&(r=a[0]),a[1]<e&&(e=a[1]),a[1]>o&&(o=a[1])};for(let a of t){let i=a.points;s(i[0]);for(let c=0;c+3<i.length;c+=3)for(let u=1;u<=8;u++)s(Dn(i[c],i[c+1],i[c+2],i[c+3],u/8))}return n===1/0?null:{x0:n,y0:e,x1:r,y1:o}}function qe(t){let n=new be;return n.moveTo([t.x0,t.y0]),n.lineTo([t.x1,t.y0]),n.lineTo([t.x1,t.y1]),n.lineTo([t.x0,t.y1]),n.close(),n.finish()[0]}var va={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Ta(t){let n=[],e=/([MLHVCSQTAZmlhvcsqtaz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,r;for(;r=e.exec(t);)n.push(r[1]?r[1]:parseFloat(r[2]));return n}function jn(t){let n=Ta(t),e=new be,r=0,o="",s=null,a=null,i=()=>n[r++];for(;r<n.length;){let c=n[r];if(typeof c=="string"){if(o=c,r++,o==="Z"||o==="z"){e.close(),s=a=null;continue}}else if(!o){r++;continue}let u=o.toUpperCase(),f=o!==u,l=va[u];if(l===void 0||r+l>n.length||n.slice(r,r+l).some(g=>typeof g!="number"))break;let m=e.current,h=(g,w)=>f?[m[0]+g,m[1]+w]:[g,w],p=null,d=null;switch(u){case"M":{let g=h(i(),i());e.moveTo(g),o=f?"l":"L";break}case"L":e.lineTo(h(i(),i()));break;case"H":{let g=i();e.lineTo([f?m[0]+g:g,m[1]]);break}case"V":{let g=i();e.lineTo([m[0],f?m[1]+g:g]);break}case"C":{let g=h(i(),i()),w=h(i(),i()),M=h(i(),i());e.cubicTo(g,w,M),p=w;break}case"S":{let g=s?[2*m[0]-s[0],2*m[1]-s[1]]:m,w=h(i(),i()),M=h(i(),i());e.cubicTo(g,w,M),p=w;break}case"Q":{let g=h(i(),i()),w=h(i(),i());e.quadTo(g,w),d=g;break}case"T":{let g=a?[2*m[0]-a[0],2*m[1]-a[1]]:m,w=h(i(),i());e.quadTo(g,w),d=g;break}case"A":{let g=i(),w=i(),M=i(),S=i(),b=i(),_=h(i(),i()),x=Ko(m,g,w,M,S!==0,b!==0,_);for(let P=0;P<x.length;P+=3)e.cubicTo(x[P],x[P+1],x[P+2]);break}}s=p,a=d}return e.finish()}var Rr="#000000",Kn=Tt.BLUE,Tr=Tt.BLUE_D,Fa=Tt.RED;function Be(t,n){let e=t.filter(r=>r&&typeof r.then=="function");return e.length?Promise.all(e).then(n):n()}function Se(t,n,e,r){let o=at($(t,n));Oe(t,n,Z(e-o[0],r-o[1]))}function De(t,n,e,r,o,s={}){X(t,n,e,r,U(r),[],{children:o,...s})}function Ra(t,n,e,r){let o=Mt(t,n,"start"),s=Mt(t,n,"end"),a=Mt(t,e,"start"),i=Mt(t,e,"end"),c=[s[0]-o[0],s[1]-o[1]],u=[i[0]-a[0],i[1]-a[1]],f=c[0]*u[1]-c[1]*u[0],l;if(Math.abs(f)<1e-12)l=s;else{let h=((a[0]-o[0])*u[1]-(a[1]-o[1])*u[0])/f;l=[o[0]+c[0]*h,o[1]+c[1]*h]}let m=(h,p)=>{let d=Math.hypot(h[0],h[1])||1;return[h[0]/d*p,h[1]/d*p]};return{p:l,u:m(c,r[0]<0?-1:1),v:m(u,r[1]<0?-1:1)}}function Yo(t,n,e,r,o){let s=t.w,{p:a,u:i,v:c}=Ra(s,W(s,r.line1),W(s,r.line2),Array.isArray(r.quadrant)?r.quadrant:[1,1]),u=Math.atan2(i[1],i[0]),l=((Math.atan2(c[1],c[0])-u)%_t+_t)%_t;r.other_angle&&(l-=_t);let m;if(o||r.elbow){let h=y(r.length,.4);m=[ot([[a[0]+i[0]*h,a[1]+i[1]*h],[a[0]+(i[0]+c[0])*h,a[1]+(i[1]+c[1])*h],[a[0]+c[0]*h,a[1]+c[1]*h]],!1)]}else{let h=y(r.radius,.4);m=[It(a,h,h,u,l,!1,8)]}X(t,n,e,r,U(r),m,{data:{value:Math.abs(l),vertex:a}})}function Vo(t,n,e,r,o,s){let a=Yt(t,r.arc_center,[0,0]),i=y(r.start_angle,0),c=y(r.angle,_t/4),u=(m,h)=>{let p=m[m.length-1];m.push([p[0]+(h[0]-p[0])/3,p[1]+(h[1]-p[1])/3],[p[0]+2*(h[0]-p[0])/3,p[1]+2*(h[1]-p[1])/3],[h[0],h[1]])},f=It(a,s,s,i+c,-c,!1,8).points,l;o>1e-9?(l=[...It(a,o,o,i,c,!1,8).points],u(l,f[0]),l.push(...f.slice(1))):(l=[[a[0],a[1]]],u(l,[a[0]+s*Math.cos(i),a[1]+s*Math.sin(i)]),l.push(...It(a,s,s,i,c,!1,8).points.slice(1))),u(l,l[0]),X(t,n,e,r,U(r,{sw:0,fo:1}),[{points:l,closed:!0}],{data:{start:l[0],end:l[0]}})}function ts(t,n,e){if(Math.abs(e)<1e-6)return dt(t,n);let r=Math.hypot(n[0]-t[0],n[1]-t[1])||1e-9,o=r/(2*Math.sin(Math.abs(e)/2)),s=(t[0]+n[0])/2,a=(t[1]+n[1])/2,i=-(n[1]-t[1])/r,c=(n[0]-t[0])/r,u=o*Math.cos(e/2)*Math.sign(e),f=s+i*u,l=a+c*u,m=Math.atan2(t[1]-l,t[0]-f);return It([f,l],o,o,m,e,!1,8)}function Xo(t,n,e,r,o){var b,_;let[s,a]=Le(t,(b=r.start)!=null?b:r.start_point,(_=r.end)!=null?_:r.end_point),i=ts(s,a,y(r.angle,_t/4)),c=hr([i]),u=Math.min(y(r.tip_length,.35),.25*c),f=U(r),l=o?u/c:0,m=1-u/c,h=Fe([i],l,m),p=i.points,d=(x,P)=>{let k=[p[x][0]-p[P][0],p[x][1]-p[P][1]],v=Math.hypot(k[0],k[1])||1;return[k[0]/v,k[1]/v]},g={...f,fc:f.sc,fo:1,sw:0},w=[],M=d(p.length-1,p.length-2),S=t.w.newId();if(t.w.set(H(S,"tip",g,Ue(a,M[0],M[1],u,u))),w.push(S),o){let x=d(0,1),P=t.w.newId();t.w.set(H(P,"tip",g,Ue(s,x[0],x[1],u,u))),w.push(P)}X(t,n,e,r,f,h,{children:w,data:{start:s,end:a}})}function Cr(t,n){return n.map(e=>e.kind==="text"?ae(t,e.id,"text",e.props,e.str):e.kind==="number"?ae(t,e.id,"text",e.props,e.str):yn(t,e.id,e.kind,{...e.props,parts:[e.str]},e.kind==="mathtex"?"math":"text"))}function qo(t,n,e,r,o,s=!1){let a=Xe(y(r.font_size,48)),i=o.map(()=>t.w.newId()),c=Cr(t,o.map((u,f)=>({id:i[f],kind:"text",str:s?`\u2022 ${u}`:u,props:{font_size:r.font_size,color:r.color,weight:r.weight,slant:r.slant,font:r.font,letter_spacing:r.letter_spacing}})));return Be(c,()=>{let u=String(r.alignment||"left").toLowerCase(),f=s?a*1.2+y(r.buff,.5)*.5:a*1.25*y(r.line_spacing,1);i.forEach((l,m)=>{let h=$(t.w,l),p=u==="center"?-(h[0]+h[2])/2:u==="right"?-h[2]:-h[0];Oe(t.w,l,Z(p,-m*f-(h[1]+h[3])/2))}),De(t,n,e,r,i),Se(t.w,n,0,0)})}function es(t,n,e,r){var M,S,b;let o=String((M=r.text)!=null?M:""),s=(_,x)=>ke(_,x,r.font),i=Array.from(new Set([s("normal","normal"),s("bold","normal"),s("normal","italic"),s("bold","italic")])).filter(_=>t.text.font(_)===void 0);if(i.length)return Promise.all(i.map(_=>t.text.load(_))).then(()=>es(t,n,e,r));let c=U(r,{sw:0,fo:1}),u=[],f=[],l=/<\s*(\/?)\s*(\w+)([^>]*)>|([^<]+)/g,m;for(;m=l.exec(o);)if(m[4]!=null){let _=m[4].replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),x=f.some(v=>v.tag==="b"||v.tag==="strong"),P=f.some(v=>v.tag==="i"||v.tag==="em"),k=(b=(S=[...f].reverse().find(v=>v.color))==null?void 0:S.color)!=null?b:null;for(let v of Array.from(_))u.push({ch:v,bold:x,italic:P,color:k})}else if(m[1]){let _=f.map(x=>x.tag).lastIndexOf(m[2].toLowerCase());_>=0&&f.splice(_,1)}else{let _=m[3]||"",x=/(?:foreground|fgcolor|color)\s*=\s*["']([^"']+)["']/i.exec(_);f.push({tag:m[2].toLowerCase(),color:x?Q(x[1],lt):void 0})}let h=Xe(y(r.font_size,48)),p=0,d=0,g=[],w="";for(let _ of u){if(_.ch===`
5
- `){p=0,d-=h*1.25;continue}let x=s(_.bold?"bold":"normal",_.italic?"italic":"normal"),P=t.text.glyph(_.ch,h,x);if(w+=_.ch,!!P){if(P.paths.length){let k=t.w.newId(),v=_.color?{...c,sc:_.color,fc:_.color}:c;t.w.set(H(k,"glyph",v,P.paths,{m:Z(p,d),data:{char:_.ch}})),g.push(k)}p+=P.advance+y(r.letter_spacing,0)*h}}if(!g.length&&w.trim())return ae(t,n,e,r,w);De(t,n,e,r,g,{data:{text:w}}),Se(t.w,n,0,0)}function zn(t,n,e,r,o){var f,l;let s=(l=(f=r.table)!=null?f:r.data)!=null?l:[];if(r.col_labels&&(s=[r.col_labels,...s]),r.row_labels){let m=r.row_labels;s=s.map((h,p)=>{var d;return[r.col_labels?p===0?(d=r.top_left_entry)!=null?d:"":m[p-1]:m[p],...h]})}let a=s.length,i=Math.max(0,...s.map(m=>m.length)),c=[],u=[];return s.forEach(m=>{var h;for(let p=0;p<i;p++){let d=t.w.newId();c.push(d);let g=(h=m[p])!=null?h:"";u.push({id:d,kind:o,str:String(g),props:{font_size:r.font_size,color:r.color}})}}),Be(Cr(t,u),()=>{var ut;let m=t.w,h=y(r.h_buff,1.3),p=y(r.v_buff,.8),d=new Array(i).fill(0),g=new Array(a).fill(0);c.forEach((G,ct)=>{let ht=$(m,G),Kt=Math.floor(ct/i),wt=ct%i;d[wt]=Math.max(d[wt],ht[2]-ht[0]),g[Kt]=Math.max(g[Kt],ht[3]-ht[1])});let w=[],M=[],S=0;for(let G=0;G<i;G++)w.push(S+d[G]/2),S+=d[G]+h;let b=S-h;S=0;for(let G=0;G<a;G++)M.push(-(S+g[G]/2)),S+=g[G]+p;let _=S-p;c.forEach((G,ct)=>Se(m,G,w[ct%i]-b/2,M[Math.floor(ct/i)]+_/2));let x={...U(r.line_config||{}),sw:y((ut=r.line_config)==null?void 0:ut.stroke_width,2)},P=!!r.include_outer_lines,k=[],v=[],C=-b/2-h/2,F=b/2+h/2,T=_/2+p/2,I=-_/2-p/2;for(let G=0;G<a-1;G++){let ct=M[G]-g[G]/2-p/2+_/2;k.push(dt([C,ct],[F,ct]))}for(let G=0;G<i-1;G++){let ct=w[G]+d[G]/2+h/2-b/2;v.push(dt([ct,T],[ct,I]))}P&&(k.unshift(dt([C,T],[F,T])),k.push(dt([C,I],[F,I])),v.unshift(dt([C,T],[C,I])),v.push(dt([F,T],[F,I])));let B=m.newId(),L=m.newId(),D=m.newId();m.set(H(B,"group",x,[],{children:c}));let j=(G,ct)=>{let ht=ct.map(Kt=>{let wt=m.newId();return m.set(H(wt,"line",x,[Kt])),wt});m.set(H(G,"group",x,[],{children:ht}))},J=r.include_inner_lines!==!1;j(L,J?k:P?[k[0],k[k.length-1]]:[]),j(D,J?v:P?[v[0],v[v.length-1]]:[]),De(t,n,e,r,[B,L,D],{data:{rows:a,cols:i}})})}function Zo(t,n){let o=n?-1:1,s=[[0,t/2],[o*.14,t/2],[o*.14,t/2-.035],[o*.035,t/2-.035],[o*.035,-t/2+.035],[o*.14,-t/2+.035],[o*.14,-t/2],[0,-t/2]];return[ot(s,!0)]}function $n(t,n,e,r,o,s){var l,m;let a=(m=(l=r.matrix)!=null?l:r.data)!=null?m:[],i=a.length,c=Math.max(0,...a.map(h=>h.length)),u=[],f=[];return a.forEach(h=>{for(let p=0;p<c;p++){let d=t.w.newId();u.push(d);let g=h[p],w=o==="number"?Bn(Number(g),s):String(g!=null?g:"");f.push({id:d,kind:o==="number"?"number":o,str:w,props:{font_size:r.font_size,color:r.color}})}}),Be(Cr(t,f),()=>{let h=t.w,p=y(r.v_buff,.8),d=y(r.h_buff,1.3);u.forEach((P,k)=>Se(h,P,k%c*d,-Math.floor(k/c)*p));let g=h.newId();h.set(H(g,"group",U(r),[],{children:u}));let w=$(h,g),M=w[3]-w[1]+2*y(r.bracket_v_buff,.25),S=y(r.bracket_h_buff,.25),b=U({...r,fill_opacity:1,stroke_width:0},{sw:0,fo:1}),_=h.newId(),x=h.newId();h.set(H(_,"bracket",b,Zo(M,!1),{m:Z(w[0]-S,(w[1]+w[3])/2)})),h.set(H(x,"bracket",b,Zo(M,!0),{m:Z(w[2]+S,(w[1]+w[3])/2)})),De(t,n,e,r,[g,_,x],{data:{rows:i,cols:c}}),Se(h,n,0,0)})}var Ne={python:["def","class","return","if","elif","else","for","while","in","import","from","as","with","try","except","finally","raise","lambda","yield","pass","break","continue","and","or","not","is","None","True","False","await","async","global","nonlocal","del","assert"],js:["function","const","let","var","return","if","else","for","while","of","in","import","from","export","class","new","this","null","undefined","true","false","async","await","try","catch","finally","throw","typeof","switch","case","break","continue","default"]};Ne.javascript=Ne.js;Ne.typescript=Ne.ts=Ne.js;var Pe={kw:"#F92672",str:"#E6DB74",com:"#75715E",num:"#FD971F",fn:"#A6E22E",text:"#F8F8F2"};function Ca(t,n){var a;let e=new Set(Ne[n]||Ne.python),r=[],o=/(#.*$|\/\/.*$)|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_]\w*)(?=\s*\()|([A-Za-z_]\w*)|(\s+)|(.)/g,s;for(;s=o.exec(t);)s[1]?r.push({s:s[1],c:Pe.com}):s[2]?r.push({s:s[2],c:Pe.str}):s[3]?r.push({s:s[3],c:Pe.num}):s[4]?r.push({s:s[4],c:e.has(s[4])?Pe.kw:Pe.fn}):s[5]?r.push({s:s[5],c:e.has(s[5])?Pe.kw:Pe.text}):r.push({s:(a=s[6])!=null?a:s[7],c:Pe.text});return r}function Ia(t,n,e,r){var k,v,C;let o=" ".repeat(Math.max(1,Math.round(y(r.tab_width,4)))),s=String((v=(k=r.code_string)!=null?k:r.code)!=null?v:"").replace(/\t/g,o).replace(/\s+$/,""),a=String(r.language||"python").toLowerCase(),i=Xe(y(r.font_size,24)),c=i*.6,u=i*1.45,f=s.split(`
6
- `),l=r.add_line_numbers!==!1,m=Math.round(y(r.line_numbers_from,1)),h=l?(String(f.length+m-1).length+2)*c:0,p=t.w,d=(F,T,I,B)=>{let L=p.newId(),D=F.length*c;return p.set(H(L,"code_token",{sc:T,fc:T,sw:0,so:1,fo:1},[],{text:{str:F,em:i,weight:"normal",slant:"normal",w:D,h:i,family:"mono",left:!0},m:Z(I+D/2,B),data:{text:F}})),L},g=[],w=[];f.forEach((F,T)=>{let I=-T*u;l&&g.push(d(String(T+m),"#75715E",0,I));let B=[],L=0;for(let j of Ca(F,a))j.s.trim()&&B.push(d(j.s,j.c,h+L*c,I)),L+=j.s.length;let D=p.newId();p.set(H(D,"code_line",U(r),[],{children:B,data:{text:F}})),w.push(D)});let M=p.newId(),S=p.newId();p.set(H(M,"group",U(r),[],{children:g})),p.set(H(S,"group",U(r),[],{children:w}));let b=La(p,[M,S]),_=.3,x=p.newId(),P=Q((C=r.background_color)!=null?C:"#272822","#272822");p.set(H(x,"code_background",{sc:P,fc:P,sw:0,so:1,fo:1},[Ge(b[2]-b[0]+2*_,b[3]-b[1]+2*_,.2)],{m:Z((b[0]+b[2])/2,(b[1]+b[3])/2)})),De(t,n,e,r,[x,M,S],{data:{code:s}}),Se(p,n,0,0)}function La(t,n){let e=null;for(let r of n){let o=$(t,r);o[0]===o[2]&&o[1]===o[3]&&!t.get(r).children.length||(e=e?[Math.min(e[0],o[0]),Math.min(e[1],o[1]),Math.max(e[2],o[2]),Math.max(e[3],o[3])]:o)}return e||[0,0,0,0]}function Gn(t,n){for(let e of t){if(!e.length)continue;let r=Math.min(e[0][0],e[e.length-1][0]),o=Math.max(e[0][0],e[e.length-1][0]);if(!(n<r-1e-9||n>o+1e-9))for(let s=0;s+1<e.length;s++){let a=e[s],i=e[s+1];if((n-a[0])*(n-i[0])<=0){let c=i[0]===a[0]?0:(n-a[0])/(i[0]-a[0]);return a[1]+(i[1]-a[1])*c}}}return null}function Hn(t,n){var s,a;let e=t.get(n),r=(s=e.data)==null?void 0:s.samples,o=(a=e.data)==null?void 0:a.axes;if(!r||!o)throw new Error("this needs a graph plotted on axes");return{samples:r,map:o,m:e.m}}function Oa(t,n,e,r){var d,g,w;let{samples:o,map:s,m:a}=Hn(t.w,W(t.w,r.graph)),i=o.flat().map(M=>M[0]),[c,u]=Array.isArray(r.x_range)?r.x_range.map(Number):[Math.min(...i),Math.max(...i)],f=r.bounded_graph!=null?Hn(t.w,W(t.w,r.bounded_graph)).samples:null,l=120,m=[],h=[];for(let M=0;M<=l;M++){let S=c+(u-c)*M/l,b=(d=Gn(o,S))!=null?d:0,_=f&&(g=Gn(f,S))!=null?g:0;m.push(Nt(s,S,b)),h.push(Nt(s,S,_))}let p=[ot([...m,...h.reverse()],!0)];X(t,n,e,r,U({fill_opacity:y(r.opacity,.3),...r},{color:(w=Tt.GRAY)!=null?w:lt,sw:0}),p,{m:a})}function Na(t,n,e,r){var d,g,w,M;let{samples:o,map:s,m:a}=Hn(t.w,W(t.w,r.graph)),i=o.flat().map(S=>S[0]),[c,u]=Array.isArray(r.x_range)?r.x_range.map(Number):[Math.min(...i),Math.max(...i)],f=y(r.dx,.1),l=String(r.input_sample_type||"left"),m=Array.isArray(r.color)?r.color.map(S=>Q(S,Kn)):[Q((d=r.color)!=null?d:Kn,Kn),Q((g=r.color)!=null?g:Tt.GREEN,Tt.GREEN)],h=Math.max(1,Math.round((u-c)/f)),p=[];for(let S=0;S<h;S++){let b=c+S*f,_=b+f,x=l==="right"?_:l==="center"?(b+_)/2:b,P=(w=Gn(o,x))!=null?w:0,k=Nt(s,b,0),v=Nt(s,_,P),C=m.length>1?ns(m,h>1?S/(h-1):0):m[0],F=t.w.newId();t.w.set(H(F,"rectangle",{sc:Q((M=r.stroke_color)!=null?M:Rr,Rr),fc:C,sw:y(r.stroke_width,1),so:1,fo:y(r.fill_opacity,1)},[ot([[v[0],v[1]],[k[0],v[1]],[k[0],k[1]],[v[0],k[1]]],!0)],{m:a})),p.push(F)}De(t,n,e,r,p)}function ns(t,n){let e=Math.max(0,Math.min(1,n))*(t.length-1),r=Math.min(t.length-2,Math.floor(e)),o=e-r,s=c=>[1,3,5].map(u=>parseInt(c.slice(u,u+2),16)||0),a=s(t[r]),i=s(t[r+1]);return"#"+a.map((c,u)=>Math.round(c+(i[u]-c)*o).toString(16).padStart(2,"0")).join("").toUpperCase()}function Ba(t,n,e,r){var f;let o=((f=r.values)!=null?f:[]).map(Number),s=o.length,a=Math.max(0,...o),i=Math.min(0,...o),c=Array.isArray(r.y_range)?r.y_range:[i,a>0?a:1,Math.max(1,Math.ceil((a-i)/6))],u=Ye(t,n,"axes",{x_range:[0,s,1],y_range:c,x_length:y(r.x_length,s),y_length:y(r.y_length,t.fh-4),tips:!1,axis_config:{include_tip:!1,...r.axis_config||{}},x_axis_config:{include_ticks:!1,...r.x_axis_config||{}}});return Be([u],()=>{var _;let l=t.w,m=l.get(n),h=m.data.axes,p=(Array.isArray(r.bar_colors)?r.bar_colors:wo).map(x=>Q(x,Kn)),d=y(r.bar_width,.6),g=o.map((x,P)=>{let k=Nt(h,P+.5-d/2,0),v=Nt(h,P+.5+d/2,x),C=p.length>1?ns(p,s>1?P/(s-1):0):p[0],F=l.newId();return l.set(H(F,"bar",{sc:C,fc:C,sw:y(r.bar_stroke_width,3),so:1,fo:y(r.bar_fill_opacity,.7)},[ot([[v[0],v[1]],[k[0],v[1]],[k[0],k[1]],[v[0],k[1]]],!0)],{m:m.m})),F}),w=l.newId();l.set(H(w,"group",m.style,[],{children:g}));let M=(_=r.bar_names)!=null?_:[],S=[],b=M.map((x,P)=>{let k=l.newId();return S.push(k),ae(t,k,"text",{font_size:24},String(x))});return Be(b,()=>{S.forEach((P,k)=>{let v=yt(m.m,Nt(h,k+.5,0)),C=$(l,P);Se(l,P,v[0],v[1]-.25-(C[3]-C[1])/2)});let x=l.newId();l.set(H(x,"group",m.style,[],{children:S})),l.update(n,{kind:e,children:[...m.children,w,x],data:{...m.data,bars:w,values:o,props:r}})})})}function Da(t,n,e,r){var M,S;let o=y(r.radius_max,t.fh/2),a=y(r.size,o*2)/2/o,i=y(r.radius_step,1),c=Math.max(1,Math.round(y(r.azimuth_step,12))),u={sc:Q((S=(M=r.background_line_style)==null?void 0:M.stroke_color)!=null?S:Tr,Tr),fc:Tr,sw:2,so:1,fo:0},f=[];for(let b=i;b<=o+1e-9;b+=i)f.push(ee([0,0],b*a));let l=[];for(let b=0;b<c;b++){let _=_t*b/c;l.push(dt([0,0],[Math.cos(_)*o*a,Math.sin(_)*o*a]))}let m=t.w.newId(),h=t.w.newId();t.w.set(H(m,"background_lines",u,f)),t.w.set(H(h,"background_lines",u,l));let p={sc:lt,fc:lt,sw:2,so:1,fo:0},d=t.w.newId(),g=t.w.newId();t.w.set(H(d,"number_line",p,[dt([-o*a,0],[o*a,0])])),t.w.set(H(g,"number_line",p,[dt([0,-o*a],[0,o*a])])),X(t,n,e,r,p,[],{children:[m,h,d,g],data:{axes:{x0:0,y0:0,sx:a,sy:a,ox:0,oy:0},polar:!0}})}function Wa(t){return()=>{t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function ja(t,n,e,r,o=0){var m;let s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h=e;return s=Array.from({length:t},(p,d)=>{var w,M;let g=(M=(w=h[d])!=null?w:h[String(d)])!=null?M:[0,0];return[Number(g[0]),Number(g[1])]}),s}let a=String(e||"spring");if(a==="circular"||a==="shell")return Array.from({length:t},(h,p)=>[r*Math.cos(_t*p/t),r*Math.sin(_t*p/t)]);if(a==="tree"){let h=Array.from({length:t},()=>[]);for(let[w,M]of n)h[w].push(M),h[M].push(w);let p=new Array(t).fill(-1),d=[];p[o]=0;let g=[o];for(;g.length;){let w=g.shift();(d[m=p[w]]||(d[m]=[])).push(w);for(let M of h[w])p[M]<0&&(p[M]=p[w]+1,g.push(M))}s=new Array(t).fill(null).map(()=>[0,0]),d.forEach((w,M)=>w.forEach((S,b)=>{s[S]=[w.length>1?b/(w.length-1)*2-1:0,1-(d.length>1?2*M/(d.length-1):0)]}))}else{let h=Wa(1);s=Array.from({length:t},()=>[h()*2-1,h()*2-1]);let p=Math.sqrt(4/Math.max(1,t)),d=.2;for(let g=0;g<120;g++){let w=s.map(()=>[0,0]);for(let M=0;M<t;M++)for(let S=M+1;S<t;S++){let b=s[M][0]-s[S][0],_=s[M][1]-s[S][1],x=Math.hypot(b,_)||1e-6,P=p*p/x;w[M][0]+=b/x*P,w[M][1]+=_/x*P,w[S][0]-=b/x*P,w[S][1]-=_/x*P}for(let[M,S]of n){let b=s[M][0]-s[S][0],_=s[M][1]-s[S][1],x=Math.hypot(b,_)||1e-6,P=x*x/p;w[M][0]-=b/x*P,w[M][1]-=_/x*P,w[S][0]+=b/x*P,w[S][1]+=_/x*P}for(let M=0;M<t;M++){let S=Math.hypot(w[M][0],w[M][1])||1e-6;s[M][0]+=w[M][0]/S*Math.min(S,d),s[M][1]+=w[M][1]/S*Math.min(S,d)}d*=.97}}let i=s.map(h=>h[0]),c=s.map(h=>h[1]),u=(Math.min(...i)+Math.max(...i))/2,f=(Math.min(...c)+Math.max(...c))/2,l=Math.max(Math.max(...i)-Math.min(...i),Math.max(...c)-Math.min(...c))/2||1;return s.map(h=>[(h[0]-u)/l*r,(h[1]-f)/l*r])}function Jo(t,n,e,r,o){var g,w;let s=(g=r.vertices)!=null?g:[],a=s.length,i=M=>typeof M=="number"&&Number.isInteger(M)&&M>=0&&M<a?M:Math.max(0,s.indexOf(M)),c=((w=r.edges)!=null?w:[]).map(M=>[i(M[0]),i(M[1])]),u=typeof r.root_vertex=="number"?r.root_vertex:Math.max(0,s.indexOf(r.root_vertex)),f=ja(a,c,r.layout,y(r.layout_scale,2),u),l=(M,S)=>M?M.per&&typeof M.per=="object"?{...M.per[S]||{}}:M:{},m=t.w,h=s.map(()=>m.newId()),p=r.labels,d=h.map((M,S)=>{let b=l(r.vertex_config,String(S));if(p)return rs(t,M,"labeled_dot",{label:String(s[S]),point:[...f[S],0],...b});X(t,M,"dot",b,U(b,{sw:0,fo:1}),[ee([0,0],y(b.radius,.08))],{m:Z(f[S][0],f[S][1])})});return Be(d,()=>{let M=c.map(([_,x])=>{let P=l(r.edge_config,`${_},${x}`),k=m.newId(),v=$(m,h[_]),C=$(m,h[x]),F=Math.max((v[2]-v[0])/2,(C[2]-C[0])/2);return o?bn(t,k,"arrow",{stroke_width:2,...P},f[_],f[x],F,!1):X(t,k,"line",P,U(P),[dt(f[_],f[x])],{z:-1,data:{start:f[_],end:f[x]}}),k}),S=m.newId(),b=m.newId();m.set(H(S,"group",U({}),[],{children:h})),m.set(H(b,"group",U({}),[],{children:M})),De(t,n,e,r,[S,b],{data:{vertices:s,edges:c,props:r}})})}function rs(t,n,e,r){var i,c,u,f;let o=t.w.newId(),s={font_size:(i=r.font_size)!=null?i:48,color:(c=r.label_color)!=null?c:Rr},a=t.tex&&r.label_is_text!==!0?yn(t,o,"mathtex",{...s,parts:[String((u=r.label)!=null?u:"")]},"math"):ae(t,o,"text",s,String((f=r.label)!=null?f:""));return Be([a],()=>{let l=$(t.w,o),m=r.radius!=null?y(r.radius,.3):.92*Math.max(l[2]-l[0],l[3]-l[1]),h=Yt(t,r.point,[0,0]);Se(t.w,o,h[0],h[1]),X(t,n,e,r,U(r,{sw:0,fo:1}),[ee([0,0],m)],{m:Z(h[0],h[1]),children:[o]})})}function za(t){var o;let n={},e=/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g,r;for(;r=e.exec(t);)n[r[1]]=(o=r[3])!=null?o:r[4];if(n.style)for(let s of n.style.split(";")){let[a,i]=s.split(":").map(c=>c&&c.trim());a&&i&&(n[a]=i)}return n}function $a(t){var o;let n=[1,0,0,1,0,0];if(!t)return n;let e=/(matrix|translate|scale|rotate)\s*\(([^)]*)\)/g,r;for(;r=e.exec(t);){let s=r[2].split(/[\s,]+/).filter(Boolean).map(Number),a=[1,0,0,1,0,0];if(r[1]==="matrix")a=[s[0],s[1],s[2],s[3],s[4],s[5]];else if(r[1]==="translate")a=[1,0,0,1,s[0]||0,s[1]||0];else if(r[1]==="scale")a=[s[0],0,0,(o=s[1])!=null?o:s[0],0,0];else if(r[1]==="rotate"){let i=(s[0]||0)*Math.PI/180,c=Math.cos(i),u=Math.sin(i);a=[c,u,-u,c,0,0],s.length>=3&&(a=Y(Y([1,0,0,1,s[1],s[2]],a),[1,0,0,1,-s[1],-s[2]]))}n=Y(n,a)}return n}function Ka(t,n){let e=(r,o=0)=>n[r]!=null?parseFloat(n[r]):o;switch(t){case"path":return n.d?jn(n.d):[];case"rect":{let r=e("x"),o=e("y"),s=e("width"),a=e("height"),i=e("rx",e("ry"));return i>0?zt([Ge(s,a,i)],Z(r+s/2,o+a/2)):[ot([[r,o],[r+s,o],[r+s,o+a],[r,o+a]],!0)]}case"circle":return[ee([e("cx"),e("cy")],e("r"))];case"ellipse":return[It([e("cx"),e("cy")],e("rx"),e("ry"),0,_t,!0)];case"line":return[dt([e("x1"),e("y1")],[e("x2"),e("y2")])];case"polyline":case"polygon":{let r=(n.points||"").trim().split(/[\s,]+/).map(Number),o=[];for(let s=0;s+1<r.length;s+=2)o.push([r[s],r[s+1]]);return[ot(o,t==="polygon")]}}return[]}function Fr(t,n,e,r){var g,w,M;let o=String((M=(w=(g=r.svg)!=null?g:r.svg_string)!=null?w:r.file_content)!=null?M:""),s=t.w,a=[],i=[{M:[1,0,0,1,0,0],a:{}}],c=/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g,u,f=(S,b)=>{var _,x;return(x=b[S])!=null?x:(_=[...i].reverse().find(P=>P.a[S]!=null))==null?void 0:_.a[S]};for(;u=c.exec(o);){let[,S,b,_,x]=u,P=b.toLowerCase().replace(/^svg:/,"");if(S){(P==="g"||P==="svg")&&i.pop();continue}let k=za(_),v=Y(i[i.length-1].M,$a(k.transform));if(P==="g"||P==="svg"){x||i.push({M:v,a:k});continue}if(P==="defs"||P==="clippath"||P==="mask")continue;let C=Ka(P,k);if(!C.length)continue;let F=f("fill",k),T=f("stroke",k),I=F&&F!=="none"?Q(F,lt):lt,B=T&&T!=="none"?Q(T,lt):I,L=T&&T!=="none"?parseFloat(f("stroke-width",k)||"1"):0,D={sc:B,fc:I,sw:L,so:1,fo:F==="none"?0:parseFloat(f("fill-opacity",k)||f("opacity",k)||"1")},j=s.newId();s.set(H(j,"svg_part",D,zt(C,Y([1,0,0,-1,0,0],v)),{evenodd:(f("fill-rule",k)||"").trim()==="evenodd"})),a.push(j)}X(t,n,e,r,U(r),[],{children:a});let l=$(s,n),m=r.width!=null&&r.height==null?y(r.width,2)*((l[3]-l[1])/(l[2]-l[0]||1)):y(r.height,2),h=l[3]-l[1]>1e-9?m/(l[3]-l[1]):1,p=at(l);Oe(s,n,Y(St(h,h,[0,0]),Z(-p[0],-p[1])));let d={};r.color!=null&&(d.sc=Q(r.color,lt),d.fc=d.sc),r.fill_color!=null&&(d.fc=Q(r.fill_color,lt)),r.stroke_color!=null&&(d.sc=Q(r.stroke_color,lt)),r.fill_opacity!=null&&(d.fo=y(r.fill_opacity,1)),r.stroke_width!=null&&(d.sw=y(r.stroke_width,0));for(let S of a){let b=s.get(S);s.set({...b,style:{...b.style,sw:r.stroke_width!=null?b.style.sw:b.style.sw*h*100/4,...d}})}}async function os(t,n,e){var s;let r=null;try{r=((s=globalThis.parent)==null?void 0:s.__cirImages)||globalThis.__cirImages}catch(a){r=null}if(!r||typeof r.chain!="function")throw new Error("Image operations need the Circuitry editor");let o=await r.chain(globalThis,t,n,e!=null?e:null);return typeof o=="string"?JSON.parse(o):o}function Qo(t){return new Promise(n=>{let e=new Image;e.onload=()=>n(e),e.onerror=()=>n(null),e.src=t})}function Ga(t,n,e,r){var u,f,l;let o=(l=(f=(u=r.src)!=null?u:r.filename_or_array)!=null?f:r.url)!=null?l:null,s=r.element,a=(m,h,p)=>{let d=y(r.scale_to_resolution,1080),g=p/d*t.fh,w=h/d*t.fh;if(r.height!=null){let M=y(r.height,g)/(g||1);g*=M,w*=M}if(r.width!=null){let M=y(r.width,w)/(w||1);g*=M,w*=M}X(t,n,e,r,U({fill_opacity:1,...r},{sw:0}),[],{image:{src:m,w:w||1,h:g||1,fullW:w||1,fullH:g||1}})},i=m=>[m.naturalWidth||m.width||1080,m.naturalHeight||m.height||1080],c=Array.isArray(r.ops)?r.ops:[];if(c.length)return os(s!=null?s:o,c,null).then(async m=>{let h=m&&m.url?await Qo(m.url):null;if(!h)throw new Error("the image from "+String(c.map(p=>p[0]).join(", "))+" could not be loaded");a(h,m.width||h.naturalWidth,m.height||h.naturalHeight)});if(s){let[m,h]=i(s);a(s,m,h);return}if(typeof Image=="undefined"||!o){a(null,y(r.px_width,1080),y(r.px_height,1080));return}return Qo(String(o)).then(m=>{m?a(m,m.naturalWidth,m.naturalHeight):a(null,1080,1080)})}function Ha(t,n,e,r){var s,a;let o=r.svg_element;if(o!=null){let i=typeof o=="string"?o:(s=o.outerHTML)!=null?s:String(o);return Fr(t,n,e,{...r,svg:i})}if(r.svg==null&&(r.image_src!=null||r.element!=null)&&r.trace!=null){let i=Array.isArray(r.ops)?r.ops:[];return os((a=r.element)!=null?a:r.image_src,i,r.trace).then(c=>{if(!c||!c.svg)throw new Error("tracing the image gave no shapes");let u=y(r.scale_to_resolution,1080),f=r.height!=null?r.height:r.width!=null?void 0:(c.height||1080)/u*t.fh;Fr(t,n,e,{...r,svg:c.svg,height:f})})}return Fr(t,n,e,r)}var vr={angle:(t,n,e,r)=>Yo(t,n,r,e,!1),right_angle:(t,n,e,r)=>Yo(t,n,r,e,!0),sector:(t,n,e,r)=>{var o;return Vo(t,n,r,e,y(e.inner_radius,0),y((o=e.outer_radius)!=null?o:e.radius,1))},annular_sector:(t,n,e,r)=>Vo(t,n,r,e,y(e.inner_radius,1),y(e.outer_radius,2)),arc_between_points:(t,n,e,r)=>{let[o,s]=Le(t,e.start,e.end);X(t,n,r,e,U(e),[ts(o,s,y(e.angle,_t/4))],{data:{start:o,end:s}})},curved_arrow:(t,n,e,r)=>Xo(t,n,r,e,!1),curved_double_arrow:(t,n,e,r)=>Xo(t,n,r,e,!0),elbow:(t,n,e,r)=>{let o=y(e.width,.2);X(t,n,r,e,U(e),zt([ot([[0,o],[o,o],[o,0]],!1)],te(y(e.angle,0),[0,0])))},cross:(t,n,e,r)=>{var m;let o={...U({stroke_width:6,...e},{color:Fa,sw:6}),fc:e.fill_color!=null?Q(e.fill_color,lt):lt},s=[-1,-1,1,1];(e.mobject!=null||e.target!=null)&&(s=Ve(t.w,(m=e.mobject)!=null?m:e.target));let a=y(e.scale_factor,1),i=at(s),c=(s[2]-s[0])/2*a,u=(s[3]-s[1])/2*a,f=t.w.newId(),l=t.w.newId();t.w.set(H(f,"line",o,[dt([i[0]-c,i[1]+u],[i[0]+c,i[1]-u])])),t.w.set(H(l,"line",o,[dt([i[0]+c,i[1]+u],[i[0]-c,i[1]-u])])),X(t,n,r,e,o,[],{children:[f,l]})},underline:(t,n,e,r)=>{var a;let o=Ve(t.w,(a=e.mobject)!=null?a:e.target),s=o[1]-y(e.buff,.1);X(t,n,r,e,U(e),[dt([o[0],s],[o[2],s])],{data:{start:[o[0],s],end:[o[2],s]}})},labeled_dot:(t,n,e,r)=>rs(t,n,r,e),dashed_vmobject:(t,n,e,r)=>{var c;let o=W(t.w,(c=e.vmobject)!=null?c:e.target),s=Math.max(1,Math.round(y(e.num_dashes,15))),a=y(e.dashed_ratio,.5),i=[];for(let u of et(t.w,o)){let f=t.w.get(u),l=zt(f.paths,f.m),m=l.length===1&&l[0].closed,h=a/s,p=m||s===1?1/s:(1-h)/(s-1);for(let d=0;d<s;d++)for(let g of Fe(l,d*p,Math.min(1,d*p+h))){let w=t.w.newId();t.w.set(H(w,"dash",f.style,[{points:g.points,closed:!1}])),i.push(w)}}X(t,n,r,e,U(e),[],{children:i})},tangent_line:(t,n,e,r)=>{var w;let o=W(t.w,(w=e.vmobject)!=null?w:e.target),s=et(t.w,o).flatMap(M=>zt(t.w.get(M).paths,t.w.get(M).m)),a=Math.max(0,Math.min(1,y(e.alpha,.5))),i=y(e.d_alpha,1e-6),c=we(s,Math.max(0,a-i)),u=we(s,Math.min(1,a+i)),f=we(s,a),l=u[0]-c[0],m=u[1]-c[1],h=Math.hypot(l,m)||1,p=y(e.length,1)/2,d=[f[0]-l/h*p,f[1]-m/h*p],g=[f[0]+l/h*p,f[1]+m/h*p];X(t,n,r,e,U(e),[dt(d,g)],{data:{start:d,end:g}})},cubic_bezier:(t,n,e,r)=>{let o=[e.start_anchor,e.start_handle,e.end_handle,e.end_anchor].map(s=>it(t.w,s));X(t,n,r,e,U(e),[{points:o,closed:!1}],{data:{start:o[0],end:o[3]}})},paragraph:(t,n,e,r)=>{var s;let o=Array.isArray(e.lines)?e.lines.map(String):String((s=e.text)!=null?s:"").split(`
7
- `);return qo(t,n,r,e,o)},bulleted_list:(t,n,e,r)=>{var o;return qo(t,n,r,e,((o=e.items)!=null?o:[]).map(String),!0)},markup_text:(t,n,e,r)=>es(t,n,r,e),table:(t,n,e,r)=>zn(t,n,r,e,e.element==="mathtex"?"mathtex":"text"),math_table:(t,n,e,r)=>zn(t,n,r,e,"mathtex"),decimal_table:(t,n,e,r)=>zn(t,n,r,e,"number"),integer_table:(t,n,e,r)=>zn(t,n,r,e,"number"),matrix:(t,n,e,r)=>$n(t,n,r,e,"mathtex",0),integer_matrix:(t,n,e,r)=>$n(t,n,r,e,"number",0),decimal_matrix:(t,n,e,r)=>{var o;return $n(t,n,r,e,"number",y((o=e.element_to_mobject_config)==null?void 0:o.num_decimal_places,1))},mobject_matrix:(t,n,e,r)=>$n(t,n,r,e,"text",0),code:(t,n,e,r)=>Ia(t,n,r,e),complex_plane:(t,n,e)=>Ye(t,n,"number_plane",e),polar_plane:(t,n,e,r)=>Da(t,n,r,e),bar_chart:(t,n,e,r)=>Ba(t,n,r,e),area:(t,n,e,r)=>Oa(t,n,r,e),riemann_rectangles:(t,n,e,r)=>Na(t,n,r,e),network_graph:(t,n,e,r)=>Jo(t,n,r,e,!!e.directed),di_graph:(t,n,e,r)=>Jo(t,n,r,e,!0),svg_mobject:(t,n,e,r)=>Ha(t,n,r,e),image_mobject:(t,n,e,r)=>Ga(t,n,r,e)};function ss(t,n,e){let{samples:r,map:o,m:s}=Hn(t,n),a=Gn(r,e);return yt(s,Nt(o,e,a!=null?a:0))}function Un(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Yn(t){return Un(t)&&typeof t.id=="number"&&Object.keys(t).every(n=>n==="id"||n==="path")}function as(t){return Un(t)&&!("$pt"in t)&&!Yn(t)}function Ot(t,n){let e={},r=[];Array.isArray(t)?(r=t.slice(),r.length&&as(r[r.length-1])&&Object.assign(e,r.pop())):as(t)?Object.assign(e,t):t!=null&&(r=[t]);for(let o=0;o<n.length&&o<r.length;o++){let s=n[o];if(s[0]==="*"){e[s.slice(1)]=r.slice(o);break}s in e||(e[s]=r[o])}return e}function W(t,n){if(typeof n=="number"){if(!t.has(n))throw new Error(n===Ut?"no camera frame":`that object does not exist (#${n})`);return n}if(Yn(n)){let e=W(t,n.id);for(let r of n.path||[]){let o=t.get(e).children,s=r<0?o.length+r:r;if(s<0||s>=o.length)throw new Ir(`index ${r} is out of range (it has ${o.length} parts)`);e=o[s]}return e}throw new Error("expected an object, got "+JSON.stringify(n))}var Ir=class extends Error{constructor(n){super(n),this.name="IndexError"}};function Ft(t){return typeof t=="number"||Yn(t)}var Ua={center:[0,0],centre:[0,0],origin:[0,0],top:[0,1],up:[0,1],bottom:[0,-1],down:[0,-1],left:[-1,0],right:[1,0],ul:[-1,1],ur:[1,1],dl:[-1,-1],dr:[1,-1],top_left:[-1,1],top_right:[1,1],bottom_left:[-1,-1],bottom_right:[1,-1]};function Ya(t){return Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0]:typeof t=="string"&&Ua[t.toLowerCase().replace(/^get_/,"")]||null}function Lr(t,n,e){if(typeof e=="string"){let o=e.toLowerCase().replace(/^get_/,"");if(o==="start"||o==="end")return Mt(t,n,o)}let r=Ya(e!=null?e:"center");if(!r)throw new Error(`unknown point "${e}"`);return Et($(t,n),r)}function Mt(t,n,e){let r=t.get(n);if(r.data&&r.data[e])return yt(r.m,r.data[e]);let o=r.paths;if(!o.length){let a=r.children;return a.length?Mt(t,e==="start"?a[0]:a[a.length-1],e):pt(t,n)}let s=e==="start"?o[0].points[0]:o[o.length-1].points[o[o.length-1].points.length-1];return yt(r.m,s)}function is(t,n,e,r){let o=t.get(n),s=o.data&&o.data.axes;if(!s)throw new Error("c2p needs Axes, a NumberPlane or a NumberLine");return yt(o.m,Nt(s,e,r))}function Nt(t,n,e){return[t.ox+(n-t.x0)*t.sx,t.oy+(e-t.y0)*t.sy]}function it(t,n){var e;if(Array.isArray(n))return typeof n[0]=="string"?Or($t(t,n)):[Number(n[0])||0,Number(n[1])||0];if(Un(n)&&("$pt"in n||"$x"in n))return Or($t(t,(e=n.$pt)!=null?e:n.$x));if(Ft(n))return pt(t,W(t,n));throw new Error("expected a point, got "+JSON.stringify(n))}function Or(t){return Array.isArray(t)?[t[0]||0,t[1]||0]:[t,0]}var mt={t:0,dt:0,alpha:0,homotopy:!1},We=null;function cs(t,n){let e=We;We=t;try{return n()}finally{We=e}}function Pt(t,n,e){return typeof t=="number"&&typeof n=="number"?e(t,n):Array.isArray(t)&&Array.isArray(n)?t.map((r,o)=>{var s;return e(r,(s=n[o])!=null?s:0)}):Array.isArray(t)?t.map(r=>e(r,n)):n.map(r=>e(t,r))}function gt(t,n){return typeof t=="number"?n(t):t.map(n)}var ie=t=>{var n;return typeof t=="number"?t:(n=t[0])!=null?n:0},ce=t=>[t[0],t[1],0],qt={hypot:(t,n)=>Pt(t,n,Math.hypot),sin:t=>gt(t,Math.sin),cos:t=>gt(t,Math.cos),tan:t=>gt(t,Math.tan),arcsin:t=>gt(t,Math.asin),arccos:t=>gt(t,Math.acos),arctan:t=>gt(t,Math.atan),arctan2:(t,n)=>Pt(t,n,Math.atan2),sinh:t=>gt(t,Math.sinh),cosh:t=>gt(t,Math.cosh),tanh:t=>gt(t,Math.tanh),exp:t=>gt(t,Math.exp),log:t=>gt(t,Math.log),log10:t=>gt(t,Math.log10),log2:t=>gt(t,Math.log2),sqrt:t=>gt(t,Math.sqrt),abs:t=>gt(t,Math.abs),floor:t=>gt(t,Math.floor),ceil:t=>gt(t,Math.ceil),round:(t,n)=>{let e=Math.pow(10,n==null?0:ie(n));return gt(t,r=>Math.round(r*e)/e)},sign:t=>gt(t,Math.sign),min:(...t)=>t.reduce((n,e)=>Pt(n,e,Math.min)),max:(...t)=>t.reduce((n,e)=>Pt(n,e,Math.max)),clip:(t,n,e)=>Pt(Pt(t,n,Math.max),e,Math.min),interpolate:(t,n,e)=>Pt(t,Pt(Pt(n,t,(r,o)=>r-o),e,(r,o)=>r*o),(r,o)=>r+o),norm:t=>typeof t=="number"?Math.abs(t):Math.hypot(...t),dot:(t,n)=>t.reduce((e,r,o)=>{var s;return e+r*((s=n[o])!=null?s:0)},0),cross:(t,n)=>t[0]*n[1]-t[1]*n[0],normalize:t=>{if(typeof t=="number")return Math.sign(t);let n=Math.hypot(...t)||1;return t.map(e=>e/n)},rotate_vector:(t,n)=>{var a;let e=t,r=ie(n),o=Math.cos(r),s=Math.sin(r);return[e[0]*o-e[1]*s,e[0]*s+e[1]*o,(a=e[2])!=null?a:0]},deg:t=>gt(t,n=>n*180/Math.PI),rad:t=>gt(t,n=>n*Math.PI/180)};Object.assign(qt,{asin:qt.arcsin,acos:qt.arccos,atan:qt.arctan,atan2:qt.arctan2,degrees:qt.deg,radians:qt.rad,absolute:qt.abs,fabs:qt.abs,minimum:qt.min,maximum:qt.max});var Ae={"<":(t,n)=>+(t<n),"<=":(t,n)=>+(t<=n),">":(t,n)=>+(t>n),">=":(t,n)=>+(t>=n),"==":(t,n)=>+(t===n),"!=":(t,n)=>+(t!==n)};Object.assign(Ae,{lt:Ae["<"],le:Ae["<="],gt:Ae[">"],ge:Ae[">="],eq:Ae["=="],ne:Ae["!="]});function $t(t,n){var r,o,s;if(typeof n=="number")return n;if(typeof n=="boolean")return+n;if(Un(n)){if("$x"in n)return $t(t,n.$x);if("$pt"in n)return $t(t,n.$pt);if(Yn(n))return ce(pt(t,W(t,n)))}if(!Array.isArray(n))throw new Error("cannot evaluate "+JSON.stringify(n));if(typeof n[0]!="string")return n.map(a=>ie($t(t,a)));let e=a=>$t(t,a);switch(n[0]){case"t":return mt.t;case"dt":return mt.dt;case"num":return Number(n[1]);case"val":return Number((o=(r=t.get(W(t,n[1])).data)==null?void 0:r.value)!=null?o:0);case"v":return Array.isArray(n[1])?n[1].map(a=>ie(e(a))):e(n[1]);case"vec":return n.slice(1).map(a=>ie(e(a)));case"prop":return xn(t,W(t,n[1]),String(n[2]),n.slice(3).map(e));case"var":{let a=String(n[1]);if(a==="t"&&mt.homotopy)return mt.alpha;if(a==="t"||a==="time")return mt.t;if(a==="dt")return mt.dt;if(a==="alpha")return mt.alpha;let i=We||[0,0];return a==="p"?[i[0],i[1],0]:a==="x"?i[0]:a==="y"?i[1]:0}case"of":return ce(Lr(t,W(t,n[1]),Array.isArray(n[2])?e(n[2]):n[2]));case"c2p":return ce(is(t,W(t,n[1]),ie(e(n[2])),ie(e(n[3]))));case"p2c":{let a=Or(e(n[2])),i=us(t,W(t,n[1]),a);return[i[0],i[1]]}case"get":return xn(t,W(t,n[1]),String(n[2]),n.slice(3).map(e));case"ppf":{let a=W(t,n[1]);return xn(t,a,"point_from_proportion",[ie(e(n[2]))])}case"graph_point":return ce(ss(t,W(t,n[1]),ie(e(n[2]))));case"p":return We?[We[0],We[1],0]:[0,0,0];case"alpha":return mt.alpha;case"+":case"add":return Pt(e(n[1]),e(n[2]),(a,i)=>a+i);case"-":case"sub":return Pt(e(n[1]),e(n[2]),(a,i)=>a-i);case"*":case"mul":return Pt(e(n[1]),e(n[2]),(a,i)=>a*i);case"/":case"div":return Pt(e(n[1]),e(n[2]),(a,i)=>a/i);case"**":case"pow":return Pt(e(n[1]),e(n[2]),Math.pow);case"%":case"mod":return Pt(e(n[1]),e(n[2]),(a,i)=>(a%i+i)%i);case"//":return Pt(e(n[1]),e(n[2]),(a,i)=>Math.floor(a/i));case"neg":return gt(e(n[1]),a=>-a);case"idx":{let a=e(n[1]);return typeof a=="number"?a:(s=a[Number(e(n[2]))])!=null?s:0}case"cmp":return Pt(e(n[2]),e(n[3]),Ae[n[1]]||(()=>0));case"where":return ie(e(n[1]))?e(n[2]):e(n[3]);case"fn":{let a=qt[n[1]];if(!a)throw new Error(`the animation layer cannot evaluate ${n[1]}() yet`);return a(...n.slice(2).map(e))}}throw new Error("unknown expression "+n[0])}function Bt(t,n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(o=>Bt(t,o));if("$x"in n)return $t(t,n.$x);if("$pt"in n){let o=$t(t,n.$pt);return typeof o=="number"?[o,0,0]:o}let e=!1,r={};for(let o of Object.keys(n))r[o]=Bt(t,n[o]),r[o]!==n[o]&&(e=!0);return e?r:n}function us(t,n,e){let r=t.get(n),o=r.data&&r.data.axes;if(!o)throw new Error("p2c needs Axes, a NumberPlane or a NumberLine");let s=yt(xe(r.m),e);return[o.sx?o.x0+(s[0]-o.ox)/o.sx:0,o.sy?o.y0+(s[1]-o.oy)/o.sy:0]}function xn(t,n,e,r=[]){var i,c,u,f;let o=String(e).replace(/^get_/,""),s=$(t,n),a=r[0];switch(o){case"center":return ce(at(s));case"width":return s[2]-s[0];case"height":return s[3]-s[1];case"x":return at(s)[0];case"y":return at(s)[1];case"z":return 0;case"top":case"bottom":case"left":case"right":return ce(Lr(t,n,o));case"corner":case"critical_point":case"edge_center":return ce(Lr(t,n,a));case"start":case"end":return ce(Mt(t,n,o));case"len":case"length_of_children":case"submobject_count":return t.get(n).children.length;case"value":return Number((c=(i=t.get(n).data)==null?void 0:i.value)!=null?c:0);case"point_from_proportion":{let l=[];for(let m of et(t,n))l.push(...zt(t.get(m).paths,t.get(m).m));return ce(we(l,y(a,0)))}case"c2p":case"coords_to_point":case"n2p":case"number_to_point":{let l=Array.isArray(a)?a:[a,(u=r[1])!=null?u:0];return ce(is(t,n,y(l[0],0),y(l[1],0)))}case"p2c":case"point_to_coords":case"p2n":case"point_to_number":{let l=us(t,n,it(t,a));return o==="p2n"||o==="point_to_number"?l[0]:[l[0],l[1]]}case"color":{let l=t.get((f=et(t,n)[0])!=null?f:n);return l.style.fo>0?l.style.fc:l.style.sc}case"length":case"arc_length":{let l=Mt(t,n,"start"),m=Mt(t,n,"end");return Math.hypot(m[0]-l[0],m[1]-l[1])}case"angle":{let l=Mt(t,n,"start"),m=Mt(t,n,"end");return Math.atan2(m[1]-l[1],m[0]-l[0])}case"unit_vector":{let l=Mt(t,n,"start"),m=Mt(t,n,"end"),h=Math.hypot(m[0]-l[0],m[1]-l[1])||1;return[(m[0]-l[0])/h,(m[1]-l[1])/h,0]}}throw new Error(`cannot read "${e}" from an object`)}function Rt(t,n,e){return n==null?e:it(t,n)}function y(t,n){if(t==null)return n;let e=Number(Array.isArray(t)?t[0]:t);return Number.isFinite(e)?e:n}var Wt=[0,0],hs=[1,0];var je=.25,ls=.5;function ds(t,n){if(Ft(n))return $(t,W(t,n));let e=it(t,n);return[e[0],e[1],e[0],e[1]]}function Zt(t,n,e){(e[0]||e[1])&&At(t,n,Z(e[0],e[1]))}function Vn(t,n,e){if(e.about_point!=null)return it(t,e.about_point);let r=$(t,n);return e.about_edge!=null?Et(r,Rt(t,e.about_edge,Wt)):at(r)}function Ze(t){return t>1e-9?1:t<-1e-9?-1:0}function Je(t,n,e){let r=0,o=0,s=1;Array.isArray(n)&&(r=Number(n[0])||0,o=Number(n[1])||0,s=Number(n[2])||0);let a=Math.hypot(r,o,s)||1;if(r/=a,o/=a,s/=a,Math.abs(Math.abs(s)-1)<1e-9)return te(t*s,e);let i=Math.cos(t),c=Math.sin(t),u=1-i,f=i+r*r*u,l=r*o*u-s*c,m=o*r*u+s*c,h=i+o*o*u,p=[f,m,l,h,0,0];return Y(Z(e[0],e[1]),Y(p,Z(-e[0],-e[1])))}function wn(t){return Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"||Array.isArray(n))}function Va(t,n){if(t.length===1)return t[0];let e=Math.max(0,Math.min(1,n))*(t.length-1),r=Math.min(t.length-2,Math.floor(e));return Ie(t[r],t[r+1],e-r)}function Mn(t,n,e,r="both"){if(e==null)return;let o=(a,i)=>r==="fill"?{...a,fc:i}:r==="stroke"?{...a,sc:i}:{...a,sc:i,fc:i};if(wn(e)){let a=e.map(c=>Q(c,"#FFFFFF")),i=st(t,n).filter(c=>ne(t.get(c)));i.forEach((c,u)=>{let f=t.get(c);t.set({...f,style:o(f.style,Va(a,i.length>1?u/(i.length-1):0))})});return}let s=Q(e,"#FFFFFF");vt(t,n,a=>o(a,s))}function ms(t,n){for(let e of st(t,n)){let r=t.get(e);if(ne(r))return r.style}return t.get(n).style}function Dt(t,n,e,r,o=!1){let s=$(t,n),a=e===0?s[2]-s[0]:s[3]-s[1];if(a<=1e-12)return;let i=r/a,c=at(s);At(t,n,o?St(e===0?i:1,e===0?1:i,c):St(i,i,c))}function ps(t,n,e){var u;let r=ds(t,(u=e.mobject_or_point)!=null?u:Wt),o=Rt(t,e.direction,hs),s=Rt(t,e.aligned_edge,Wt),a=y(e.buff,je),i=Et(r,[s[0]+o[0],s[1]+o[1]]),c=Et($(t,n),[s[0]-o[0],s[1]-o[1]]);Zt(t,n,[i[0]-c[0]+a*o[0],i[1]-c[1]+a*o[1]])}function fs(t,n,e,r,o){let s=[Ze(e[0])*o.fw/2,Ze(e[1])*o.fh/2],a=Et($(t,n),e);Zt(t,n,[(s[0]-a[0]-r*Ze(e[0]))*Math.abs(Ze(e[0])),(s[1]-a[1]-r*Ze(e[1]))*Math.abs(Ze(e[1]))])}function Xa(t,n,e){let r=t.get(n).children,o=Rt(t,e.direction,hs),s=y(e.buff,je),a=e.aligned_edge!=null?Rt(t,e.aligned_edge,Wt):Wt,i=at($(t,n));for(let c=1;c<r.length;c++)ps(t,r[c],{mobject_or_point:r[c-1],direction:o,buff:s,aligned_edge:a});if(e.center!==!1){let c=at($(t,n));Zt(t,n,[i[0]-c[0],i[1]-c[1]])}}function qa(t,n,e){let r=t.get(n).children,o=r.length;if(!o)return;let s=at($(t,n)),a=e.rows!=null?Number(e.rows):0,i=e.cols!=null?Number(e.cols):0;!a&&!i?(i=Math.ceil(Math.sqrt(o)),a=Math.ceil(o/i)):a?i||(i=Math.ceil(o/a)):a=Math.ceil(o/i);let c=je,u=je;Array.isArray(e.buff)?(c=y(e.buff[0],je),u=y(e.buff[1],je)):e.buff!=null&&(c=u=y(e.buff,je));let f=String(e.flow_order||"rd").toLowerCase(),l=_=>{let x=f[0],P=f[1]||(x==="r"||x==="l"?"d":"r");if(x==="r"||x==="l"){let C=_%i,F=Math.floor(_/i);return[P==="u"?a-1-F:F,x==="l"?i-1-C:C]}let k=_%a,v=Math.floor(_/a);return[x==="u"?a-1-k:k,P==="l"?i-1-v:v]},m=r.map((_,x)=>l(x)),h=0,p=0;for(let[_,x]of m)h=Math.max(h,_+1),p=Math.max(p,x+1);a=Math.min(a,h),i=Math.min(i,p);let d=r.map(_=>$(t,_)),g=new Array(i).fill(0),w=new Array(a).fill(0);d.forEach((_,x)=>{let[P,k]=m[x];P>=a||k>=i||(g[k]=Math.max(g[k],_[2]-_[0]),w[P]=Math.max(w[P],_[3]-_[1]))});let M=g.reduce((_,x)=>_+x,0)+c*(i-1),S=w.reduce((_,x)=>_+x,0)+u*(a-1),b=e.cell_alignment!=null?Rt(t,e.cell_alignment,Wt):Wt;r.forEach((_,x)=>{let[P,k]=m[x];if(P>=a||k>=i)return;let v=-M/2+g.slice(0,k).reduce((I,B)=>I+B,0)+c*k+g[k]/2,C=S/2-w.slice(0,P).reduce((I,B)=>I+B,0)-u*P-w[P]/2,F=[s[0]+v+b[0]*g[k]/2,s[1]+C+b[1]*w[P]/2],T=Et(d[x],b);Zt(t,_,[F[0]-T[0],F[1]-T[1]])})}var ge={width:(t,n,e)=>Dt(t,n,0,y(e,1)),height:(t,n,e)=>Dt(t,n,1,y(e,1)),color:(t,n,e)=>Mn(t,n,e),fill_color:(t,n,e)=>{let r=Q(e,"#FFFFFF");vt(t,n,o=>({...o,fc:r}))},stroke_color:(t,n,e)=>{let r=Q(e,"#FFFFFF");vt(t,n,o=>({...o,sc:r}))},fill_opacity:(t,n,e)=>vt(t,n,r=>({...r,fo:y(e,r.fo)})),stroke_opacity:(t,n,e)=>vt(t,n,r=>({...r,so:y(e,r.so)})),stroke_width:(t,n,e)=>vt(t,n,r=>({...r,sw:y(e,r.sw)})),opacity:(t,n,e)=>vt(t,n,r=>({...r,fo:y(e,1),so:y(e,1)})),z_index:(t,n,e)=>{for(let r of st(t,n))t.update(r,{z:y(e,0)})},x:(t,n,e)=>{let r=at($(t,n));Zt(t,n,[y(e,0)-r[0],0])},y:(t,n,e)=>{let r=at($(t,n));Zt(t,n,[0,y(e,0)-r[1]])}},Wr={shift:{params:["*vectors"],run:(t,n,e)=>{let r=e.vectors||[],o=0,s=0;for(let a of r){let i=it(t,a);o+=i[0],s+=i[1]}Zt(t,n,[o,s])}},move_to:{params:["point_or_mobject","aligned_edge"],run:(t,n,e)=>{var i;let r=Rt(t,e.aligned_edge,Wt),o=Ft(e.point_or_mobject)?Et($(t,W(t,e.point_or_mobject)),r):it(t,(i=e.point_or_mobject)!=null?i:Wt),s=Et($(t,n),r),a=Array.isArray(e.coor_mask)?[y(e.coor_mask[0],1),y(e.coor_mask[1],1)]:[1,1];Zt(t,n,[(o[0]-s[0])*a[0],(o[1]-s[1])*a[1]])}},center:{params:[],run:(t,n)=>{let e=at($(t,n));Zt(t,n,[-e[0],-e[1]])}},next_to:{params:["mobject_or_point","direction","buff","aligned_edge"],run:(t,n,e)=>ps(t,n,e)},to_edge:{params:["edge","buff"],run:(t,n,e,r)=>fs(t,n,Rt(t,e.edge,[-1,0]),y(e.buff,ls),r)},to_corner:{params:["corner","buff"],run:(t,n,e,r)=>fs(t,n,Rt(t,e.corner,[-1,-1]),y(e.buff,ls),r)},align_to:{params:["mobject_or_point","direction"],run:(t,n,e)=>{let r=Rt(t,e.direction,Wt),o=Et(ds(t,e.mobject_or_point),r),s=Et($(t,n),r);Zt(t,n,[r[0]?o[0]-s[0]:0,r[1]?o[1]-s[1]:0])}},arrange:{params:["direction","buff","center"],run:(t,n,e)=>Xa(t,n,e)},arrange_in_grid:{params:["rows","cols","buff"],run:(t,n,e)=>qa(t,n,e)},scale:{params:["scale_factor","about_point","about_edge"],run:(t,n,e)=>{let r=e.scale_factor,o=Array.isArray(r)?y(r[0],1):y(r,1),s=Array.isArray(r)?y(r[1],1):o;At(t,n,St(o,s,Vn(t,n,e)))}},rotate:{params:["angle","axis","about_point","about_edge"],run:(t,n,e)=>At(t,n,Je(y(e.angle,0),e.axis,Vn(t,n,e)))},rotate_about_origin:{params:["angle","axis"],run:(t,n,e)=>At(t,n,Je(y(e.angle,0),e.axis,Wt))},flip:{params:["axis","about_point","about_edge"],run:(t,n,e)=>{var r;return At(t,n,Je(Math.PI,(r=e.axis)!=null?r:[0,1,0],Vn(t,n,e)))}},stretch:{params:["factor","dim","about_point","about_edge"],run:(t,n,e)=>{let r=y(e.factor,1),o=y(e.dim,0);At(t,n,St(o===0?r:1,o===1?r:1,Vn(t,n,e)))}},scale_to_fit_width:{params:["width"],run:(t,n,e)=>Dt(t,n,0,y(e.width,1))},scale_to_fit_height:{params:["height"],run:(t,n,e)=>Dt(t,n,1,y(e.height,1))},set_width:{params:["width","stretch"],run:(t,n,e)=>Dt(t,n,0,y(e.width,1),!!e.stretch)},set_height:{params:["height","stretch"],run:(t,n,e)=>Dt(t,n,1,y(e.height,1),!!e.stretch)},stretch_to_fit_width:{params:["width"],run:(t,n,e)=>Dt(t,n,0,y(e.width,1),!0)},stretch_to_fit_height:{params:["height"],run:(t,n,e)=>Dt(t,n,1,y(e.height,1),!0)},set_x:{params:["x"],run:(t,n,e,r)=>ge.x(t,n,e.x,r)},set_y:{params:["y"],run:(t,n,e,r)=>ge.y(t,n,e.y,r)},set:{params:[],run:(t,n,e,r)=>{for(let o of Object.keys(e)){let s=ge[o];if(!s)throw new Error(`set() does not know "${o}"`);s(t,n,e[o],r)}}},set_color:{params:["color"],run:(t,n,e)=>Mn(t,n,e.color)},set_fill:{params:["color","opacity"],run:(t,n,e)=>{wn(e.color)&&Mn(t,n,e.color,"fill");let r=e.color!=null&&!wn(e.color)?Q(e.color,"#FFFFFF"):null;vt(t,n,o=>({...o,fc:r!=null?r:o.fc,fo:y(e.opacity,o.fo)}))}},set_stroke:{params:["color","width","opacity"],run:(t,n,e)=>{wn(e.color)&&Mn(t,n,e.color,"stroke");let r=e.color!=null&&!wn(e.color)?Q(e.color,"#FFFFFF"):null;vt(t,n,o=>({...o,sc:r!=null?r:o.sc,sw:y(e.width,o.sw),so:y(e.opacity,o.so)}))}},set_opacity:{params:["opacity"],run:(t,n,e)=>ge.opacity(t,n,e.opacity,null)},set_fill_opacity:{params:["opacity"],run:(t,n,e)=>ge.fill_opacity(t,n,e.opacity,null)},set_stroke_width:{params:["width"],run:(t,n,e)=>ge.stroke_width(t,n,e.width,null)},fade:{params:["darkness"],run:(t,n,e)=>{let r=1-y(e.darkness,.5);vt(t,n,o=>({...o,fo:o.fo*r,so:o.so*r}))}},set_z_index:{params:["z_index"],run:(t,n,e,r)=>ge.z_index(t,n,e.z_index,r)},become:{params:["mobject","match_height","match_width","match_depth","match_center","stretch"],run:(t,n,e)=>{let r=$(t,n);if(Re(t,n,W(t,e.mobject)),e.match_height&&Dt(t,n,1,r[3]-r[1],!!e.stretch),e.match_width&&Dt(t,n,0,r[2]-r[0],!!e.stretch),e.match_center){let o=at($(t,n)),s=at(r);Zt(t,n,[s[0]-o[0],s[1]-o[1]])}}},save_state:{params:[],run:(t,n)=>{let e=Me(t,n);t.update(n,{data:{...t.get(n).data||{},saved:e}})}},restore:{params:[],run:(t,n)=>{var o;let e=(o=t.get(n).data)==null?void 0:o.saved;if(e==null||!t.has(e))throw new Error("restore() needs save_state() first");let r=t.get(n).data;Re(t,n,e),t.update(n,{data:{...t.get(n).data||{},saved:r.saved}})}},put_start_and_end_on:{params:["start","end"],run:(t,n,e)=>{let r=Mt(t,n,"start"),o=Mt(t,n,"end"),s=it(t,e.start),a=it(t,e.end),i=[o[0]-r[0],o[1]-r[1]],c=[a[0]-s[0],a[1]-s[1]],u=Math.hypot(i[0],i[1])||1e-9,f=Math.hypot(c[0],c[1])/u,l=Math.atan2(c[1],c[0])-Math.atan2(i[1],i[0]),m=Y(Z(s[0],s[1]),Y(te(l,Wt),Y(St(f,f,Wt),Z(-r[0],-r[1]))));At(t,n,m)}},set_points:{params:["points","smooth"],run:(t,n,e)=>{let r=(e.points||[]).map(o=>it(t,o));t.update(n,{paths:r.length?[e.smooth?fn(r,!1):ot(r,!1)]:[],m:ft})}},set_z:{params:["z"],run:()=>{}},set_corner_radius:{params:["radius"],run:(t,n,e)=>Nr(t,n,r=>{var o;return{...r,radius:y((o=e.radius)!=null?o:e.corner_radius,0)}})},set_border:{params:["color","width"],run:(t,n,e)=>Nr(t,n,r=>{var o,s,a;return{...r,border:y((o=e.width)!=null?o:e.stroke_width,4)>0?{color:Q((s=e.color)!=null?s:"#FFFFFF","#FFFFFF"),width:y((a=e.width)!=null?a:e.stroke_width,4)}:void 0}})},crop:{params:["box"],run:(t,n,e)=>Nr(t,n,r=>{var f,l;let o=(e.box||[0,0,1,1]).map(Number),s=[Math.max(0,o[0]),Math.max(0,o[1]),Math.min(1,o[2]),Math.min(1,o[3])],a=(f=r.fullW)!=null?f:r.w,i=(l=r.fullH)!=null?l:r.h,c=r.w/(a*((r.crop?r.crop[2]-r.crop[0]:1)||1)),u=r.h/(i*((r.crop?r.crop[3]-r.crop[1]:1)||1));return{...r,crop:s,w:a*(s[2]-s[0])*c,h:i*(s[3]-s[1])*u}})},set_shadow:{params:["blur","offset","color","opacity"],run:(t,n,e)=>{var a;let r=Array.isArray(e.offset)?e.offset.map(Number):[.05,-.08],o={blur:y(e.blur,.2),dx:r[0]||0,dy:r[1]||0,color:Q((a=e.color)!=null?a:"#000000","#000000"),opacity:y(e.opacity,.5)},s=o.blur<=0&&!o.dx&&!o.dy;for(let i of st(t,n)){let c=t.get(i);ne(c)&&t.set({...c,shadow:s?void 0:o})}}},apply_matrix:{params:["matrix","about_point"],run:(t,n,e)=>{let r=e.matrix,o=e.about_point!=null?it(t,e.about_point):Wt,s=[r[0][0],r[1][0],r[0][1],r[1][1],0,0];At(t,n,Y(Z(o[0],o[1]),Y(s,Z(-o[0],-o[1]))))}},add_coordinates:{params:["num_decimal_places"],run:(t,n,e)=>Br(t,n,{include_numbers:!0})},change_bar_values:{params:["values"],run:(t,n,e)=>Br(t,n,{values:e.values})},change_layout:{params:["layout","layout_scale","layout_config","root_vertex"],run:(t,n,e)=>Br(t,n,Object.fromEntries(Object.entries(e).filter(([,r])=>r!=null)))},set_value:{params:["value"],run:(t,n,e)=>Vt(t,n,y(e.value,0))},increment_value:{params:["value"],run:(t,n,e)=>{var r,o,s;return Vt(t,n,Number((o=(r=t.get(n).data)==null?void 0:r.value)!=null?o:0)+y((s=e.value)!=null?s:e.d_value,0))}},surround:{params:["mobject","dim_to_match","stretch","buff","buffer_factor"],run:(t,n,e)=>{let r=$(t,W(t,e.mobject)),o=y(e.buffer_factor,1.2),s=y(e.dim_to_match,0)===1?1:0,a=(s===0?r[2]-r[0]:r[3]-r[1])*o+2*y(e.buff,0);Dt(t,n,s,a,!!e.stretch),e.stretch&&Dt(t,n,s===0?1:0,(s===0?r[3]-r[1]:r[2]-r[0])*o+2*y(e.buff,0),!0);let i=at($(t,n)),c=at(r);Zt(t,n,[c[0]-i[0],c[1]-i[1]])}},match_width:{params:["mobject"],run:(t,n,e)=>{let r=$(t,W(t,e.mobject));Dt(t,n,0,r[2]-r[0])}},match_height:{params:["mobject"],run:(t,n,e)=>{let r=$(t,W(t,e.mobject));Dt(t,n,1,r[3]-r[1])}},match_x:{params:["mobject"],run:(t,n,e,r)=>ge.x(t,n,at($(t,W(t,e.mobject)))[0],r)},match_y:{params:["mobject"],run:(t,n,e,r)=>ge.y(t,n,at($(t,W(t,e.mobject)))[1],r)},match_color:{params:["mobject"],run:(t,n,e)=>{let r=ms(t,W(t,e.mobject));vt(t,n,o=>({...o,sc:r.sc,fc:r.fc}))}},match_style:{params:["mobject"],run:(t,n,e)=>{let r=ms(t,W(t,e.mobject));vt(t,n,()=>({...r}))}},set_color_by_tex:{params:["tex","color","substring"],run:(t,n,e)=>{var r;for(let o of t.get(n).children){let s=(r=t.get(o).data)==null?void 0:r.tex;typeof s=="string"&&(e.substring===!1?s===e.tex:s.includes(String(e.tex)))&&Mn(t,o,e.color)}}},set_color_by_tex_to_color_map:{params:["texs_to_color_map"],run:(t,n,e)=>{let r=e.texs_to_color_map||{};for(let o of Object.keys(r))Wr.set_color_by_tex.run(t,n,{tex:o,color:r[o]},null)}},add:{params:["*mobjects"],run:(t,n,e)=>{let r=(e.mobjects||[]).map(s=>W(t,s)).filter(s=>s!==n),o=t.get(n).children.filter(s=>!r.includes(s));t.update(n,{children:[...o,...r]})}},remove:{params:["*mobjects"],run:(t,n,e)=>{let r=(e.mobjects||[]).map(o=>W(t,o));t.update(n,{children:t.get(n).children.filter(o=>!r.includes(o))})}}},bs=Object.keys(Wr);function Nr(t,n,e){let r=!1;for(let o of st(t,n)){let s=t.get(o);s.image&&(t.set({...s,image:e(s.image)}),r=!0)}if(!r)throw new Error("this works on images (ImageMobject)")}var Dr=null;function gs(t){Dr=t}function Br(t,n,e){var s;let r=t.get(n),o=(s=r.data)==null?void 0:s.props;if(!o||!Dr)throw new Error(`this ${r.kind} cannot be rebuilt here`);Dr(t,n,r.kind,{...o,...e}),At(t,n,r.m),t.update(n,{z:r.z})}var Za={move_to:{target:"point_or_mobject"},next_to:{target:"mobject_or_point"},align_to:{target:"mobject_or_point"},scale:{factor:"scale_factor"},become:{source:"mobject"},surround:{target:"mobject"},match_width:{source:"mobject"},match_height:{source:"mobject"},match_x:{source:"mobject"},match_y:{source:"mobject"},match_color:{source:"mobject"},match_style:{source:"mobject"}};function ue(t,n,e,r,o){let s=Wr[e];if(!s)throw new Error(`"${e}" is not something the animation layer can do yet`);let a=Ot(r,s.params),i=Za[e];if(i)for(let c of Object.keys(i))c in a&&!(i[c]in a)&&(a[i[c]]=a[c],delete a[c]);e==="shift"&&a.vector!=null&&a.vectors==null&&(a.vectors=[a.vector]),s.run(t,n,a,o)}function Ja(t){return t&&typeof t=="object"&&!Array.isArray(t)&&"key"in t&&"kind"in t&&"props"in t}var Qa=-1;function Qe(t){let n=t[1]&&typeof t[1]=="object"?{...t[1]}:{};return Array.isArray(n.children)&&(n.children=n.children.map(e=>ze(e)?Qe(e):e)),{key:Qa--,kind:String(t[0]),props:n,ops:Array.isArray(t[2])?t[2]:[]}}function ze(t){if(!Array.isArray(t)||typeof t[0]!="string"||t.length<2||t.length>3)return!1;let n=t[1];return!n||typeof n!="object"||Array.isArray(n)||"$pt"in n||"$x"in n||"tmpl"in n||typeof n.id=="number"&&Object.keys(n).every(e=>e==="id"||e==="path")?!1:t.length===2||Array.isArray(t[2])}function tn(t,n,e,r){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(a=>tn(t,a,e,r));if(Ja(n))return Zn(t,n,e,r);if(Array.isArray(n.mobject)&&ze(n.mobject)&&(n={...n,mobject:Qe(n.mobject)}),Array.isArray(n.children)&&n.children.some(ze)&&(n={...n,children:n.children.map(a=>ze(a)?Qe(a):a)}),"tmpl"in n&&Object.keys(n).every(a=>a==="tmpl"||a==="path")){let a=e.get(Number(n.tmpl));if(a==null)throw new Error("an object made inside an updater was used before it was made");return n.path&&n.path.length?{id:a,path:n.path}:a}let o=!1,s={};for(let a of Object.keys(n))s[a]=tn(t,n[a],e,r),s[a]!==n[a]&&(o=!0);return o?s:n}function Zn(t,n,e,r,o){let s=e.get(n.key);if(s!=null)return s;let a=o!=null?o:t.newId();e.set(n.key,a);let i=Bt(t,tn(t,n.props,e,r));if(n.kind==="copy"?Me(t,W(t,i.mobject),a):r.make(t,a,n.kind,i),!t.has(a))throw new Error(`${n.kind} could not be built here yet`);for(let[c,u]of n.ops||[])ue(t,a,c,Bt(t,tn(t,u,e,r)),r.env);return a}function Xn(t,n,e,r){let o=new Map,s=[];for(let a of n||[]){let[i,c,u]=a,f=u!=null?W(t,tn(t,u,o,r)):e;f!=null&&(ue(t,f,String(i),Bt(t,tn(t,c,o,r)),r.env),s.push(f))}return s}var kn=1/60,qn=class{constructor(){this.list=[];this.dtCache=new WeakMap;this.redrawCache=new Map}reset(){this.list=[],this.dtCache=new WeakMap,this.redrawCache.clear()}add(n,e,r){let o=e.uid!=null?String(e.uid):`u${this.list.length}`;this.list.push({uid:o,target:n,spec:e,from:r,to:1/0,off:[]})}remove(n,e,r){for(let o of this.list)o.target===n&&o.uid===String(e)&&o.to===1/0&&(o.to=r)}clear(n,e){for(let r of this.list)r.target===n&&r.to===1/0&&(r.to=e)}suspend(n,e){for(let r of this.list){if(r.target!==n||r.to!==1/0)continue;let o=r.off[r.off.length-1];(!o||o[1]!==1/0)&&r.off.push([e,1/0])}}resume(n,e){for(let r of this.list){let o=r.off[r.off.length-1];r.target===n&&o&&o[1]===1/0&&(o[1]=e)}}active(n){return this.list.filter(e=>e.from<=n&&n<e.to&&!e.off.some(([r,o])=>r<=n&&n<o))}apply(n,e,r,o){let s=[];for(let a of this.active(e))if(!(!n.has(a.target)&&a.spec.kind!=="redraw")){mt.t=e,mt.dt=0;try{if(a.spec.kind==="op"&&!a.spec.accumulate)s.push(...Xn(n,a.spec.ops,a.target,o));else if(a.spec.kind==="redraw")this.redraw(n,a,o);else if((a.spec.kind==="dt"||a.spec.kind==="op")&&r)this.integrate(n,a,e,r,o);else{if(a.spec.kind==="python")continue;continue}}catch(i){continue}s.push(a.target)}return s}redraw(n,e,r){!e.spec.template&&e.spec.make&&ze(e.spec.make)&&(e.spec.template=Qe(e.spec.make));let o=e.spec.template,[s,a]=e.spec.make||[o?o.kind:"group",o||{}],i=Bt(n,a),c=JSON.stringify(i),u=`${e.uid}|${e.target}`,f=this.redrawCache.get(u);if(f&&f.key===c){for(let p of f.mobs)n.set(p);return}let l=n.fork(),m=l.has(e.target)?l.get(e.target):null;if(o?Zn(l,o,new Map,r,e.target):r.make(l,e.target,s,i),!l.has(e.target))return;m&&l.update(e.target,{z:m.z});let h=st(l,e.target).map(p=>l.get(p));this.redrawCache.set(u,{key:c,mobs:h});for(let p of h)n.set(p)}integrate(n,e,r,o,s){var g,w,M,S,b,_,x,P;let a=Math.max(o.t0,e.from);if(r<=a)return;let i=this.dtCache.get(o);i||(i=new Map,this.dtCache.set(o,i));let c=`${e.uid}|${e.target}|${a}`,u=i.get(c);if(!u){let k=new Ht(new Map(o.before.mobs),o.before.display.slice(),s.ids);if(!k.has(e.target))return;let v=k.get(e.target);u={states:[{m:v.m,value:Number((w=(g=v.data)==null?void 0:g.value)!=null?w:0)}],sim:k},i.set(c,u)}let f=(k,v,C)=>{mt.t=C,mt.dt=v,Xn(k,e.spec.ops,e.target,s)},l=Math.floor((r-a)/kn+1e-9);for(;u.states.length<=l;){f(u.sim,kn,a+(u.states.length-1)*kn);let k=u.sim.get(e.target);u.states.push({m:k.m,value:Number((S=(M=k.data)==null?void 0:M.value)!=null?S:0)})}let m=u.states[l],h=r-a-l*kn;if(h>1e-9){let k=new Ht(new Map(u.sim.mobs),u.sim.display.slice(),s.ids);k.update(e.target,{m:m.m,data:{...k.get(e.target).data||{},value:m.value}}),f(k,h,a+l*kn);let v=k.get(e.target);m={m:v.m,value:Number((_=(b=v.data)==null?void 0:b.value)!=null?_:0)}}let p=u.states[0],d=Y(m.m,xe(p.m));for(let k of st(n,e.target)){let v=n.get(k);n.set({...v,m:Y(d,v.m)})}m.value!==p.value&&Vt(n,e.target,Number((P=(x=n.get(e.target).data)==null?void 0:x.value)!=null?P:0)+m.value-p.value),mt.dt=0}activeUid(n,e){let r=this.list.filter(o=>o.uid===n);return r.length?r.some(o=>o.from<=e&&e<o.to&&!o.off.some(([s,a])=>s<=e&&e<a)):null}get any(){return this.list.length>0}};var ti=t=>t<0?0:t>1?1:t,ys=t=>1/(1+Math.exp(-t));function xt(t,n=10){let e=ys(-n/2);return ti((ys(n*(t-.5))-e)/(1-2*e))}var jt=t=>t;function Ee(t){return xt(t<.5?2*t:2*(1-t))}function ei(t,n){let e=t.length-1,r=0,o=1;for(let s=0;s<=e;s++)s>0&&(o=o*(e-s+1)/s),r+=o*Math.pow(1-n,e-s)*Math.pow(n,s)*t[s];return r}var en=Math.PI,tr=1.70158,Jn=tr*1.525,_s=tr+1,xs=2*en/3,ws=2*en/4.5;function Qn(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}var jr={linear:jt,smooth:t=>xt(t),smoothstep:t=>t<=0?0:t>=1?1:3*t*t-2*t*t*t,smootherstep:t=>t<=0?0:t>=1?1:t*t*t*(10-15*t+6*t*t),smoothererstep:t=>t<=0?0:t>=1?1:t**4*(35-84*t+70*t*t-20*t*t*t),rush_into:t=>2*xt(t/2),rush_from:t=>2*xt(t/2+.5)-1,slow_into:t=>Math.sqrt(1-(1-t)*(1-t)),double_smooth:t=>t<.5?.5*xt(2*t):.5*(1+xt(2*t-1)),there_and_back:Ee,there_and_back_with_pause:t=>{let n=.3333333333333333,e=1/n;return t<.5-n/2?xt(e*t):t<.5+n/2?1:xt(e-e*t)},running_start:t=>ei([0,0,-.5,-.5,1,1,1],t),not_quite_there:t=>.7*xt(t),wiggle:t=>Ee(t)*Math.sin(2*en*t),lingering:t=>t<.8?t/.8:1,exponential_decay:t=>1-Math.exp(-t/.1),ease_in_sine:t=>1-Math.cos(t*en/2),ease_out_sine:t=>Math.sin(t*en/2),ease_in_out_sine:t=>-(Math.cos(en*t)-1)/2,ease_in_quad:t=>t*t,ease_out_quad:t=>1-(1-t)*(1-t),ease_in_out_quad:t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,ease_in_cubic:t=>t*t*t,ease_out_cubic:t=>1-Math.pow(1-t,3),ease_in_out_cubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,ease_in_quart:t=>t**4,ease_out_quart:t=>1-Math.pow(1-t,4),ease_in_out_quart:t=>t<.5?8*t**4:1-Math.pow(-2*t+2,4)/2,ease_in_quint:t=>t**5,ease_out_quint:t=>1-Math.pow(1-t,5),ease_in_out_quint:t=>t<.5?16*t**5:1-Math.pow(-2*t+2,5)/2,ease_in_expo:t=>t===0?0:Math.pow(2,10*t-10),ease_out_expo:t=>t===1?1:1-Math.pow(2,-10*t),ease_in_out_expo:t=>t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2,ease_in_circ:t=>1-Math.sqrt(1-t*t),ease_out_circ:t=>Math.sqrt(1-Math.pow(t-1,2)),ease_in_out_circ:t=>t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2,ease_in_back:t=>_s*t*t*t-tr*t*t,ease_out_back:t=>1+_s*Math.pow(t-1,3)+tr*Math.pow(t-1,2),ease_in_out_back:t=>t<.5?Math.pow(2*t,2)*((Jn+1)*2*t-Jn)/2:(Math.pow(2*t-2,2)*((Jn+1)*(t*2-2)+Jn)+2)/2,ease_in_elastic:t=>t===0?0:t===1?1:-Math.pow(2,10*t-10)*Math.sin((t*10-10.75)*xs),ease_out_elastic:t=>t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*xs)+1,ease_in_out_elastic:t=>t===0?0:t===1?1:t<.5?-(Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*ws))/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*ws)/2+1,ease_in_bounce:t=>1-Qn(1-t),ease_out_bounce:Qn,ease_in_out_bounce:t=>t<.5?(1-Qn(1-2*t))/2:(1+Qn(2*t-1))/2};function ni(t){let n=t.length-1;return e=>{if(e<=0)return t[0];if(e>=1)return t[n];let r=e*n,o=Math.floor(r);return t[o]+(t[o+1]-t[o])*(r-o)}}function er(t,n=jr.smooth){if(t&&typeof t=="object"&&Array.isArray(t.samples)){let o=t.samples.map(Number);if(o.length>=2)return ni(o)}if(typeof t!="string"||!t)return n;let e=t.replace(/^rate_functions\./,"").replace(/^rate_func\./,"");e=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase();let r=jr[e];return r?e==="exponential_decay"?o=>o>1?1:r(o<0?0:o):o=>r(o<0?0:o>1?1:o):n}var Ms=Object.keys(jr);var $e=class{constructor(n){this.scene=n;this.over=new Map;this.extras=[]}get(n){let e=this.over.get(n);if(e)return e;let r=this.scene.mobs.get(n);return r?(e={m:r.m,alpha:1,style:r.style,partial:null},this.over.set(n,e),e):null}};function nn(t,n,e){return e<=0?t:e>=1?n:{sc:Ie(t.sc,n.sc,e),fc:Ie(t.fc,n.fc,e),sw:t.sw+(n.sw-t.sw)*e,so:t.so+(n.so-t.so)*e,fo:t.fo+(n.fo-t.fo)*e}}var vs=t=>t<0?0:t>1?1:t;function le(t,n,e,r){if(e<=1||r<=0)return t;let o=(e-1)*r+1;return vs(t*o-n*r)}function ve(t,n,e){return(r,o,s,a)=>{let i=t.length;t.forEach((c,u)=>{let f=o.get(c);if(!f)return;let l=s(le(r,u,i,a));f.m=Y(n(l),f.m),e&&(f.alpha*=e(l))})}}function Sn(t){return t.paths.length?zt(t.paths,t.m):[]}var nr=t=>({...t,so:0,fo:0});function on(t,n,e,r,o,s,a=0){let i=n.map(h=>t.mobs.get(h)),c=r.map(h=>e.mobs.get(h)),u=Math.max(i.length,c.length),f=[],l=-1,m=-1;for(let h=0;h<u;h++){let p=i.length?Math.floor(h*i.length/u):-1,d=c.length?Math.floor(h*c.length/u):-1,g=p>=0?i[p]:null,w=d>=0?c[d]:null,M=p===l,S=d===m;if(l=p,m=d,g&&(g.text||g.image)&&!g.paths.length||w&&(w.text||w.image)&&!w.paths.length){f.push({A:[],B:[],sa:g==null?void 0:g.style,sb:w==null?void 0:w.style,z:(w||g).z,fadeA:g&&!M?g:void 0,fadeB:w&&!S?w:void 0});continue}let b=w?S?nr(w.style):w.style:nr(g.style),_=g?M?nr(g.style):g.style:nr(w.style),[x,P]=_o(g?Sn(g):[],w?Sn(w):[],o,s);f.push({A:x,B:P,sa:_,sb:b,z:w?w.z:g.z,arc:a})}return f}function ri(t,n,e,r){if(e<=0)return t;if(e>=1)return n;let o=1/(2*Math.tan(r/2)),s=Math.cos(e*r),a=Math.sin(e*r);return t.map((i,c)=>({closed:e<.5?i.closed:n[c].closed,points:i.points.map((u,f)=>{let l=n[c].points[f],m=l[0]-u[0],h=l[1]-u[1],p=u[0]+m/2-h*o,d=u[1]+h/2+m*o,g=u[0]-p,w=u[1]-d;return[p+s*g-a*w,d+a*g+s*w]})}))}function Pn(t,n,e,r,o=[]){let s=t.length;return t.forEach((a,i)=>{let c=e(le(n,i,s,r));if(a.fadeA||a.fadeB){a.fadeA&&o.push(rn(a.fadeA,1-c)),a.fadeB&&o.push(rn(a.fadeB,c));return}let u=a.arc&&Math.abs(a.arc)>1e-6?ri(a.A,a.B,c,a.arc):dr(a.A,a.B,c);o.push({paths:u,m:ft,style:nn(a.sa,a.sb,c),alpha:1,partial:null,z:a.z})}),o}function rn(t,n){return{paths:t.paths,m:t.m,style:t.style,alpha:n,partial:null,z:t.z,text:t.text,image:t.image,shadow:t.shadow,evenodd:t.evenodd}}function ks(t,n,e){for(let o of Array.from(t.mobs.values()))o.id!==e&&o.children.includes(n)&&t.update(o.id,{children:o.children.map(s=>s===n?e:s)});if(t.display.indexOf(n)>=0){let o=t.display.filter(s=>s!==e);o[o.indexOf(n)]=e,t.setDisplay(o)}else oe(t,[n]),Lt(t,[e])}function oi(t,n){return{sc:t.sw>0?t.sc:t.fc,fc:t.fc,sw:n,so:1,fo:0}}function zr(t,n,e,r){let o=t.get(n);if(!o)return;if(!t.scene.mobs.get(n).paths.length){o.alpha*=e;return}let a=oi(o.style,r);e<.5?(o.partial=[0,e*2],o.style=a):o.style=nn(a,o.style,e*2-1)}function si(t,n,e,r){let o=$(t,n),s=at(o);return r?[ee(s,Math.hypot(o[2]-o[0],o[3]-o[1])/2+e)]:zt([ot(pe(o[2]-o[0]+2*e,o[3]-o[1]+2*e),!0)],Z(s[0],s[1]))}function Ps(t,n,e){let r=(n[2]-n[0])/(t[2]-t[0]||1),o=(n[3]-n[1])/(t[3]-t[1]||1);t[2]-t[0]<1e-9&&(r=o),t[3]-t[1]<1e-9&&(o=r),e||(r=o=Math.min(r,o));let s=[(t[0]+t[2])/2,(t[1]+t[3])/2],a=[(n[0]+n[2])/2,(n[1]+n[3])/2];return Y(Z(a[0]-s[0],a[1]-s[1]),St(r,o,s))}function ai(t,n,e,r){if(Math.abs(r)<1e-6)return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e];let o=1/(2*Math.tan(r/2)),s=n[0]-t[0],a=n[1]-t[1],i=t[0]+s/2-a*o,c=t[1]+a/2+s*o,u=Math.cos(e*r),f=Math.sin(e*r),l=t[0]-i,m=t[1]-c;return[i+u*l-f*m,c+f*l+u*m]}function $r(t,n){let e=t*(1+n);return[Math.max(0,e-n),Math.min(1,e)]}var ii={apply_pointwise_function:["function"],apply_complex_function:["function"],homotopy:["homotopy"],complex_homotopy:["complex_homotopy"],apply_wave:["direction","amplitude"],swap:["*mobjects"],cyclic_replace:["*mobjects"],broadcast:["focal_point"],focus_on:["focus_point"],blink:["time_on","time_off","blinks","hide_at_end"],fade_in:["shift","target_position","scale"],fade_out:["shift","target_position","scale"],transform:["target_mobject","path_arc"],replacement_transform:["target_mobject","path_arc"],transform_from_copy:["target_mobject","path_arc"],transform_matching_tex:["target_mobject"],transform_matching_shapes:["target_mobject"],fade_transform:["target_mobject"],grow_from_point:["point"],grow_from_edge:["edge"],spin_in_from_nothing:["angle"],indicate:["scale_factor","color"],circumscribe:["shape","fade_in","fade_out","time_width","buff","color"],flash:["point","line_length","num_lines","flash_radius","line_stroke_width","color","time_width"],wiggle:["scale_value","rotation_angle","n_wiggles"],rotate:["angle","axis","about_point","about_edge"],move_along_path:["path"],animate:["ops"],change_decimal_to_value:["number"],changing_decimal:["function"],show_passing_flash:["time_width"],draw_border_then_fill:["stroke_width"]},Ts=["create","uncreate","write","unwrite","draw_border_then_fill","fade_in","fade_out","transform","replacement_transform","transform_from_copy","transform_matching_tex","transform_matching_shapes","fade_transform","grow_from_center","grow_from_point","grow_from_edge","grow_arrow","shrink_to_center","spin_in_from_nothing","indicate","circumscribe","flash","wiggle","rotate","move_along_path","animate","show_passing_flash","restore","change_decimal_to_value","apply_pointwise_function","apply_complex_function","homotopy","complex_homotopy","apply_wave","show_increasing_subsets","show_submobjects_one_by_one","add_text_letter_by_letter","remove_text_letter_by_letter","swap","cyclic_replace","fade_transform_pieces","broadcast","blink","focus_on","change_speed","changing_decimal","wait","group","lagged","succession"],ci={_animate:"animate",_method_animation:"animate",method_animation:"animate",move_to_target:"transform",rotating:"rotate",show_creation:"create",clockwise_transform:"transform",counterclockwise_transform:"transform",lagged_start:"lagged",animation_group:"group"};function or(t){let n=String(t||"").replace(/^\./,"_").replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase();return ci[n]||n}var ui=new Set(["wait","flash","transform_from_copy","broadcast","focus_on","swap","cyclic_replace","fade_transform","fade_transform_pieces"]);function li(t,n){let e=mi(t,n),r=or(t.kind);if(!e.begin&&!ui.has(r)&&t.target!=null&&t.target!==0){let o=W(n.w,t.target);e.begin=s=>{br(s,o)||Lt(s,[o])}}return e}function mi(t,n){var i,c,u,f,l,m,h,p,d,g,w,M,S;let e=n.w,r=or(t.kind),o=Ot(t.args,ii[r]||[]);o.to!=null&&o.target_mobject==null&&(o.target_mobject=o.to);let s=()=>W(e,t.target),a=b=>({run:1,rate:xt,lag:0,...b});switch(r){case"wait":return a({run:y((i=o.duration)!=null?i:t.run_time,1),apply:()=>{}});case"fade_in":case"fade_out":{let b=s(),_=et(e,b),x=pt(e,b),P=o.shift!=null?it(e,o.shift):[0,0],k=y(o.scale,1);if(r==="fade_in"){let C=Y(St(k,k,[x[0]-P[0],x[1]-P[1]]),Z(-P[0],-P[1]));if(o.target_position!=null){let F=Ft(o.target_position)?pt(e,W(e,o.target_position)):it(e,o.target_position);C=Z(F[0]-x[0],F[1]-x[1])}return a({intro:!0,target:b,apply:ve(_,F=>de(C,ft,F),F=>F),begin:F=>Lt(F,[b])})}let v=Y(St(k,k,[x[0]+P[0],x[1]+P[1]]),Z(P[0],P[1]));return a({apply:ve(_,C=>de(ft,v,C),C=>1-C),end:C=>oe(C,[b])})}case"create":case"uncreate":case"show_passing_flash":{let b=s(),_=et(e,b),x=y(o.time_width,.1),P=r==="create"?v=>[0,v]:r==="uncreate"?v=>[0,1-v]:v=>$r(v,x),k=(v,C,F,T)=>{_.forEach((I,B)=>{let L=C.get(I);if(!L)return;let D=F(le(v,B,_.length,T));if(!C.scene.mobs.get(I).paths.length){L.alpha*=r==="create"?D:1-D;return}L.partial=P(D)})};return a(r==="create"?{lag:1,intro:!0,target:b,apply:k,begin:v=>Lt(v,[b])}:r==="uncreate"?{lag:1,apply:k,end:v=>oe(v,[b])}:{apply:k,intro:!0,target:b,begin:v=>Lt(v,[b]),end:v=>oe(v,[b])})}case"write":case"unwrite":case"draw_border_then_fill":{let b=s(),_=et(e,b),x=_.length,P=y(o.stroke_width,2);if(r==="draw_border_then_fill")return a({run:2,rate:er("double_smooth"),intro:!0,target:b,apply:(T,I,B,L)=>_.forEach((D,j)=>zr(I,D,B(le(T,j,x,L)),P)),begin:T=>Lt(T,[b])});let k=0;for(let T of _){let I=e.get(T).text;k+=I?Math.max(1,Array.from(I.str).filter(B=>B.trim()).length):1}let v=k<15?1:2,C=Math.min(4/Math.max(1,k),.2),F=T=>(r==="write"?o.reverse:o.reverse!==!1)?x-1-T:T;return a(r==="write"?{run:v,rate:jt,lag:C,intro:!0,target:b,apply:(T,I,B,L)=>_.forEach((D,j)=>zr(I,D,B(le(T,F(j),x,L)),P)),begin:T=>Lt(T,[b])}:{run:v,rate:jt,lag:C,apply:(T,I,B,L)=>_.forEach((D,j)=>zr(I,D,1-B(le(T,F(j),x,L)),P)),end:T=>oe(T,[b])})}case"transform":case"replacement_transform":case"transform_from_copy":case"transform_matching_shapes":case"transform_matching_tex":{let b=s(),_=W(e,o.target_mobject),x=pt(e,b),P=pt(e,_);if(r==="transform_matching_tex"||r==="transform_matching_shapes"){let T=r==="transform_matching_tex"?fi(e,b,_,x,P):hi(e,b,_,x,P);if(T)return a({apply:(I,B,L)=>{let D=B.get(b);if(!D)return;let j=L(I),J=Pn(T.pairs,I,L,0);for(let G of T.out)J.push(rn(B.scene.mobs.get(G)||e.get(G),1-j));for(let G of T.in)J.push(rn(e.get(G),j));D.replace=J;let ut=B.get(_);ut&&_!==b&&(ut.hidden=!0)},end:I=>ks(I,b,_)})}let k=on(e,et(e,b),e,et(e,_),P,x,y(o.path_arc,0)),v=r==="transform_from_copy"?_:b,C=st(e,b).filter(T=>T!==b),F=(T,I,B,L)=>{let D=I.get(v);if(D){if(D.replace=Pn(k,T,B,L),r!=="transform_from_copy")for(let j of C){let J=I.get(j);J&&(J.hidden=!0)}if(r!=="transform_from_copy"&&_!==b){let j=I.get(_);j&&(j.hidden=!0)}}};return a(r==="transform"?{apply:F,end:T=>Re(T,b,_)}:r==="transform_from_copy"?{apply:F,intro:!0,target:_,begin:T=>Lt(T,[_])}:{apply:F,end:T=>ks(T,b,_)})}case"grow_from_center":case"grow_from_point":case"grow_from_edge":case"grow_arrow":case"spin_in_from_nothing":case"shrink_to_center":{let b=s(),_=et(e,b),x=pt(e,b);r==="grow_from_point"&&(x=Ft(o.point)?pt(e,W(e,o.point)):it(e,(c=o.point)!=null?c:[0,0])),r==="grow_from_edge"&&(x=Et($(e,b),Rt(e,o.edge,[0,-1]))),r==="grow_arrow"&&(x=Mt(e,b,"start"));let P=[0,0,0,0,x[0],x[1]];if(r==="shrink_to_center")return a({apply:ve(_,T=>de(ft,P,T)),end:T=>At(T,b,P)});let k=r==="spin_in_from_nothing"?y(o.angle,Math.PI/2):0,C=ve(_,T=>k?Y(te(-(1-T)*k,x),St(T,T,x)):de(P,ft,T));return a({intro:!0,target:b,apply:r!=="grow_arrow"?C:(T,I,B,L)=>{C(T,I,B,L),_.forEach((D,j)=>{let J=I.get(D);J&&(J.style={...J.style,sw:J.style.sw*B(le(T,j,_.length,L))})})},begin:T=>Lt(T,[b])})}case"restore":{let b=s(),_=(u=e.get(b).data)==null?void 0:u.saved;if(_==null||!e.has(_))throw new Error("Restore needs save_state() first");let x=on(e,et(e,b),e,et(e,_),pt(e,_),pt(e,b),y(o.path_arc,0)),P=e.get(b).data;return a({apply:(k,v,C,F)=>{let T=v.get(b);T&&(T.replace=Pn(x,k,C,F))},end:k=>{Re(k,b,_),k.update(b,{data:{...k.get(b).data||{},saved:P.saved}})}})}case"indicate":{let b=s(),_=et(e,b),x=pt(e,b),P=y(o.scale_factor,1.2),k=Q((f=o.color)!=null?f:pn,pn);return a({rate:Ee,apply:(v,C,F,T)=>_.forEach((I,B)=>{let L=C.get(I);if(!L)return;let D=F(le(v,B,_.length,T));L.m=Y(St(1+(P-1)*D,1+(P-1)*D,x),L.m),L.style=nn(L.style,{...L.style,sc:k,fc:k},D)})})}case"circumscribe":{let b=s(),_=si(e,b,y(o.buff,.1),String(o.shape||"").toLowerCase()==="circle"),x=Q((l=o.color)!=null?l:Ce,Ce),P=y(o.time_width,.3),k={sc:x,fc:x,sw:y(o.stroke_width,4),so:1,fo:0};return a({rate:jt,apply:(v,C,F)=>{let T=xt(F(v)),I,B=1;o.fade_out?(I=[0,Math.min(1,T*2)],B=T<.5?1:2-2*T):o.fade_in?(I=[0,1],B=T<.5?2*T:2-2*T):I=$r(T,P),C.extras.push({paths:_,m:ft,style:k,alpha:B,partial:I,z:1e6})}})}case"flash":{let b=t.target!=null?t.target:o.point,_=Ft(b)?pt(e,W(e,b)):it(e,b!=null?b:[0,0]),x=Math.max(1,Math.round(y(o.num_lines,12))),P=y(o.flash_radius,.1)+.2,k=y(o.line_length,.2),v=Q((m=o.color)!=null?m:Ce,Ce),C=y(o.time_width,1),F={sc:v,fc:v,sw:y(o.line_stroke_width,3),so:1,fo:0},T=[];for(let I=0;I<x;I++){let B=2*Math.PI*I/x,L=Math.cos(B),D=Math.sin(B);T.push(ot([[_[0]+L*P,_[1]+D*P],[_[0]+L*(P+k),_[1]+D*(P+k)]],!1))}return a({rate:jt,apply:(I,B,L)=>{let D=$r(xt(L(I)),C);for(let j of T)B.extras.push({paths:[j],m:ft,style:F,alpha:1,partial:D,z:1e6})}})}case"wiggle":{let b=s(),_=et(e,b),x=pt(e,b),P=y(o.scale_value,1.1),k=y(o.rotation_angle,.01*2*Math.PI),v=y(o.n_wiggles,6);return a({run:2,apply:ve(_,C=>{let F=1+(P-1)*Ee(C);return Y(te(Ee(C)*Math.sin(v*Math.PI*C)*k,x),St(F,F,x))})})}case"rotate":{let b=s(),_=et(e,b),x=y(o.angle,Math.PI),P=o.about_point!=null?it(e,o.about_point):o.about_edge!=null?Et($(e,b),Rt(e,o.about_edge,[0,0])):pt(e,b);return a({apply:ve(_,k=>Je(x*k,o.axis,P)),end:k=>At(k,b,Je(x,o.axis,P))})}case"move_along_path":{let b=s(),_=et(e,b),x=pt(e,b),P=W(e,o.path),k=[];for(let C of et(e,P))k.push(...Sn(e.get(C)));let v=C=>{let F=we(k,C);return Z(F[0]-x[0],F[1]-x[1])};return a({apply:ve(_,v),end:C=>At(C,b,v(1))})}case"apply_pointwise_function":case"apply_complex_function":case"homotopy":case"complex_homotopy":case"apply_wave":{let b=s(),_=et(e,b),x=(p=(h=o.function)!=null?h:o.func)!=null?p:o.homotopy,P=_.map(I=>({id:I,mob:e.get(I),paths:Sn(e.get(I))})),k=r==="apply_complex_function"||r==="complex_homotopy",v=r==="homotopy"||r==="complex_homotopy",C=(I,B)=>{mt.alpha=B,mt.homotopy=v;let L=cs(I,()=>$t(e,x));return mt.homotopy=!1,k&&typeof L!="number"?[L[0],L[1]]:typeof L=="number"?[L,0]:[L[0],L[1]]},F=(I,B)=>I.map(L=>({closed:L.closed,points:L.points.map(B)}));if(r==="apply_wave"){let I=$(e,b),B=Rt(e,o.direction,[0,1]),L=y(o.amplitude,.2),D=y(o.time_width,1),j=Math.max(1,y(o.ripples,1)),J=I[2]-I[0]||1,ut=(G,ct)=>{let ht=(G-(ct*(1+D)-D))/D;return ht<=0||ht>=1?0:j===1?Ee(ht):Math.sin(j*Math.PI*ht)*Ee(ht)};return a({run:2,apply:(G,ct,ht)=>{let Kt=ht(G);for(let wt of P){let Jt=ct.get(wt.id);if(!Jt)continue;let Qt=F(wt.paths,Gt=>{let ye=L*ut((Gt[0]-I[0])/J,Kt);return[Gt[0]+B[0]*ye,Gt[1]+B[1]*ye]});Jt.replace=[{paths:Qt,m:ft,style:Jt.style,alpha:Jt.alpha,partial:null,z:wt.mob.z}]}}})}if(x==null)throw new Error(`${t.kind} needs a function the preview can trace`);let T=v?null:P.map(I=>F(I.paths,B=>C(B,1)));return a({run:3,apply:(I,B,L)=>{let D=L(I);P.forEach((j,J)=>{let ut=B.get(j.id);if(!ut)return;let G=v?F(j.paths,ct=>C(ct,D)):dr(j.paths,T[J],D);ut.replace=[{paths:G,m:ft,style:ut.style,alpha:ut.alpha,partial:null,z:j.mob.z}]})},end:I=>P.forEach((B,L)=>{if(!I.has(B.id))return;let D=v?F(B.paths,j=>C(j,1)):T[L];I.update(B.id,{paths:D,m:ft})})})}case"show_increasing_subsets":case"show_submobjects_one_by_one":case"add_text_letter_by_letter":case"remove_text_letter_by_letter":{let b=s(),_=r.endsWith("letter_by_letter")?et(e,b):e.get(b).children,x=_.length,P=_.map(F=>st(e,F)),k=r==="remove_text_letter_by_letter",v=r.endsWith("letter_by_letter")?Math.max(.06,y(o.time_per_char,.1)*x):1,C=(F,T,I)=>{let B=I(F)*x,D=(o.int_func?o.int_func==="ceil":r.endsWith("letter_by_letter"))?Math.ceil(B-1e-9):Math.floor(B+1e-9);k&&(D=x-D),P.forEach((j,J)=>{if(r==="show_submobjects_one_by_one"?J!==Math.min(x-1,D):J>=D)for(let G of j){let ct=T.get(G);ct&&(ct.hidden=!0)}})};return a(k?{run:v,rate:jt,apply:C,end:F=>oe(F,[b])}:{run:v,rate:r.endsWith("letter_by_letter")?jt:xt,intro:!0,target:b,apply:C,begin:F=>Lt(F,[b])})}case"swap":case"cyclic_replace":{let b=[...t.target!=null?[s()]:[],...(o.mobjects||[]).map(k=>W(e,k))],_=y(o.path_arc,Math.PI/2),x=b.map(k=>pt(e,k)),P=b.map((k,v)=>{let C=x[v],F=x[(v+1)%b.length];return{id:k,ids:et(e,k),at:T=>{let I=ai(C,F,T,_);return Z(I[0]-C[0],I[1]-C[1])}}});return a({apply:(k,v,C,F)=>{for(let T of P)ve(T.ids,T.at)(k,v,C,F)},end:k=>{for(let v of P)At(k,v.id,v.at(1))}})}case"fade_transform":case"fade_transform_pieces":{let b=s(),_=W(e,o.target_mobject),x=o.stretch!==!1,k=(r==="fade_transform_pieces"&&e.get(b).children.length===e.get(_).children.length&&e.get(b).children.length?e.get(b).children.map((v,C)=>[v,e.get(_).children[C]]):[[b,_]]).map(([v,C])=>{let F=$(e,v),T=$(e,C);return{s:et(e,v),d:et(e,C),toB:Ps(F,T,x),toA:Ps(T,F,x)}});return a({apply:(v,C,F)=>{let T=F(v);for(let I of k){for(let B of I.s){let L=C.get(B);L&&(L.m=Y(de(ft,I.toB,T),L.m),L.alpha*=1-T)}for(let B of I.d){let L=C.get(B);L&&(L.m=Y(de(I.toA,ft,T),L.m),L.alpha*=T)}}},begin:v=>Lt(v,[_]),end:v=>oe(v,[b])})}case"broadcast":{let b=s(),_=et(e,b),x=pt(e,b),P=o.focal_point!=null?it(e,o.focal_point):x,k=Math.max(1,Math.round(y(o.n_mobs,5))),v=$(e,b),C=y(o.initial_width,0)/(v[2]-v[0]||1),F=y(o.initial_opacity,1),T=y(o.final_opacity,0),I=_.map(B=>e.get(B));return a({run:3,lag:y((d=t.lag_ratio)!=null?d:o.lag_ratio,.2),apply:(B,L,D,j)=>{for(let J=0;J<k;J++){let ut=D(le(B,J,k,j));if(ut<=0||ut>=1)continue;let G=C+(1-C)*ut,ct=Y(St(G,G,P),Z(P[0]-x[0],P[1]-x[1]));for(let ht of I)L.extras.push({paths:ht.paths,m:Y(ct,ht.m),style:ht.style,alpha:F+(T-F)*ut,partial:null,z:ht.z,text:ht.text})}}})}case"blink":{let b=s(),_=et(e,b),x=y(o.time_on,.5),P=y(o.time_off,.5),k=Math.max(1,Math.round(y(o.blinks,1))),v=!!o.hide_at_end,C=x+k*(P+x)-(v?x:0);return a({run:C,rate:jt,apply:(F,T)=>{let I=F*C;if(F>=1?v:I>=x&&(I-x)%(P+x)<P)for(let L of _){let D=T.get(L);D&&(D.alpha=0)}},end:v?F=>vt(F,b,T=>({...T,fo:0,so:0})):void 0})}case"focus_on":{let b=t.target!=null?t.target:o.focus_point,_=Ft(b)?pt(e,W(e,b)):it(e,b!=null?b:[0,0]),x=Q((g=o.color)!=null?g:"#888888","#888888"),P=y(o.opacity,.2),k=Math.hypot(n.env.fw,n.env.fh);return a({run:2,apply:(v,C,F)=>{let T=F(v),I=Math.max(.001,k*(1-T));C.extras.push({paths:[ee(_,I)],m:ft,style:{sc:x,fc:x,sw:0,so:0,fo:P*T},alpha:1,partial:null,z:1e6})}})}case"animate":return Es(t,o,n);case"change_decimal_to_value":return Es(t,{ops:[["set_value",[(M=(w=o.number)!=null?w:o.value)!=null?M:o.target_number]]]},n);case"changing_decimal":{let b=s(),_=(S=o.function)!=null?S:o.number_update_func,x=new Ht(new Map(e.mobs),e.display.slice(),e.ids),P=k=>(mt.alpha=k,Number($t(e,_)));return a({apply:(k,v,C)=>{let F=v.get(b);if(!F)return;let T=x.fork();Vt(T,b,P(C(k))),F.replace=et(T,b).map(I=>rn(T.get(I),F.alpha))},end:k=>Vt(k,b,P(1))})}}throw new Error(`the animation layer cannot play "${r}" yet`)}function fi(t,n,e,r,o){let s=t.get(n).children.filter(l=>{var m;return typeof((m=t.get(l).data)==null?void 0:m.tex)=="string"}),a=t.get(e).children.filter(l=>{var m;return typeof((m=t.get(l).data)==null?void 0:m.tex)=="string"});if(!s.length||!a.length)return null;let i=new Set,c=[],u=[];for(let l of a){let m=t.get(l).data.tex.trim(),h=s.find(p=>!i.has(p)&&t.get(p).data.tex.trim()===m);h!=null?(i.add(h),c.push(...on(t,et(t,h),t,et(t,l),o,r))):u.push(...et(t,l))}let f=[];for(let l of s)i.has(l)||f.push(...et(t,l));return{pairs:c,in:u,out:f}}function Ss(t,n,e){var u,f,l,m;let r=(h,p)=>h+(p-h)*e,o=t.crop||[0,0,1,1],s=n.crop||[0,0,1,1],a=t.border,i=n.border,c=a||i?{color:Ie((u=a==null?void 0:a.color)!=null?u:i.color,(f=i==null?void 0:i.color)!=null?f:a.color,e),width:r((l=a==null?void 0:a.width)!=null?l:0,(m=i==null?void 0:i.width)!=null?m:0)}:void 0;return{...n,w:r(t.w,n.w),h:r(t.h,n.h),radius:r(t.radius||0,n.radius||0),border:c,crop:t.crop||n.crop?[r(o[0],s[0]),r(o[1],s[1]),r(o[2],s[2]),r(o[3],s[3])]:void 0}}function As(t,n){let e=Sn(t.get(n)),r=hn(e);if(!r)return"";let o=r[3]-r[1]||r[2]-r[0]||1;return e.map(s=>s.points.map(a=>`${Math.round((a[0]-r[0])/o*100)},${Math.round((a[1]-r[1])/o*100)}`).join(";")).join("|")}function hi(t,n,e,r,o){let s=et(t,n),a=et(t,e);if(!s.length||!a.length)return null;let i=new Map(s.map(m=>[m,As(t,m)])),c=new Set,u=[],f=[];for(let m of a){let h=As(t,m),p=s.find(d=>!c.has(d)&&i.get(d)===h);p!=null?(c.add(p),u.push(...on(t,[p],t,[m],o,r))):f.push(m)}let l=s.filter(m=>!c.has(m));return{pairs:u,in:f,out:l}}function Es(t,n,e){let r=e.w,o=W(r,t.target),s=r.fork(),a=Array.isArray(n.ops)?n.ops:[],i=[];for(let c of a)if(Array.isArray(c)&&c[2]==null)ue(s,o,String(c[0]),c[1],e.env);else if(c&&typeof c=="object"){let u=Array.isArray(c)?{name:c[0],args:c[1],target:c[2]}:c,f=u.target!=null?W(s,u.target):o;f!==o&&!st(r,o).includes(f)&&i.push(f),ue(s,f,String(u.name),u.args,e.env)}return i.length?di([Kr(r,s,o),...Array.from(new Set(i)).map(c=>Kr(r,s,c))]):Kr(r,s,o)}function di(t){return{run:1,rate:xt,lag:0,apply:(n,e,r,o)=>{for(let s of t)s.apply(n,e,r,o)},end:(n,e)=>{var r;for(let o of t)(r=o.end)==null||r.call(o,n,e)}}}function Kr(t,n,e){let r=st(t,e),o=st(n,e),s=r.length===o.length&&r.every((l,m)=>l===o[m]),a=o.map(l=>n.get(l)),i=(l,m=1)=>{var h,p;if(Math.abs(m-1)<1e-9){for(let d of a)l.set(d);return}if(!(Math.abs(m)<1e-9))for(let d of a){if(!l.has(d.id)||!t.has(d.id)){l.set(d);continue}let g=t.get(d.id),w=(h=g.data)==null?void 0:h.value,M=(p=d.data)==null?void 0:p.value;l.set({...d,m:de(g.m,d.m,m),style:nn(g.style,d.style,m),...g.image&&d.image&&g.image!==d.image?{image:Ss(g.image,d.image,m)}:{},data:typeof w=="number"&&typeof M=="number"?{...d.data,value:w+(M-w)*m}:d.data})}},c=t.get(e),u=n.get(e);if(Do(c)&&c.data.value!==u.data.value){let l=Number(c.data.value),m=Number(u.data.value),h=new Ht(new Map(t.mobs),t.display.slice(),t.ids);return{run:1,rate:xt,lag:0,apply:(p,d,g)=>{let w=d.get(e);if(!w)return;let M=g(p),S=h.fork();Vt(S,e,l+(m-l)*M),w.replace=et(S,e).map(b=>rn(S.get(b),w.alpha))},end:i}}if(!s){let l=on(t,et(t,e),n,et(n,e),pt(n,e),pt(t,e));return{run:1,rate:xt,lag:0,apply:(m,h,p,d)=>{let g=h.get(e);g&&(g.replace=Pn(l,m,p,d))},end:i}}let f=[];for(let l of r){let m=t.get(l),h=n.get(l);if(m===h)continue;let p={id:l,s:m,e:h,inv:xe(m.m)};ne(m)&&(m.paths!==h.paths||m.text!==h.text||!!m.image!=!!h.image)&&(p.pairs=on(t,[l],n,[l],pt(n,l),pt(t,l))),f.push(p)}return{run:1,rate:xt,lag:0,apply:(l,m,h,p)=>{f.forEach((d,g)=>{var _,x;let w=m.get(d.id);if(!w)return;let M=h(le(l,g,f.length,p));if(d.pairs){w.replace=Pn(d.pairs,M,jt,0);return}d.s.m!==d.e.m&&(w.m=Y(Y(de(d.s.m,d.e.m,M),d.inv),w.m)),d.s.style!==d.e.style&&(w.style=nn(w.style,d.e.style,M)),d.s.image&&d.e.image&&d.s.image!==d.e.image&&(w.image=Ss(d.s.image,d.e.image,M));let S=(_=d.s.data)==null?void 0:_.value,b=(x=d.e.data)==null?void 0:x.value;typeof S=="number"&&typeof b=="number"&&S!==b&&(w.value=S+(b-S)*M)})},end:i}}function pi(t,n,e){let r=n.run_time!=null?Math.max(0,Number(n.run_time)):t.run,o=n.rate_func!=null?er(n.rate_func,t.rate):t.rate,s=n.lag_ratio!=null?Number(n.lag_ratio):t.lag,a=t.target!=null&&br(e.pre,t.target);return{run:r,intro:!!t.intro,shownBefore:a,frame:(i,c)=>t.apply(r>0?vs(i/r):1,c,o,s),events:()=>{let i=[];if(t.begin&&i.push({t:0,end:!1,fn:t.begin}),t.end){let c=o(1);i.push({t:r,end:!0,fn:u=>t.end(u,c)})}return i}}}function Fs(t,n,e,r){let o=[],s=0,a=0;for(let u of t)o.push(s),a=Math.max(a,s+u.run),s+=n*u.run;let i=e!=null?e:a,c=a>0?i/a:1;return{run:i,intro:t.some(u=>u.intro),shownBefore:t.every(u=>u.shownBefore),frame:(u,f)=>{let l=Math.max(0,Math.min(i,u));r!==jt&&i>0&&(l=i*r(l/i));let m=c>0?l/c:l;t.forEach((h,p)=>{let d=m-o[p];d<0&&!(h.intro&&!h.shownBefore)||h.frame(d,f)})},events:()=>{let u=[];return t.forEach((f,l)=>{for(let m of f.events())u.push({t:(o[l]+m.t)*c,end:m.end,fn:m.fn})}),u}}}function rr(t,n){let e=or(t.kind);if(e==="group"||e==="lagged"||e==="succession"){let r=t.items||[],o=t.lag_ratio!=null?Number(t.lag_ratio):e==="lagged"?.05:e==="succession"?1:0,s=t.rate_func!=null?er(t.rate_func,jt):jt,a;if(e==="succession"){let i={...n,w:n.w.fork()};a=r.map(c=>{let u=rr(c,i),f=u.events().sort((l,m)=>l.t-m.t||Number(m.end)-Number(l.end));for(let l of f)l.fn(i.w);return u})}else a=r.map(i=>rr(i,n));return Fs(a,o,t.run_time!=null?Number(t.run_time):null,s)}return e==="change_speed"?bi(t,n):pi(li(t,n),t,n)}function bi(t,n){let e=Ot(t.args,["speedinfo"]),r=rr((t.items||[])[0]||t.anim||e.anim||{kind:"wait",run_time:0},n),o=Object.entries(e.speedinfo||{}).map(([i,c])=>[Number(i),Math.max(.001,Number(c))]).sort((i,c)=>i[0]-c[0]);(!o.length||o[0][0]>0)&&o.unshift([0,1]),o[o.length-1][0]<1&&o.push([1,o[o.length-1][1]]);let s=o.slice(0,-1).map(([i,c],u)=>{let[f,l]=o[u+1];return{u0:i,u1:f,s0:c,s1:l,T:(f-i)*r.run/((c+l)/2)}}),a=s.reduce((i,c)=>i+c.T,0);return{run:a,intro:r.intro,shownBefore:r.shownBefore,frame:(i,c)=>{let u=Math.max(0,Math.min(a,i));for(let f of s){if(u<=f.T||f===s[s.length-1]){let l=Math.min(u,f.T),m=f.s0*l+(f.s1-f.s0)*l*l/(2*(f.T||1));r.frame(f.u0*r.run+m,c);return}u-=f.T}},events:()=>r.events().map(i=>({...i,t:i.t<=0?0:i.t>=r.run?a:i.t}))}}function Rs(t,n,e){let r=t.map(o=>{let s={...o};n.run_time!=null&&(s.run_time=Number(n.run_time)),n.rate_func!=null&&(s.rate_func=n.rate_func);let a=or(s.kind);return n.lag_ratio!=null&&a!=="group"&&a!=="lagged"&&a!=="succession"&&(s.lag_ratio=Number(n.lag_ratio)),rr(s,e)});return Fs(r,0,null,jt)}function Cs(t){return t.events().sort((n,e)=>n.t-e.t||Number(e.end)-Number(n.end))}var An=1,Is=new WeakMap,Os=typeof Path2D!="undefined";function Ns(t){let n=new Path2D;for(let e of t){let r=e.points;if(r.length){n.moveTo(r[0][0],r[0][1]);for(let o=1;o+2<r.length;o+=3)n.bezierCurveTo(r[o][0],r[o][1],r[o+1][0],r[o+1][1],r[o+2][0],r[o+2][1]);e.closed&&n.closePath()}}return n}function gi(t){let n=Is.get(t);return n||(n=Ns(t),Is.set(t,n)),n}function yi(t,n){t.beginPath();for(let e of n){let r=e.points;if(r.length){t.moveTo(r[0][0],r[0][1]);for(let o=1;o+2<r.length;o+=3)t.bezierCurveTo(r[o][0],r[o][1],r[o+1][0],r[o+1][1],r[o+2][0],r[o+2][1]);e.closed&&t.closePath()}}}function Hr(t,n){t.setTransform(n[0],n[1],n[2],n[3],n[4],n[5])}function Bs(t,n){let e=[],r=new Set,{mobs:o}=t.scene,s=a=>{var u;if(r.has(a))return;r.add(a);let i=t.over.get(a);if(i&&i.hidden)return;if(i&&i.replace){for(let f of i.replace)e.push(f);return}let c=o.get(a);if(c){ne(c)&&e.push(i?{paths:c.paths,m:i.m,style:i.style,alpha:i.alpha,partial:i.partial,z:c.z,text:c.text,image:(u=i.image)!=null?u:c.image,shadow:c.shadow,evenodd:c.evenodd}:{paths:c.paths,m:c.m,style:c.style,alpha:1,partial:null,z:c.z,text:c.text,image:c.image,shadow:c.shadow,evenodd:c.evenodd});for(let f of c.children)s(f)}};for(let a of n||t.scene.display)s(a);if(!n)for(let a of t.extras)e.push(a);if(e.some(a=>a.z!==0)){let a=new Map(e.map((i,c)=>[i,c]));e.sort((i,c)=>i.z-c.z||a.get(i)-a.get(c))}return e}function _i(t,n,e=ft){var i,c,u,f;let r=(f=(u=(i=t.over.get(Ut))==null?void 0:i.m)!=null?u:(c=t.scene.mobs.get(Ut))==null?void 0:c.m)!=null?f:ft,o=yt(r,[0,0]),s=un(r),a=Math.min(n.pxW/n.fw,n.pxH/n.fh)/s;return Y(e,[a,0,0,-a,n.pxW/2-a*o[0],n.pxH/2+a*o[1]])}function me(t,n,e){let r=ft;if(typeof t.getTransform=="function"){let s=t.getTransform();r=[s.a,s.b,s.c,s.d,s.e,s.f]}t.save(),e.clear!==!1&&(Hr(t,r),t.clearRect(0,0,e.pxW,e.pxH)),e.clipX&&(Hr(t,r),t.beginPath(),t.rect(e.clipX[0],0,Math.max(0,e.clipX[1]-e.clipX[0]),e.pxH),t.clip());let o=_i(n,e,r);e.shiftX&&(o=Y(o,[1,0,0,1,e.shiftX,0])),t.lineJoin="round",t.lineCap="round",An=e.alpha==null?1:Math.max(0,Math.min(1,e.alpha));try{if(An>0)for(let s of Bs(n))ki(t,An===1?s:{...s,alpha:s.alpha*An},o)}finally{An=1}t.restore()}function ir(t,n,e,r){if(!n)return;let o=Rn(n.color)||[0,0,0];t.shadowColor=`rgba(${o[0]},${o[1]},${o[2]},${Math.max(0,Math.min(1,n.opacity*r))})`,t.shadowBlur=n.blur*e,t.shadowOffsetX=n.dx*e,t.shadowOffsetY=-n.dy*e}function ar(t){t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}var sr=new Map;function Ds(t,n,e,r){let o=Math.max(0,Math.min(r,n/2,e/2)),s=-n/2,a=-e/2;t.moveTo(s+o,a),t.arcTo(s+n,a,s+n,a+e,o),t.arcTo(s+n,a+e,s,a+e,o),t.arcTo(s,a+e,s,a,o),t.arcTo(s,a,s+n,a,o),t.closePath()}function xi(t,n,e){if(!Os)return null;let r=`${t}|${n}|${e}`,o=sr.get(r);return o||(o=new Path2D,Ds(o,t,n,e),sr.size>500&&sr.clear(),sr.set(r,o),o)}function Gr(t,n,e,r,o,s){if(n){t[s](n);return}t.beginPath(),Ds(t,e,r,o),t[s]()}var Ls=new WeakMap;function Ws(t){let n=t;return[n.naturalWidth||n.videoWidth||n.width||0,n.naturalHeight||n.videoHeight||n.height||0]}function wi(t,n){if(n>=.5||typeof document=="undefined")return{img:t,k:1};let e=Ls.get(t);if(e&&e.k>=n)return{img:e.canvas,k:e.k};let[r,o]=Ws(t),s=Math.min(1,Math.pow(2,Math.ceil(Math.log2(n*1.25))));if(s>=.5||!r||!o)return{img:t,k:1};let a=document.createElement("canvas");a.width=Math.max(1,Math.round(r*s)),a.height=Math.max(1,Math.round(o*s));let i=a.getContext("2d");return i.imageSmoothingQuality="high",i.drawImage(t,0,0,a.width,a.height),Ls.set(t,{canvas:a,k:s}),{img:a,k:s}}function Mi(t,n,e,r){let o=n.image,s=n.style;if(!o.src)return;let a=Math.min(1,n.alpha*(s.fo>0?s.fo:1));if(a<=0)return;t.setTransform(e[0],e[1],-e[2],-e[3],e[4],e[5]),t.globalAlpha=a;let[i,c]=Ws(o.src),[u,f,l,m]=o.crop||[0,0,1,1],h=Math.hypot(e[0],e[1])*o.w,p=o.src,d=1;!o.live&&i&&c&&({img:p,k:d}=wi(o.src,h/(i*(l-u))));let g=u*i*d,w=(1-m)*c*d,M=(l-u)*i*d,S=(m-f)*c*d,b=o.radius||0,_=b>0||o.border?xi(o.w,o.h,b):null,x=()=>{try{i&&c?t.drawImage(p,g,w,M,S,-o.w/2,-o.h/2,o.w,o.h):t.drawImage(p,-o.w/2,-o.h/2,o.w,o.h)}catch(P){}};if(n.shadow){if(b>0)t.save(),ir(t,n.shadow,r,a),t.fillStyle="#000",Gr(t,_,o.w,o.h,b,"fill"),t.restore();else if(ir(t,n.shadow,r,a),x(),ar(t),!o.border)return}b>0?(t.save(),Gr(t,_,o.w,o.h,b,"clip"),x(),t.restore()):n.shadow||x(),o.border&&o.border.width>0&&(t.strokeStyle=o.border.color,t.lineWidth=o.border.width*.01/un(n.m),Gr(t,_,o.w,o.h,b,"stroke"))}function ki(t,n,e){let r=n.style,o=n.alpha;if(o<=0)return;let s=Y(e,n.m),a=un(e);if(n.image){Mi(t,n,s,a);return}if(n.text){let m=n.text,h=r.fo*o;if(h<=0)return;let p=.01;t.setTransform(s[0]*p,s[1]*p,-s[2]*p,-s[3]*p,s[4],s[5]),t.globalAlpha=Math.min(1,h),t.fillStyle=r.fc;let d=m.family==="mono"?'Menlo, Consolas, "Liberation Mono", monospace':Po(m.family||"");t.font=`${m.slant==="italic"?"italic ":""}${m.weight==="bold"?"bold ":""}${m.em*100}px ${d}`,t.textAlign=m.left?"left":"center",t.textBaseline="middle";let g=m.str.split(`
8
- `),w=m.left?-m.w/2*100:0;ir(t,n.shadow,a,h),g.forEach((M,S)=>t.fillText(M,w,(S-(g.length-1)/2)*m.em*120)),n.shadow&&ar(t);return}let i=n.paths;if(n.partial&&(i=Fe(i,n.partial[0],n.partial[1]),!i.length)||!i.length)return;let c=r.fo*o,u=r.sw>0?r.so*o:0;if(c<=0&&u<=0)return;Hr(t,s);let f=Os?n.partial?Ns(i):gi(i):null;f||yi(t,i);let l=n.evenodd?"evenodd":"nonzero";ir(t,n.shadow,a,Math.max(c,u)),c>0&&(t.globalAlpha=Math.min(1,c),t.fillStyle=r.fc,f?t.fill(f,l):t.fill(l),n.shadow&&ar(t)),u>0&&(t.globalAlpha=Math.min(1,u),t.strokeStyle=r.sc,t.lineWidth=r.sw*.01/un(n.m),f?t.stroke(f):t.stroke()),n.shadow&&ar(t)}function Ur(t,n){var f;let e=Bs(t,[n]),r=null,o=null,s=null;for(let l of e){let m=l.partial?Fe(l.paths,l.partial[0],l.partial[1]):l.paths;l.partial&&!m.length&&l.paths.length&&(m=[{points:[l.paths[0].points[0]],closed:!1}]);for(let p of m)for(let d of p.points){let g=yt(l.m,d);o||(o=g),r=r?[Math.min(r[0],g[0]),Math.min(r[1],g[1]),Math.max(r[2],g[0]),Math.max(r[3],g[1])]:[g[0],g[1],g[0],g[1]]}let h=l.text||l.image;if(h&&!m.length)for(let p of[[-h.w/2,-h.h/2],[h.w/2,-h.h/2],[h.w/2,h.h/2],[-h.w/2,h.h/2]]){let d=yt(l.m,p);r=r?[Math.min(r[0],d[0]),Math.min(r[1],d[1]),Math.max(r[2],d[0]),Math.max(r[3],d[1])]:[d[0],d[1],d[0],d[1]]}if(l===e[0]&&m.length){let p=m[m.length-1].points;s=yt(l.m,p[p.length-1])}}let a=e[0],i=a?a.style:(f=t.scene.mobs.get(n))==null?void 0:f.style,c=r||[0,0,0,0],u=l=>l?[l[0],l[1],0]:null;return{center:[(c[0]+c[2])/2,(c[1]+c[3])/2,0],width:c[2]-c[0],height:c[3]-c[1],left:c[0],right:c[2],bottom:c[1],top:c[3],first_point:u(o),partial_end_point:u(s),stroke_width:i?i.sw:0,stroke_opacity:i&&a?i.so*a.alpha:i?i.so:0,fill_opacity:i&&a?i.fo*a.alpha:i?i.fo:0,color:i?i.fo>0?i.fc:i.sc:null,fill_color:i?i.fc:null,stroke_color:i?i.sc:null,items:e.length}}var Pi=16/9,Si=new Set(["none","crossfade","slide_left","slide","slide_right","wipe"]),Ai=new Set(["add_coordinates","change_bar_values","change_layout"]),Ei=new Set(["shift","rotate","scale","stretch","flip","increment_value","rotate_about_origin"]);function js(t={}){var io,co;let n=new Cn((io=t.base)!=null?io:null),e=new Map,r=(co=t.tex)!=null?co:null,o={frame_height:8,frame_width:null,background:"#000000"},s=new Ht,a=[],i=0,c=[],u=0,f=[],l=0,m=new qn,h={ops:new Map,values:new Map,sets:new Map,adds:new Map,deltas:new Map},p=()=>h.ops.size+h.values.size+h.sets.size+h.adds.size+h.deltas.size,d=0,g=null,w=new Map,M=!1,S=!1;Oo(n),gs((A,E,R,O)=>{let N=_n({...P(),w:A},E,R,O);if(N&&typeof N.then=="function")throw new Error("rebuilding this needs a font first; try again after it has loaded")}),Wo((A,E)=>{if(typeof document=="undefined")return null;let R=document.createElement("canvas");return R.width=A,R.height=E,R});let b=()=>o.frame_height,_=()=>{var A;return(A=o.frame_width)!=null?A:o.frame_height*Pi},x=()=>({fw:_(),fh:b()}),P=()=>({w:s,fw:_(),fh:b(),text:n,tex:r,texCache:e});function k(A=ft){return H(Ut,"camera",{sc:"#FFFFFF",fc:"#FFFFFF",sw:0,so:0,fo:0},[ot(pe(_(),b()),!0)],{m:A})}s.set(k());function v(){u++}let C=0,F=null,T=[],I=[];function B(A,E=l){let R=A&&A.message||String(A);f.push({message:R,line:E}),typeof console!="undefined"&&console.error("[pyctures.anim]",R)}function L(A,E){l=E;let R=A();if(R&&typeof R.then=="function"){let O=C;F=R.then(()=>v(),N=>B(N,E)).then(()=>{O===C&&(F=null,D())})}else v()}function D(){for(;!F&&T.length;){let A=T.shift();try{L(A.fn,A.line)}catch(E){B(E,A.line)}}if(!F&&!T.length){let A=I;I=[];for(let E of A)E()}}function j(A){let E=Number(Tn.line)||0;F||T.length?T.push({fn:A,line:E}):L(A,E)}function J(A){var R;let E=Ot(A,[]);E.frame_height!=null&&(o.frame_height=y(E.frame_height,8)),E.frame_width!=null&&(o.frame_width=y(E.frame_width,_())),(E.background!=null||E.background_color!=null)&&(o.background=String((R=E.background)!=null?R:E.background_color)),E.transition!=null&&(o.transition=String(E.transition)),E.transition_time!=null&&(o.transition_time=y(E.transition_time,.5)),(E.frame_height!=null||E.frame_width!=null)&&s.set(k(s.get(Ut).m))}function ut(A,E){if(mt.t=i,!E)return;if(E.kind==="redraw"&&!E.template&&E.make&&ze(E.make)&&(E.template=Qe(E.make)),E.kind==="python"||E.kind!=="redraw"||s.has(A)){W(s,A),m.add(A,E,i);return}let R=[],O={...wt(),make:(K,z,nt,tt)=>{let q=_n({...P(),w:K},z,nt,tt);q&&typeof q.then=="function"&&R.push(q)}},N=()=>{if(E.template)Zn(s,E.template,new Map,O,A);else{let[K,z]=E.make||["group",{}];O.make(s,A,K,Bt(s,z))}};try{N()}catch(K){if(!R.length)throw K}if(R.length)return Promise.all(R).then(()=>{R.length=0,N(),m.add(A,E,i)});m.add(A,E,i)}function G(A){let E=R=>{if(!R||typeof R!="object")return R;let O={...R};return R.args!=null&&(O.args=Bt(s,R.args)),Array.isArray(R.items)&&(O.items=R.items.map(E)),O};return Array.isArray(A)?A.map(E):E(A)}function ct(A){return(Array.isArray(A)?A:[A]).map(R=>W(s,R))}function ht(A,E){let R=Array.isArray(A)?A:[A];if(!R.length)return;let O=s.snapshot(),N=Rs(R,Ot(E,[]),{w:s.fork(),pre:O,env:x()}),K=Cs(N),z=s.fork();for(let tt of K)tt.end||tt.fn(z);let nt=z.snapshot();for(let tt of K)tt.fn(s);if(N.run>0){let tt={t0:i,t1:i+N.run,before:nt,node:N};a.push(tt),i+=N.run,Kt(tt)}}function Kt(A){if(!m.any)return;let E=s.fork();for(let R of m.apply(E,A.t1,A,wt()))for(let O of st(E,R))E.has(O)&&s.set(E.get(O))}let wt=()=>({env:x(),ids:s.ids,make:(A,E,R,O)=>{_n({...P(),w:A},E,R,O)}});function Jt(A){let E=Math.max(0,y(Array.isArray(A)?A[0]:A,1));if(E<=0)return;let R={t0:i,t1:i+E,before:s.snapshot(),node:null};a.push(R),i+=E,Kt(R)}function Qt(A,E,R){var nt,tt;let O=String(E).replace(/^get_/,""),N=Ot(R,["arg"]);if(O==="frame")return{width:_(),height:b()};if(mt.t=i,O==="point"&&(A==null||A===0)){let q=it(s,(nt=N.arg)!=null?nt:R);return[q[0],q[1],0]}if((O==="expr"||O==="eval"||O==="number")&&(A==null||A===0))return $t(s,(tt=N.arg)!=null?tt:R);let K=W(s,A);if(O==="describe"||O==="state")return Ur(new $e(s.snapshot()),K);if(O==="point"){let q=Ft(N.arg)?at($(s,W(s,N.arg))):it(s,N.arg);return[q[0],q[1],0]}let z=Array.isArray(R)?R:R==null?[]:[R];return xn(s,K,O,z)}let Gt=[],ye=[];function ea(A){for(let E of ye)if(A>=E.t&&A<E.t+E.dur)return E;return null}function na(A){if(!a.length||A>=i)return null;let E=0,R=a.length-1;for(;E<R;){let O=E+R+1>>1;a[O].t0<=A?E=O:R=O-1}return a[E]}function an(A,E=!0){return so(A,E).f}function so(A,E){A=Math.max(0,A);let R=na(A),O=new $e(R?R.before:s.snapshot());R&&R.node&&R.node.frame(A-R.t0,O);let N=E&&p()>0,K=m.any||N||S?ra(O,A,R,N):null;return{f:O,view:K}}function ao(A){let E=new Map(A.scene.mobs);for(let[R,O]of A.over){let N=E.get(R);!N||O.m===N.m&&O.style===N.style&&O.value==null||E.set(R,{...N,m:O.m,style:O.style,data:O.value!=null?{...N.data||{},value:O.value}:N.data})}return new Ht(E,A.scene.display.slice(),s.ids)}function ra(A,E,R,O){var nt,tt;let N=ao(A),K=N.snapshot(),z=[];if(mt.t=E,O){for(let[rt,kt]of h.values)N.has(rt)&&(Vt(N,rt,kt),z.push(rt));let q=wt(),bt=rt=>{try{z.push(...Xn(N,rt,null,q))}catch(kt){}},V=rt=>{let kt=/^[ud](\d+)$/.exec(rt);return!kt||m.activeUid(kt[1],E)!==!1};for(let[rt,kt]of h.sets)V(rt)&&bt(kt);for(let[rt,kt]of h.adds)V(rt)&&bt(Array.from(kt.values()));for(let[rt,kt]of h.deltas)if(V(rt)){for(let[fe,cn]of kt)if(N.has(fe)){for(let he of st(N,fe)){let _e=N.get(he);N.set({..._e,m:Y(cn.M,_e.m)})}cn.dv&&Vt(N,fe,Number((tt=(nt=N.get(fe).data)==null?void 0:nt.value)!=null?tt:0)+cn.dv),z.push(fe)}}for(let rt of h.ops.values())if(N.has(rt.target))try{ue(N,rt.target,rt.name,Bt(N,rt.args),x()),z.push(rt.target)}catch(kt){}}if(z.push(...m.apply(N,E,R,wt())),!M)for(let q of Array.from(N.mobs.values())){if(q.kind!=="traced_path")continue;let bt=sa(q,E,N);N.set({...q,paths:bt.length>=2?[ot(bt,!1)]:[]}),z.push(q.id)}return oa(A,N,K,z),N}function oa(A,E,R,O){var N;for(let K of Array.from(new Set(O))){let z=st(E,K),nt=st(R,K);if(z.length===nt.length&&z.every((q,bt)=>{if(q!==nt[bt])return!1;let V=E.get(q),rt=R.mobs.get(q);return V.paths===rt.paths&&V.text===rt.text&&V.image===rt.image}))for(let q of z){let bt=E.get(q);if(bt===R.mobs.get(q))continue;let V=A.get(q);V&&(V.m=bt.m,V.style=bt.style,((N=bt.data)==null?void 0:N.value)!=null&&(V.value=Number(bt.data.value)))}else{let q=A.get(K);if(!q)continue;let bt=q.alpha;q.replace=z.map(V=>E.get(V)).filter(ne).map(V=>({paths:V.paths,m:V.m,style:V.style,alpha:bt,partial:null,z:V.z,text:V.text,image:V.image,shadow:V.shadow,evenodd:V.evenodd}))}}}function sa(A,E,R){var q,bt;let O=(q=A.data)==null?void 0:q.trace;if(!O||O.point==null)return[];let N=Number((bt=O.from)!=null?bt:0),K=1/30,z=w.get(A.id);(!z||z.version!==u)&&(z={version:u,pts:[]},w.set(A.id,z));let nt=Math.floor((Math.min(E,i)-N)/K+1e-9);M=!0;try{for(;z.pts.length<=nt&&z.pts.length<2e4;){let V=N+z.pts.length*K,rt=so(V,!1),kt=rt.view||ao(rt.f);mt.t=V;let fe=it(kt,O.point);z.pts.push(fe)}}catch(V){}finally{M=!1,mt.t=E}let tt=z.pts.slice(0,Math.max(0,nt+1));try{let V=it(R,O.point),rt=tt[tt.length-1];(!rt||Math.hypot(V[0]-rt[0],V[1]-rt[1])>1e-9)&&tt.push(V)}catch(V){}if(O.dissipating!=null&&O.dissipating>0){let V=Math.ceil(O.dissipating/K)+1;return tt.slice(Math.max(0,tt.length-V))}return tt}let Tn={reset(A){C++,F=null,T.length=0,o={frame_height:8,frame_width:null,background:"#000000"},s=new Ht,s.set(k()),a=[],i=0,c=[],f=[],m.reset(),h.ops.clear(),h.values.clear(),h.sets.clear(),h.adds.clear(),h.deltas.clear(),w.clear(),S=!1,ye=[],Gt=[],A&&J(A),v(),D()},config(A){j(()=>J(A))},make(A,E,R,O){j(()=>{if(mt.t=i,O!=null){let z=String(E).replace(/_/g,"").toLowerCase();z==="pycturescanvas"?R={...R,canvas:O}:z==="imagemobject"?R={...R,element:O}:z==="svgmobject"&&(R=typeof O=="string"||O.outerHTML?{...R,svg_element:O}:{...R,element:O})}let N=String(E).toLowerCase().replace(/_/g,"")==="tracedpath",K=_n(P(),A,E,N?R||{}:Bt(s,R||{}));if(K&&typeof K.then=="function"&&(K=K.catch(z=>{throw s.has(A)||s.set(H(A,"group",{sc:"#FFFFFF",fc:"#FFFFFF",sw:0,so:1,fo:0},[])),z})),N&&s.has(A)){let z=s.get(A).data;s.update(A,{data:{...z,trace:{...z.trace,from:i}}}),S=!0}return K})},copy(A,E){j(()=>{Me(s,W(s,E),A)})},op(A,E,R){j(()=>{mt.t=i;let O=()=>ue(s,W(s,A),E,Bt(s,R),x());if(Ai.has(E)&&n.font("normal|normal")===void 0)return n.load("normal|normal").then(O);O()})},add_updater(A,E){j(()=>ut(A,E))},updater(A,E){j(()=>ut(A,E))},remove_updater(A,E){j(()=>m.remove(W(s,A),E,i))},clear_updaters(A){j(()=>m.clear(W(s,A),i))},suspend_updating(A){j(()=>m.suspend(W(s,A),i))},resume_updating(A){j(()=>m.resume(W(s,A),i))},live_op(A,E,R,O){var K,z;let N=W(s,A);if(O&&O.accumulate){Tn.live(`acc|${N}`,[[E,R,N]],{mode:"add"});return}if(E==="set_value"||E==="increment_value"){let nt=Ot(R,["value"]),tt=h.values.has(N)?h.values.get(N):Number((z=(K=s.get(N).data)==null?void 0:K.value)!=null?z:0);h.values.set(N,E==="set_value"?y(nt.value,0):tt+y(nt.value,0))}else h.ops.set(`${N}|${E}`,{target:N,name:E,args:R});d++},live_set(A,E){h.values.set(W(s,A),y(E,0)),d++},live_clear(){h.ops.clear(),h.values.clear(),h.sets.clear(),h.adds.clear(),h.deltas.clear(),d++},live(A,E,R){var z,nt,tt,q;let O=String(A),N=Array.isArray(E)?E:[];if((R&&R.mode||"set")==="set")h.adds.delete(O),h.deltas.delete(O),N.length?h.sets.set(O,N):h.sets.delete(O);else{let bt=h.adds.get(O)||new Map,V=h.deltas.get(O)||new Map;for(let rt of N){let[kt,fe,cn]=rt,he;try{he=W(s,cn)}catch(_e){continue}if(Ei.has(String(kt))){let _e=s.fork(),uo=_e.get(he);try{ue(_e,he,String(kt),Bt(_e,fe),x())}catch(Xi){continue}let lo=_e.get(he),aa=Y(lo.m,xe(uo.m)),mo=V.get(he)||{M:ft,dv:0};V.set(he,{M:Y(aa,mo.M),dv:mo.dv+(Number((nt=(z=lo.data)==null?void 0:z.value)!=null?nt:0)-Number((q=(tt=uo.data)==null?void 0:tt.value)!=null?q:0))})}else bt.set(`${he}|${kt}`,rt)}h.adds.set(O,bt),h.deltas.set(O,V)}d++},sound(A){j(()=>{let E=Ot(A,["src"]);if(E.src==null||E.src==="")throw new Error("add_sound needs a file");let R=E.kind==="music";Gt.push({src:String(E.src),t0:i+y(E.time_offset,0),volume:Math.max(0,y(E.volume,R?.3:1)),fade_in:Math.max(0,y(E.fade_in,0)),fade_out:Math.max(0,y(E.fade_out,R?1:0)),loop:E.loop!=null?!!E.loop:R,kind:R?"music":"sound",...E.t1!=null?{t1:y(E.t1,0)}:{}})})},wait_sound(A){j(()=>{let E=Ot(A,["src","extra"]),R=E.src!=null?[...Gt].reverse().find(N=>N.src===String(E.src)):Gt[Gt.length-1];if(!R)return;let O=globalThis.__cirSoundDuration;if(typeof O=="function")return Promise.resolve(O(R.src)).then(N=>{let K=R.t0+Math.max(0,Number(N)||0)+y(E.extra,0);K>i+1e-9&&Jt(K-i)})})},trackerValues(A){return Tn.values_at(A)},values_at(A){var N,K;let E=`${A}|${u}|${d}`;if(g&&g.key===E)return g.out;let R=an(A),O={};for(let[z,nt]of R.scene.mobs){if(nt.kind!=="value_tracker")continue;let tt=R.over.get(z);O[z]=tt&&tt.value!=null?tt.value:Number((K=(N=nt.data)==null?void 0:N.value)!=null?K:0)}return g={key:E,out:O},O},canvas_for(A){let E=s.get(W(s,A));if(!E.image)throw new Error("that object is not a PycturesCanvas");return E.image.src},attach_canvas(A,E){let R=W(s,A),O=s.get(R);O.image&&(O.image.src=E)},add(A){j(()=>Lt(s,ct(A)))},remove(A){j(()=>oe(s,ct(A)))},clear(){j(()=>{s.setDisplay([]),s.set(k())})},play(A,E){j(()=>{mt.t=i,ht(G(A),E)})},wait(A){j(()=>Jt(A))},section(A,E){j(()=>{var K;c.push({name:String(A!=null?A:""),t:i});let R=E&&typeof E=="object"?E:{},O=String(R.transition||o.transition||"none");Si.has(O)||(B(new Error(`unknown transition '${O}'; use crossfade, slide_left, slide_right or wipe`)),O="crossfade");let N=y((K=R.transition_time)!=null?K:o.transition_time,.5);O!=="none"&&N>0&&i>0&&ye.push({t:i,dur:N,kind:O,out:s.snapshot()})})},value(A,E,R){return new Promise((O,N)=>{j(()=>{try{O(Qt(A,E,R))}catch(K){N(K)}})})},ready(){return!F&&!T.length?Promise.resolve():new Promise(A=>I.push(A))},renderAt(A,E,R,O,N){let K={pxW:R,pxH:O,fw:_(),fh:b(),clear:N==null?void 0:N.clear},z=ea(E);if(!z){me(A,an(E),K);return}let nt=xt((E-z.t)/z.dur),tt=new $e(z.out),q=an(E),bt=Math.hypot(s.get(Ut).m[0],s.get(Ut).m[1])||1,V=_()*bt;z.kind==="slide_left"||z.kind==="slide"?(me(A,tt,{...K,shiftX:-V*nt}),me(A,q,{...K,clear:!1,shiftX:V*(1-nt)})):z.kind==="slide_right"?(me(A,tt,{...K,shiftX:V*nt}),me(A,q,{...K,clear:!1,shiftX:-V*(1-nt)})):z.kind==="wipe"?(me(A,tt,{...K,clipX:[nt*R,R]}),me(A,q,{...K,clear:!1,clipX:[0,nt*R]})):(me(A,tt,{...K,alpha:1-nt}),me(A,q,{...K,clear:!1,alpha:nt}))},frameAt:an,measure(A,E){let R=an(A);return Ur(R,W(s,E))},isShown(A){let E=W(s,A);return s.display.some(R=>st(s,R).includes(E))},line:0,takeErrors(){let A=f;return f=[],A},get errors(){return f.slice()},get duration(){return i},get sections(){return c.slice()},get background(){return o.background},get sounds(){return Gt.slice()},get version(){return u+d},get liveVersion(){return d},get frameSize(){return{width:_(),height:b()}},get hasContent(){return i>0||s.display.length>0},get busy(){return!!F||T.length>0},get capabilities(){return{kinds:zo(),anims:Ts,ops:bs,rates:Ms}}};return Tn}var vi="",Ti=!1;function cr(){if(Ti)return vi;let t=globalThis.__cirAnimBase;if(t)return t.endsWith("/")?t:t+"/";let n=document.querySelector('link[href*="katex"][rel="stylesheet"]');return n?n.href.replace(/[^/]*$/,""):""}var Yr=new Map;function zs(t,n){let e=Yr.get(t);if(!e){let r=t.slice(t.lastIndexOf("/")+1),o=Array.from(document.scripts).find(s=>s.src&&s.src.split("?")[0].endsWith("/"+r));e=new Promise((s,a)=>{if(o){if(n())return s();o.addEventListener("load",()=>s()),o.addEventListener("error",()=>a(new Error(`Could not load ${o.src}`)));return}let i=document.createElement("script");i.src=t,i.async=!0,i.onload=()=>s(),i.onerror=()=>a(new Error(`Could not load ${t}`)),document.head.appendChild(i)}),Yr.set(t,e),e.catch(()=>Yr.delete(t))}return e}function Fi(){let t=document.createElement("span");t.className="katex",t.style.position="absolute",t.style.visibility="hidden",document.body.appendChild(t);let n=getComputedStyle(t).fontFamily;return t.remove(),/KaTeX_Main/.test(n)}var En=null;function Ri(){return En||(En=Fi()?Promise.resolve():new Promise((t,n)=>{let e=document.createElement("link");e.rel="stylesheet",e.href=cr()+"katex.min.css",e.onload=()=>t(),e.onerror=()=>n(new Error(`Could not load ${e.href}`)),document.head.appendChild(e)}),En.catch(()=>En=null)),En}async function Xr(){let t=window;if(await Promise.all([Ri(),t.katex?null:zs(cr()+"katex.min.js",()=>!!t.katex),t.opentype?null:zs(cr()+"opentype.min.js",()=>!!t.opentype)]),!t.katex)throw new Error("KaTeX did not load");return t.katex}var Ci={KaTeX_AMS:["Regular"],KaTeX_Caligraphic:["Regular","Bold"],KaTeX_Fraktur:["Regular","Bold"],KaTeX_Main:["Regular","Bold","Italic","BoldItalic"],KaTeX_Math:["Italic","BoldItalic"],KaTeX_SansSerif:["Regular","Bold","Italic"],KaTeX_Script:["Regular"],KaTeX_Size1:["Regular"],KaTeX_Size2:["Regular"],KaTeX_Size3:["Regular"],KaTeX_Size4:["Regular"],KaTeX_Typewriter:["Regular"]};function $s(t,n,e){let r=Ci[t];if(!r)return null;let a=[n&&e?"BoldItalic":n?"Bold":e?"Italic":"Regular",n?"Bold":e?"Italic":"Regular","Regular",...r].find(i=>r.includes(i));return`${t}-${a}.ttf`}var Vr=new Map;function Ks(t){let n=Vr.get(t);return n||(n=(async()=>{await Xr();let e=window.opentype;if(!e)throw new Error("opentype.js did not load");let r=await fetch(cr()+"fonts/"+t);if(!r.ok)throw new Error(`Could not load font ${t} (${r.status})`);return e.parse(await r.arrayBuffer())})(),Vr.set(t,n),n.catch(()=>Vr.delete(t))),n}var Te=null;function Ii(){return Te&&Te.isConnected||(Te=document.createElement("div"),Te.setAttribute("aria-hidden","true"),Te.style.cssText='position:fixed;left:0;top:0;visibility:hidden;pointer-events:none;z-index:-1;white-space:nowrap;width:max-content;font-size:100px;line-height:normal;font-variant-ligatures:none;font-feature-settings:"liga" 0,"clig" 0;',document.body.appendChild(Te)),Te}var Gs=/[\s​‌‍⁠]/;function Li(t){for(let n of Array.from(t.classList)){let e=/^cir-p(\d+)$/.exec(n);if(e)return+e[1]}return null}function Us(t,n){let e=/^(-?[\d.]+)em$/.exec(t.trim());return e?parseFloat(e[1])*n:null}function Oi(t,n){return{x0:Math.max(t.x0,n.x0),y0:Math.max(t.y0,n.y0),x1:Math.min(t.x1,n.x1),y1:Math.min(t.y1,n.y1)}}var qr=t=>({x0:t.left,y0:t.top,x1:t.right,y1:t.bottom}),Jr=class{constructor(n){this.root=n;this.out=[];this.markers=new Map;this.markerSet=null}run(){let n=document.createTreeWalker(this.root,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode()){let r=e;if(!r.data||!Array.from(r.data).some(s=>!Gs.test(s)))continue;let o=document.createElement("span");o.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0",r.parentNode.insertBefore(o,r),this.markers.set(r,o)}this.walk(this.root,0,this.out);for(let e of this.markers.values())e.remove();return this.out}walk(n,e,r){if(n.classList.contains("katex-mathml"))return;let o=Li(n);if(o!==null&&(e=o),n instanceof SVGSVGElement){this.svg(n,e,r);return}if(n.tagName==="SPAN"&&this.markersHas(n))return;if(this.borders(n,e,r),n.classList.contains("mtable")){this.table(n,e,r);return}let s=n.classList.contains("vlist")?Hs(n):Array.from(n.childNodes);for(let a of s)this.visit(a,e,r)}visit(n,e,r){n.nodeType===Node.TEXT_NODE?this.text(n,e,r):n.nodeType===Node.ELEMENT_NODE&&this.walk(n,e,r)}markersHas(n){return this.markerSet||(this.markerSet=new Set(this.markers.values())),this.markerSet.has(n)}table(n,e,r){let o=[],s=[];for(let i of Array.from(n.children)){let c=/col-align/.test(i.className)?i.querySelector(".vlist"):null;if(!c){this.walk(i,e,s);continue}this.borders(i,e,s),o.push(Hs(c).map(u=>{let f=[];return this.visit(u,e,f),f}))}let a=Math.max(0,...o.map(i=>i.length));for(let i=0;i<a;i++)for(let c of o)c[i]&&r.push(...c[i]);r.push(...s)}text(n,e,r){var p,d;let o=this.markers.get(n);if(!o)return;let s=n.parentElement,a=getComputedStyle(s),i=a.fontFamily.split(",")[0].trim().replace(/^["']|["']$/g,""),c=a.fontWeight==="bold"?700:parseInt(a.fontWeight,10)||400,u=(p=$s(i,c>=600,a.fontStyle!=="normal"))!=null?p:"KaTeX_Main-Regular.ttf",f=parseFloat(a.fontSize),l=o.getBoundingClientRect().bottom,m=document.createRange(),h=0;for(let g of Array.from(n.data)){if(!Gs.test(g)){m.setStart(n,h),m.setEnd(n,h+g.length);let w=(d=m.getClientRects()[0])!=null?d:m.getBoundingClientRect();r.push({part:e,glyph:{file:u,ch:g,x:w.left,baseline:l,px:f}})}h+=g.length}}borders(n,e,r){var f;let o=getComputedStyle(n),s=["Top","Right","Bottom","Left"],a={},i=!1;for(let l of s){let m=o.getPropertyValue(`border-${l.toLowerCase()}-style`);if(m==="none"||m==="hidden")continue;let h=parseFloat(o.getPropertyValue(`border-${l.toLowerCase()}-width`))||0;if(h<=0)continue;let p=parseFloat(o.fontSize);a[l]=(f=Us(n.style.getPropertyValue(`border-${l.toLowerCase()}-width`),p))!=null?f:h,i=!0}if(!i)return;let c=qr(n.getBoundingClientRect());if(n.classList.contains("rule")){r.push({part:e,subpaths:[qe(c)]});return}let u=[];a.Top&&u.push(qe({...c,y1:c.y0+a.Top})),a.Bottom&&u.push(qe({...c,y0:c.y1-a.Bottom})),a.Left&&u.push(qe({...c,x1:c.x0+a.Left})),a.Right&&u.push(qe({...c,x0:c.x1-a.Right}));for(let l of u)r.push({part:e,subpaths:[l]})}svg(n,e,r){let o=n.getBoundingClientRect();if(o.width<=0||o.height<=0)return;let s=n.getAttribute("viewBox"),a=s?s.trim().split(/[\s,]+/).map(Number):null,i=a?Ho(a,o.width,o.height,n.getAttribute("preserveAspectRatio")):[1,0,0,1,0,0],c=[i[0],i[1],i[2],i[3],i[4]+o.left,i[5]+o.top],u=qr(o);for(let d=n.parentElement;d&&d!==this.root;d=d.parentElement){let g=getComputedStyle(d);(g.overflowX!=="visible"||g.overflowY!=="visible")&&(u=Oi(u,qr(d.getBoundingClientRect())))}if(u.x1<=u.x0||u.y1<=u.y0)return;let f=[];for(let d of Array.from(n.querySelectorAll("path")))f.push(...Go(jn(d.getAttribute("d")||""),c));for(let d of Array.from(n.querySelectorAll("line")))f.push(...Ni(d,o,c));let l=Wn(f),m=.01,p=l&&(l.x0<u.x0-m||l.y0<u.y0-m||l.x1>u.x1+m||l.y1>u.y1+m)?Uo(f,u):f;p.length&&r.push({part:e,subpaths:p})}};function Ni(t,n,e){var w;let r=(M,S)=>{let b=t.getAttribute(M)||"0";return b.endsWith("%")?parseFloat(b)/100*S:parseFloat(b)},o=parseFloat(getComputedStyle(t).fontSize)||16,s=t.getAttribute("stroke-width")||"1",a=(w=Us(s,o))!=null?w:parseFloat(s),i=[r("x1",n.width/e[0]),r("y1",n.height/e[3])],c=[r("x2",n.width/e[0]),r("y2",n.height/e[3])],u=[e[0]*i[0]+e[4],e[3]*i[1]+e[5]],f=[e[0]*c[0]+e[4],e[3]*c[1]+e[5]],l=f[0]-u[0],m=f[1]-u[1],h=Math.hypot(l,m)||1,p=-m/h*(a/2),d=l/h*(a/2),g=new be;return g.moveTo([u[0]+p,u[1]+d]),g.lineTo([f[0]+p,f[1]+d]),g.lineTo([f[0]-p,f[1]-d]),g.lineTo([u[0]-p,u[1]-d]),g.close(),g.finish()}function Hs(t){return Array.from(t.children).map((e,r)=>({r:e,i:r,top:parseFloat(e.style.top)||0})).sort((e,r)=>e.top-r.top||e.i-r.i).map(e=>e.r)}function Bi(t,n){let e=t.charToGlyph(n.ch);if(!e||e.index===0)return null;let r=new be;for(let o of e.getPath(n.x,n.baseline,n.px).commands)o.type==="M"?r.moveTo([o.x,o.y]):o.type==="L"?r.lineTo([o.x,o.y]):o.type==="Q"?r.quadTo([o.x1,o.y1],[o.x,o.y]):o.type==="C"?r.cubicTo([o.x1,o.y1],[o.x2,o.y2],[o.x,o.y]):o.type==="Z"&&r.close();return r.finish()}var Zr=["KaTeX_Main-Regular.ttf","KaTeX_AMS-Regular.ttf","KaTeX_Size1-Regular.ttf"];async function Di(t){let n=new Set(Zr);for(let o of t)o.glyph&&n.add(o.glyph.file);let e=new Map;await Promise.all(Array.from(n).map(async o=>{try{e.set(o,await Ks(o))}catch(s){if(!Zr.includes(o))throw s}}));let r=new Set;for(let o of t){if(!o.glyph)continue;let s=null;for(let a of[o.glyph.file,...Zr]){let i=e.get(a);if(i&&(s=Bi(i,o.glyph)))break}s||r.add(o.glyph.ch),o.subpaths=s!=null?s:[]}r.size&&console.warn(`[pyctures.anim] TeX: no outline for ${Array.from(r).join(" ")}`)}async function Wi(t){let n=new Set,e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let r=e.nextNode();r;r=e.nextNode()){let o=r.parentElement;if(!o||!r.data.trim())continue;let s=getComputedStyle(o);n.add(`${s.fontStyle} ${s.fontWeight} 16px ${s.fontFamily.split(",")[0].trim()}`)}await Promise.all(Array.from(n).map(r=>document.fonts.load(r).catch(()=>[]))),await document.fonts.ready}var vn=class extends Error{};async function Qr(t,n,e){var o;let r=document.createElement("div");Ii().appendChild(r);try{try{t.render(n,r,{displayMode:e,output:"html",throwOnError:!0,strict:!1,trust:u=>u.command==="\\htmlClass"})}catch(u){throw new vn(u instanceof Error?u.message:String(u))}await Wi(r);let s=(o=r.querySelector(".katex"))!=null?o:r,a=parseFloat(getComputedStyle(s).fontSize),i=new Jr(s).run();return await Di(i),{items:i.filter(u=>u.subpaths&&u.subpaths.length).map(u=>({part:u.part,subpaths:u.subpaths})),emPx:a}}finally{r.remove()}}function Vs(t){return t/48*.498}function sn(t){return t.parts&&t.parts.length?t.parts:[t.tex]}function to(t){return`${t.mode}${Zs(t)}${sn(t).join("")}`}function Xs(t){return`${to(t)}${t.fontSize}`}function ji(t){let n=[],e="",r=()=>{e&&n.push(`\\text{${e}}`),e=""},o=0;for(;o<t.length;){let s=t[o];if(s==="\\"&&o+1<t.length){let a=t[o+1];if(a==="("||a==="["){let i=a==="("?"\\)":"\\]",c=t.indexOf(i,o+2);if(c>=0){r(),n.push(`{${t.slice(o+2,c)}}`),o=c+2;continue}}if(a==="\\"){r(),n.push("\\\\"),o+=2;continue}e+=s+a,o+=2;continue}if(s==="$"){let a=t[o+1]==="$",i=a?2:1,c=zi(t,o+i,a);if(c>=0){r(),n.push(`{${t.slice(o+i,c)}}`),o=c+i;continue}}e+=s,o++}return r(),n.join("")}function zi(t,n,e){for(let r=n;r<t.length;r++){if(t[r]==="\\"){r++;continue}if(t[r]==="$"&&(!e||t[r+1]==="$"))return r}return-1}function $i(t){let n=0;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"){r++;continue}if(o==="{")n++;else if(o==="}"&&--n<0)return!1}if(n!==0)return!1;let e=r=>(t.match(r)||[]).length;return e(/\\left(?![a-zA-Z])/g)===e(/\\right(?![a-zA-Z])/g)&&e(/\\begin\s*\{/g)===e(/\\end\s*\{/g)}function qs(t){let n=sn(t);return n.length>1&&n.every($i)}function Ki(t){let n=[],e=0,r=0,o=0,s=0,a=(i,c)=>{n.push(t.slice(o,i),t.slice(i,i+c)),o=i+c};for(;s<t.length;){let i=t[s];if(i==="\\"){let c=t.slice(s);if(c.startsWith("\\begin"))r++;else if(c.startsWith("\\end"))r--;else if(t[s+1]==="\\"&&e===0&&r===0){let u=/^\\\\\s*\[[^\]]*\]/.exec(c),f=u?u[0].length:2;a(s,f),s+=f;continue}s+=2;continue}i==="{"?e++:i==="}"?e--:i==="&"&&e===0&&r===0&&a(s,1),s++}return n.push(t.slice(o)),n}var Ys=t=>t==="&"||t.startsWith("\\\\");function eo(t,n){let e=sn(t).map(i=>t.mode==="text"?ji(i):i),r=e.map(Ki),o=r.some(i=>i.some(Ys)),s=n?r.map((i,c)=>i.map(u=>Ys(u)||!u.trim()?u:`\\htmlClass{cir-p${c}}{${u}}`).join("")).join(" "):e.join(" ");if(!o)return s;let a=Zs(t);return a.startsWith("array")?`\\begin{array}{${a.slice(5)}}${s}\\end{array}`:`\\begin{${a}}${s}\\end{${a}}`}function Zs(t){let n=(t.environment||"").trim().replace(/^\\begin\{|\}$/g,"");return t.mode==="text"?n==="flushleft"?"arrayl":n==="flushright"?"arrayr":"arrayc":/^(gather\*?|gathered|center)$/.test(n)?"gathered":"aligned"}var no=new Map,ro=new Map;function Qs(t){let n=Xs(t),e=ro.get(n);return e||(e=Gi(t).then(r=>Yi(r,Vs(t.fontSize))),ro.set(n,e),e.catch(()=>ro.delete(n))),e}function Gi(t){let n=to(t),e=no.get(n);return e||(e=Hi(t),no.set(n,e),e.catch(()=>no.delete(n))),e}async function Hi(t){let n=await Xr(),e=sn(t).length,r=t.mode==="math",o,s=qs(t);try{o=await Qr(n,eo(t,s),r)}catch(a){if(!(a instanceof vn))throw a;if(!s)throw Js(t,a);try{o=await Qr(n,eo(t,!1),r)}catch(i){throw Js(t,i)}}return Ui(o,e)}function Js(t,n){let e=n instanceof Error?n.message:String(n),r=t.mode==="text"?"Tex":"MathTex";return new Error(`${r} could not read "${sn(t).join(" ")}": ${e.replace(/^KaTeX parse error: /,"").replace(/\u0332/g,"")}`)}function Ui(t,n){let e=Array.from({length:n},()=>[]),r=t.items.flatMap(u=>u.subpaths),o=Wn(r);if(!o)return{parts:e,width:0,height:0};let s=(o.x0+o.x1)/2,a=(o.y0+o.y1)/2,i=1/t.emPx,c=u=>[(u[0]-s)*i,-(u[1]-a)*i];for(let u of t.items){let f=Math.min(Math.max(u.part,0),n-1);e[f].push(u.subpaths.map(l=>({closed:l.closed,points:l.points.map(c)})))}return{parts:e,width:(o.x1-o.x0)*i,height:(o.y1-o.y0)*i}}function Yi(t,n){let e=n;return{parts:t.parts.map(r=>r.map(o=>o.map(s=>({closed:s.closed,points:s.points.map(([a,i])=>[a*e,i*e])})))),width:t.width*e,height:t.height*e}}var Ke=globalThis,oo=typeof document!="undefined"?document.currentScript:null,Vi=oo&&oo.src?oo.src.replace(/[^/]*$/,""):"/preview-packages/pymations/",ta=typeof Ke.__cirAnimBase=="string"&&Ke.__cirAnimBase?Ke.__cirAnimBase.endsWith("/")?Ke.__cirAnimBase:Ke.__cirAnimBase+"/":Vi;Ke.__cirAnimBase=ta;Ke.__cirAnim=js({base:ta,tex:Qs});})();
2
+ (()=>{var Ja=Object.create;var zs=Object.defineProperty;var tc=Object.getOwnPropertyDescriptor;var ec=Object.getOwnPropertyNames;var nc=Object.getPrototypeOf,rc=Object.prototype.hasOwnProperty;var oc=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var sc=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ec(n))!rc.call(t,o)&&o!==e&&zs(t,o,{get:()=>n[o],enumerable:!(r=tc(n,o))||r.enumerable});return t};var ic=(t,n,e)=>(e=t!=null?Ja(nc(t)):{},sc(n||!t||!t.__esModule?zs(e,"default",{value:t,enumerable:!0}):e,t));var Ti=oc((ts,es)=>{(function(t,n){typeof ts=="object"&&typeof es!="undefined"?es.exports=n():typeof define=="function"&&define.amd?define(n):(t=typeof globalThis!="undefined"?globalThis:t||self,t.polygonClipping=n())})(ts,(function(){"use strict";function t(B,d){var y={label:0,sent:function(){if(h[0]&1)throw h[1];return h[1]},trys:[],ops:[]},k,I,h,_;return _={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function w(R){return function(W){return E([R,W])}}function E(R){if(k)throw new TypeError("Generator is already executing.");for(;y;)try{if(k=1,I&&(h=R[0]&2?I.return:R[0]?I.throw||((h=I.return)&&h.call(I),0):I.next)&&!(h=h.call(I,R[1])).done)return h;switch(I=0,h&&(R=[R[0]&2,h.value]),R[0]){case 0:case 1:h=R;break;case 4:return y.label++,{value:R[1],done:!1};case 5:y.label++,I=R[1],R=[0];continue;case 7:R=y.ops.pop(),y.trys.pop();continue;default:if(h=y.trys,!(h=h.length>0&&h[h.length-1])&&(R[0]===6||R[0]===2)){y=0;continue}if(R[0]===3&&(!h||R[1]>h[0]&&R[1]<h[3])){y.label=R[1];break}if(R[0]===6&&y.label<h[1]){y.label=h[1],h=R;break}if(h&&y.label<h[2]){y.label=h[2],y.ops.push(R);break}h[2]&&y.ops.pop(),y.trys.pop();continue}R=d.call(B,y)}catch(W){R=[6,W],I=0}finally{k=h=0}if(R[0]&5)throw R[1];return{value:R[0]?R[1]:void 0,done:!0}}}var n=(function(){function B(d,y){this.next=null,this.key=d,this.data=y,this.left=null,this.right=null}return B})();function e(B,d){return B>d?1:B<d?-1:0}function r(B,d,y){for(var k=new n(null,null),I=k,h=k;;){var _=y(B,d.key);if(_<0){if(d.left===null)break;if(y(B,d.left.key)<0){var w=d.left;if(d.left=w.right,w.right=d,d=w,d.left===null)break}h.left=d,h=d,d=d.left}else if(_>0){if(d.right===null)break;if(y(B,d.right.key)>0){var w=d.right;if(d.right=w.left,w.left=d,d=w,d.right===null)break}I.right=d,I=d,d=d.right}else break}return I.right=d.left,h.left=d.right,d.left=k.right,d.right=k.left,d}function o(B,d,y,k){var I=new n(B,d);if(y===null)return I.left=I.right=null,I;y=r(B,y,k);var h=k(B,y.key);return h<0?(I.left=y.left,I.right=y,y.left=null):h>=0&&(I.right=y.right,I.left=y,y.right=null),I}function s(B,d,y){var k=null,I=null;if(d){d=r(B,d,y);var h=y(d.key,B);h===0?(k=d.left,I=d.right):h<0?(I=d.right,d.right=null,k=d):(k=d.left,d.left=null,I=d)}return{left:k,right:I}}function i(B,d,y){return d===null?B:(B===null||(d=r(B.key,d,y),d.left=B),d)}function a(B,d,y,k,I){if(B){k(""+d+(y?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+I(B)+`
3
+ `);var h=d+(y?" ":"\u2502 ");B.left&&a(B.left,h,!1,k,I),B.right&&a(B.right,h,!0,k,I)}}var c=(function(){function B(d){d===void 0&&(d=e),this._root=null,this._size=0,this._comparator=d}return B.prototype.insert=function(d,y){return this._size++,this._root=o(d,y,this._root,this._comparator)},B.prototype.add=function(d,y){var k=new n(d,y);this._root===null&&(k.left=k.right=null,this._size++,this._root=k);var I=this._comparator,h=r(d,this._root,I),_=I(d,h.key);return _===0?this._root=h:(_<0?(k.left=h.left,k.right=h,h.left=null):_>0&&(k.right=h.right,k.left=h,h.right=null),this._size++,this._root=k),this._root},B.prototype.remove=function(d){this._root=this._remove(d,this._root,this._comparator)},B.prototype._remove=function(d,y,k){var I;if(y===null)return null;y=r(d,y,k);var h=k(d,y.key);return h===0?(y.left===null?I=y.right:(I=r(d,y.left,k),I.right=y.right),this._size--,I):y},B.prototype.pop=function(){var d=this._root;if(d){for(;d.left;)d=d.left;return this._root=r(d.key,this._root,this._comparator),this._root=this._remove(d.key,this._root,this._comparator),{key:d.key,data:d.data}}return null},B.prototype.findStatic=function(d){for(var y=this._root,k=this._comparator;y;){var I=k(d,y.key);if(I===0)return y;I<0?y=y.left:y=y.right}return null},B.prototype.find=function(d){return this._root&&(this._root=r(d,this._root,this._comparator),this._comparator(d,this._root.key)!==0)?null:this._root},B.prototype.contains=function(d){for(var y=this._root,k=this._comparator;y;){var I=k(d,y.key);if(I===0)return!0;I<0?y=y.left:y=y.right}return!1},B.prototype.forEach=function(d,y){for(var k=this._root,I=[],h=!1;!h;)k!==null?(I.push(k),k=k.left):I.length!==0?(k=I.pop(),d.call(y,k),k=k.right):h=!0;return this},B.prototype.range=function(d,y,k,I){for(var h=[],_=this._comparator,w=this._root,E;h.length!==0||w;)if(w)h.push(w),w=w.left;else{if(w=h.pop(),E=_(w.key,y),E>0)break;if(_(w.key,d)>=0&&k.call(I,w))return this;w=w.right}return this},B.prototype.keys=function(){var d=[];return this.forEach(function(y){var k=y.key;return d.push(k)}),d},B.prototype.values=function(){var d=[];return this.forEach(function(y){var k=y.data;return d.push(k)}),d},B.prototype.min=function(){return this._root?this.minNode(this._root).key:null},B.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},B.prototype.minNode=function(d){if(d===void 0&&(d=this._root),d)for(;d.left;)d=d.left;return d},B.prototype.maxNode=function(d){if(d===void 0&&(d=this._root),d)for(;d.right;)d=d.right;return d},B.prototype.at=function(d){for(var y=this._root,k=!1,I=0,h=[];!k;)if(y)h.push(y),y=y.left;else if(h.length>0){if(y=h.pop(),I===d)return y;I++,y=y.right}else k=!0;return null},B.prototype.next=function(d){var y=this._root,k=null;if(d.right){for(k=d.right;k.left;)k=k.left;return k}for(var I=this._comparator;y;){var h=I(d.key,y.key);if(h===0)break;h<0?(k=y,y=y.left):y=y.right}return k},B.prototype.prev=function(d){var y=this._root,k=null;if(d.left!==null){for(k=d.left;k.right;)k=k.right;return k}for(var I=this._comparator;y;){var h=I(d.key,y.key);if(h===0)break;h<0?y=y.left:(k=y,y=y.right)}return k},B.prototype.clear=function(){return this._root=null,this._size=0,this},B.prototype.toList=function(){return l(this._root)},B.prototype.load=function(d,y,k){y===void 0&&(y=[]),k===void 0&&(k=!1);var I=d.length,h=this._comparator;if(k&&b(d,y,0,I-1,h),this._root===null)this._root=u(d,y,0,I),this._size=I;else{var _=p(this.toList(),f(d,y),h);I=this._size+I,this._root=m({head:_},0,I)}return this},B.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(B.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),B.prototype.toString=function(d){d===void 0&&(d=function(k){return String(k.key)});var y=[];return a(this._root,"",!0,function(k){return y.push(k)},d),y.join("")},B.prototype.update=function(d,y,k){var I=this._comparator,h=s(d,this._root,I),_=h.left,w=h.right;I(d,y)<0?w=o(y,k,w,I):_=o(y,k,_,I),this._root=i(_,w,I)},B.prototype.split=function(d){return s(d,this._root,this._comparator)},B.prototype[Symbol.iterator]=function(){var d,y,k;return t(this,function(I){switch(I.label){case 0:d=this._root,y=[],k=!1,I.label=1;case 1:return k?[3,6]:d===null?[3,2]:(y.push(d),d=d.left,[3,5]);case 2:return y.length===0?[3,4]:(d=y.pop(),[4,d]);case 3:return I.sent(),d=d.right,[3,5];case 4:k=!0,I.label=5;case 5:return[3,1];case 6:return[2]}})},B})();function u(B,d,y,k){var I=k-y;if(I>0){var h=y+Math.floor(I/2),_=B[h],w=d[h],E=new n(_,w);return E.left=u(B,d,y,h),E.right=u(B,d,h+1,k),E}return null}function f(B,d){for(var y=new n(null,null),k=y,I=0;I<B.length;I++)k=k.next=new n(B[I],d[I]);return k.next=null,y.next}function l(B){for(var d=B,y=[],k=!1,I=new n(null,null),h=I;!k;)d?(y.push(d),d=d.left):y.length>0?(d=h=h.next=y.pop(),d=d.right):k=!0;return h.next=null,I.next}function m(B,d,y){var k=y-d;if(k>0){var I=d+Math.floor(k/2),h=m(B,d,I),_=B.head;return _.left=h,B.head=B.head.next,_.right=m(B,I+1,y),_}return null}function p(B,d,y){for(var k=new n(null,null),I=k,h=B,_=d;h!==null&&_!==null;)y(h.key,_.key)<0?(I.next=h,h=h.next):(I.next=_,_=_.next),I=I.next;return h!==null?I.next=h:_!==null&&(I.next=_),k.next}function b(B,d,y,k,I){if(!(y>=k)){for(var h=B[y+k>>1],_=y-1,w=k+1;;){do _++;while(I(B[_],h)<0);do w--;while(I(B[w],h)>0);if(_>=w)break;var E=B[_];B[_]=B[w],B[w]=E,E=d[_],d[_]=d[w],d[w]=E}b(B,d,y,w,I),b(B,d,w+1,k,I)}}let g=(B,d)=>B.ll.x<=d.x&&d.x<=B.ur.x&&B.ll.y<=d.y&&d.y<=B.ur.y,x=(B,d)=>{if(d.ur.x<B.ll.x||B.ur.x<d.ll.x||d.ur.y<B.ll.y||B.ur.y<d.ll.y)return null;let y=B.ll.x<d.ll.x?d.ll.x:B.ll.x,k=B.ur.x<d.ur.x?B.ur.x:d.ur.x,I=B.ll.y<d.ll.y?d.ll.y:B.ll.y,h=B.ur.y<d.ur.y?B.ur.y:d.ur.y;return{ll:{x:y,y:I},ur:{x:k,y:h}}},M=Number.EPSILON;M===void 0&&(M=Math.pow(2,-52));let F=M*M,N=(B,d)=>{if(-M<B&&B<M&&-M<d&&d<M)return 0;let y=B-d;return y*y<F*B*d?0:B<d?-1:1};class P{constructor(){this.reset()}reset(){this.xRounder=new A,this.yRounder=new A}round(d,y){return{x:this.xRounder.round(d),y:this.yRounder.round(y)}}}class A{constructor(){this.tree=new c,this.round(0)}round(d){let y=this.tree.add(d),k=this.tree.prev(y);if(k!==null&&N(y.key,k.key)===0)return this.tree.remove(d),k.key;let I=this.tree.next(y);return I!==null&&N(y.key,I.key)===0?(this.tree.remove(d),I.key):d}}let v=new P,L=11102230246251565e-32,T=134217729,O=(3+8*L)*L;function K(B,d,y,k,I){let h,_,w,E,R=d[0],W=k[0],C=0,z=0;W>R==W>-R?(h=R,R=d[++C]):(h=W,W=k[++z]);let V=0;if(C<B&&z<y)for(W>R==W>-R?(_=R+h,w=h-(_-R),R=d[++C]):(_=W+h,w=h-(_-W),W=k[++z]),h=_,w!==0&&(I[V++]=w);C<B&&z<y;)W>R==W>-R?(_=h+R,E=_-h,w=h-(_-E)+(R-E),R=d[++C]):(_=h+W,E=_-h,w=h-(_-E)+(W-E),W=k[++z]),h=_,w!==0&&(I[V++]=w);for(;C<B;)_=h+R,E=_-h,w=h-(_-E)+(R-E),R=d[++C],h=_,w!==0&&(I[V++]=w);for(;z<y;)_=h+W,E=_-h,w=h-(_-E)+(W-E),W=k[++z],h=_,w!==0&&(I[V++]=w);return(h!==0||V===0)&&(I[V++]=h),V}function D(B,d){let y=d[0];for(let k=1;k<B;k++)y+=d[k];return y}function j(B){return new Float64Array(B)}let G=(3+16*L)*L,U=(2+12*L)*L,$=(9+64*L)*L*L,q=j(4),H=j(8),et=j(12),st=j(16),Q=j(4);function ot(B,d,y,k,I,h,_){let w,E,R,W,C,z,V,Y,Z,X,J,ft,vt,kt,St,Tt,Yt,rt,xt=B-I,Wt=y-I,ee=d-h,ue=k-h;kt=xt*ue,z=T*xt,V=z-(z-xt),Y=xt-V,z=T*ue,Z=z-(z-ue),X=ue-Z,St=Y*X-(kt-V*Z-Y*Z-V*X),Tt=ee*Wt,z=T*ee,V=z-(z-ee),Y=ee-V,z=T*Wt,Z=z-(z-Wt),X=Wt-Z,Yt=Y*X-(Tt-V*Z-Y*Z-V*X),J=St-Yt,C=St-J,q[0]=St-(J+C)+(C-Yt),ft=kt+J,C=ft-kt,vt=kt-(ft-C)+(J-C),J=vt-Tt,C=vt-J,q[1]=vt-(J+C)+(C-Tt),rt=ft+J,C=rt-ft,q[2]=ft-(rt-C)+(J-C),q[3]=rt;let Re=D(4,q),nr=U*_;if(Re>=nr||-Re>=nr||(C=B-xt,w=B-(xt+C)+(C-I),C=y-Wt,R=y-(Wt+C)+(C-I),C=d-ee,E=d-(ee+C)+(C-h),C=k-ue,W=k-(ue+C)+(C-h),w===0&&E===0&&R===0&&W===0)||(nr=$*_+O*Math.abs(Re),Re+=xt*W+ue*w-(ee*R+Wt*E),Re>=nr||-Re>=nr))return Re;kt=w*ue,z=T*w,V=z-(z-w),Y=w-V,z=T*ue,Z=z-(z-ue),X=ue-Z,St=Y*X-(kt-V*Z-Y*Z-V*X),Tt=E*Wt,z=T*E,V=z-(z-E),Y=E-V,z=T*Wt,Z=z-(z-Wt),X=Wt-Z,Yt=Y*X-(Tt-V*Z-Y*Z-V*X),J=St-Yt,C=St-J,Q[0]=St-(J+C)+(C-Yt),ft=kt+J,C=ft-kt,vt=kt-(ft-C)+(J-C),J=vt-Tt,C=vt-J,Q[1]=vt-(J+C)+(C-Tt),rt=ft+J,C=rt-ft,Q[2]=ft-(rt-C)+(J-C),Q[3]=rt;let qa=K(4,q,4,Q,H);kt=xt*W,z=T*xt,V=z-(z-xt),Y=xt-V,z=T*W,Z=z-(z-W),X=W-Z,St=Y*X-(kt-V*Z-Y*Z-V*X),Tt=ee*R,z=T*ee,V=z-(z-ee),Y=ee-V,z=T*R,Z=z-(z-R),X=R-Z,Yt=Y*X-(Tt-V*Z-Y*Z-V*X),J=St-Yt,C=St-J,Q[0]=St-(J+C)+(C-Yt),ft=kt+J,C=ft-kt,vt=kt-(ft-C)+(J-C),J=vt-Tt,C=vt-J,Q[1]=vt-(J+C)+(C-Tt),rt=ft+J,C=rt-ft,Q[2]=ft-(rt-C)+(J-C),Q[3]=rt;let Qa=K(qa,H,4,Q,et);kt=w*W,z=T*w,V=z-(z-w),Y=w-V,z=T*W,Z=z-(z-W),X=W-Z,St=Y*X-(kt-V*Z-Y*Z-V*X),Tt=E*R,z=T*E,V=z-(z-E),Y=E-V,z=T*R,Z=z-(z-R),X=R-Z,Yt=Y*X-(Tt-V*Z-Y*Z-V*X),J=St-Yt,C=St-J,Q[0]=St-(J+C)+(C-Yt),ft=kt+J,C=ft-kt,vt=kt-(ft-C)+(J-C),J=vt-Tt,C=vt-J,Q[1]=vt-(J+C)+(C-Tt),rt=ft+J,C=rt-ft,Q[2]=ft-(rt-C)+(J-C),Q[3]=rt;let Za=K(Qa,et,4,Q,st);return st[Za-1]}function nt(B,d,y,k,I,h){let _=(d-h)*(y-I),w=(B-I)*(k-h),E=_-w,R=Math.abs(_+w);return Math.abs(E)>=G*R?E:-ot(B,d,y,k,I,h,R)}let it=(B,d)=>B.x*d.y-B.y*d.x,yt=(B,d)=>B.x*d.x+B.y*d.y,Ct=(B,d,y)=>{let k=nt(B.x,B.y,d.x,d.y,y.x,y.y);return k>0?-1:k<0?1:0},Ft=B=>Math.sqrt(yt(B,B)),Ht=(B,d,y)=>{let k={x:d.x-B.x,y:d.y-B.y},I={x:y.x-B.x,y:y.y-B.y};return it(I,k)/Ft(I)/Ft(k)},wt=(B,d,y)=>{let k={x:d.x-B.x,y:d.y-B.y},I={x:y.x-B.x,y:y.y-B.y};return yt(I,k)/Ft(I)/Ft(k)},jt=(B,d,y)=>d.y===0?null:{x:B.x+d.x/d.y*(y-B.y),y},ae=(B,d,y)=>d.x===0?null:{x:y,y:B.y+d.y/d.x*(y-B.x)},Tr=(B,d,y,k)=>{if(d.x===0)return ae(y,k,B.x);if(k.x===0)return ae(B,d,y.x);if(d.y===0)return jt(y,k,B.y);if(k.y===0)return jt(B,d,y.y);let I=it(d,k);if(I==0)return null;let h={x:y.x-B.x,y:y.y-B.y},_=it(h,d)/I,w=it(h,k)/I,E=B.x+w*d.x,R=y.x+_*k.x,W=B.y+w*d.y,C=y.y+_*k.y,z=(E+R)/2,V=(W+C)/2;return{x:z,y:V}};class ce{static compare(d,y){let k=ce.comparePoints(d.point,y.point);return k!==0?k:(d.point!==y.point&&d.link(y),d.isLeft!==y.isLeft?d.isLeft?1:-1:_e.compare(d.segment,y.segment))}static comparePoints(d,y){return d.x<y.x?-1:d.x>y.x?1:d.y<y.y?-1:d.y>y.y?1:0}constructor(d,y){d.events===void 0?d.events=[this]:d.events.push(this),this.point=d,this.isLeft=y}link(d){if(d.point===this.point)throw new Error("Tried to link already linked events");let y=d.point.events;for(let k=0,I=y.length;k<I;k++){let h=y[k];this.point.events.push(h),h.point=this.point}this.checkForConsuming()}checkForConsuming(){let d=this.point.events.length;for(let y=0;y<d;y++){let k=this.point.events[y];if(k.segment.consumedBy===void 0)for(let I=y+1;I<d;I++){let h=this.point.events[I];h.consumedBy===void 0&&k.otherSE.point.events===h.otherSE.point.events&&k.segment.consume(h.segment)}}}getAvailableLinkedEvents(){let d=[];for(let y=0,k=this.point.events.length;y<k;y++){let I=this.point.events[y];I!==this&&!I.segment.ringOut&&I.segment.isInResult()&&d.push(I)}return d}getLeftmostComparator(d){let y=new Map,k=I=>{let h=I.otherSE;y.set(I,{sine:Ht(this.point,d.point,h.point),cosine:wt(this.point,d.point,h.point)})};return(I,h)=>{y.has(I)||k(I),y.has(h)||k(h);let{sine:_,cosine:w}=y.get(I),{sine:E,cosine:R}=y.get(h);return _>=0&&E>=0?w<R?1:w>R?-1:0:_<0&&E<0?w<R?-1:w>R?1:0:E<_?-1:E>_?1:0}}}let Fr=0;class _e{static compare(d,y){let k=d.leftSE.point.x,I=y.leftSE.point.x,h=d.rightSE.point.x,_=y.rightSE.point.x;if(_<k)return 1;if(h<I)return-1;let w=d.leftSE.point.y,E=y.leftSE.point.y,R=d.rightSE.point.y,W=y.rightSE.point.y;if(k<I){if(E<w&&E<R)return 1;if(E>w&&E>R)return-1;let C=d.comparePoint(y.leftSE.point);if(C<0)return 1;if(C>0)return-1;let z=y.comparePoint(d.rightSE.point);return z!==0?z:-1}if(k>I){if(w<E&&w<W)return-1;if(w>E&&w>W)return 1;let C=y.comparePoint(d.leftSE.point);if(C!==0)return C;let z=d.comparePoint(y.rightSE.point);return z<0?1:z>0?-1:1}if(w<E)return-1;if(w>E)return 1;if(h<_){let C=y.comparePoint(d.rightSE.point);if(C!==0)return C}if(h>_){let C=d.comparePoint(y.rightSE.point);if(C<0)return 1;if(C>0)return-1}if(h!==_){let C=R-w,z=h-k,V=W-E,Y=_-I;if(C>z&&V<Y)return 1;if(C<z&&V>Y)return-1}return h>_?1:h<_||R<W?-1:R>W?1:d.id<y.id?-1:d.id>y.id?1:0}constructor(d,y,k,I){this.id=++Fr,this.leftSE=d,d.segment=this,d.otherSE=y,this.rightSE=y,y.segment=this,y.otherSE=d,this.rings=k,this.windings=I}static fromRing(d,y,k){let I,h,_,w=ce.comparePoints(d,y);if(w<0)I=d,h=y,_=1;else if(w>0)I=y,h=d,_=-1;else throw new Error(`Tried to create degenerate segment at [${d.x}, ${d.y}]`);let E=new ce(I,!0),R=new ce(h,!1);return new _e(E,R,[k],[_])}replaceRightSE(d){this.rightSE=d,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let d=this.leftSE.point.y,y=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:d<y?d:y},ur:{x:this.rightSE.point.x,y:d>y?d:y}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(d){return d.x===this.leftSE.point.x&&d.y===this.leftSE.point.y||d.x===this.rightSE.point.x&&d.y===this.rightSE.point.y}comparePoint(d){if(this.isAnEndpoint(d))return 0;let y=this.leftSE.point,k=this.rightSE.point,I=this.vector();if(y.x===k.x)return d.x===y.x?0:d.x<y.x?1:-1;let h=(d.y-y.y)/I.y,_=y.x+h*I.x;if(d.x===_)return 0;let w=(d.x-y.x)/I.x,E=y.y+w*I.y;return d.y===E?0:d.y<E?-1:1}getIntersection(d){let y=this.bbox(),k=d.bbox(),I=x(y,k);if(I===null)return null;let h=this.leftSE.point,_=this.rightSE.point,w=d.leftSE.point,E=d.rightSE.point,R=g(y,w)&&this.comparePoint(w)===0,W=g(k,h)&&d.comparePoint(h)===0,C=g(y,E)&&this.comparePoint(E)===0,z=g(k,_)&&d.comparePoint(_)===0;if(W&&R)return z&&!C?_:!z&&C?E:null;if(W)return C&&h.x===E.x&&h.y===E.y?null:h;if(R)return z&&_.x===w.x&&_.y===w.y?null:w;if(z&&C)return null;if(z)return _;if(C)return E;let V=Tr(h,this.vector(),w,d.vector());return V===null||!g(I,V)?null:v.round(V.x,V.y)}split(d){let y=[],k=d.events!==void 0,I=new ce(d,!0),h=new ce(d,!1),_=this.rightSE;this.replaceRightSE(h),y.push(h),y.push(I);let w=new _e(I,_,this.rings.slice(),this.windings.slice());return ce.comparePoints(w.leftSE.point,w.rightSE.point)>0&&w.swapEvents(),ce.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),k&&(I.checkForConsuming(),h.checkForConsuming()),y}swapEvents(){let d=this.rightSE;this.rightSE=this.leftSE,this.leftSE=d,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let y=0,k=this.windings.length;y<k;y++)this.windings[y]*=-1}consume(d){let y=this,k=d;for(;y.consumedBy;)y=y.consumedBy;for(;k.consumedBy;)k=k.consumedBy;let I=_e.compare(y,k);if(I!==0){if(I>0){let h=y;y=k,k=h}if(y.prev===k){let h=y;y=k,k=h}for(let h=0,_=k.rings.length;h<_;h++){let w=k.rings[h],E=k.windings[h],R=y.rings.indexOf(w);R===-1?(y.rings.push(w),y.windings.push(E)):y.windings[R]+=E}k.rings=null,k.windings=null,k.consumedBy=y,k.leftSE.consumedBy=y.leftSE,k.rightSE.consumedBy=y.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let d=this.prev.consumedBy||this.prev;this._beforeState=d.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let d=this.beforeState();this._afterState={rings:d.rings.slice(0),windings:d.windings.slice(0),multiPolys:[]};let y=this._afterState.rings,k=this._afterState.windings,I=this._afterState.multiPolys;for(let w=0,E=this.rings.length;w<E;w++){let R=this.rings[w],W=this.windings[w],C=y.indexOf(R);C===-1?(y.push(R),k.push(W)):k[C]+=W}let h=[],_=[];for(let w=0,E=y.length;w<E;w++){if(k[w]===0)continue;let R=y[w],W=R.poly;if(_.indexOf(W)===-1)if(R.isExterior)h.push(W);else{_.indexOf(W)===-1&&_.push(W);let C=h.indexOf(R.poly);C!==-1&&h.splice(C,1)}}for(let w=0,E=h.length;w<E;w++){let R=h[w].multiPoly;I.indexOf(R)===-1&&I.push(R)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let d=this.beforeState().multiPolys,y=this.afterState().multiPolys;switch(we.type){case"union":{let k=d.length===0,I=y.length===0;this._isInResult=k!==I;break}case"intersection":{let k,I;d.length<y.length?(k=d.length,I=y.length):(k=y.length,I=d.length),this._isInResult=I===we.numMultiPolys&&k<I;break}case"xor":{let k=Math.abs(d.length-y.length);this._isInResult=k%2===1;break}case"difference":{let k=I=>I.length===1&&I[0].isSubject;this._isInResult=k(d)!==k(y);break}default:throw new Error(`Unrecognized operation type found ${we.type}`)}return this._isInResult}}class tr{constructor(d,y,k){if(!Array.isArray(d)||d.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=y,this.isExterior=k,this.segments=[],typeof d[0][0]!="number"||typeof d[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let I=v.round(d[0][0],d[0][1]);this.bbox={ll:{x:I.x,y:I.y},ur:{x:I.x,y:I.y}};let h=I;for(let _=1,w=d.length;_<w;_++){if(typeof d[_][0]!="number"||typeof d[_][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=v.round(d[_][0],d[_][1]);E.x===h.x&&E.y===h.y||(this.segments.push(_e.fromRing(h,E,this)),E.x<this.bbox.ll.x&&(this.bbox.ll.x=E.x),E.y<this.bbox.ll.y&&(this.bbox.ll.y=E.y),E.x>this.bbox.ur.x&&(this.bbox.ur.x=E.x),E.y>this.bbox.ur.y&&(this.bbox.ur.y=E.y),h=E)}(I.x!==h.x||I.y!==h.y)&&this.segments.push(_e.fromRing(h,I,this))}getSweepEvents(){let d=[];for(let y=0,k=this.segments.length;y<k;y++){let I=this.segments[y];d.push(I.leftSE),d.push(I.rightSE)}return d}}class In{constructor(d,y){if(!Array.isArray(d))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new tr(d[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let k=1,I=d.length;k<I;k++){let h=new tr(d[k],this,!1);h.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=h.bbox.ll.x),h.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=h.bbox.ll.y),h.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=h.bbox.ur.x),h.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=h.bbox.ur.y),this.interiorRings.push(h)}this.multiPoly=y}getSweepEvents(){let d=this.exteriorRing.getSweepEvents();for(let y=0,k=this.interiorRings.length;y<k;y++){let I=this.interiorRings[y].getSweepEvents();for(let h=0,_=I.length;h<_;h++)d.push(I[h])}return d}}class Cr{constructor(d,y){if(!Array.isArray(d))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof d[0][0][0]=="number"&&(d=[d])}catch(k){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let k=0,I=d.length;k<I;k++){let h=new In(d[k],this);h.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=h.bbox.ll.x),h.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=h.bbox.ll.y),h.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=h.bbox.ur.x),h.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=h.bbox.ur.y),this.polys.push(h)}this.isSubject=y}getSweepEvents(){let d=[];for(let y=0,k=this.polys.length;y<k;y++){let I=this.polys[y].getSweepEvents();for(let h=0,_=I.length;h<_;h++)d.push(I[h])}return d}}class Rn{static factory(d){let y=[];for(let k=0,I=d.length;k<I;k++){let h=d[k];if(!h.isInResult()||h.ringOut)continue;let _=null,w=h.leftSE,E=h.rightSE,R=[w],W=w.point,C=[];for(;_=w,w=E,R.push(w),w.point!==W;)for(;;){let z=w.getAvailableLinkedEvents();if(z.length===0){let Z=R[0].point,X=R[R.length-1].point;throw new Error(`Unable to complete output ring starting at [${Z.x}, ${Z.y}]. Last matching segment found ends at [${X.x}, ${X.y}].`)}if(z.length===1){E=z[0].otherSE;break}let V=null;for(let Z=0,X=C.length;Z<X;Z++)if(C[Z].point===w.point){V=Z;break}if(V!==null){let Z=C.splice(V)[0],X=R.splice(Z.index);X.unshift(X[0].otherSE),y.push(new Rn(X.reverse()));continue}C.push({index:R.length,point:w.point});let Y=w.getLeftmostComparator(_);E=z.sort(Y)[0].otherSE;break}y.push(new Rn(R))}return y}constructor(d){this.events=d;for(let y=0,k=d.length;y<k;y++)d[y].segment.ringOut=this;this.poly=null}getGeom(){let d=this.events[0].point,y=[d];for(let R=1,W=this.events.length-1;R<W;R++){let C=this.events[R].point,z=this.events[R+1].point;Ct(C,d,z)!==0&&(y.push(C),d=C)}if(y.length===1)return null;let k=y[0],I=y[1];Ct(k,d,I)===0&&y.shift(),y.push(y[0]);let h=this.isExteriorRing()?1:-1,_=this.isExteriorRing()?0:y.length-1,w=this.isExteriorRing()?y.length:-1,E=[];for(let R=_;R!=w;R+=h)E.push([y[R].x,y[R].y]);return E}isExteriorRing(){if(this._isExteriorRing===void 0){let d=this.enclosingRing();this._isExteriorRing=d?!d.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let d=this.events[0];for(let I=1,h=this.events.length;I<h;I++){let _=this.events[I];ce.compare(d,_)>0&&(d=_)}let y=d.segment.prevInResult(),k=y?y.prevInResult():null;for(;;){if(!y)return null;if(!k)return y.ringOut;if(k.ringOut!==y.ringOut)return k.ringOut.enclosingRing()!==y.ringOut?y.ringOut:y.ringOut.enclosingRing();y=k.prevInResult(),k=y?y.prevInResult():null}}}class Lr{constructor(d){this.exteriorRing=d,d.poly=this,this.interiorRings=[]}addInterior(d){this.interiorRings.push(d),d.poly=this}getGeom(){let d=[this.exteriorRing.getGeom()];if(d[0]===null)return null;for(let y=0,k=this.interiorRings.length;y<k;y++){let I=this.interiorRings[y].getGeom();I!==null&&d.push(I)}return d}}class Or{constructor(d){this.rings=d,this.polys=this._composePolys(d)}getGeom(){let d=[];for(let y=0,k=this.polys.length;y<k;y++){let I=this.polys[y].getGeom();I!==null&&d.push(I)}return d}_composePolys(d){let y=[];for(let k=0,I=d.length;k<I;k++){let h=d[k];if(!h.poly)if(h.isExteriorRing())y.push(new Lr(h));else{let _=h.enclosingRing();_.poly||y.push(new Lr(_)),_.poly.addInterior(h)}}return y}}class Nr{constructor(d){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_e.compare;this.queue=d,this.tree=new c(y),this.segments=[]}process(d){let y=d.segment,k=[];if(d.consumedBy)return d.isLeft?this.queue.remove(d.otherSE):this.tree.remove(y),k;let I=d.isLeft?this.tree.add(y):this.tree.find(y);if(!I)throw new Error(`Unable to find segment #${y.id} [${y.leftSE.point.x}, ${y.leftSE.point.y}] -> [${y.rightSE.point.x}, ${y.rightSE.point.y}] in SweepLine tree.`);let h=I,_=I,w,E;for(;w===void 0;)h=this.tree.prev(h),h===null?w=null:h.key.consumedBy===void 0&&(w=h.key);for(;E===void 0;)_=this.tree.next(_),_===null?E=null:_.key.consumedBy===void 0&&(E=_.key);if(d.isLeft){let R=null;if(w){let C=w.getIntersection(y);if(C!==null&&(y.isAnEndpoint(C)||(R=C),!w.isAnEndpoint(C))){let z=this._splitSafely(w,C);for(let V=0,Y=z.length;V<Y;V++)k.push(z[V])}}let W=null;if(E){let C=E.getIntersection(y);if(C!==null&&(y.isAnEndpoint(C)||(W=C),!E.isAnEndpoint(C))){let z=this._splitSafely(E,C);for(let V=0,Y=z.length;V<Y;V++)k.push(z[V])}}if(R!==null||W!==null){let C=null;R===null?C=W:W===null?C=R:C=ce.comparePoints(R,W)<=0?R:W,this.queue.remove(y.rightSE),k.push(y.rightSE);let z=y.split(C);for(let V=0,Y=z.length;V<Y;V++)k.push(z[V])}k.length>0?(this.tree.remove(y),k.push(d)):(this.segments.push(y),y.prev=w)}else{if(w&&E){let R=w.getIntersection(E);if(R!==null){if(!w.isAnEndpoint(R)){let W=this._splitSafely(w,R);for(let C=0,z=W.length;C<z;C++)k.push(W[C])}if(!E.isAnEndpoint(R)){let W=this._splitSafely(E,R);for(let C=0,z=W.length;C<z;C++)k.push(W[C])}}}this.tree.remove(y)}return k}_splitSafely(d,y){this.tree.remove(d);let k=d.rightSE;this.queue.remove(k);let I=d.split(y);return I.push(k),d.consumedBy===void 0&&this.tree.add(d),I}}let Br=typeof process!="undefined"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,qe=typeof process!="undefined"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class er{run(d,y,k){we.type=d,v.reset();let I=[new Cr(y,!0)];for(let C=0,z=k.length;C<z;C++)I.push(new Cr(k[C],!1));if(we.numMultiPolys=I.length,we.type==="difference"){let C=I[0],z=1;for(;z<I.length;)x(I[z].bbox,C.bbox)!==null?z++:I.splice(z,1)}if(we.type==="intersection")for(let C=0,z=I.length;C<z;C++){let V=I[C];for(let Y=C+1,Z=I.length;Y<Z;Y++)if(x(V.bbox,I[Y].bbox)===null)return[]}let h=new c(ce.compare);for(let C=0,z=I.length;C<z;C++){let V=I[C].getSweepEvents();for(let Y=0,Z=V.length;Y<Z;Y++)if(h.insert(V[Y]),h.size>Br)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let _=new Nr(h),w=h.size,E=h.pop();for(;E;){let C=E.key;if(h.size===w){let V=C.segment;throw new Error(`Unable to pop() ${C.isLeft?"left":"right"} SweepEvent [${C.point.x}, ${C.point.y}] from segment #${V.id} [${V.leftSE.point.x}, ${V.leftSE.point.y}] -> [${V.rightSE.point.x}, ${V.rightSE.point.y}] from queue.`)}if(h.size>Br)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(_.segments.length>qe)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let z=_.process(C);for(let V=0,Y=z.length;V<Y;V++){let Z=z[V];Z.consumedBy===void 0&&h.insert(Z)}w=h.size,E=h.pop()}v.reset();let R=Rn.factory(_.segments);return new Or(R).getGeom()}}let we=new er;var Io={union:function(B){for(var d=arguments.length,y=new Array(d>1?d-1:0),k=1;k<d;k++)y[k-1]=arguments[k];return we.run("union",B,y)},intersection:function(B){for(var d=arguments.length,y=new Array(d>1?d-1:0),k=1;k<d;k++)y[k-1]=arguments[k];return we.run("intersection",B,y)},xor:function(B){for(var d=arguments.length,y=new Array(d>1?d-1:0),k=1;k<d;k++)y[k-1]=arguments[k];return we.run("xor",B,y)},difference:function(B){for(var d=arguments.length,y=new Array(d>1?d-1:0),k=1;k<d;k++)y[k-1]=arguments[k];return we.run("difference",B,y)}};return Io}))});var Mt=[1,0,0,1,0,0];function lt(t,n){return[t[0]*n[0]+t[2]*n[1],t[1]*n[0]+t[3]*n[1],t[0]*n[2]+t[2]*n[3],t[1]*n[2]+t[3]*n[3],t[0]*n[4]+t[2]*n[5]+t[4],t[1]*n[4]+t[3]*n[5]+t[5]]}function Nt(t,n){return[t[0]*n[0]+t[2]*n[1]+t[4],t[1]*n[0]+t[3]*n[1]+t[5]]}function le(t){let n=t[0]*t[3]-t[1]*t[2]||1e-12,e=t[3]/n,r=-t[1]/n,o=-t[2]/n,s=t[0]/n;return[e,r,o,s,-(e*t[4]+o*t[5]),-(r*t[4]+s*t[5])]}function bt(t,n){return[1,0,0,1,t,n]}function Jt(t,n,e){return[t,0,0,n,e[0]-t*e[0],e[1]-n*e[1]]}function Te(t,n){let e=Math.cos(t),r=Math.sin(t);return[e,r,-r,e,n[0]-e*n[0]+r*n[1],n[1]-r*n[0]-e*n[1]]}function We(t,n,e){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e,t[2]+(n[2]-t[2])*e,t[3]+(n[3]-t[3])*e,t[4]+(n[4]-t[4])*e,t[5]+(n[5]-t[5])*e]}function hn(t){return Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))||1e-9}var Rt=Math.PI*2;function fe(t,n,e){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e]}function ac(t,n){return Math.hypot(n[0]-t[0],n[1]-t[1])}function or(t,n,e){t.push(fe(n,e,1/3),fe(n,e,2/3),[e[0],e[1]])}function Lt(t,n){let e=[[t[0],t[1]]];return or(e,t,n),{points:e,closed:!1}}function _t(t,n){if(!t.length)return{points:[[0,0]],closed:!1};let e=[[t[0][0],t[0][1]]];for(let r=1;r<t.length;r++)or(e,t[r-1],t[r]);return n&&t.length>1&&or(e,t[t.length-1],t[0]),{points:e,closed:n}}function me(t,n,e,r,o,s=!1,i=0){let a=i>0?i:Math.max(1,Math.ceil(Math.abs(o)/(Rt/8)-1e-9)),c=o/a,u=4/3*Math.tan(c/4),f=m=>[t[0]+n*Math.cos(m),t[1]+e*Math.sin(m)],l=[f(r)];for(let m=0;m<a;m++){let p=r+c*m,b=p+c,g=f(p),x=f(b);l.push([g[0]-u*n*Math.sin(p),g[1]+u*e*Math.cos(p)],[x[0]+u*n*Math.sin(b),x[1]-u*e*Math.cos(b)],x)}return s&&(l[l.length-1]=[l[0][0],l[0][1]]),{points:l,closed:s}}function Fe(t,n){return me(t,n,n,0,Rt,!0)}function Fn(t,n,e){if(e=Math.max(0,Math.min(e,t/2,n/2)),e<=1e-9)return _t($e(t,n),!0);let r=t/2,o=n/2,s=[],i=(a,c,u)=>{let f=me([a,c],e,e,u,Math.PI/2,!1,1);s.length?(or(s,s[s.length-1],f.points[0]),s.push(...f.points.slice(1))):s.push(...f.points)};return i(r-e,o-e,0),i(-r+e,o-e,Math.PI/2),i(-r+e,-o+e,Math.PI),i(r-e,-o+e,Math.PI*1.5),or(s,s[s.length-1],s[0]),s[s.length-1]=[s[0][0],s[0][1]],{points:s,closed:!0}}function $e(t,n){return[[t/2,n/2],[-t/2,n/2],[-t/2,-n/2],[t/2,-n/2]]}function Fo(t,n,e){let r=[];for(let o=0;o<t;o++){let s=e+Rt*o/t;r.push([n*Math.cos(s),n*Math.sin(s)])}return r}function Ws(t,n,e,r){let o=[];for(let s=0;s<2*t;s++){let i=r+Math.PI*s/t,a=s%2?e:n;o.push([a*Math.cos(i),a*Math.sin(i)])}return o}function sr(t,n){let e=t.length;if(e<3)return _t(t,n);let r=i=>n?t[(i%e+e)%e]:t[Math.max(0,Math.min(e-1,i))],o=[[t[0][0],t[0][1]]],s=n?e:e-1;for(let i=0;i<s;i++){let a=r(i-1),c=r(i),u=r(i+1),f=r(i+2);o.push([c[0]+(u[0]-a[0])/6,c[1]+(u[1]-a[1])/6],[u[0]-(f[0]-c[0])/6,u[1]-(f[1]-c[1])/6],[u[0],u[1]])}return{points:o,closed:n}}function ne(t,n){return t.map(e=>({points:e.points.map(r=>Nt(n,r)),closed:e.closed}))}function ir(t,n){let e=1/0,r=1/0,o=-1/0,s=-1/0;for(let i of t)for(let a of i.points){let c=n?n[0]*a[0]+n[2]*a[1]+n[4]:a[0],u=n?n[1]*a[0]+n[3]*a[1]+n[5]:a[1];c<e&&(e=c),c>o&&(o=c),u<r&&(r=u),u>s&&(s=u)}return e===1/0?null:[e,r,o,s]}function Cn(t,n){return t?n?[Math.min(t[0],n[0]),Math.min(t[1],n[1]),Math.max(t[2],n[2]),Math.max(t[3],n[3])]:t:n}function $s(t,n,e,r,o){let s=1-o,i=s*s*s,a=3*s*s*o,c=3*s*o*o,u=o*o*o;return[i*t[0]+a*n[0]+c*e[0]+u*r[0],i*t[1]+a*n[1]+c*e[1]+u*r[1]]}function Ks(t,n,e,r,o,s){let[i,a,c,u]=cc(t,n,e,r,s);if(o>0){let f=s>0?o/s:0;[i,a,c,u]=uc(i,a,c,u,f)}return[i,a,c,u]}function cc(t,n,e,r,o){let s=fe(t,n,o),i=fe(n,e,o),a=fe(e,r,o),c=fe(s,i,o),u=fe(i,a,o),f=fe(c,u,o);return[t,s,c,f]}function uc(t,n,e,r,o){let s=fe(t,n,o),i=fe(n,e,o),a=fe(e,r,o),c=fe(s,i,o),u=fe(i,a,o);return[fe(c,u,o),u,a,r]}var rr=12,Ds=new WeakMap;function Co(t){let n=Ds.get(t);if(n)return n;let e=[],r=0;return t.forEach((o,s)=>{let i=o.points;for(let a=0;a+3<i.length;a+=3){let c=new Float64Array(rr+1),u=i[a],f=0;for(let l=1;l<=rr;l++){let m=$s(i[a],i[a+1],i[a+2],i[a+3],l/rr);f+=ac(u,m),c[l]=f,u=m}e.push({sub:s,i:a,len:f,cum:c}),r+=f}}),n={segs:e,total:r},Ds.set(t,n),n}function Lo(t){return Co(t).total}function Ro(t,n){if(n<=0)return 0;if(n>=t.len)return 1;let e=t.cum,r=1;for(;r<rr&&e[r]<n;)r++;let o=e[r]-e[r-1]||1;return(r-1+(n-e[r-1])/o)/rr}function pn(t,n,e){if(n<=0&&e>=1)return t;if(e<=n)return[];let r=Co(t),o=r.total;if(o<=1e-12)return e>=1?t:[];let s=n*o,i=e*o,a=[],c=0,u=null,f=-1,l=!0;for(let m of r.segs){let p=c+m.len,b=t[m.sub].points;m.sub!==f&&(u&&a.push({points:u,closed:l&&t[f].closed}),u=null,f=m.sub,l=!0);let g=Math.max(s,c),x=Math.min(i,p);if(x>g||m.len===0&&c>=s&&c<=i){(g>c+1e-12||x<p-1e-12)&&(l=!1);let M=Ro(m,g-c),F=Ro(m,x-c),N=M<=0&&F>=1?[b[m.i],b[m.i+1],b[m.i+2],b[m.i+3]]:Ks(b[m.i],b[m.i+1],b[m.i+2],b[m.i+3],M,F);u||(u=[N[0]]),u.push(N[1],N[2],N[3])}else l=!1;c=p}return u&&a.push({points:u,closed:l&&t[f].closed}),a}function Qe(t,n){var s;let e=Co(t);if(!e.segs.length){let i=(s=t[0])==null?void 0:s.points[0];return i?[i[0],i[1]]:[0,0]}let r=Math.max(0,Math.min(1,n))*e.total,o=0;for(let i of e.segs){if(r<=o+i.len||i===e.segs[e.segs.length-1]){let a=t[i.sub].points;return $s(a[i.i],a[i.i+1],a[i.i+2],a[i.i+3],Ro(i,r-o))}o+=i.len}return[0,0]}function Gs(t,n,e){let r=Lo(t),o=Math.max(2,Math.ceil(r/Math.max(1e-6,n)*e)),s=e/o,a=t.length===1&&t[0].closed?1/o:(1-s)/(o-1),c=[];for(let u=0;u<o;u++){let f=u*a;for(let l of pn(t,f,Math.min(1,f+s)))c.push({points:l.points,closed:!1})}return c}function To(t){return Math.max(0,(t.points.length-1)/3)}function js(t,n){let e=To(t);if(e===n)return t;let r=t.points;if(e===0){let i=r[0]||[0,0],a=[i];for(let c=0;c<n;c++)a.push(i,i,i);return{points:a,closed:t.closed}}let o=new Array(e).fill(0);for(let i=0;i<n;i++)o[Math.floor(i*e/n)]++;let s=[r[0]];for(let i=0;i<e;i++){let a=o[i],c=r[3*i],u=r[3*i+1],f=r[3*i+2],l=r[3*i+3];if(a<=1){s.push(u,f,l);continue}for(let m=0;m<a;m++){let p=Ks(c,u,f,l,m/a,(m+1)/a);s.push(p[1],p[2],p[3])}}return{points:s,closed:t.closed}}function Vs(t,n,e,r){let o=t.length?t:[{points:[e],closed:!1}],s=n.length?n:[{points:[r],closed:!1}],i=Math.max(o.length,s.length),a=[],c=[],u=(f,l)=>{if(l<f.length)return f[l];let m=f[f.length-1].points;return{points:[m[m.length-1]],closed:!1}};for(let f=0;f<i;f++){let l=u(o,f),m=u(s,f),p=Math.max(To(l),To(m),1);a.push(js(l,p)),c.push(js(m,p))}return[a,c]}function Oo(t,n,e){if(e<=0)return t;if(e>=1)return n;let r=new Array(t.length);for(let o=0;o<t.length;o++){let s=t[o].points,i=n[o].points,a=new Array(s.length);for(let c=0;c<s.length;c++)a[c]=[s[c][0]+(i[c][0]-s[c][0])*e,s[c][1]+(i[c][1]-s[c][1])*e];r[o]={points:a,closed:e<.5?t[o].closed:n[o].closed}}return r}var Xt=[1,0,0,0,1,0,0,0,1,0,0,0];function Vt(t,n){let[e,r,o,s,i,a,c,u,f,l,m,p]=t,[b,g,x,M,F,N,P,A,v,L,T,O]=n;return[e*b+r*M+o*P,e*g+r*F+o*A,e*x+r*N+o*v,s*b+i*M+a*P,s*g+i*F+a*A,s*x+i*N+a*v,c*b+u*M+f*P,c*g+u*F+f*A,c*x+u*N+f*v,e*L+r*T+o*O+l,s*L+i*T+a*O+m,c*L+u*T+f*O+p]}function zt(t,n,e,r){return[t[0]*n+t[1]*e+t[2]*r+t[9],t[3]*n+t[4]*e+t[5]*r+t[10],t[6]*n+t[7]*e+t[8]*r+t[11]]}function Bt(t){return[t[0],t[2],0,t[1],t[3],0,0,0,1,t[4],t[5],0]}function he(t){return[t[0],t[3],t[1],t[4],t[9],t[10]]}function Us(t){return t[2]===0&&t[5]===0&&t[6]===0&&t[7]===0&&t[8]===1&&t[11]===0}function ke(t,n,e){return[1,0,0,0,1,0,0,0,1,t,n,e]}function Ys(t,n,e,r){return[t,0,0,0,n,0,0,0,e,r[0]-t*r[0],r[1]-n*r[1],r[2]-e*r[2]]}function Ke(t,n,e=[0,0,0]){let[r,o,s]=t,i=Math.hypot(r,o,s)||1;r/=i,o/=i,s/=i;let a=Math.cos(n),c=Math.sin(n),u=1-a,f=[a+r*r*u,r*o*u-s*c,r*s*u+o*c,o*r*u+s*c,a+o*o*u,o*s*u-r*c,s*r*u-o*c,s*o*u+r*c,a+s*s*u,0,0,0];return Vt(ke(e[0],e[1],e[2]),Vt(f,ke(-e[0],-e[1],-e[2])))}function Hs(t,n,e){return t.map((r,o)=>r+(n[o]-r)*e)}function Xs(t){let[n,e,r,o,s,i,a,c,u,f,l,m]=t,p=s*u-i*c,b=-(o*u-i*a),g=o*c-s*a,x=n*p+e*b+r*g||1e-12,M=[p/x,-(e*u-r*c)/x,(e*i-r*s)/x,b/x,(n*u-r*a)/x,-(n*i-r*o)/x,g/x,-(n*c-e*a)/x,(n*s-e*o)/x,0,0,0];return M[9]=-(M[0]*f+M[1]*l+M[2]*m),M[10]=-(M[3]*f+M[4]*l+M[5]*m),M[11]=-(M[6]*f+M[7]*l+M[8]*m),M}var It=0,Se=class t{constructor(n,e,r){this.shared=!1;this.mobs=n||new Map,this.display=e||[],this.ids=r||{n:-1}}snapshot(){return this.shared=!0,{mobs:this.mobs,display:this.display}}fork(){this.shared=!0;let n=new t(this.mobs,this.display,this.ids);return n.shared=!0,n}own(){this.shared&&(this.mobs=new Map(this.mobs),this.display=this.display.slice(),this.shared=!1)}has(n){return this.mobs.has(n)}get(n){let e=this.mobs.get(n);if(!e)throw new Error(n===It?"no camera frame":`that object does not exist (#${n})`);return e}set(n){this.own(),this.mobs.set(n.id,n)}update(n,e){this.set({...this.get(n),...e})}setDisplay(n){this.own(),this.display=n}newId(){return this.ids.n--}};function Pe(t){return t.paths.length>0||!!t.text||!!t.image||!!(t.p3&&t.p3.length)}function Ze(t){var r;let n=(r=t.m3)!=null?r:Bt(t.m),e=new Array(t.p3.length);for(let o=0;o<t.p3.length;o+=3){let s=zt(n,t.p3[o],t.p3[o+1],t.p3[o+2]);e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2]}return e}function mt(t,n,e=[],r){let o=t.mobs.get(n);if(!o||(r=r||new Set,r.has(n)))return e;r.add(n),e.push(n);for(let s of o.children)mt(t,s,e,r);return e}function dt(t,n){return mt(t,n).filter(e=>Pe(t.mobs.get(e)))}function No(t,n=t.m){let e=t.paths.length?ir(t.paths,n):null;if(t.p3&&t.p3.length){let o=Ze(t),s=n===t.m?null:lt(n,le(t.m)),i=1/0,a=1/0,c=-1/0,u=-1/0;for(let f=0;f<o.length;f+=3){let l=s?Nt(s,[o[f],o[f+1]]):[o[f],o[f+1]];i=Math.min(i,l[0]),c=Math.max(c,l[0]),a=Math.min(a,l[1]),u=Math.max(u,l[1])}i!==1/0&&(e=Cn(e,[i,a,c,u]))}let r=t.text||t.image;if(r){let{w:o,h:s}=r;e=Cn(e,ir([{points:[[-o/2,-s/2],[o/2,-s/2],[o/2,s/2],[-o/2,s/2]],closed:!0}],n))}return e}function at(t,n){let e=null;for(let r of mt(t,n))e=Cn(e,No(t.mobs.get(r)));if(!e){let r=t.mobs.get(n),o=r?Nt(r.m,[0,0]):[0,0];return[o[0],o[1],o[0],o[1]]}return e}function Pt(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function re(t,n){let e=(r,o,s)=>s>1e-9?o:s<-1e-9?r:(r+o)/2;return[e(t[0],t[2],n[0]),e(t[1],t[3],n[1])]}function Ot(t,n){return Pt(at(t,n))}function oe(t,n,e){for(let r of mt(t,n)){let o=t.get(r);if(o.m3){let s=Vt(Bt(e),o.m3);t.set({...o,m3:s,m:he(s)})}else t.set({...o,m:lt(e,o.m)})}}function dn(t,n,e){var o;let r=Us(e);for(let s of mt(t,n)){let i=t.get(s);if(!i.m3&&r){t.set({...i,m:lt(he(e),i.m)});continue}let a=Vt(e,(o=i.m3)!=null?o:Bt(i.m));t.set({...i,m3:a,m:he(a)})}}function Ge(t,n){let e=at(t,n),r=1/0,o=-1/0;for(let s of mt(t,n)){let i=t.mobs.get(s);if(i.p3&&i.p3.length){let a=Ze(i);for(let c=2;c<a.length;c+=3)r=Math.min(r,a[c]),o=Math.max(o,a[c])}else if(Pe(i)){let a=i.m3;if(!a){r=Math.min(r,0),o=Math.max(o,0);continue}for(let u of i.paths)for(let f of u.points){let l=zt(a,f[0],f[1],0)[2];r=Math.min(r,l),o=Math.max(o,l)}let c=i.text||i.image;if(c)for(let[u,f]of[[-c.w/2,-c.h/2],[c.w/2,c.h/2],[-c.w/2,c.h/2],[c.w/2,-c.h/2]]){let l=zt(a,u,f,0)[2];r=Math.min(r,l),o=Math.max(o,l)}}}return r===1/0&&(r=0,o=0),[e[0],e[1],r,e[2],e[3],o]}function Ve(t,n){return mt(t,n).some(e=>{let r=t.mobs.get(e);return!!(r.m3||r.p3)})}function se(t,n,e){for(let r of mt(t,n)){let o=t.get(r);t.set({...o,style:e(o.style,o)})}}function Je(t,n,e){let r=t.get(n),o=e!=null?e:t.newId(),s=r.children.map(i=>Je(t,i));return t.set({...r,id:o,children:s,data:r.data?{...r.data}:void 0}),o}function bn(t,n,e){if(n===e)return;let r=t.get(e),o=t.has(n)?t.get(n).children:[],s=o.length&&o.length===r.children.length?o.map((i,a)=>(bn(t,i,r.children[a]),i)):r.children.map(i=>Je(t,i));t.set({...r,id:n,children:s,data:r.data?{...r.data}:void 0})}function pe(t,n){let e=new Set(n),r=t.display.filter(o=>!e.has(o));for(let o of n)o!==It&&!r.includes(o)&&r.push(o);t.setDisplay(r)}function Ne(t,n){let e=t.display.slice();for(let r of n){let o=[];for(let s of e)s!==r&&o.push(...qs(t,s,r));e=o}t.setDisplay(e)}function qs(t,n,e){if(n===e)return[];if(!mt(t,n).includes(e))return[n];let r=[];for(let o of t.get(n).children)r.push(...qs(t,o,e));return r}function Bo(t,n){for(let e of t.display)if(e===n||mt(t,e).includes(n))return!0;return!1}function ct(t,n,e,r=[],o){return{id:t,kind:n,paths:r,m:Mt,children:[],style:e,z:0,...o}}var $t={BLACK:"#000000",BLUE:"#58C4DD",BLUE_A:"#C7E9F1",BLUE_B:"#9CDCEB",BLUE_C:"#58C4DD",BLUE_D:"#29ABCA",BLUE_E:"#236B8E",DARKER_GRAY:"#222222",DARKER_GREY:"#222222",DARK_BLUE:"#236B8E",DARK_BROWN:"#8B4513",DARK_GRAY:"#444444",DARK_GREY:"#444444",GOLD:"#F0AC5F",GOLD_A:"#F7C797",GOLD_B:"#F9B775",GOLD_C:"#F0AC5F",GOLD_D:"#E1A158",GOLD_E:"#C78D46",GRAY:"#888888",GRAY_A:"#DDDDDD",GRAY_B:"#BBBBBB",GRAY_BROWN:"#736357",GRAY_C:"#888888",GRAY_D:"#444444",GRAY_E:"#222222",GREEN:"#83C167",GREEN_A:"#C9E2AE",GREEN_B:"#A6CF8C",GREEN_C:"#83C167",GREEN_D:"#77B05D",GREEN_E:"#699C52",GREY:"#888888",GREY_A:"#DDDDDD",GREY_B:"#BBBBBB",GREY_BROWN:"#736357",GREY_C:"#888888",GREY_D:"#444444",GREY_E:"#222222",LIGHTER_GRAY:"#DDDDDD",LIGHTER_GREY:"#DDDDDD",LIGHT_BROWN:"#CD853F",LIGHT_GRAY:"#BBBBBB",LIGHT_GREY:"#BBBBBB",LIGHT_PINK:"#DC75CD",LOGO_BLACK:"#343434",LOGO_BLUE:"#525893",LOGO_GREEN:"#87C2A5",LOGO_RED:"#E07A5F",LOGO_WHITE:"#ECE7E2",MAROON:"#C55F73",MAROON_A:"#ECABC1",MAROON_B:"#EC92AB",MAROON_C:"#C55F73",MAROON_D:"#A24D61",MAROON_E:"#94424F",ORANGE:"#FF862F",PINK:"#D147BD",PURE_BLUE:"#0000FF",PURE_CYAN:"#00FFFF",PURE_GREEN:"#00FF00",PURE_MAGENTA:"#FF00FF",PURE_RED:"#FF0000",PURE_YELLOW:"#FFFF00",PURPLE:"#9A72AC",PURPLE_A:"#CAA3E8",PURPLE_B:"#B189C6",PURPLE_C:"#9A72AC",PURPLE_D:"#715582",PURPLE_E:"#644172",RED:"#FC6255",RED_A:"#F7A1A3",RED_B:"#FF8080",RED_C:"#FC6255",RED_D:"#E65A4C",RED_E:"#CF5044",TEAL:"#5CD0B3",TEAL_A:"#ACEAD7",TEAL_B:"#76DDC0",TEAL_C:"#5CD0B3",TEAL_D:"#55C1A7",TEAL_E:"#49A88F",WHITE:"#FFFFFF",YELLOW:"#F7D96F",YELLOW_A:"#FFF1B6",YELLOW_B:"#FFEA94",YELLOW_C:"#F7D96F",YELLOW_D:"#F4D345",YELLOW_E:"#E8C11C"},gt="#FFFFFF",tn="#F7D96F",ar="#FFFF00",Qs=["#003F5C","#58508D","#BC5090","#FF6361","#FFA600"],zr=new Map;function Ln(t){let n=zr.get(t);if(n!==void 0)return n;let e=t.trim();$t[e.toUpperCase()]&&(e=$t[e.toUpperCase()]);let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e);if(r){let o=parseInt(r[1],16);n=[o>>16&255,o>>8&255,o&255]}else(r=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e))?n=[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)]:n=null;return zr.size>2e3&&zr.clear(),zr.set(t,n),n}function ht(t,n){if(typeof t=="string"){let e=t.toUpperCase();return $t[e]?$t[e]:t}if(Array.isArray(t)&&t.length>=3){let e=t.some(r=>Number(r)>1)?1:255;return Zs([Number(t[0])*e,Number(t[1])*e,Number(t[2])*e])}return n}function Zs(t){let n=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return"#"+n(t[0])+n(t[1])+n(t[2])}function en(t,n,e){if(t===n||e<=0)return t;if(e>=1)return n;let r=Ln(t),o=Ln(n);if(!r||!o)return e<.5?t:n;let s=(i,a)=>Math.floor(i+(a-i)*e+1e-6);return Zs([s(r[0],o[0]),s(r[1],o[1]),s(r[2],o[2])])}var lc={"normal|normal":"LiberationSans-Regular.ttf","bold|normal":"LiberationSans-Bold.ttf","normal|italic":"LiberationSans-Italic.ttf","bold|italic":"LiberationSans-BoldItalic.ttf","serif:normal|normal":"KaTeX_Main-Regular.ttf","serif:bold|normal":"KaTeX_Main-Bold.ttf","serif:normal|italic":"KaTeX_Main-Italic.ttf","serif:bold|italic":"KaTeX_Main-BoldItalic.ttf","mono:normal|normal":"KaTeX_Typewriter-Regular.ttf","mono:bold|normal":"KaTeX_Typewriter-Regular.ttf","mono:normal|italic":"KaTeX_Typewriter-Regular.ttf","mono:bold|italic":"KaTeX_Typewriter-Regular.ttf"};function fc(t){let n=String(t||"");return/\.(ttf|otf|woff2?)(\?|#|$)/i.test(n)||/^(blob:|data:|https?:)/.test(n)}function mc(t){let n=String(t||"").toLowerCase();return/mono|courier|consol|menlo|typewriter|code/.test(n)?"mono":/serif/.test(n)&&!/sans/.test(n)||/times|georgia|garamond|roman|palatino|baskerville|cambria|book/.test(n)?"serif":"sans"}function nn(t,n,e){if(e&&fc(e))return"url:"+String(e);let r=String(t||"normal").toLowerCase(),o=String(n||"normal").toLowerCase(),s=r==="bold"||r==="heavy"||r==="ultrabold"||r==="semibold"||Number(r)>=600,i=o==="italic"||o==="oblique",a=e?mc(e):"sans";return`${a==="sans"?"":a+":"}${s?"bold":"normal"}|${i?"italic":"normal"}`}function ti(t){return t.startsWith("url:")?`"${ei(t)}", "Liberation Sans", Arial, sans-serif`:t.startsWith("mono:")?'Menlo, Consolas, "Liberation Mono", monospace':t.startsWith("serif:")?'"KaTeX_Main", "Times New Roman", serif':'"Liberation Sans", Arial, sans-serif'}function ei(t){let n=0;for(let e of t)n=n*31+e.charCodeAt(0)|0;return"pymations-font-"+(n>>>0).toString(36)}var Dr=null,jr=12e4;function Wr(t){let n=globalThis.__cirAnimVersion;return n==null||n===""?t:t+(t.includes("?")?"&":"?")+"v="+encodeURIComponent(String(n))}async function Kr(t){let n=typeof AbortController!="undefined"?new AbortController:null,e=setTimeout(()=>n==null?void 0:n.abort(),jr);try{let r=await fetch(t,n?{signal:n.signal}:void 0);if(!r.ok)throw new Error(`could not load ${t} (${r.status})`);return await r.arrayBuffer()}catch(r){throw n!=null&&n.signal.aborted?new Error(`${t} did not load within ${jr/1e3} s`):r}finally{clearTimeout(e)}}function zo(t,n){let e=globalThis;return e[n]?Promise.resolve(e[n]):typeof document=="undefined"?Promise.reject(new Error("no document to load "+t)):new Promise((r,o)=>{let s=setTimeout(()=>o(new Error(`${t} did not load within ${jr/1e3} s`)),jr),i=r,a=o;r=p=>{clearTimeout(s),i(p)},o=p=>{clearTimeout(s),a(p)};let c=t.split("?")[0],u=c.slice(c.lastIndexOf("/")+1),f=Array.from(document.scripts).find(p=>p.src&&p.src.split("?")[0].endsWith("/"+u))||null,l=f||document.createElement("script"),m=()=>e[n]?r(e[n]):o(new Error(n+" did not load"));l.addEventListener("load",m),l.addEventListener("error",()=>o(new Error("could not load "+t))),f||(l.src=t,l.async=!0,l.dataset.cirSrc=t,document.head.appendChild(l))})}var $r=class{constructor(n){this.base=n;this.fonts=new Map;this.loading=new Map;this.cache=new Map;this.chars=new Map}font(n){return this.fonts.get(n)}load(n){if(this.fonts.has(n))return Promise.resolve(this.fonts.get(n));let e=this.loading.get(n);return e||(e=this.fetchFont(n).then(r=>(this.fonts.set(n,r),r),()=>(this.fonts.set(n,null),null)),this.loading.set(n,e),e)}async fetchFont(n){if(!this.base||typeof fetch=="undefined")return null;Dr||(Dr=zo(Wr(this.base+"opentype.min.js"),"opentype").catch(s=>{throw Dr=null,s}));let e=await Dr,r=n.startsWith("url:")?n.slice(4):Wr(this.base+"fonts/"+lc[n]),o=await Kr(r);if(n.startsWith("url:")&&typeof FontFace!="undefined"&&typeof document!="undefined")try{let s=new FontFace(ei(n),o.slice(0));await s.load(),document.fonts.add(s)}catch(s){}return e.parse(o)}glyph(n,e,r){let o=`${r}|${e}|${n}`,s=this.chars.get(o);if(s!==void 0)return s;let i=this.fonts.get(r);if(!i)return null;let a=e/i.unitsPerEm,c=i.charToGlyph(n),u=n.trim()?Js(c.path.commands,a,0,0):[],f=1/0,l=-1/0,m=1/0,p=-1/0;for(let b of u)for(let g of b.points)f=Math.min(f,g[1]),l=Math.max(l,g[1]),m=Math.min(m,g[0]),p=Math.max(p,g[0]);return s={paths:u,advance:c.advanceWidth*a,box:u.length?[m,f,p,l]:null},this.chars.size>4e3&&this.chars.clear(),this.chars.set(o,s),s}outline(n,e,r,o=1.2,s=0){let i=`${r}|${e}|${o}|${s}|${n}`;if(this.cache.has(i))return this.cache.get(i);let a=this.fonts.get(r);if(!a)return null;let c=e/a.unitsPerEm,u=[],f=n.split(`
4
+ `),l=0;f.forEach((N,P)=>{let A=0,v=-P*o*e,L=null;for(let T of Array.from(N)){let O=a.charToGlyph(T);L&&(A+=a.getKerningValue(L,O)*c),T.trim()&&u.push({char:T,paths:Js(O.path.commands,c,A,v)}),A+=O.advanceWidth*c+s,L=O}l=Math.max(l,A)});let m=1/0,p=1/0,b=-1/0,g=-1/0;for(let N of u)for(let P of N.paths)for(let A of P.points)A[0]<m&&(m=A[0]),A[0]>b&&(b=A[0]),A[1]<p&&(p=A[1]),A[1]>g&&(g=A[1]);m===1/0&&(m=0,b=l,p=0,g=0);let x=(m+b)/2,M=(p+g)/2;for(let N of u)N.paths=N.paths.map(P=>({points:P.points.map(A=>[A[0]-x,A[1]-M]),closed:P.closed}));let F={glyphs:u,width:b-m,height:g-p};return this.cache.size>500&&this.cache.clear(),this.cache.set(i,F),F}};function Js(t,n,e,r){let o=[],s=null,i=(f,l)=>[e+f*n,r+l*n],a=()=>s[s.length-1],c=f=>{let l=a();s.push([l[0]+(f[0]-l[0])/3,l[1]+(f[1]-l[1])/3],[l[0]+2*(f[0]-l[0])/3,l[1]+2*(f[1]-l[1])/3],f)},u=f=>{s&&s.length>1&&o.push({points:s,closed:f}),s=null};for(let f of t)switch(f.type){case"M":u(!1),s=[i(f.x,f.y)];break;case"L":s&&c(i(f.x,f.y));break;case"Q":{if(!s)break;let l=a(),m=i(f.x1,f.y1),p=i(f.x,f.y);s.push([l[0]+2/3*(m[0]-l[0]),l[1]+2/3*(m[1]-l[1])],[p[0]+2/3*(m[0]-p[0]),p[1]+2/3*(m[1]-p[1])],p);break}case"C":s&&s.push(i(f.x1,f.y1),i(f.x2,f.y2),i(f.x,f.y));break;case"Z":{if(!s)break;let l=s[0],m=a();(Math.abs(l[0]-m[0])>1e-9||Math.abs(l[1]-m[1])>1e-9)&&c([l[0],l[1]]),u(!0);break}}return u(!1),o}var Do=$t.BLUE,Gr=$t.BLUE_D,hc=$t.BLUE_E,ni=$t.LIGHT_GREY;function ur(t,n,e,r=!0,o=!0,s="face"){let i=t.newId();return t.set(ct(i,s,e,[],{p3:n,closed3:r,shade3:o,m3:Xt})),i}function Ur(t,n,e){var s;let r=t.get(n),o=Vt(e,(s=r.m3)!=null?s:Bt(r.m));t.set({...r,m3:o,m:he(o)})}function Ue(t,n,e,r,o,s=Xt,i={}){if(t.w.set(ct(n,e,ut(r),[],{children:o,m3:s,m:he(s),z:S(r.z_index,0),...i})),s!==Xt)for(let a of mt(t.w,n))a!==n&&Ur(t.w,a,s)}function Nn(t,n,e){if(Array.isArray(t))return[Math.max(1,Math.round(S(t[0],n))),Math.max(1,Math.round(S(t[1],e)))];if(t!=null){let r=Math.max(1,Math.round(S(t,n)));return[r,r]}return[n,e]}function Bn(t,n={}){var s,i,a,c,u,f,l;let e=ht((a=(i=(s=t.fill_color)!=null?s:t.color)!=null?i:n.fill)!=null?a:Gr,Gr),r=t.checkerboard_colors!==void 0?t.checkerboard_colors:"cb"in n?n.cb:[Gr,hc],o=Array.isArray(r)&&r.length?r.map(m=>ht(m,Gr)):null;return{fill:e,fills:o,fo:S(t.fill_opacity,(c=n.fo)!=null?c:1),sc:ht((f=(u=t.stroke_color)!=null?u:n.sc)!=null?f:ni,ni),sw:S(t.stroke_width,(l=n.sw)!=null?l:.5)}}function $o(t,n,e){for(let r of mt(t,n)){let o=t.get(r);o.p3&&t.set({...o,style:{...o.style,fc:e,sc:e}})}}function lr(t,n,e){let r=[];for(let o=0;o+1<n.length;o++)for(let s=0;s+1<n[o].length;s++){let i=n[o][s],a=n[o+1][s],c=n[o+1][s+1],u=n[o][s+1],f=e.fills?e.fills[(o+s)%e.fills.length]:e.fill,l=ur(t,[...i,...a,...c,...u],{sc:e.sc,fc:f,sw:e.sw,so:1,fo:e.fo});t.update(l,{data:{uv:[o,s]}}),r.push(l)}return r}function fr(t,n,e,r,o){let s=[];for(let i=0;i<=r;i++){let a=n[0]+(n[1]-n[0])*i/r,c=[];for(let u=0;u<=o;u++)c.push(t(a,e[0]+(e[1]-e[0])*u/o));s.push(c)}return s}function On(t,n){return Array.isArray(t)?[S(t[0],n[0]),S(t[1],n[1])]:n}function Yr(t){let[n,e,r]=t,o=Math.hypot(n,e,r),s=o>0?Math.acos(r/o):0,i=n===0?e===0?0:Math.PI/2+(e<0?Math.PI:0):Math.atan(e/n);return n<0&&(i+=Math.PI),Vt(Ke([0,0,1],i),Ke([0,1,0],s))}function pc(t,n,e,r){var c,u,f;let o=t.w,[s,i]=Nn(r.resolution,32,32),a;if(Array.isArray(r.grid))a=r.grid.map(l=>l.map(m=>qt(o,m)));else if(r.func!=null){let l=r.func;a=fr((m,p)=>{let b=gn([m,p],()=>Kt(o,l));return Array.isArray(b)?[b[0]||0,b[1]||0,b[2]||0]:[Number(b)||0,0,0]},On(r.u_range,[0,1]),On(r.v_range,[0,1]),s,i)}else throw new Error("Surface needs its points (grid) or a function the preview can trace (func)");if(r.axes!=null){let l=o.get(tt(o,r.axes)),m=(c=l.data)==null?void 0:c.axes,p=(u=l.data)==null?void 0:u.axes3,b=(f=l.m3)!=null?f:Bt(l.m);m&&(a=a.map(g=>g.map(([x,M,F])=>zt(b,m.ox+(x-m.x0)*m.sx,m.oy+(M-m.y0)*m.sy,p?p.oz+(F-p.z0)*p.sz:F))))}Ue(t,n,e,r,lr(o,a,Bn(r)))}function jo(t,n,e,r,o=[24,12],s={}){var l;let i=S(r.radius,1),[a,c]=Nn(r.resolution,o[0],o[1]),u=fr((m,p)=>[i*Math.cos(m)*Math.sin(p),i*Math.sin(m)*Math.sin(p),-i*Math.cos(p)],On(r.u_range,[0,Rt]),On(r.v_range,[0,Math.PI]),a,c),f=(l=r.center)!=null?l:r.point;Ue(t,n,e,r,lr(t.w,u,Bn(r,s)),f!=null?ke(...qt(t.w,f)):Xt)}function dc(t,n,e,r){let o=S(r.major_radius,3),s=S(r.minor_radius,1),[i,a]=Nn(r.resolution,24,24),c=fr((u,f)=>[(o-s*Math.cos(f))*Math.cos(u),(o-s*Math.cos(f))*Math.sin(u),-s*Math.sin(f)],On(r.u_range,[0,Rt]),On(r.v_range,[0,Rt]),i,a);Ue(t,n,e,r,lr(t.w,c,Bn(r)))}function Wo(t,n,e,r,o){let i=[];for(let a=0;a<48;a++)i.push(n*Math.cos(Rt*a/48),n*Math.sin(Rt*a/48),e);return ur(t,i,{sc:r,fc:r,sw:0,so:1,fo:o},!0,!0,"circle")}function si(t,n,e,r,o,s,i){let a=fr((u,f)=>[n*Math.cos(f),n*Math.sin(f),u],[-e/2,e/2],[0,Rt],r,o),c=lr(t,a,s);return i&&c.push(Wo(t,n,-e/2,s.fill,s.fo),Wo(t,n,e/2,s.fill,s.fo)),c}function bc(t,n,e,r){let o=S(r.radius,1),s=S(r.height,2),[i,a]=Nn(r.resolution,24,24),c=si(t.w,o,s,i,a,Bn(r),r.show_ends!==!1),u=r.direction!=null?qt(t.w,r.direction):[0,0,1];Ue(t,n,e,r,c,Yr(u))}function ii(t,n,e,r,o,s,i){let a=Math.PI-Math.atan(n/e),c=fr((f,l)=>[f*Math.sin(a)*Math.cos(l),f*Math.sin(a)*Math.sin(l),f*Math.cos(a)],[0,Math.hypot(n,e)],[0,Rt],r,o),u=lr(t,c,s);return i&&u.push(Wo(t,n,-e,s.fill,s.fo)),u}function gc(t,n,e,r){let o=S(r.base_radius,1),s=S(r.height,1),[i,a]=Nn(r.resolution,32,32),c=ii(t.w,o,s,i,a,Bn(r,{cb:!1}),!!r.show_base),u=r.direction!=null?qt(t.w,r.direction):[0,0,1],f=Math.hypot(...u)||1;Ue(t,n,e,r,c,Yr(u),{data:{start3:[-s*u[0]/f,-s*u[1]/f,-s*u[2]/f],end3:[0,0,0]}})}function ri(t,n,e,r,o){let s=n/2,i=e/2,a=r/2;return[[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1]],[[-1,1,1],[1,1,1],[1,-1,1],[-1,-1,1]],[[-1,1,-1],[-1,1,1],[-1,-1,1],[-1,-1,-1]],[[1,1,1],[1,1,-1],[1,-1,-1],[1,-1,1]],[[-1,1,-1],[1,1,-1],[1,1,1],[-1,1,1]],[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]]].map(u=>ur(t,u.flatMap(f=>[f[0]*s,f[1]*i,f[2]*a]),o))}function yc(t){let n=[],e=new Set,r=t.length,o=[0,0,0];for(let c of t)o[0]+=c[0]/r,o[1]+=c[1]/r,o[2]+=c[2]/r;let s=(c,u)=>[c[0]-u[0],c[1]-u[1],c[2]-u[2]],i=(c,u)=>[c[1]*u[2]-c[2]*u[1],c[2]*u[0]-c[0]*u[2],c[0]*u[1]-c[1]*u[0]],a=(c,u)=>c[0]*u[0]+c[1]*u[1]+c[2]*u[2];for(let c=0;c<r;c++)for(let u=c+1;u<r;u++)for(let f=u+1;f<r;f++){let l=i(s(t[u],t[c]),s(t[f],t[c])),m=Math.hypot(...l);if(m<1e-9)continue;l=[l[0]/m,l[1]/m,l[2]/m];let p=a(l,t[c]),b=0,g=0,x=[];for(let L=0;L<r;L++){let T=a(l,t[L])-p;Math.abs(T)<1e-6?x.push(L):T>0?b++:g++}if(b&&g)continue;let M=x.join(",");if(e.has(M))continue;e.add(M),a(l,s(t[c],o))<0&&(l=[-l[0],-l[1],-l[2]]);let F=[0,0,0];for(let L of x)F[0]+=t[L][0]/x.length,F[1]+=t[L][1]/x.length,F[2]+=t[L][2]/x.length;let N=s(t[x[0]],F),P=Math.hypot(...N),A=[N[0]/P,N[1]/P,N[2]/P],v=i(l,A);x.sort((L,T)=>{let O=s(t[L],F),K=s(t[T],F);return Math.atan2(a(O,v),a(O,A))-Math.atan2(a(K,v),a(K,A))}),n.push(x)}return n}function Vr(t,n){if(t==="tetrahedron"){let s=n*Math.SQRT2/4;return{V:[[s,s,s],[s,-s,-s],[-s,s,-s],[-s,-s,s]],F:[[0,1,2],[3,0,2],[0,1,3],[3,1,2]]}}if(t==="octahedron"){let s=n*Math.SQRT2/2;return{V:[[s,0,0],[-s,0,0],[0,s,0],[0,-s,0],[0,0,s],[0,0,-s]],F:[[2,4,1],[0,4,2],[4,3,0],[1,3,4],[3,5,0],[1,5,3],[2,5,1],[0,5,2]]}}if(t==="icosahedron"){let s=n*(1+Math.sqrt(5))/4,i=n/2;return{V:[[0,i,s],[0,-i,s],[0,i,-s],[0,-i,-s],[i,s,0],[i,-s,0],[-i,s,0],[-i,-s,0],[s,0,i],[s,0,-i],[-s,0,i],[-s,0,-i]],F:[[1,8,0],[1,5,7],[8,5,1],[7,3,5],[5,9,3],[8,9,5],[3,2,9],[9,4,2],[8,4,9],[0,4,8],[6,4,0],[6,2,4],[11,2,6],[3,11,2],[0,6,10],[10,1,0],[10,7,1],[11,7,3],[10,11,7],[10,11,6]]}}let e=n*(1+Math.sqrt(5))/4,r=n*(3+Math.sqrt(5))/4,o=n/2;return{V:[[e,e,e],[e,e,-e],[e,-e,e],[e,-e,-e],[-e,e,e],[-e,e,-e],[-e,-e,e],[-e,-e,-e],[0,o,r],[0,o,-r],[0,-o,-r],[0,-o,r],[o,r,0],[-o,r,0],[o,-r,0],[-o,-r,0],[r,0,o],[-r,0,o],[r,0,-o],[-r,0,-o]],F:[[18,16,0,12,1],[3,18,16,2,14],[3,10,9,1,18],[1,9,5,13,12],[0,8,4,13,12],[2,16,0,8,11],[4,17,6,11,8],[17,19,5,13,4],[19,7,15,6,17],[6,15,14,2,11],[19,5,9,10,7],[7,10,3,14,15]]}}function cr(t,n,e,r,o,s){let i=t.w,a={...r.faces_config||{}},c=ut({fill_opacity:.5,...a},{color:Do}),u=s.map(A=>ur(i,A.flatMap(v=>o[v]),c,!0,a.shade_in_3d!==!1,"polygon")),f=i.newId();i.set(ct(f,"vgroup",c,[],{children:u,m3:Xt}));let l=r.graph_config||{},m=l.vertex_config||{},p=o.map(A=>{var L,T,O;let v=i.newId();return jo(t,v,"dot3d",{radius:S(m.radius,.08),resolution:(L=m.resolution)!=null?L:[8,8],center:A}),$o(i,v,ht((O=(T=m.color)!=null?T:m.fill_color)!=null?O:gt,gt)),v}),b=l.edge_config||{},g=ut({stroke_opacity:0,...b}),x=new Set,M=[];for(let A of s)A.forEach((v,L)=>{let T=A[(L+1)%A.length],O=v<T?v+","+T:T+","+v;x.has(O)||(x.add(O),M.push(ur(i,[...o[v],...o[T]],g,!1,!1,"line")))});let F=i.newId(),N=i.newId(),P=i.newId();i.set(ct(F,"vgroup",g,[],{children:p,m3:Xt})),i.set(ct(N,"vgroup",g,[],{children:M,m3:Xt})),i.set(ct(P,"graph",g,[],{children:[F,N],m3:Xt})),Ue(t,n,e,r,[f,P],Xt,{data:{vertices:o}})}function xc(t,n,e,r){var m;let o=Array.isArray(r.x_range)?r.x_range:[-6,6,1],s=Array.isArray(r.y_range)?r.y_range:[-5,5,1],i=(Array.isArray(r.z_range)?r.z_range:[-4,4,1]).map(Number),a=S(r.x_length,t.fh+2.5),c=S(r.y_length,t.fh+2.5),u=S(r.z_length,t.fh-1.5),f=rn(t,n,e,{...r,x_range:o,y_range:s,x_length:a,y_length:c,tips:(m=r.tips)!=null?m:!0}),l=()=>{var G,U,$;let p=t.w,b=p.newId(),g={...r.axis_config||{},...r.z_axis_config||{}},x=(G=i[2])!=null?G:1,M=[i[0],i[1],x],F=M[0]>0?M[0]:M[1]<0?M[1]:0;mr.number_line(t,b,{x_range:M,length:u,include_tip:($=g.include_tip)!=null?$:(U=r.tips)!=null?U:!0,include_numbers:!1,color:g.color,stroke_width:g.stroke_width},"number_line");let N=u/(M[1]-M[0]||1),P=-u/2+(F-M[0])*N,A=p.get(n),v=A.data.axes,L=o[0]>0?o[0]:o[1]<0?o[1]:0,T=s[0]>0?s[0]:s[1]<0?s[1]:0,O=v.ox+(L-v.x0)*v.sx,K=v.oy+(T-v.y0)*v.sy,D=Vt(ke(O,K,0),Vt(Ke([0,1,0],-Math.PI/2),ke(-P,0,0)));for(let q of mt(p,b))Ur(p,q,D);let j=[...A.children,b];p.set({...A,children:j,m3:Xt,data:{...A.data,axes3:{z0:M[0],sz:N,oz:-(F-M[0])*N}}})};if(f&&typeof f.then=="function")return f.then(l);l()}function oi(t,n,e,r,o){var v,L;let s=t.w,i=qt(s,(v=r.start)!=null?v:[-1,0,0]),a=qt(s,(L=r.end)!=null?L:[1,0,0]),c=[a[0]-i[0],a[1]-i[1],a[2]-i[2]],u=Math.hypot(...c)||1e-9,f=[c[0]/u,c[1]/u,c[2]/u],l=S(r.thickness,.02),m=r.resolution==null?[2,24]:Array.isArray(r.resolution)?r.resolution:[2,r.resolution],[p,b]=Nn(m,2,24),g=o?S(r.height,.3):0,x=u-g,M=Bn(r,o?{cb:!1,fill:gt,sc:gt}:{}),F=si(s,l,x,p,b,M,!0),N=[i[0]+f[0]*x/2,i[1]+f[1]*x/2,i[2]+f[2]*x/2],P=Vt(ke(...N),Yr(f));for(let T of F)Ur(s,T,P);let A=[...F];if(o){let T=s.newId(),O=ii(s,S(r.base_radius,.08),g,2,32,M,!1);s.set(ct(T,"cone",ut(r),[],{children:O,m3:Xt}));let K=Vt(ke(...a),Yr(f));for(let D of O)Ur(s,D,K);A.push(T)}Ue(t,n,e,r,A,Xt,{data:{start3:i,end3:a}}),r.color!=null&&$o(s,n,ht(r.color,gt))}function ai(t){return t.some(n=>Math.abs(n[2])>1e-12)?t.flat():null}var Ko={surface:(t,n,e,r)=>pc(t,n,r,e),sphere:(t,n,e,r)=>jo(t,n,r,e),dot3d:(t,n,e,r)=>{var o,s;jo(t,n,r,{...e,center:(o=e.point)!=null?o:e.center,radius:S(e.radius,.08),resolution:(s=e.resolution)!=null?s:[8,8]},[8,8],{cb:!1,fill:gt,sc:gt}),e.color!=null&&$o(t.w,n,ht(e.color,gt))},torus:(t,n,e,r)=>dc(t,n,r,e),cylinder:(t,n,e,r)=>bc(t,n,r,e),cone:(t,n,e,r)=>gc(t,n,r,e),cube:(t,n,e,r)=>{let o=S(e.side_length,2),s={...ut({fill_opacity:.75,...e},{color:Do,sw:0})};Ue(t,n,r,e,ri(t.w,o,o,o,s))},prism:(t,n,e,r)=>{let o=Array.isArray(e.dimensions)?e.dimensions.map(Number):[3,2,1],s={...ut({fill_opacity:.75,...e},{color:Do,sw:0})};Ue(t,n,r,e,ri(t.w,o[0],o[1],o[2],s))},line3d:(t,n,e,r)=>oi(t,n,r,e,!1),arrow3d:(t,n,e,r)=>oi(t,n,r,e,!0),tetrahedron:(t,n,e,r)=>{let{V:o,F:s}=Vr("tetrahedron",S(e.edge_length,1));cr(t,n,r,e,o,s)},octahedron:(t,n,e,r)=>{let{V:o,F:s}=Vr("octahedron",S(e.edge_length,1));cr(t,n,r,e,o,s)},icosahedron:(t,n,e,r)=>{let{V:o,F:s}=Vr("icosahedron",S(e.edge_length,1));cr(t,n,r,e,o,s)},dodecahedron:(t,n,e,r)=>{let{V:o,F:s}=Vr("dodecahedron",S(e.edge_length,1));cr(t,n,r,e,o,s)},polyhedron:(t,n,e,r)=>{var i;let o=((i=e.vertex_coords)!=null?i:[]).map(a=>qt(t.w,a)),s=Array.isArray(e.faces_list)?e.faces_list.map(a=>a.map(Number)):yc(o);cr(t,n,r,e,o,s)},three_d_axes:(t,n,e,r)=>xc(t,n,r,e)};function Wn(t){return t/48*.65}var ci=$t.RED,Hr=$t.BLUE,Go=$t.BLUE_D,_c="#000000";function ut(t,n={}){var i,a,c,u;let e=t.color!=null?ht(t.color,gt):null,r=t.stroke_color!=null?ht(t.stroke_color,gt):(i=e!=null?e:n.color)!=null?i:gt,o=t.fill_color!=null?ht(t.fill_color,gt):(a=e!=null?e:n.color)!=null?a:gt,s=t.opacity!=null?S(t.opacity,1):1;return{sc:r,fc:o,sw:S(t.stroke_width,(c=n.sw)!=null?c:4),so:S(t.stroke_opacity,1)*s,fo:S(t.fill_opacity,(u=n.fo)!=null?u:0)*s}}function Ee(t,n,e){return n==null?e:Et(t.w,n)}function ui(t,n,e){let r=null,o=-1/0;for(let s of mt(t.w,n)){let i=t.w.get(s);for(let a of ne(i.paths,i.m)){let c=a.points;for(let u=0;u+3<c.length;u+=3)for(let f=0;f<=8;f++){let l=f/8,m=1-l,p=m*m*m*c[u][0]+3*m*m*l*c[u+1][0]+3*m*l*l*c[u+2][0]+l*l*l*c[u+3][0],b=m*m*m*c[u][1]+3*m*m*l*c[u+1][1]+3*m*l*l*c[u+2][1]+l*l*l*c[u+3][1],g=p*e[0]+b*e[1];g>o&&(o=g,r=[p,b])}}}return r||Pt(at(t.w,n))}function yn(t,n,e){let r=(a,c)=>a==null?c:Qt(a)?Pt(at(t.w,tt(t.w,a))):Et(t.w,a),o=r(n,[-1,0]),s=r(e,[1,0]),i=[s[0]-o[0],s[1]-o[1]];return Qt(n)&&(o=ui(t,tt(t.w,n),i)),Qt(e)&&(s=ui(t,tt(t.w,e),[-i[0],-i[1]])),[o,s]}function pt(t,n,e,r,o,s,i){let a=ct(n,e,o,s,{z:S(r.z_index,0),...i});return t.w.set(a),a}function Vo(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1]);if(r<=2*e||e<=0)return[t,n];let o=(n[0]-t[0])/r,s=(n[1]-t[1])/r;return[[t[0]+o*e,t[1]+s*e],[n[0]-o*e,n[1]-s*e]]}function Dn(t,n,e,r,o){let s=t[0]-n*r,i=t[1]-e*r,a=-e*o/2,c=n*o/2;return[_t([t,[s+a,i+c],[s-a,i-c]],!0)]}function hr(t,n,e,r,o,s,i,a){let[c,u]=Vo(o,s,i),f=Math.hypot(u[0]-c[0],u[1]-c[1])||1e-9,l=(u[0]-c[0])/f,m=(u[1]-c[1])/f,p=Math.min(S(r.tip_length,.35),S(r.max_tip_length_to_length_ratio,.25)*f),b=a?Math.max(0,f-2*p):f,g=Math.min(S(r.stroke_width,6),S(r.max_stroke_width_to_length_ratio,5)*b),x=ut({...r,stroke_width:g},{sw:6}),M=a?[c[0]+l*p,c[1]+m*p]:c,F=[u[0]-l*p,u[1]-m*p],N={...x,fc:x.sc,fo:1,sw:0},P=[],A=t.w.newId();if(t.w.set(ct(A,"tip",N,Dn(u,l,m,p,p))),P.push(A),a){let v=t.w.newId();t.w.set(ct(v,"tip",N,Dn(c,-l,-m,p,p))),P.push(v)}pt(t,n,e,r,x,[Lt(M,F)],{children:P,data:{start:c,end:u}})}function Zr(t,n,e=!1){let o=(n>0?t.toFixed(n):String(Math.round(t))).replace(/^-/,"\u2212");return e&&t>=0?"+"+o:o}function ze(t,n,e,r,o){let s=nn(r.weight,r.slant,r.font);if(t.text.font(s)===void 0)return t.text.load(s).then(()=>ze(t,n,e,r,o));let i=Wn(S(r.font_size,48)),a=ut(r,{sw:0,fo:1}),c=S(r.line_spacing,1.2),u=t.text.outline(o,i,s,c>0?c:1.2,S(r.letter_spacing,0)*i);if(!u){let p=o.split(`
5
+ `),b=Math.max(...p.map(F=>F.length))*i*.55,g=p.length*i*.75,[x,M]=s.replace(/^[a-z]+:/,"").split("|");pt(t,n,e,r,a,[],{text:{str:o,em:i,weight:s.startsWith("url:")?"normal":x,slant:s.startsWith("url:")?"normal":M,w:b,h:g,family:s},data:{text:o}});return}let f=u.glyphs.map(()=>null),l=r.t2c||r.text_to_color_map;if(l&&typeof l=="object"){let p=Array.from(o).filter(b=>b.trim()).join("");for(let b of Object.keys(l)){let g=Array.from(b).filter(M=>M.trim()).join("");if(!g)continue;let x=p.indexOf(g);for(;x>=0;){for(let M=x;M<x+Array.from(g).length&&M<f.length;M++)f[M]=ht(l[b],gt);x=p.indexOf(g,x+1)}}}let m=u.glyphs.map((p,b)=>{let g=t.w.newId(),x=f[b];return t.w.set(ct(g,"glyph",x?{...a,sc:x,fc:x}:a,p.paths,{data:{char:p.char}})),g});pt(t,n,e,r,a,[],{children:m,data:{text:o}})}function dr(t,n,e,r,o){var p,b;let s=(b=(p=r.parts)!=null?p:r.tex_strings)!=null?b:r.tex!=null?[r.tex]:[];Array.isArray(s)||(s=[String(s)]),s=s.map(String);let i=S(r.font_size,48),a=r.arg_separator!=null?String(r.arg_separator):o==="math"?" ":"",c=r.tex_environment!=null?String(r.tex_environment):r.environment!=null?String(r.environment):void 0,u=`${o}|${i}|${a}|${c!=null?c:""}|${s.join("")}`,f=g=>{let x=ut(r,{sw:0,fo:1}),M=g.parts.map((F,N)=>{var v;let P=t.w.newId(),A=F.map(L=>{let T=t.w.newId();return t.w.set(ct(T,"glyph",x,L)),T});return t.w.set(ct(P,"tex_part",x,[],{children:A,data:{tex:(v=s[N])!=null?v:""}})),P});pt(t,n,e,r,x,[],{children:M,data:{tex:s.join(a),parts:s}})},l=t.texCache.get(u);if(l&&!(l instanceof Promise))return f(l);if(!t.tex)throw new Error("MathTex is not available in this preview");let m=l||t.tex({tex:s.join(a),mode:o,parts:s,fontSize:i,...c?{environment:c}:{}});return t.texCache.set(u,m),m.then(g=>{t.texCache.set(u,g),f(g)},g=>{throw t.texCache.delete(u),g})}function Uo(t,n){return Array.isArray(t)?[S(t[0],n[0]),S(t[1],n[1]),S(t[2],1)]:n}function li(t){let n=[],[e,r,o]=t;if(o<=0)return n;let s=Math.floor((r-e)/o+1e-9);for(let i=0;i<=s&&i<1e3;i++)n.push(+(e+i*o).toFixed(10));return n}function Xr(t,n,e,r,o){let s=[];if(r<=0)return s;let i=1e-9,a=Math.ceil((t-e)/r-i),c=Math.floor((n-e)/r+i);for(let u=a;u<=c&&s.length<2e3;u++){let f=+(e+u*r).toFixed(10);!o&&(Math.abs(f-t)<i||Math.abs(f-n)<i)||s.push(f)}return s}function wc(t){let n=String(+t.toFixed(6)),e=n.indexOf(".");return e<0?0:Math.min(3,n.length-e-1)}function Yo(t,n){var r,o,s,i,a,c,u,f,l,m,p,b,g,x,M,F;let e=S((r=t.tip_height)!=null?r:t.tip_length,.35);return{color:ht((i=(s=(o=t.color)!=null?o:t.stroke_color)!=null?s:n.color)!=null?i:gt,gt),sw:S(t.stroke_width,(a=n.sw)!=null?a:2),tip:(u=(c=t.include_tip)!=null?c:n.tip)!=null?u:!1,tipLen:e,tipWidth:S(t.tip_width,e),ticks:(l=(f=t.include_ticks)!=null?f:n.ticks)!=null?l:!0,tickSize:S(t.tick_size,.1),numbers:(p=(m=t.include_numbers)!=null?m:n.numbers)!=null?p:!1,fontSize:S(t.font_size,(b=n.fontSize)!=null?b:36),exclude:((x=(g=t.numbers_to_exclude)!=null?g:n.exclude)!=null?x:[]).map(Number),numberBuff:S(t.line_to_number_buff,(M=n.numberBuff)!=null?M:.25),labelDir:Array.isArray(t.label_direction)?[Number(t.label_direction[0]),Number(t.label_direction[1])]:(F=n.labelDir)!=null?F:[0,-1]}}function Ho(t,n,e,r,o,s,i=[]){let a=o(e[0]),c=o(e[1]),u={sc:r.color,fc:r.color,sw:r.sw,so:1,fo:0},f=[],l=-s[1],m=s[0],p=g=>i.some(x=>Math.abs(x-g)<1e-9);if(r.ticks){let g=li(e).filter(M=>!p(M)).map(M=>{let F=o(M),N=t.w.newId();return t.w.set(ct(N,"tick",u,[Lt([F[0]-l*r.tickSize,F[1]-m*r.tickSize],[F[0]+l*r.tickSize,F[1]+m*r.tickSize])])),N}),x=t.w.newId();t.w.set(ct(x,"group",u,[],{children:g})),f.push(x)}let b=c;if(r.tip){let g=t.w.newId();t.w.set(ct(g,"tip",{...u,fo:1,sw:0},Dn(c,s[0],s[1],r.tipLen,r.tipWidth))),f.push(g),b=[c[0]-s[0]*r.tipLen,c[1]-s[1]*r.tipLen]}if(r.numbers){let g=wc(e[2]),x=li(e).filter(N=>!r.exclude.some(P=>Math.abs(P-N)<1e-9)&&!(r.tip&&Math.abs(N-e[1])<1e-9)),M=t.w.newId(),F=x.map(N=>{let P=t.w.newId();ze(t,P,"text",{font_size:r.fontSize,color:r.color},Zr(N,g));let A=o(N),v=at(t.w,P),L=r.labelDir,T=(v[2]-v[0])/2,O=(v[3]-v[1])/2,K=A[0]+L[0]*(r.numberBuff+T),D=A[1]+L[1]*(r.numberBuff+O);return xn(t.w,P,bt(K-(v[0]+v[2])/2,D-(v[1]+v[3])/2)),P});t.w.set(ct(M,"group",u,[],{children:F})),f.push(M)}t.w.set(ct(n,"number_line",u,[Lt(a,b)],{children:f,data:{start:a,end:c}}))}function xn(t,n,e){for(let r of mt(t,n)){let o=t.get(r);t.set({...o,m:lt(e,o.m)})}}function fi(t){return t[0]>0?t[0]:t[1]<0?t[1]:0}function Mc(...t){return t.some(n=>n&&n.include_numbers)}function rn(t,n,e,r){var K,D,j,G,U;let o=e==="number_plane",s=r.axis_config||{},i={...s,...r.x_axis_config||{}},a={...s,...r.y_axis_config||{}};if(r.include_numbers!=null&&((K=i.include_numbers)!=null||(i.include_numbers=r.include_numbers),(D=a.include_numbers)!=null||(a.include_numbers=r.include_numbers)),Mc(i,a)){let $=nn("normal","normal");if(t.text.font($)===void 0)return t.text.load($).then(()=>rn(t,n,e,r))}let c=t.fw,u=t.fh,f=Uo(r.x_range,o?[-c/2,c/2,1]:[-Math.round(c/2),Math.round(c/2),1]),l=Uo(r.y_range,[-u/2,u/2,1]),m=S(r.x_length,o?f[1]-f[0]:Math.round(c)-2),p=S(r.y_length,o?l[1]-l[0]:Math.round(u)-2),b={x0:f[0],y0:l[0],sx:m/(f[1]-f[0]||1),sy:p/(l[1]-l[0]||1),ox:-m/2,oy:-p/2},g=($,q)=>be(b,$,q),x=r.color!=null?ht(r.color,gt):void 0,M=(j=r.tips)!=null?j:!o,F=o?{color:x!=null?x:gt,sw:2,tip:!1,ticks:!1,numberBuff:.1,fontSize:24,labelDir:[1,-1]}:{color:x!=null?x:gt,sw:2,tip:M,exclude:[0]},N=Yo(i,{...F}),P=Yo(a,{...F,labelDir:o?[1,-1]:[-1,0]}),A=fi(l),v=fi(f),L=[];if(o){let $=r.background_line_style||{},q={sc:ht((U=(G=$.stroke_color)!=null?G:$.color)!=null?U:Go,Go),fc:Go,sw:S($.stroke_width,2),so:S($.stroke_opacity,1),fo:0},H=(yt,Ct)=>[...yt.map(Ft=>Lt(g(Ft,l[0]),g(Ft,l[1]))),...Ct.map(Ft=>Lt(g(f[0],Ft),g(f[1],Ft)))],et=t.w.newId(),st=t.w.newId(),Q=Xr(f[0],f[1],v,f[2],!1),ot=Xr(l[0],l[1],A,l[2],!1);t.w.set(ct(et,"background_lines",q,H(Q,ot)));let nt=Math.round(S(r.faded_line_ratio,1)),it=[];if(nt>1){let yt=(Ct,Ft)=>Ct.filter(Ht=>!Ft.some(wt=>Math.abs(wt-Ht)<1e-9));it=H(yt(Xr(f[0],f[1],v,f[2]/nt,!0),Q),yt(Xr(l[0],l[1],A,l[2]/nt,!0),ot))}t.w.set(ct(st,"faded_lines",{...q,sw:q.sw/2,so:q.so*.5},it)),L.push(et,st)}let T=t.w.newId(),O=t.w.newId();Ho(t,T,f,N,$=>g($,A),[1,0],o?[]:[v,...N.tip?[f[1]]:[]]),Ho(t,O,l,P,$=>g(v,$),[0,1],o?[]:[A,...P.tip?[l[1]]:[]]),t.w.update(T,{data:{...t.w.get(T).data,axes:{...b,sy:0,oy:g(0,A)[1],y0:0}}}),t.w.update(O,{data:{...t.w.get(O).data,axes:{x0:l[0],y0:0,sx:0,sy:b.sy,ox:g(v,0)[0],oy:b.oy}}}),L.push(T,O),pt(t,n,e,r,{sc:gt,fc:gt,sw:2,so:1,fo:0},[],{children:L,data:{axes:b,props:r}})}function bi(t,n,e){if(e.include_numbers){let a=nn("normal","normal");if(t.text.font(a)===void 0)return t.text.load(a).then(()=>bi(t,n,e))}let r=Uo(e.x_range,[-7,7,1]),o=S(e.length,S(e.unit_size,1)*(r[1]-r[0])),s={x0:r[0],y0:0,sx:o/(r[1]-r[0]||1),sy:0,ox:-o/2,oy:0},i=Yo(e,{color:e.color!=null?ht(e.color,gt):gt,sw:2,tip:!1});Ho(t,n,r,i,a=>be(s,a,0),[1,0]),t.w.update(n,{z:S(e.z_index,0),data:{...t.w.get(n).data,axes:s}})}function kc(t,n,e){var m;let r=null,o;if(e.axes!=null){let p=t.w.get(tt(t.w,e.axes));if(r=(m=p.data)==null?void 0:m.axes,!r)throw new Error("plot needs Axes, a NumberPlane or a NumberLine");o=p.m}let s=[],i=[],a=p=>{let b=[],g=[];for(let x of p){if(!(Array.isArray(x)&&Number.isFinite(Number(x[0]))&&Number.isFinite(Number(x[1])))){b.length&&(s.push(b),i.push(g)),b=[],g=[];continue}let F=Number(x[0]),N=Number(x[1]);b.push(r?be(r,F,N):[F,N]),g.push([F,N])}b.length&&(s.push(b),i.push(g))};if(Array.isArray(e.segments))for(let p of e.segments)a(p);else a(e.points||[]);let c=Array.isArray(e.segments)?e.segments:[e.points||[]];if(r&&c.some(p=>(p||[]).some(b=>Array.isArray(b)&&Math.abs(Number(b[2])||0)>1e-12))){let p=tt(t.w,e.axes),b=c.map(g=>(g||[]).filter(x=>Array.isArray(x)).map(x=>Jr(t.w,p,Number(x[0]),Number(x[1]),Number(x[2])||0)));ki(t,n,"graph",e,b.map(g=>e.use_smoothing===!1?g:Mi(g,!1)),!!e.closed,{color:tn});return}let u=e.use_smoothing!==!1&&e.smooth!==!1,f=!!e.closed,l=s.filter(p=>p.length>=2).map(p=>u?sr(p,f):_t(p,f));Array.isArray(e.color)&&typeof e.color[0]=="string"&&(e={...e,color:e.color[0]}),pt(t,n,"graph",e,ut(e,{color:tn}),l,{...o?{m:o}:{},data:{...r?{axes:r}:{},samples:i}})}var qr=null;function gi(t){qr=t}var zn=new Map;function Ce(t){let n=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of t)for(let i of s.points)i[0]<n&&(n=i[0]),i[0]>r&&(r=i[0]),i[1]<e&&(e=i[1]),i[1]>o&&(o=i[1]);return[n,e,r,o]}function Qr(t,n,e){return t.map(r=>({closed:r.closed,points:r.points.map(o=>[o[0]-n,o[1]-e])}))}async function Sc(t,n){let e=g=>t({tex:g,mode:"math",parts:[g],fontSize:n}).then(x=>x.parts.flat()),[r,o,s,i,a]=await Promise.all([e("0123456789"),e("0.0"),e("-0"),e("+0"),e("0{,}0")]),c=new Map;if(r.length!==10)throw new Error("unexpected digit layout");let u=r.map(Ce),f=g=>(g[0]+g[2])/2,l=(f(u[9])-f(u[0]))/9,m=u[0][1];r.forEach((g,x)=>{let M=f(u[x])-l/2,F=Qr(g,M,m);c.set(String(x),{paths:F,advance:l,box:Ce(F)})});let p=(g,x)=>{if(g.length!==3)return;let M=Ce(g[0]),F=Ce(g[2]),N=f(M)+l/2,P=f(F)-l/2,A=Qr(g[1],N,M[1]);c.set(x,{paths:A,advance:P-N,box:Ce(A)})};p(o,"."),p(a,",");let b=(g,x)=>{if(g.length!==2)return;let M=Ce(g[0]),F=Ce(g[1]),N=M[0],P=f(F)-l/2,A=Qr(g[0],N,F[1]);c.set(x,{paths:A,advance:P-N,box:Ce(A)})};return b(s,"-"),b(s,"\u2212"),b(i,"+"),c}function Pc(t,n){let e=zn.get(n);if(e)return e;if(!t||!t.tex)return null;let r=Sc(t.tex,n).then(o=>(zn.set(n,o),o),()=>(zn.delete(n),null));return zn.set(n,r),r}function Qo(t,n){let e=Zr(n,t.places,t.sign);if(t.commas){let[o,s]=e.split(".");e=o.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(s!=null?"."+s:"")}let r=Array.from(e);return t.ellipsis&&r.push("\\ldots"),t.unit&&r.push(t.unit),r}function Zo(t,n){return Qo(t,n).map(e=>e==="\\ldots"?"\u2026":e).join("")}function Xo(t,n){if(t.src==="tex"){let o=zn.get(t.fontSize);if(o&&!(o instanceof Promise)){let s=o.get(n)||(n==="\u2212"?o.get("-"):null);if(s)return s}}if(!qr)return null;if(n.length===1||Array.from(n).length===1)return qr.glyph(n,t.em,t.key);let e=[],r=0;for(let o of Array.from(n==="\\ldots"?"\u2026":n.replace(/\\text\{([^}]*)\}/g,"$1"))){let s=qr.glyph(o,t.em,t.key);if(!s)return null;e.push(...s.paths.map(i=>({closed:i.closed,points:i.points.map(a=>[a[0]+r,a[1]])}))),r+=s.advance}return{paths:e,advance:r,box:e.length?Ce(e):null}}var yi=t=>.048*(t.fontSize/48);function xi(t,n,e,r,o){let s=Qo(e,e.value),i=s.map(f=>Xo(e,f));if(i.some(f=>!f)){let f=Zo(e,e.value),l=f.length*e.em*.55;return{children:[],text:{str:f,em:e.em,weight:e.key.split("|")[0],slant:e.key.split("|")[1],w:l,h:e.em*.75}}}let a=e.left,c=yi(e),u=[];return s.forEach((f,l)=>{let m=i[l];if(!m.paths.length||!m.box){a+=m.advance;return}let p=a-m.box[0],b=t.newId();t.set(ct(b,"glyph",r,m.paths,{m:lt(o,bt(p,-e.mid)),data:{char:f}})),u.push(b),a+=m.box[2]-m.box[0]+c}),{children:u}}function Ec(t,n,e){let r=zn.get(n);if(!(!r||r instanceof Promise||r.has(e)||!t.tex))return t.tex({tex:e,mode:"math",parts:[e],fontSize:n}).then(o=>{let s=o.parts.flat().flat();if(!s.length)return;let i=Ce(s),a=Qr(s,i[0],i[1]);r.set(e,{paths:a,advance:i[2]-i[0],box:Ce(a)})},()=>{})}function pr(t,n,e,r){var M;let o=nn(r.weight,r.slant);if(t.text.font(o)===void 0)return t.text.load(o).then(()=>pr(t,n,e,r));let s=S(r.font_size,48),i=Pc(t,s);if(i instanceof Promise)return i.then(()=>pr(t,n,e,r));let a=r.unit!=null&&r.unit!==""?String(r.unit):"";for(let F of[a,r.show_ellipsis?"\\ldots":""]){if(!F)continue;let N=Ec(t,s,F);if(N)return N.then(()=>pr(t,n,e,r))}let c=r.num_decimal_places!=null?S(r.num_decimal_places,2):e==="integer"?0:2,u=Wn(s),f={value:S((M=r.number)!=null?M:r.value,0),places:c,sign:!!r.include_sign,unit:i?a:a.replace(/^\^\\circ$/,"\xB0").replace(/\\circ/g,"\xB0").replace(/\\text\{([^}]*)\}/g,"$1"),em:u,key:o,left:0,mid:0,text:"",src:i?"tex":"text",fontSize:s,commas:r.group_with_commas!==!1,ellipsis:!!r.show_ellipsis},l=Xo(f,"0");f.mid=l&&l.box?(l.box[1]+l.box[3])/2:u*.35;let m=0,p=0;for(let F of Qo(f,f.value)){let N=Xo(f,F);N&&N.box&&(m+=N.box[2]-N.box[0],p++)}m+=Math.max(0,p-1)*yi(f),f.left=-m/2,f.text=Zo(f,f.value);let b=ut(r,{sw:0,fo:1}),{children:g,text:x}=xi(t.w,n,f,b,Mt);pt(t,n,e,r,b,[],{children:g,text:x,data:{...f,number:!0}})}function Ae(t,n,e){let r=t.get(n),o=r.data;if(!o||!o.number){t.update(n,{data:{...r.data||{},value:e}});return}if(o.value===e&&!r.text)return;let s={...o,value:e},i=r.children.length?t.get(r.children[0]).style:r.style,{children:a,text:c}=xi(t,n,s,i,r.m);s.text=Zo(o,e),t.set({...r,children:a,text:c,data:s})}function _i(t){return!!(t.data&&t.data.number)}var qo=null;function wi(t){qo=t}function Mi(t,n){let e=t.length;if(e<3)return t;let r=i=>n?t[(i%e+e)%e]:t[Math.max(0,Math.min(e-1,i))],o=[t[0]],s=n?e:e-1;for(let i=0;i<s;i++){let a=r(i-1),c=r(i),u=r(i+1),f=r(i+2);for(let l=1;l<=6;l++){let m=l/6,p=m*m,b=p*m;o.push([0,1,2].map(g=>.5*(2*c[g]+(-a[g]+u[g])*m+(2*a[g]-5*c[g]+4*u[g]-f[g])*p+(-a[g]+3*c[g]-3*u[g]+f[g])*b)))}}return o}function ki(t,n,e,r,o,s,i={}){let a=ut(r,i),c=o.filter(f=>f.length>=2);if(c.length===1){pt(t,n,e,r,a,[],{p3:c[0].flat(),closed3:s,m3:[1,0,0,0,1,0,0,0,1,0,0,0],data:{start3:c[0][0],end3:c[0][c[0].length-1]}});return}let u=c.map(f=>{let l=t.w.newId();return t.w.set(ct(l,"curve3",a,[],{p3:f.flat(),closed3:s,m3:[1,0,0,0,1,0,0,0,1,0,0,0]})),l});pt(t,n,e,r,a,[],{children:u})}function mi(t,n,e,r,o,s){for(let i=s.length?1:0;i<=o;i++){let a=i/o,c=1-a;s.push([c*c*c*t[0]+3*c*c*a*n[0]+3*c*a*a*e[0]+a*a*a*r[0],c*c*c*t[1]+3*c*c*a*n[1]+3*c*a*a*e[1]+a*a*a*r[1]])}}var Si=.273;function Ac(t){let e=Math.min(.18,t/4),r=t/2,o=[];mi([-r,0],[-r,-.25*.45],[-r+e*.3,-.25/2],[-r+e,-.25/2],16,o),o.push([-e,-.25/2]);let s=[];mi([-e,-.25/2],[-e*.3,-.25/2],[0,-.25*.55],[0,-.25],16,s),o.push(...s.slice(1));let i=[...o,...o.slice(0,-1).reverse().map(x=>[-x[0],x[1]])],a=i.length,c=[],u=[];for(let x=0;x<a;x++){let M=i[Math.max(0,x-1)],F=i[Math.min(a-1,x+1)],N=F[0]-M[0],P=F[1]-M[1],A=Math.hypot(N,P)||1;N/=A,P/=A;let v=x/(a-1),L=.016+.045*Math.sin(Math.PI*((v<=.5?v:1-v)*2));c.push([i[x][0]-P*L/2,i[x][1]+N*L/2]),u.push([i[x][0]+P*L/2,i[x][1]-N*L/2])}let f=[...c,...u.reverse()],l=-1/0,m=1/0,p=0;for(let x of f)l=Math.max(l,x[1]),m=Math.min(m,x[1]),p=Math.max(p,Math.abs(x[0]));let b=Si/(l-m||1),g=r/(p||1);return[_t(f.map(x=>[x[0]*g,(x[1]-l)*b]),!0)]}function jn(t,n,e){let r=Array.isArray(n)?n:[n],o=null;for(let s of r)for(let i of mt(t,tt(t,s))){let a=t.get(i);(a.paths.length||a.text)&&(o=Cn(o,No(a,e?lt(e,a.m):a.m)))}return o||[0,0,0,0]}function vc(t,n,e){var m;let r=t.w,o=e.direction?Et(r,e.direction):[0,-1],s=Math.atan2(o[1],o[0])+Math.PI/2,i=S(e.buff,.2),a=Te(-s,[0,0]),c=(m=e.target)!=null?m:e.mobject,u;if(c!=null)u=jn(r,c,a);else{let p=Nt(a,Ee(t,e.start,[-1,0])),b=Nt(a,Ee(t,e.end,[1,0]));u=[Math.min(p[0],b[0]),Math.min(p[1],b[1]),Math.max(p[0],b[0]),Math.max(p[1],b[1])]}let f=u[2]-u[0],l=lt(Te(s,[0,0]),bt((u[0]+u[2])/2,u[1]-i));pt(t,n,"brace",e,ut(e,{sw:0,fo:1}),Ac(Math.max(f,.1)),{m:l,data:{tip:[0,-Si],start:[-f/2,0],end:[f/2,0]}})}function hi(t,n){if(Array.isArray(t))return[S(t[0],n),S(t[1],n)];let e=S(t,n);return[e,e]}function Be(t,n={},e){return(r,o,s,i)=>{let a=e?e(s,r):null;pt(r,o,i,s,ut(s,n),t(s,r),a?{m:bt(a[0],a[1])}:void 0)}}var pi=(t,n)=>t.arc_center!=null?Ee(n,t.arc_center,[0,0]):null;function di(t,n){var r,o;return((o=(r=n.vertices)!=null?r:n.points)!=null?o:[]).map(s=>Et(t.w,s))}var mr={circle:Be(t=>[Fe([0,0],S(t.radius,1))],{color:ci},pi),dot:Be(t=>[Fe([0,0],S(t.radius,.08))],{sw:0,fo:1},(t,n)=>Ee(n,t.point,[0,0])),point:Be(()=>[],{},(t,n)=>{var e;return Ee(n,(e=t.location)!=null?e:t.point,[0,0])}),square:Be(t=>[_t($e(S(t.side_length,2),S(t.side_length,2)),!0)]),rectangle:Be(t=>[_t($e(S(t.width,4),S(t.height,2)),!0)]),rounded_rectangle:Be(t=>[Fn(S(t.width,4),S(t.height,2),S(t.corner_radius,.5))]),ellipse:Be(t=>[me([0,0],S(t.width,2)/2,S(t.height,1)/2,0,Rt,!0)],{color:ci},pi),arc:(t,n,e,r)=>{let o=Ee(t,e.arc_center,[0,0]);pt(t,n,r,e,ut(e),[me(o,S(e.radius,1),S(e.radius,1),S(e.start_angle,0),S(e.angle,Rt/4),!1,8)])},annulus:(t,n,e,r)=>{let o=Ee(t,e.arc_center,[0,0]),s=S(e.inner_radius,1),i=S(e.outer_radius,2);pt(t,n,r,e,ut(e,{sw:0,fo:1}),[me(o,i,i,0,Rt,!0),me(o,s,s,0,-Rt,!0)])},triangle:Be(t=>[_t(Fo(3,S(t.radius,1),S(t.start_angle,Math.PI/2)),!0)],{color:Hr}),regular_polygon:Be(t=>{let n=Math.max(3,Math.round(S(t.n,6)));return[_t(Fo(n,S(t.radius,1),S(t.start_angle,n%2?Math.PI/2:0)),!0)]},{color:Hr}),star:Be(t=>{let n=Math.max(2,Math.round(S(t.n,5))),e=S(t.outer_radius,1),r=S(t.density,2),o=t.inner_radius!=null?S(t.inner_radius,.4):e*Math.cos(Math.PI*r/n)/Math.cos(Math.PI*(r-1)/n);return[_t(Ws(n,e,o,S(t.start_angle,Math.PI/2)),!0)]},{color:Hr}),polygon:(t,n,e,r)=>{pt(t,n,r,e,ut(e,{color:Hr}),[_t(di(t,e),!0)])},polyline:(t,n,e,r)=>{pt(t,n,r,e,ut(e),[_t(di(t,e),!1)])},vmobject:(t,n,e,r)=>{var u;let o=Array.isArray(e.subpaths)?e.subpaths:[e.points||[]],s=(u=e.mode)!=null?u:e.smooth?"smooth":"corners",i=!!e.closed,a=o.map(f=>f.map(l=>qt(t.w,l)));if(a.some(f=>ai(f))){let f=a.map(l=>s==="smooth"?Mi(l,i):l);ki(t,n,r,e,f,i);return}let c=o.map(f=>{let l=f.map(m=>Et(t.w,m));return s==="bezier"?{points:l,closed:i}:s==="smooth"?sr(l,i):_t(l,i)}).filter(f=>f.points.length);pt(t,n,r,e,ut(e),c)},line:(t,n,e,r)=>{let[o,s]=Vo(...yn(t,e.start,e.end),S(e.buff,0));pt(t,n,r,e,ut(e),[Lt(o,s)],{data:{start:o,end:s}})},dashed_line:(t,n,e,r)=>{let[o,s]=Vo(...yn(t,e.start,e.end),S(e.buff,0)),i=ut(e),a=Gs([Lt(o,s)],S(e.dash_length,.05),S(e.dashed_ratio,.5)).map(c=>{let u=t.w.newId();return t.w.set(ct(u,"dash",i,[c])),u});pt(t,n,r,e,i,[],{children:a,data:{start:o,end:s}})},arrow:(t,n,e,r)=>hr(t,n,r,e,...yn(t,e.start,e.end),S(e.buff,.25),!1),double_arrow:(t,n,e,r)=>hr(t,n,r,e,...yn(t,e.start,e.end),S(e.buff,.25),!0),vector:(t,n,e,r)=>hr(t,n,r,e,[0,0],Ee(t,e.direction,[1,0]),S(e.buff,0),!1),group:(t,n,e,r)=>{let o=(e.children||[]).map(s=>tt(t.w,s));pt(t,n,r,e,ut(e),[],{children:o})},text:(t,n,e,r)=>{var o;return ze(t,n,r,e,String((o=e.text)!=null?o:""))},decimal_number:(t,n,e,r)=>pr(t,n,r,e),value_tracker:(t,n,e,r)=>{pt(t,n,r,e,ut(e),[],{data:{value:S(e.value,0),...e.camera!=null?{camera:String(e.camera)}:{}}})},variable:(t,n,e,r)=>{var m,p,b;let o=nn("normal","normal");if(t.text.font(o)===void 0)return t.text.load(o).then(()=>mr.variable(t,n,e,r));let s=t.w.newId(),i=t.w.newId(),a=typeof e.var=="number"?e.var:e.var!=null?Number((p=(m=t.w.get(tt(t.w,e.var)).data)==null?void 0:m.value)!=null?p:0):S(e.value,0);ze(t,s,"text",{font_size:e.font_size,color:e.color},`${(b=e.label)!=null?b:"x"} =`),pr(t,i,"decimal_number",{number:a,num_decimal_places:e.num_decimal_places,font_size:e.font_size,color:e.color}),pt(t,n,r,e,ut(e),[],{children:[s,i]});let c=t.w.get(n).children,u=at(t.w,c[0]),f=at(t.w,c[1]);xn(t.w,c[1],bt(u[2]+.2-f[0],(u[1]+u[3])/2-(f[1]+f[3])/2));let l=Pt(at(t.w,n));xn(t.w,n,bt(-l[0],-l[1]))},traced_path:(t,n,e,r)=>{var o;pt(t,n,r,e,ut(e,{sw:S(e.stroke_width,2)}),[],{data:{trace:{point:(o=e.point)!=null?o:e.traced_point,dissipating:e.dissipating_time!=null?S(e.dissipating_time,0):null}}})},pyctures_canvas:(t,n,e,r)=>{var f,l;let o=S(e.width,4),s=S(e.height,3),i=Math.max(1,Math.round(S((f=e.px_width)!=null?f:e.pixel_width,o*100))),a=Math.max(1,Math.round(S((l=e.px_height)!=null?l:e.pixel_height,s*100))),c=e.canvas&&typeof e.canvas=="object"?e.canvas:qo?qo(i,a):null,u=e.point!=null?Ee(t,e.point,[0,0]):null;pt(t,n,r,e,ut({fill_opacity:1,...e},{sw:0}),[],{image:{src:c,w:o,h:s,fullW:o,fullH:s,live:!0},...u?{m:bt(u[0],u[1])}:{},data:{pxW:i,pxH:a}})},mathtex:(t,n,e,r)=>dr(t,n,r,e,"math"),tex:(t,n,e,r)=>dr(t,n,r,e,"text"),axes:(t,n,e,r)=>rn(t,n,r,e),number_plane:(t,n,e,r)=>rn(t,n,r,e),number_line:(t,n,e)=>bi(t,n,e),graph:(t,n,e)=>kc(t,n,e),brace:(t,n,e)=>vc(t,n,e),surrounding_rectangle:(t,n,e,r)=>{var u;let o=jn(t.w,(u=e.target)!=null?u:e.mobject),[s,i]=hi(e.buff,.1),a=o[2]-o[0]+2*s,c=o[3]-o[1]+2*i;pt(t,n,r,e,ut(e,{color:ar}),[Fn(a,c,S(e.corner_radius,0))],{m:bt((o[0]+o[2])/2,(o[1]+o[3])/2)})},background_rectangle:(t,n,e,r)=>{var u;let o=jn(t.w,(u=e.target)!=null?u:e.mobject),[s,i]=hi(e.buff,0),a=o[2]-o[0]+2*s,c=o[3]-o[1]+2*i;pt(t,n,r,e,ut({fill_opacity:.75,stroke_opacity:0,...e},{color:_c,sw:0}),[_t($e(a,c),!0)],{m:bt((o[0]+o[2])/2,(o[1]+o[3])/2)})}},Ic={vgroup:"group",v_group:"group",mobject:"group",v_mobject:"vmobject",math_tex:"mathtex",integer:"decimal_number",regular_polygram:"regular_polygon",surrounding_rect:"surrounding_rectangle",round_rectangle:"rounded_rectangle",plot:"graph",parametric_function:"graph"};function Rc(t){let n=String(t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase();return Ic[n]||n}var Pi=()=>[...Object.keys(mr),...Object.keys(Jo),...Object.keys(Ko)];function br(t,n,e,r){let o=Rc(e),s=mr[o]||Jo[o]||Ko[o];if(!s)throw new Error(`the animation layer cannot make "${e}" yet`);return s(t,n,de(r,[]),String(e).toLowerCase()==="integer"?"integer":o)}var ve=(t,n,e)=>[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e],Ye=class{constructor(){this.subpaths=[];this.cur=null;this.start=[0,0]}get current(){return this.cur?this.cur[this.cur.length-1]:this.start}moveTo(n){this.flush(!1),this.cur=[n],this.start=n}lineTo(n){let e=this.ensure();this.cur.push(ve(e,n,1/3),ve(e,n,2/3),n)}quadTo(n,e){let r=this.ensure();this.cur.push(ve(r,n,2/3),ve(e,n,2/3),e)}cubicTo(n,e,r){this.ensure(),this.cur.push(n,e,r)}close(){if(!this.cur)return;let n=this.cur[this.cur.length-1];(n[0]!==this.start[0]||n[1]!==this.start[1])&&this.lineTo(this.start),this.flush(!0)}finish(){return this.flush(!1),this.subpaths}ensure(){return this.cur||(this.cur=[this.start]),this.cur[this.cur.length-1]}flush(n){this.cur&&this.cur.length>1&&this.subpaths.push({points:this.cur,closed:n}),this.cur=null}};function Ai(t,n,e,r,o,s,i){if(t[0]===i[0]&&t[1]===i[1])return[];if(n=Math.abs(n),e=Math.abs(e),n===0||e===0)return[ve(t,i,1/3),ve(t,i,2/3),i];let a=r*Math.PI/180,c=Math.cos(a),u=Math.sin(a),f=(t[0]-i[0])/2,l=(t[1]-i[1])/2,m=c*f+u*l,p=-u*f+c*l,b=m*m/(n*n)+p*p/(e*e);if(b>1){let $=Math.sqrt(b);n*=$,e*=$}let g=n*n*e*e-n*n*p*p-e*e*m*m,x=n*n*p*p+e*e*m*m,M=Math.sqrt(Math.max(0,g/x));o===s&&(M=-M);let F=M*n*p/e,N=-M*e*m/n,P=c*F-u*N+(t[0]+i[0])/2,A=u*F+c*N+(t[1]+i[1])/2,v=($,q,H,et)=>Math.atan2($*et-q*H,$*H+q*et),L=v(1,0,(m-F)/n,(p-N)/e),T=v((m-F)/n,(p-N)/e,(-m-F)/n,(-p-N)/e);!s&&T>0&&(T-=2*Math.PI),s&&T<0&&(T+=2*Math.PI);let O=Math.max(1,Math.ceil(Math.abs(T)/(Math.PI/2)-1e-9)),K=T/O,D=4/3*Math.tan(K/4),j=($,q)=>[c*n*$-u*e*q+P,u*n*$+c*e*q+A],G=[],U=L;for(let $=0;$<O;$++){let q=Math.cos(U),H=Math.sin(U),et=U+K,st=Math.cos(et),Q=Math.sin(et);G.push(j(q-D*H,H+D*q),j(st+D*Q,Q-D*st)),G.push($===O-1?i:j(st,Q)),U=et}return G}function Tc(t,n){return[t[0]*n[0]+t[2]*n[1]+t[4],t[1]*n[0]+t[3]*n[1]+t[5]]}function vi(t,n){return t.map(e=>({closed:e.closed,points:e.points.map(r=>Tc(n,r))}))}function Ii(t,n,e,r){let[o,s,i,a]=t,c=i?n/i:1,u=a?e/a:1,f=(r||"xMidYMid meet").trim().split(/\s+/),l=f[0]||"xMidYMid";l!=="none"&&(c=u=f[1]==="slice"?Math.max(c,u):Math.min(c,u));let m=-o*c,p=-s*u;if(l!=="none"){let b=l.includes("xMid")?.5:l.includes("xMax")?1:0,g=l.includes("YMid")?.5:l.includes("YMax")?1:0;m+=(n-i*c)*b,p+=(e-a*u)*g}return[c,0,0,u,m,p]}function Ei(t,n,e,r,o){let s=ve(t,n,o),i=ve(n,e,o),a=ve(e,r,o),c=ve(s,i,o),u=ve(i,a,o),f=ve(c,u,o);return[[t,s,c,f],[f,u,a,r]]}function to(t,n,e,r,o){let s=1-o,i=s*s*s,a=3*s*s*o,c=3*s*o*o,u=o*o*o;return[i*t[0]+a*n[0]+c*e[0]+u*r[0],i*t[1]+a*n[1]+c*e[1]+u*r[1]]}function Fc(t,n,e){let r=t;return e<1&&(r=Ei(r[0],r[1],r[2],r[3],e)[0]),n>0&&(r=Ei(r[0],r[1],r[2],r[3],n/e)[1]),r}function Cc(t,n){var m;let e=t.points,r=(e.length-1)/3;if(r<1)return null;let o=!0,s=!0;for(let p of e)n(p)>=0?s=!1:o=!1;if(o)return t;if(s)return null;let i=[];for(let p=0;p<r;p++){let b=e.slice(p*3,p*3+4),g=[0],x=24,M=0,F=n(b[0]);for(let N=1;N<=x;N++){let P=N/x,A=n(to(b[0],b[1],b[2],b[3],P));if(F<0!=A<0){let v=M,L=P,T=F;for(let O=0;O<40;O++){let K=(v+L)/2,D=n(to(b[0],b[1],b[2],b[3],K));D<0==T<0?(v=K,T=D):L=K}g.push((v+L)/2)}M=P,F=A}g.push(1);for(let N=0;N<g.length-1;N++){let P=g[N],A=g[N+1];if(A-P<1e-9)continue;let v=Fc(b,P,A),L=to(b[0],b[1],b[2],b[3],(P+A)/2);i.push({seg:v,inside:n(L)>=0})}}let a=i.findIndex((p,b)=>p.inside&&!i[(b-1+i.length)%i.length].inside);a<0&&(a=0);let c=i.slice(a).concat(i.slice(0,a)),u=new Ye,f=!1,l=!1;for(let p of c){if(!p.inside){l=!0;continue}f?l&&u.lineTo(p.seg[0]):(u.moveTo(p.seg[0]),f=!0),l=!1,u.cubicTo(p.seg[1],p.seg[2],p.seg[3])}return f?(u.close(),(m=u.finish()[0])!=null?m:null):null}function Ri(t,n){let e=[o=>o[0]-n.x0,o=>n.x1-o[0],o=>o[1]-n.y0,o=>n.y1-o[1]],r=[];for(let o of t){let s=o;for(let i of e){if(!s)break;s=Cc(s,i)}s&&r.push(s)}return r}function eo(t){let n=1/0,e=1/0,r=-1/0,o=-1/0,s=i=>{i[0]<n&&(n=i[0]),i[0]>r&&(r=i[0]),i[1]<e&&(e=i[1]),i[1]>o&&(o=i[1])};for(let i of t){let a=i.points;s(a[0]);for(let c=0;c+3<a.length;c+=3)for(let u=1;u<=8;u++)s(to(a[c],a[c+1],a[c+2],a[c+3],u/8))}return n===1/0?null:{x0:n,y0:e,x1:r,y1:o}}function $n(t){let n=new Ye;return n.moveTo([t.x0,t.y0]),n.lineTo([t.x1,t.y0]),n.lineTo([t.x1,t.y1]),n.lineTo([t.x0,t.y1]),n.close(),n.finish()[0]}var Lc={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Oc(t){let n=[],e=/([MLHVCSQTAZmlhvcsqtaz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,r;for(;r=e.exec(t);)n.push(r[1]?r[1]:parseFloat(r[2]));return n}function no(t){let n=Oc(t),e=new Ye,r=0,o="",s=null,i=null,a=()=>n[r++];for(;r<n.length;){let c=n[r];if(typeof c=="string"){if(o=c,r++,o==="Z"||o==="z"){e.close(),s=i=null;continue}}else if(!o){r++;continue}let u=o.toUpperCase(),f=o!==u,l=Lc[u];if(l===void 0||r+l>n.length||n.slice(r,r+l).some(x=>typeof x!="number"))break;let m=e.current,p=(x,M)=>f?[m[0]+x,m[1]+M]:[x,M],b=null,g=null;switch(u){case"M":{let x=p(a(),a());e.moveTo(x),o=f?"l":"L";break}case"L":e.lineTo(p(a(),a()));break;case"H":{let x=a();e.lineTo([f?m[0]+x:x,m[1]]);break}case"V":{let x=a();e.lineTo([m[0],f?m[1]+x:x]);break}case"C":{let x=p(a(),a()),M=p(a(),a()),F=p(a(),a());e.cubicTo(x,M,F),b=M;break}case"S":{let x=s?[2*m[0]-s[0],2*m[1]-s[1]]:m,M=p(a(),a()),F=p(a(),a());e.cubicTo(x,M,F),b=M;break}case"Q":{let x=p(a(),a()),M=p(a(),a());e.quadTo(x,M),g=x;break}case"T":{let x=i?[2*m[0]-i[0],2*m[1]-i[1]]:m,M=p(a(),a());e.quadTo(x,M),g=x;break}case"A":{let x=a(),M=a(),F=a(),N=a(),P=a(),A=p(a(),a()),v=Ai(m,x,M,F,N!==0,P!==0,A);for(let L=0;L<v.length;L+=3)e.cubicTo(v[L],v[L+1],v[L+2]);break}}s=b,i=g}return e.finish()}var gr=ic(Ti());function Nc(t,n=12){let e=t.points,r=[];if(!e.length)return r;r.push([e[0][0],e[0][1]]);for(let i=0;i+3<e.length;i+=3){let[a,c,u,f]=[e[i],e[i+1],e[i+2],e[i+3]],m=Math.abs((c[0]-a[0])*(f[1]-a[1])-(c[1]-a[1])*(f[0]-a[0]))<1e-12&&Math.abs((u[0]-a[0])*(f[1]-a[1])-(u[1]-a[1])*(f[0]-a[0]))<1e-12?1:n;for(let p=1;p<=m;p++){let b=p/m,g=1-b;r.push([g*g*g*a[0]+3*g*g*b*c[0]+3*g*b*b*u[0]+b*b*b*f[0],g*g*g*a[1]+3*g*g*b*c[1]+3*g*b*b*u[1]+b*b*b*f[1]])}}let o=r[0],s=r[r.length-1];return r.length>1&&Math.abs(o[0]-s[0])<1e-12&&Math.abs(o[1]-s[1])<1e-12&&r.pop(),r}function Kn(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r[0]*o[1]-o[0]*r[1]}return n/2}function Fi(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s[1]>t[1]!=i[1]>t[1]&&t[0]<(i[0]-s[0])*(t[1]-s[1])/(i[1]-s[1])+s[0]&&(e=!e)}return e}function Ci(t,n){let e=[];for(let o of dt(t,n)){let s=t.get(o);for(let i of ne(s.paths,s.m)){let a=Nc(i);a.length>=3&&Math.abs(Kn(a))>1e-12&&e.push(a)}}e.sort((o,s)=>Math.abs(Kn(s))-Math.abs(Kn(o)));let r=[];for(let o of e){let s=r.find(i=>Math.sign(Kn(i.outer))!==Math.sign(Kn(o))&&Fi(o[0],i.outer)&&!i.holes.some(a=>Fi(o[0],a)));s?s.holes.push(o):r.push({outer:o,holes:[]})}return r.map(o=>[o.outer,...o.holes])}function Li(t,n){let e=n.filter(s=>s.length);if(!e.length)return[];let r;e.length===1?r=e[0]:t==="union"?r=gr.default.union(e[0],...e.slice(1)):t==="intersection"?r=gr.default.intersection(e[0],...e.slice(1)):t==="difference"?r=gr.default.difference(e[0],...e.slice(1)):r=gr.default.xor(e[0],...e.slice(1));let o=[];for(let s of r)s.forEach((i,a)=>{let c=i.map(f=>[f[0],f[1]]);if(c.length>1){let f=c[0],l=c[c.length-1];f[0]===l[0]&&f[1]===l[1]&&(c=c.slice(0,-1))}let u=Kn(c)>0;a===0!==u&&c.reverse(),o.push(_t(c,!0))});return o}var os="#000000",io=$t.BLUE,ns=$t.BLUE_D,Bc=$t.RED;function wn(t,n){let e=t.filter(r=>r&&typeof r.then=="function");return e.length?Promise.all(e).then(n):n()}function sn(t,n,e,r){let o=Pt(at(t,n));xn(t,n,bt(e-o[0],r-o[1]))}function Mn(t,n,e,r,o,s={}){pt(t,n,e,r,ut(r),[],{children:o,...s})}function zc(t,n,e,r){let o=Ut(t,n,"start"),s=Ut(t,n,"end"),i=Ut(t,e,"start"),a=Ut(t,e,"end"),c=[s[0]-o[0],s[1]-o[1]],u=[a[0]-i[0],a[1]-i[1]],f=c[0]*u[1]-c[1]*u[0],l;if(Math.abs(f)<1e-12)l=s;else{let p=((i[0]-o[0])*u[1]-(i[1]-o[1])*u[0])/f;l=[o[0]+c[0]*p,o[1]+c[1]*p]}let m=(p,b)=>{let g=Math.hypot(p[0],p[1])||1;return[p[0]/g*b,p[1]/g*b]};return{p:l,u:m(c,r[0]<0?-1:1),v:m(u,r[1]<0?-1:1)}}function Oi(t,n,e,r,o){let s=t.w,{p:i,u:a,v:c}=zc(s,tt(s,r.line1),tt(s,r.line2),Array.isArray(r.quadrant)?r.quadrant:[1,1]),u=Math.atan2(a[1],a[0]),l=((Math.atan2(c[1],c[0])-u)%Rt+Rt)%Rt;r.other_angle&&(l-=Rt);let m;if(o||r.elbow){let p=S(r.length,.4);m=[_t([[i[0]+a[0]*p,i[1]+a[1]*p],[i[0]+(a[0]+c[0])*p,i[1]+(a[1]+c[1])*p],[i[0]+c[0]*p,i[1]+c[1]*p]],!1)]}else{let p=S(r.radius,.4);m=[me(i,p,p,u,l,!1,8)]}pt(t,n,e,r,ut(r),m,{data:{value:Math.abs(l),vertex:i}})}function Ni(t,n,e,r,o,s){let i=Ee(t,r.arc_center,[0,0]),a=S(r.start_angle,0),c=S(r.angle,Rt/4),u=(m,p)=>{let b=m[m.length-1];m.push([b[0]+(p[0]-b[0])/3,b[1]+(p[1]-b[1])/3],[b[0]+2*(p[0]-b[0])/3,b[1]+2*(p[1]-b[1])/3],[p[0],p[1]])},f=me(i,s,s,a+c,-c,!1,8).points,l;o>1e-9?(l=[...me(i,o,o,a,c,!1,8).points],u(l,f[0]),l.push(...f.slice(1))):(l=[[i[0],i[1]]],u(l,[i[0]+s*Math.cos(a),i[1]+s*Math.sin(a)]),l.push(...me(i,s,s,a,c,!1,8).points.slice(1))),u(l,l[0]),pt(t,n,e,r,ut(r,{sw:0,fo:1}),[{points:l,closed:!0}],{data:{start:l[0],end:l[0]}})}function $i(t,n,e){if(Math.abs(e)<1e-6)return Lt(t,n);let r=Math.hypot(n[0]-t[0],n[1]-t[1])||1e-9,o=r/(2*Math.sin(Math.abs(e)/2)),s=(t[0]+n[0])/2,i=(t[1]+n[1])/2,a=-(n[1]-t[1])/r,c=(n[0]-t[0])/r,u=o*Math.cos(e/2)*Math.sign(e),f=s+a*u,l=i+c*u,m=Math.atan2(t[1]-l,t[0]-f);return me([f,l],o,o,m,e,!1,8)}function Bi(t,n,e,r,o){var P,A;let[s,i]=yn(t,(P=r.start)!=null?P:r.start_point,(A=r.end)!=null?A:r.end_point),a=$i(s,i,S(r.angle,Rt/4)),c=Lo([a]),u=Math.min(S(r.tip_length,.35),.25*c),f=ut(r),l=o?u/c:0,m=1-u/c,p=pn([a],l,m),b=a.points,g=(v,L)=>{let T=[b[v][0]-b[L][0],b[v][1]-b[L][1]],O=Math.hypot(T[0],T[1])||1;return[T[0]/O,T[1]/O]},x={...f,fc:f.sc,fo:1,sw:0},M=[],F=g(b.length-1,b.length-2),N=t.w.newId();if(t.w.set(ct(N,"tip",x,Dn(i,F[0],F[1],u,u))),M.push(N),o){let v=g(0,1),L=t.w.newId();t.w.set(ct(L,"tip",x,Dn(s,v[0],v[1],u,u))),M.push(L)}pt(t,n,e,r,f,p,{children:M,data:{start:s,end:i}})}function ss(t,n){return n.map(e=>e.kind==="text"?ze(t,e.id,"text",e.props,e.str):e.kind==="number"?ze(t,e.id,"text",e.props,e.str):dr(t,e.id,e.kind,{...e.props,parts:[e.str]},e.kind==="mathtex"?"math":"text"))}function zi(t,n,e,r,o,s=!1){let i=Wn(S(r.font_size,48)),a=o.map(()=>t.w.newId()),c=ss(t,o.map((u,f)=>({id:a[f],kind:"text",str:s?`\u2022 ${u}`:u,props:{font_size:r.font_size,color:r.color,weight:r.weight,slant:r.slant,font:r.font,letter_spacing:r.letter_spacing}})));return wn(c,()=>{let u=String(r.alignment||"left").toLowerCase(),f=s?i*1.2+S(r.buff,.5)*.5:i*1.25*S(r.line_spacing,1);a.forEach((l,m)=>{let p=at(t.w,l),b=u==="center"?-(p[0]+p[2])/2:u==="right"?-p[2]:-p[0];xn(t.w,l,bt(b,-m*f-(p[1]+p[3])/2))}),Mn(t,n,e,r,a),sn(t.w,n,0,0)})}function Ki(t,n,e,r){var F,N,P;let o=String((F=r.text)!=null?F:""),s=(A,v)=>nn(A,v,r.font),a=Array.from(new Set([s("normal","normal"),s("bold","normal"),s("normal","italic"),s("bold","italic")])).filter(A=>t.text.font(A)===void 0);if(a.length)return Promise.all(a.map(A=>t.text.load(A))).then(()=>Ki(t,n,e,r));let c=ut(r,{sw:0,fo:1}),u=[],f=[],l=/<\s*(\/?)\s*(\w+)([^>]*)>|([^<]+)/g,m;for(;m=l.exec(o);)if(m[4]!=null){let A=m[4].replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),v=f.some(O=>O.tag==="b"||O.tag==="strong"),L=f.some(O=>O.tag==="i"||O.tag==="em"),T=(P=(N=[...f].reverse().find(O=>O.color))==null?void 0:N.color)!=null?P:null;for(let O of Array.from(A))u.push({ch:O,bold:v,italic:L,color:T})}else if(m[1]){let A=f.map(v=>v.tag).lastIndexOf(m[2].toLowerCase());A>=0&&f.splice(A,1)}else{let A=m[3]||"",v=/(?:foreground|fgcolor|color)\s*=\s*["']([^"']+)["']/i.exec(A);f.push({tag:m[2].toLowerCase(),color:v?ht(v[1],gt):void 0})}let p=Wn(S(r.font_size,48)),b=0,g=0,x=[],M="";for(let A of u){if(A.ch===`
6
+ `){b=0,g-=p*1.25;continue}let v=s(A.bold?"bold":"normal",A.italic?"italic":"normal"),L=t.text.glyph(A.ch,p,v);if(M+=A.ch,!!L){if(L.paths.length){let T=t.w.newId(),O=A.color?{...c,sc:A.color,fc:A.color}:c;t.w.set(ct(T,"glyph",O,L.paths,{m:bt(b,g),data:{char:A.ch}})),x.push(T)}b+=L.advance+S(r.letter_spacing,0)*p}}if(!x.length&&M.trim())return ze(t,n,e,r,M);Mn(t,n,e,r,x,{data:{text:M}}),sn(t.w,n,0,0)}function ro(t,n,e,r,o){var f,l;let s=(l=(f=r.table)!=null?f:r.data)!=null?l:[];if(r.col_labels&&(s=[r.col_labels,...s]),r.row_labels){let m=r.row_labels;s=s.map((p,b)=>{var g;return[r.col_labels?b===0?(g=r.top_left_entry)!=null?g:"":m[b-1]:m[b],...p]})}let i=s.length,a=Math.max(0,...s.map(m=>m.length)),c=[],u=[];return s.forEach(m=>{var p;for(let b=0;b<a;b++){let g=(p=m[b])!=null?p:"";if(kn(g)){c.push(tt(t.w,g));continue}let x=t.w.newId();c.push(x),u.push({id:x,kind:o,str:String(g),props:{font_size:r.font_size,color:r.color}})}}),wn(ss(t,u),()=>{var st;let m=t.w,p=S(r.h_buff,1.3),b=S(r.v_buff,.8),g=new Array(a).fill(0),x=new Array(i).fill(0);c.forEach((Q,ot)=>{let nt=at(m,Q),it=Math.floor(ot/a),yt=ot%a;g[yt]=Math.max(g[yt],nt[2]-nt[0]),x[it]=Math.max(x[it],nt[3]-nt[1])});let M=[],F=[],N=0;for(let Q=0;Q<a;Q++)M.push(N+g[Q]/2),N+=g[Q]+p;let P=N-p;N=0;for(let Q=0;Q<i;Q++)F.push(-(N+x[Q]/2)),N+=x[Q]+b;let A=N-b;c.forEach((Q,ot)=>sn(m,Q,M[ot%a]-P/2,F[Math.floor(ot/a)]+A/2));let v={...ut(r.line_config||{}),sw:S((st=r.line_config)==null?void 0:st.stroke_width,2)},L=!!r.include_outer_lines,T=[],O=[],K=-P/2-p/2,D=P/2+p/2,j=A/2+b/2,G=-A/2-b/2;for(let Q=0;Q<i-1;Q++){let ot=F[Q]-x[Q]/2-b/2+A/2;T.push(Lt([K,ot],[D,ot]))}for(let Q=0;Q<a-1;Q++){let ot=M[Q]+g[Q]/2+p/2-P/2;O.push(Lt([ot,j],[ot,G]))}L&&(T.unshift(Lt([K,j],[D,j])),T.push(Lt([K,G],[D,G])),O.unshift(Lt([K,j],[K,G])),O.push(Lt([D,j],[D,G])));let U=m.newId(),$=m.newId(),q=m.newId();m.set(ct(U,"group",v,[],{children:c}));let H=(Q,ot)=>{let nt=ot.map(it=>{let yt=m.newId();return m.set(ct(yt,"line",v,[it])),yt});m.set(ct(Q,"group",v,[],{children:nt}))},et=r.include_inner_lines!==!1;H($,et?T:L?[T[0],T[T.length-1]]:[]),H(q,et?O:L?[O[0],O[O.length-1]]:[]),Mn(t,n,e,r,[U,$,q],{data:{rows:i,cols:a}})})}function Di(t,n){let o=n?-1:1,s=[[0,t/2],[o*.14,t/2],[o*.14,t/2-.035],[o*.035,t/2-.035],[o*.035,-t/2+.035],[o*.14,-t/2+.035],[o*.14,-t/2],[0,-t/2]];return[_t(s,!0)]}function oo(t,n,e,r,o,s){var l,m;let i=(m=(l=r.matrix)!=null?l:r.data)!=null?m:[],a=i.length,c=Math.max(0,...i.map(p=>p.length)),u=[],f=[];return i.forEach(p=>{for(let b=0;b<c;b++){let g=p[b];if(kn(g)){u.push(tt(t.w,g));continue}let x=t.w.newId();u.push(x);let M=o==="number"?Zr(Number(g),s):String(g!=null?g:"");f.push({id:x,kind:o==="number"?"number":o,str:M,props:{font_size:r.font_size,color:r.color}})}}),wn(ss(t,f),()=>{let p=t.w,b=S(r.v_buff,.8),g=S(r.h_buff,1.3);u.forEach((L,T)=>sn(p,L,T%c*g,-Math.floor(T/c)*b));let x=p.newId();p.set(ct(x,"group",ut(r),[],{children:u}));let M=at(p,x),F=M[3]-M[1]+2*S(r.bracket_v_buff,.25),N=S(r.bracket_h_buff,.25),P=ut({...r,fill_opacity:1,stroke_width:0},{sw:0,fo:1}),A=p.newId(),v=p.newId();p.set(ct(A,"bracket",P,Di(F,!1),{m:bt(M[0]-N,(M[1]+M[3])/2)})),p.set(ct(v,"bracket",P,Di(F,!0),{m:bt(M[2]+N,(M[1]+M[3])/2)})),Mn(t,n,e,r,[x,A,v],{data:{rows:a,cols:c}}),sn(p,n,0,0)})}var _n={python:["def","class","return","if","elif","else","for","while","in","import","from","as","with","try","except","finally","raise","lambda","yield","pass","break","continue","and","or","not","is","None","True","False","await","async","global","nonlocal","del","assert"],js:["function","const","let","var","return","if","else","for","while","of","in","import","from","export","class","new","this","null","undefined","true","false","async","await","try","catch","finally","throw","typeof","switch","case","break","continue","default"]};_n.javascript=_n.js;_n.typescript=_n.ts=_n.js;var on={kw:"#F92672",str:"#E6DB74",com:"#75715E",num:"#FD971F",fn:"#A6E22E",text:"#F8F8F2"};function Dc(t,n){var i;let e=new Set(_n[n]||_n.python),r=[],o=/(#.*$|\/\/.*$)|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_]\w*)(?=\s*\()|([A-Za-z_]\w*)|(\s+)|(.)/g,s;for(;s=o.exec(t);)s[1]?r.push({s:s[1],c:on.com}):s[2]?r.push({s:s[2],c:on.str}):s[3]?r.push({s:s[3],c:on.num}):s[4]?r.push({s:s[4],c:e.has(s[4])?on.kw:on.fn}):s[5]?r.push({s:s[5],c:e.has(s[5])?on.kw:on.text}):r.push({s:(i=s[6])!=null?i:s[7],c:on.text});return r}function jc(t,n,e,r){var T,O,K;let o=" ".repeat(Math.max(1,Math.round(S(r.tab_width,4)))),s=String((O=(T=r.code_string)!=null?T:r.code)!=null?O:"").replace(/\t/g,o).replace(/\s+$/,""),i=String(r.language||"python").toLowerCase(),a=Wn(S(r.font_size,24)),c=a*.6,u=a*1.45,f=s.split(`
7
+ `),l=r.add_line_numbers!==!1,m=Math.round(S(r.line_numbers_from,1)),p=l?(String(f.length+m-1).length+2)*c:0,b=t.w,g=(D,j,G,U)=>{let $=b.newId(),q=D.length*c;return b.set(ct($,"code_token",{sc:j,fc:j,sw:0,so:1,fo:1},[],{text:{str:D,em:a,weight:"normal",slant:"normal",w:q,h:a,family:"mono",left:!0},m:bt(G+q/2,U),data:{text:D}})),$},x=[],M=[];f.forEach((D,j)=>{let G=-j*u;l&&x.push(g(String(j+m),"#75715E",0,G));let U=[],$=0;for(let H of Dc(D,i))H.s.trim()&&U.push(g(H.s,H.c,p+$*c,G)),$+=H.s.length;let q=b.newId();b.set(ct(q,"code_line",ut(r),[],{children:U,data:{text:D}})),M.push(q)});let F=b.newId(),N=b.newId();b.set(ct(F,"group",ut(r),[],{children:x})),b.set(ct(N,"group",ut(r),[],{children:M}));let P=Wc(b,[F,N]),A=.3,v=b.newId(),L=ht((K=r.background_color)!=null?K:"#272822","#272822");b.set(ct(v,"code_background",{sc:L,fc:L,sw:0,so:1,fo:1},[Fn(P[2]-P[0]+2*A,P[3]-P[1]+2*A,.2)],{m:bt((P[0]+P[2])/2,(P[1]+P[3])/2)})),Mn(t,n,e,r,[v,F,N],{data:{code:s}}),sn(b,n,0,0)}function Wc(t,n){let e=null;for(let r of n){let o=at(t,r);o[0]===o[2]&&o[1]===o[3]&&!t.get(r).children.length||(e=e?[Math.min(e[0],o[0]),Math.min(e[1],o[1]),Math.max(e[2],o[2]),Math.max(e[3],o[3])]:o)}return e||[0,0,0,0]}function ao(t,n){for(let e of t){if(!e.length)continue;let r=Math.min(e[0][0],e[e.length-1][0]),o=Math.max(e[0][0],e[e.length-1][0]);if(!(n<r-1e-9||n>o+1e-9))for(let s=0;s+1<e.length;s++){let i=e[s],a=e[s+1];if((n-i[0])*(n-a[0])<=0){let c=a[0]===i[0]?0:(n-i[0])/(a[0]-i[0]);return i[1]+(a[1]-i[1])*c}}}return null}function co(t,n){var s,i;let e=t.get(n),r=(s=e.data)==null?void 0:s.samples,o=(i=e.data)==null?void 0:i.axes;if(!r||!o)throw new Error("this needs a graph plotted on axes");return{samples:r,map:o,m:e.m}}function $c(t,n,e,r){var g,x,M;let{samples:o,map:s,m:i}=co(t.w,tt(t.w,r.graph)),a=o.flat().map(F=>F[0]),[c,u]=Array.isArray(r.x_range)?r.x_range.map(Number):[Math.min(...a),Math.max(...a)],f=r.bounded_graph!=null?co(t.w,tt(t.w,r.bounded_graph)).samples:null,l=120,m=[],p=[];for(let F=0;F<=l;F++){let N=c+(u-c)*F/l,P=(g=ao(o,N))!=null?g:0,A=f&&(x=ao(f,N))!=null?x:0;m.push(be(s,N,P)),p.push(be(s,N,A))}let b=[_t([...m,...p.reverse()],!0)];pt(t,n,e,r,ut({fill_opacity:S(r.opacity,.3),...r},{color:(M=$t.GRAY)!=null?M:gt,sw:0}),b,{m:i})}function Kc(t,n,e,r){var g,x,M,F;let{samples:o,map:s,m:i}=co(t.w,tt(t.w,r.graph)),a=o.flat().map(N=>N[0]),[c,u]=Array.isArray(r.x_range)?r.x_range.map(Number):[Math.min(...a),Math.max(...a)],f=S(r.dx,.1),l=String(r.input_sample_type||"left"),m=Array.isArray(r.color)?r.color.map(N=>ht(N,io)):[ht((g=r.color)!=null?g:io,io),ht((x=r.color)!=null?x:$t.GREEN,$t.GREEN)],p=Math.max(1,Math.round((u-c)/f)),b=[];for(let N=0;N<p;N++){let P=c+N*f,A=P+f,v=l==="right"?A:l==="center"?(P+A)/2:P,L=(M=ao(o,v))!=null?M:0,T=be(s,P,0),O=be(s,A,L),K=m.length>1?Gi(m,p>1?N/(p-1):0):m[0],D=t.w.newId();t.w.set(ct(D,"rectangle",{sc:ht((F=r.stroke_color)!=null?F:os,os),fc:K,sw:S(r.stroke_width,1),so:1,fo:S(r.fill_opacity,1)},[_t([[O[0],O[1]],[T[0],O[1]],[T[0],T[1]],[O[0],T[1]]],!0)],{m:i})),b.push(D)}Mn(t,n,e,r,b)}function Gi(t,n){let e=Math.max(0,Math.min(1,n))*(t.length-1),r=Math.min(t.length-2,Math.floor(e)),o=e-r,s=c=>[1,3,5].map(u=>parseInt(c.slice(u,u+2),16)||0),i=s(t[r]),a=s(t[r+1]);return"#"+i.map((c,u)=>Math.round(c+(a[u]-c)*o).toString(16).padStart(2,"0")).join("").toUpperCase()}function Gc(t,n,e,r){var f;let o=((f=r.values)!=null?f:[]).map(Number),s=o.length,i=Math.max(0,...o),a=Math.min(0,...o),c=Array.isArray(r.y_range)?r.y_range:[a,i>0?i:1,Math.max(1,Math.ceil((i-a)/6))],u=rn(t,n,"axes",{x_range:[0,s,1],y_range:c,x_length:S(r.x_length,s),y_length:S(r.y_length,t.fh-4),tips:!1,axis_config:{include_tip:!1,...r.axis_config||{}},x_axis_config:{include_ticks:!1,...r.x_axis_config||{}}});return wn([u],()=>{var A;let l=t.w,m=l.get(n),p=m.data.axes,b=(Array.isArray(r.bar_colors)?r.bar_colors:Qs).map(v=>ht(v,io)),g=S(r.bar_width,.6),x=o.map((v,L)=>{let T=be(p,L+.5-g/2,0),O=be(p,L+.5+g/2,v),K=b.length>1?Gi(b,s>1?L/(s-1):0):b[0],D=l.newId();return l.set(ct(D,"bar",{sc:K,fc:K,sw:S(r.bar_stroke_width,3),so:1,fo:S(r.bar_fill_opacity,.7)},[_t([[O[0],O[1]],[T[0],O[1]],[T[0],T[1]],[O[0],T[1]]],!0)],{m:m.m})),D}),M=l.newId();l.set(ct(M,"group",m.style,[],{children:x}));let F=(A=r.bar_names)!=null?A:[],N=[],P=F.map((v,L)=>{let T=l.newId();return N.push(T),ze(t,T,"text",{font_size:24},String(v))});return wn(P,()=>{N.forEach((L,T)=>{let O=Nt(m.m,be(p,T+.5,0)),K=at(l,L);sn(l,L,O[0],O[1]-.25-(K[3]-K[1])/2)});let v=l.newId();l.set(ct(v,"group",m.style,[],{children:N})),l.update(n,{kind:e,children:[...m.children,M,v],data:{...m.data,bars:M,values:o,props:r}})})})}function Vc(t,n,e,r){var F,N;let o=S(r.radius_max,t.fh/2),i=S(r.size,o*2)/2/o,a=S(r.radius_step,1),c=Math.max(1,Math.round(S(r.azimuth_step,12))),u={sc:ht((N=(F=r.background_line_style)==null?void 0:F.stroke_color)!=null?N:ns,ns),fc:ns,sw:2,so:1,fo:0},f=[];for(let P=a;P<=o+1e-9;P+=a)f.push(Fe([0,0],P*i));let l=[];for(let P=0;P<c;P++){let A=Rt*P/c;l.push(Lt([0,0],[Math.cos(A)*o*i,Math.sin(A)*o*i]))}let m=t.w.newId(),p=t.w.newId();t.w.set(ct(m,"background_lines",u,f)),t.w.set(ct(p,"background_lines",u,l));let b={sc:gt,fc:gt,sw:2,so:1,fo:0},g=t.w.newId(),x=t.w.newId();t.w.set(ct(g,"number_line",b,[Lt([-o*i,0],[o*i,0])])),t.w.set(ct(x,"number_line",b,[Lt([0,-o*i],[0,o*i])])),pt(t,n,e,r,b,[],{children:[m,p,g,x],data:{axes:{x0:0,y0:0,sx:i,sy:i,ox:0,oy:0},polar:!0}})}function Uc(t){return()=>{t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Yc(t,n,e,r,o=0){var m;let s;if(e&&typeof e=="object"&&!Array.isArray(e)){let p=e;return s=Array.from({length:t},(b,g)=>{var M,F;let x=(F=(M=p[g])!=null?M:p[String(g)])!=null?F:[0,0];return[Number(x[0]),Number(x[1])]}),s}let i=String(e||"spring");if(i==="circular"||i==="shell")return Array.from({length:t},(p,b)=>[r*Math.cos(Rt*b/t),r*Math.sin(Rt*b/t)]);if(i==="tree"){let p=Array.from({length:t},()=>[]);for(let[M,F]of n)p[M].push(F),p[F].push(M);let b=new Array(t).fill(-1),g=[];b[o]=0;let x=[o];for(;x.length;){let M=x.shift();(g[m=b[M]]||(g[m]=[])).push(M);for(let F of p[M])b[F]<0&&(b[F]=b[M]+1,x.push(F))}s=new Array(t).fill(null).map(()=>[0,0]),g.forEach((M,F)=>M.forEach((N,P)=>{s[N]=[M.length>1?P/(M.length-1)*2-1:0,1-(g.length>1?2*F/(g.length-1):0)]}))}else{let p=Uc(1);s=Array.from({length:t},()=>[p()*2-1,p()*2-1]);let b=Math.sqrt(4/Math.max(1,t)),g=.2;for(let x=0;x<120;x++){let M=s.map(()=>[0,0]);for(let F=0;F<t;F++)for(let N=F+1;N<t;N++){let P=s[F][0]-s[N][0],A=s[F][1]-s[N][1],v=Math.hypot(P,A)||1e-6,L=b*b/v;M[F][0]+=P/v*L,M[F][1]+=A/v*L,M[N][0]-=P/v*L,M[N][1]-=A/v*L}for(let[F,N]of n){let P=s[F][0]-s[N][0],A=s[F][1]-s[N][1],v=Math.hypot(P,A)||1e-6,L=v*v/b;M[F][0]-=P/v*L,M[F][1]-=A/v*L,M[N][0]+=P/v*L,M[N][1]+=A/v*L}for(let F=0;F<t;F++){let N=Math.hypot(M[F][0],M[F][1])||1e-6;s[F][0]+=M[F][0]/N*Math.min(N,g),s[F][1]+=M[F][1]/N*Math.min(N,g)}g*=.97}}let a=s.map(p=>p[0]),c=s.map(p=>p[1]),u=(Math.min(...a)+Math.max(...a))/2,f=(Math.min(...c)+Math.max(...c))/2,l=Math.max(Math.max(...a)-Math.min(...a),Math.max(...c)-Math.min(...c))/2||1;return s.map(p=>[(p[0]-u)/l*r,(p[1]-f)/l*r])}function ji(t,n,e,r,o){var x,M;let s=(x=r.vertices)!=null?x:[],i=s.length,a=F=>typeof F=="number"&&Number.isInteger(F)&&F>=0&&F<i?F:Math.max(0,s.indexOf(F)),c=((M=r.edges)!=null?M:[]).map(F=>[a(F[0]),a(F[1])]),u=typeof r.root_vertex=="number"?r.root_vertex:Math.max(0,s.indexOf(r.root_vertex)),f=Yc(i,c,r.layout,S(r.layout_scale,2),u),l=(F,N)=>F?F.per&&typeof F.per=="object"?{...F.per[N]||{}}:F:{},m=t.w,p=s.map(()=>m.newId()),b=r.labels,g=p.map((F,N)=>{let P=l(r.vertex_config,String(N));if(b)return Vi(t,F,"labeled_dot",{label:String(s[N]),point:[...f[N],0],...P});pt(t,F,"dot",P,ut(P,{sw:0,fo:1}),[Fe([0,0],S(P.radius,.08))],{m:bt(f[N][0],f[N][1])})});return wn(g,()=>{let F=c.map(([A,v])=>{let L=l(r.edge_config,`${A},${v}`),T=m.newId(),O=at(m,p[A]),K=at(m,p[v]),D=Math.max((O[2]-O[0])/2,(K[2]-K[0])/2);return o?hr(t,T,"arrow",{stroke_width:2,...L},f[A],f[v],D,!1):pt(t,T,"line",L,ut(L),[Lt(f[A],f[v])],{z:-1,data:{start:f[A],end:f[v]}}),T}),N=m.newId(),P=m.newId();m.set(ct(N,"group",ut({}),[],{children:p})),m.set(ct(P,"group",ut({}),[],{children:F})),Mn(t,n,e,r,[N,P],{data:{vertices:s,edges:c,props:r}})})}function Vi(t,n,e,r){var a,c,u,f;let o=t.w.newId(),s={font_size:(a=r.font_size)!=null?a:48,color:(c=r.label_color)!=null?c:os},i=t.tex&&r.label_is_text!==!0?dr(t,o,"mathtex",{...s,parts:[String((u=r.label)!=null?u:"")]},"math"):ze(t,o,"text",s,String((f=r.label)!=null?f:""));return wn([i],()=>{let l=at(t.w,o),m=r.radius!=null?S(r.radius,.3):.92*Math.max(l[2]-l[0],l[3]-l[1]),p=Ee(t,r.point,[0,0]);sn(t.w,o,p[0],p[1]),pt(t,n,e,r,ut(r,{sw:0,fo:1}),[Fe([0,0],m)],{m:bt(p[0],p[1]),children:[o]})})}function Hc(t){var o;let n={},e=/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g,r;for(;r=e.exec(t);)n[r[1]]=(o=r[3])!=null?o:r[4];if(n.style)for(let s of n.style.split(";")){let[i,a]=s.split(":").map(c=>c&&c.trim());i&&a&&(n[i]=a)}return n}function Xc(t){var o;let n=[1,0,0,1,0,0];if(!t)return n;let e=/(matrix|translate|scale|rotate)\s*\(([^)]*)\)/g,r;for(;r=e.exec(t);){let s=r[2].split(/[\s,]+/).filter(Boolean).map(Number),i=[1,0,0,1,0,0];if(r[1]==="matrix")i=[s[0],s[1],s[2],s[3],s[4],s[5]];else if(r[1]==="translate")i=[1,0,0,1,s[0]||0,s[1]||0];else if(r[1]==="scale")i=[s[0],0,0,(o=s[1])!=null?o:s[0],0,0];else if(r[1]==="rotate"){let a=(s[0]||0)*Math.PI/180,c=Math.cos(a),u=Math.sin(a);i=[c,u,-u,c,0,0],s.length>=3&&(i=lt(lt([1,0,0,1,s[1],s[2]],i),[1,0,0,1,-s[1],-s[2]]))}n=lt(n,i)}return n}function qc(t,n){let e=(r,o=0)=>n[r]!=null?parseFloat(n[r]):o;switch(t){case"path":return n.d?no(n.d):[];case"rect":{let r=e("x"),o=e("y"),s=e("width"),i=e("height"),a=e("rx",e("ry"));return a>0?ne([Fn(s,i,a)],bt(r+s/2,o+i/2)):[_t([[r,o],[r+s,o],[r+s,o+i],[r,o+i]],!0)]}case"circle":return[Fe([e("cx"),e("cy")],e("r"))];case"ellipse":return[me([e("cx"),e("cy")],e("rx"),e("ry"),0,Rt,!0)];case"line":return[Lt([e("x1"),e("y1")],[e("x2"),e("y2")])];case"polyline":case"polygon":{let r=(n.points||"").trim().split(/[\s,]+/).map(Number),o=[];for(let s=0;s+1<r.length;s+=2)o.push([r[s],r[s+1]]);return[_t(o,t==="polygon")]}}return[]}function rs(t,n,e,r){var x,M,F;let o=String((F=(M=(x=r.svg)!=null?x:r.svg_string)!=null?M:r.file_content)!=null?F:""),s=t.w,i=[],a=[{M:[1,0,0,1,0,0],a:{}}],c=/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g,u,f=(N,P)=>{var A,v;return(v=P[N])!=null?v:(A=[...a].reverse().find(L=>L.a[N]!=null))==null?void 0:A.a[N]};for(;u=c.exec(o);){let[,N,P,A,v]=u,L=P.toLowerCase().replace(/^svg:/,"");if(N){(L==="g"||L==="svg")&&a.pop();continue}let T=Hc(A),O=lt(a[a.length-1].M,Xc(T.transform));if(L==="g"||L==="svg"){v||a.push({M:O,a:T});continue}if(L==="defs"||L==="clippath"||L==="mask")continue;let K=qc(L,T);if(!K.length)continue;let D=f("fill",T),j=f("stroke",T),G=D&&D!=="none"?ht(D,gt):gt,U=j&&j!=="none"?ht(j,gt):G,$=j&&j!=="none"?parseFloat(f("stroke-width",T)||"1"):0,q={sc:U,fc:G,sw:$,so:1,fo:D==="none"?0:parseFloat(f("fill-opacity",T)||f("opacity",T)||"1")},H=s.newId();s.set(ct(H,"svg_part",q,ne(K,lt([1,0,0,-1,0,0],O)),{evenodd:(f("fill-rule",T)||"").trim()==="evenodd"})),i.push(H)}pt(t,n,e,r,ut(r),[],{children:i});let l=at(s,n),m=r.width!=null&&r.height==null?S(r.width,2)*((l[3]-l[1])/(l[2]-l[0]||1)):S(r.height,2),p=l[3]-l[1]>1e-9?m/(l[3]-l[1]):1,b=Pt(l);xn(s,n,lt(Jt(p,p,[0,0]),bt(-b[0],-b[1])));let g={};r.color!=null&&(g.sc=ht(r.color,gt),g.fc=g.sc),r.fill_color!=null&&(g.fc=ht(r.fill_color,gt)),r.stroke_color!=null&&(g.sc=ht(r.stroke_color,gt)),r.fill_opacity!=null&&(g.fo=S(r.fill_opacity,1)),r.stroke_width!=null&&(g.sw=S(r.stroke_width,0));for(let N of i){let P=s.get(N);s.set({...P,style:{...P.style,sw:r.stroke_width!=null?P.style.sw:P.style.sw*p*100/4,...g}})}}async function Ui(t,n,e){var s;let r=null;try{r=((s=globalThis.parent)==null?void 0:s.__cirImages)||globalThis.__cirImages}catch(i){r=null}if(!r||typeof r.chain!="function")throw new Error("Image operations need the Circuitry editor");let o=await r.chain(globalThis,t,n,e!=null?e:null);return typeof o=="string"?JSON.parse(o):o}function Wi(t){return new Promise(n=>{let e=new Image;e.onload=()=>n(e),e.onerror=()=>n(null),e.src=t})}function Qc(t,n,e,r){var u,f,l;let o=(l=(f=(u=r.src)!=null?u:r.filename_or_array)!=null?f:r.url)!=null?l:null,s=r.element,i=(m,p,b)=>{let g=S(r.scale_to_resolution,1080),x=b/g*t.fh,M=p/g*t.fh;if(r.height!=null){let F=S(r.height,x)/(x||1);x*=F,M*=F}if(r.width!=null){let F=S(r.width,M)/(M||1);x*=F,M*=F}pt(t,n,e,r,ut({fill_opacity:1,...r},{sw:0}),[],{image:{src:m,w:M||1,h:x||1,fullW:M||1,fullH:x||1}})},a=m=>[m.naturalWidth||m.width||1080,m.naturalHeight||m.height||1080],c=Array.isArray(r.ops)?r.ops:[];if(c.length)return Ui(s!=null?s:o,c,null).then(async m=>{let p=m&&m.url?await Wi(m.url):null;if(!p)throw new Error("the image from "+String(c.map(b=>b[0]).join(", "))+" could not be loaded");i(p,m.width||p.naturalWidth,m.height||p.naturalHeight)});if(s){let[m,p]=a(s);i(s,m,p);return}if(typeof Image=="undefined"||!o){i(null,S(r.px_width,1080),S(r.px_height,1080));return}return Wi(String(o)).then(m=>{m?i(m,m.naturalWidth,m.naturalHeight):i(null,1080,1080)})}function Zc(t,n,e,r){var s,i;let o=r.svg_element;if(o!=null){let a=typeof o=="string"?o:(s=o.outerHTML)!=null?s:String(o);return rs(t,n,e,{...r,svg:a})}if(r.svg==null&&(r.image_src!=null||r.element!=null)&&r.trace!=null){let a=Array.isArray(r.ops)?r.ops:[];return Ui((i=r.element)!=null?i:r.image_src,a,r.trace).then(c=>{if(!c||!c.svg)throw new Error("tracing the image gave no shapes");let u=S(r.scale_to_resolution,1080),f=r.height!=null?r.height:r.width!=null?void 0:(c.height||1080)/u*t.fh;rs(t,n,e,{...r,svg:c.svg,height:f})})}return rs(t,n,e,r)}function so(t,n,e,r,o){var a,c;let i=((c=(a=r.mobjects)!=null?a:r.vmobjects)!=null?c:[r.subject,r.clip].filter(u=>u!=null)).map(u=>Ci(t.w,tt(t.w,u)));pt(t,n,e,r,ut(r),Li(o,i))}var Jo={union:(t,n,e,r)=>so(t,n,r,e,"union"),intersection:(t,n,e,r)=>so(t,n,r,e,"intersection"),difference:(t,n,e,r)=>so(t,n,r,e,"difference"),exclusion:(t,n,e,r)=>so(t,n,r,e,"exclusion"),angle:(t,n,e,r)=>Oi(t,n,r,e,!1),right_angle:(t,n,e,r)=>Oi(t,n,r,e,!0),sector:(t,n,e,r)=>{var o;return Ni(t,n,r,e,S(e.inner_radius,0),S((o=e.outer_radius)!=null?o:e.radius,1))},annular_sector:(t,n,e,r)=>Ni(t,n,r,e,S(e.inner_radius,1),S(e.outer_radius,2)),arc_between_points:(t,n,e,r)=>{let[o,s]=yn(t,e.start,e.end);pt(t,n,r,e,ut(e),[$i(o,s,S(e.angle,Rt/4))],{data:{start:o,end:s}})},curved_arrow:(t,n,e,r)=>Bi(t,n,r,e,!1),curved_double_arrow:(t,n,e,r)=>Bi(t,n,r,e,!0),elbow:(t,n,e,r)=>{let o=S(e.width,.2);pt(t,n,r,e,ut(e),ne([_t([[0,o],[o,o],[o,0]],!1)],Te(S(e.angle,0),[0,0])))},cross:(t,n,e,r)=>{var m;let o={...ut({stroke_width:6,...e},{color:Bc,sw:6}),fc:e.fill_color!=null?ht(e.fill_color,gt):gt},s=[-1,-1,1,1];(e.mobject!=null||e.target!=null)&&(s=jn(t.w,(m=e.mobject)!=null?m:e.target));let i=S(e.scale_factor,1),a=Pt(s),c=(s[2]-s[0])/2*i,u=(s[3]-s[1])/2*i,f=t.w.newId(),l=t.w.newId();t.w.set(ct(f,"line",o,[Lt([a[0]-c,a[1]+u],[a[0]+c,a[1]-u])])),t.w.set(ct(l,"line",o,[Lt([a[0]+c,a[1]+u],[a[0]-c,a[1]-u])])),pt(t,n,r,e,o,[],{children:[f,l]})},underline:(t,n,e,r)=>{var i;let o=jn(t.w,(i=e.mobject)!=null?i:e.target),s=o[1]-S(e.buff,.1);pt(t,n,r,e,ut(e),[Lt([o[0],s],[o[2],s])],{data:{start:[o[0],s],end:[o[2],s]}})},labeled_dot:(t,n,e,r)=>Vi(t,n,r,e),dashed_vmobject:(t,n,e,r)=>{var c;let o=tt(t.w,(c=e.vmobject)!=null?c:e.target),s=Math.max(1,Math.round(S(e.num_dashes,15))),i=S(e.dashed_ratio,.5),a=[];for(let u of dt(t.w,o)){let f=t.w.get(u),l=ne(f.paths,f.m),m=l.length===1&&l[0].closed,p=i/s,b=m||s===1?1/s:(1-p)/(s-1);for(let g=0;g<s;g++)for(let x of pn(l,g*b,Math.min(1,g*b+p))){let M=t.w.newId();t.w.set(ct(M,"dash",f.style,[{points:x.points,closed:!1}])),a.push(M)}}pt(t,n,r,e,ut(e),[],{children:a})},tangent_line:(t,n,e,r)=>{var M;let o=tt(t.w,(M=e.vmobject)!=null?M:e.target),s=dt(t.w,o).flatMap(F=>ne(t.w.get(F).paths,t.w.get(F).m)),i=Math.max(0,Math.min(1,S(e.alpha,.5))),a=S(e.d_alpha,1e-6),c=Qe(s,Math.max(0,i-a)),u=Qe(s,Math.min(1,i+a)),f=Qe(s,i),l=u[0]-c[0],m=u[1]-c[1],p=Math.hypot(l,m)||1,b=S(e.length,1)/2,g=[f[0]-l/p*b,f[1]-m/p*b],x=[f[0]+l/p*b,f[1]+m/p*b];pt(t,n,r,e,ut(e),[Lt(g,x)],{data:{start:g,end:x}})},cubic_bezier:(t,n,e,r)=>{let o=[e.start_anchor,e.start_handle,e.end_handle,e.end_anchor].map(s=>Et(t.w,s));pt(t,n,r,e,ut(e),[{points:o,closed:!1}],{data:{start:o[0],end:o[3]}})},paragraph:(t,n,e,r)=>{var s;let o=Array.isArray(e.lines)?e.lines.map(String):String((s=e.text)!=null?s:"").split(`
8
+ `);return zi(t,n,r,e,o)},bulleted_list:(t,n,e,r)=>{var o;return zi(t,n,r,e,((o=e.items)!=null?o:[]).map(String),!0)},markup_text:(t,n,e,r)=>Ki(t,n,r,e),table:(t,n,e,r)=>ro(t,n,r,e,e.element==="mathtex"?"mathtex":"text"),math_table:(t,n,e,r)=>ro(t,n,r,e,"mathtex"),decimal_table:(t,n,e,r)=>ro(t,n,r,e,"number"),integer_table:(t,n,e,r)=>ro(t,n,r,e,"number"),matrix:(t,n,e,r)=>oo(t,n,r,e,"mathtex",0),integer_matrix:(t,n,e,r)=>oo(t,n,r,e,"number",0),decimal_matrix:(t,n,e,r)=>{var o;return oo(t,n,r,e,"number",S((o=e.element_to_mobject_config)==null?void 0:o.num_decimal_places,1))},mobject_matrix:(t,n,e,r)=>oo(t,n,r,e,"text",0),code:(t,n,e,r)=>jc(t,n,r,e),complex_plane:(t,n,e)=>rn(t,n,"number_plane",e),polar_plane:(t,n,e,r)=>Vc(t,n,r,e),bar_chart:(t,n,e,r)=>Gc(t,n,r,e),area:(t,n,e,r)=>$c(t,n,r,e),riemann_rectangles:(t,n,e,r)=>Kc(t,n,r,e),network_graph:(t,n,e,r)=>ji(t,n,r,e,!!e.directed),di_graph:(t,n,e,r)=>ji(t,n,r,e,!0),svg_mobject:(t,n,e,r)=>Zc(t,n,r,e),image_mobject:(t,n,e,r)=>Qc(t,n,r,e)};function Yi(t,n,e){let{samples:r,map:o,m:s}=co(t,n),i=ao(r,e);return Nt(s,be(o,e,i!=null?i:0))}function xr(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function kn(t){return xr(t)&&typeof t.id=="number"&&Object.keys(t).every(n=>n==="id"||n==="path")}function Hi(t){return xr(t)&&!("$pt"in t)&&!kn(t)}function de(t,n){let e={},r=[];Array.isArray(t)?(r=t.slice(),r.length&&Hi(r[r.length-1])&&Object.assign(e,r.pop())):Hi(t)?Object.assign(e,t):t!=null&&(r=[t]);for(let o=0;o<n.length&&o<r.length;o++){let s=n[o];if(s[0]==="*"){e[s.slice(1)]=r.slice(o);break}s in e||(e[s]=r[o])}return e}function tt(t,n){if(typeof n=="number"){if(!t.has(n))throw new Error(n===It?"no camera frame":`that object does not exist (#${n})`);return n}if(kn(n)){let e=tt(t,n.id);for(let r of n.path||[]){let o=t.get(e).children,s=r<0?o.length+r:r;if(s<0||s>=o.length)throw new is(`index ${r} is out of range (it has ${o.length} parts)`);e=o[s]}return e}throw new Error("expected an object, got "+JSON.stringify(n))}var is=class extends Error{constructor(n){super(n),this.name="IndexError"}};function Qt(t){return typeof t=="number"||kn(t)}var Jc={center:[0,0],centre:[0,0],origin:[0,0],top:[0,1],up:[0,1],bottom:[0,-1],down:[0,-1],left:[-1,0],right:[1,0],ul:[-1,1],ur:[1,1],dl:[-1,-1],dr:[1,-1],top_left:[-1,1],top_right:[1,1],bottom_left:[-1,-1],bottom_right:[1,-1]};function tu(t){return Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0]:typeof t=="string"&&Jc[t.toLowerCase().replace(/^get_/,"")]||null}function as(t,n,e){if(typeof e=="string"){let o=e.toLowerCase().replace(/^get_/,"");if(o==="start"||o==="end")return Ut(t,n,o)}let r=tu(e!=null?e:"center");if(!r)throw new Error(`unknown point "${e}"`);return re(at(t,n),r)}function Ut(t,n,e){let r=t.get(n);if(r.data&&r.data[e])return Nt(r.m,r.data[e]);let o=r.paths;if(!o.length){let i=r.children;return i.length?Ut(t,e==="start"?i[0]:i[i.length-1],e):Ot(t,n)}let s=e==="start"?o[0].points[0]:o[o.length-1].points[o[o.length-1].points.length-1];return Nt(r.m,s)}function Jr(t,n,e,r,o){var f;let s=t.get(n),i=s.data&&s.data.axes;if(!i)throw new Error("c2p needs Axes, a NumberPlane or a NumberLine");let a=be(i,e,r),c=s.data.axes3,u=c?c.oz+(o-c.z0)*c.sz:0;return zt((f=s.m3)!=null?f:Bt(s.m),a[0],a[1],u)}function _r(t,n,e){let r=as(t,n,Array.isArray(e)?[e[0],e[1]]:e);if(!Ve(t,n))return[r[0],r[1],(Array.isArray(e),0)];let o=Ge(t,n),s=Array.isArray(e)&&Number(e[2])||0;return[r[0],r[1],s>0?o[5]:s<0?o[2]:(o[2]+o[5])/2]}function qt(t,n){var r;if(Array.isArray(n)&&typeof n[0]!="string")return[Number(n[0])||0,Number(n[1])||0,Number(n[2])||0];if(Qt(n))return _r(t,tt(t,n),"center");let e=xr(n)&&("$pt"in n||"$x"in n)?Kt(t,(r=n.$pt)!=null?r:n.$x):Array.isArray(n)?Kt(t,n):null;if(e==null)throw new Error("expected a point, got "+JSON.stringify(n));return typeof e=="number"?[e,0,0]:[e[0]||0,e[1]||0,e[2]||0]}function be(t,n,e){return[t.ox+(n-t.x0)*t.sx,t.oy+(e-t.y0)*t.sy]}function Et(t,n){var e;if(Array.isArray(n))return typeof n[0]=="string"?cs(Kt(t,n)):[Number(n[0])||0,Number(n[1])||0];if(xr(n)&&("$pt"in n||"$x"in n))return cs(Kt(t,(e=n.$pt)!=null?e:n.$x));if(Qt(n))return Ot(t,tt(t,n));throw new Error("expected a point, got "+JSON.stringify(n))}function cs(t){return Array.isArray(t)?[t[0]||0,t[1]||0]:[t,0]}var At={t:0,dt:0,alpha:0,homotopy:!1},cn=null;function gn(t,n){let e=cn;cn=t;try{return n()}finally{cn=e}}function Zt(t,n,e){return typeof t=="number"&&typeof n=="number"?e(t,n):Array.isArray(t)&&Array.isArray(n)?t.map((r,o)=>{var s;return e(r,(s=n[o])!=null?s:0)}):Array.isArray(t)?t.map(r=>e(r,n)):n.map(r=>e(t,r))}function Dt(t,n){return typeof t=="number"?n(t):t.map(n)}var Le=t=>{var n;return typeof t=="number"?t:(n=t[0])!=null?n:0},Gn=t=>[t[0],t[1],0],Ie={hypot:(t,n)=>Zt(t,n,Math.hypot),sin:t=>Dt(t,Math.sin),cos:t=>Dt(t,Math.cos),tan:t=>Dt(t,Math.tan),arcsin:t=>Dt(t,Math.asin),arccos:t=>Dt(t,Math.acos),arctan:t=>Dt(t,Math.atan),arctan2:(t,n)=>Zt(t,n,Math.atan2),sinh:t=>Dt(t,Math.sinh),cosh:t=>Dt(t,Math.cosh),tanh:t=>Dt(t,Math.tanh),exp:t=>Dt(t,Math.exp),log:t=>Dt(t,Math.log),log10:t=>Dt(t,Math.log10),log2:t=>Dt(t,Math.log2),sqrt:t=>Dt(t,Math.sqrt),abs:t=>Dt(t,Math.abs),floor:t=>Dt(t,Math.floor),ceil:t=>Dt(t,Math.ceil),round:(t,n)=>{let e=Math.pow(10,n==null?0:Le(n));return Dt(t,r=>Math.round(r*e)/e)},sign:t=>Dt(t,Math.sign),min:(...t)=>t.reduce((n,e)=>Zt(n,e,Math.min)),max:(...t)=>t.reduce((n,e)=>Zt(n,e,Math.max)),clip:(t,n,e)=>Zt(Zt(t,n,Math.max),e,Math.min),interpolate:(t,n,e)=>Zt(t,Zt(Zt(n,t,(r,o)=>r-o),e,(r,o)=>r*o),(r,o)=>r+o),norm:t=>typeof t=="number"?Math.abs(t):Math.hypot(...t),dot:(t,n)=>t.reduce((e,r,o)=>{var s;return e+r*((s=n[o])!=null?s:0)},0),cross:(t,n)=>t[0]*n[1]-t[1]*n[0],normalize:t=>{if(typeof t=="number")return Math.sign(t);let n=Math.hypot(...t)||1;return t.map(e=>e/n)},rotate_vector:(t,n)=>{var i;let e=t,r=Le(n),o=Math.cos(r),s=Math.sin(r);return[e[0]*o-e[1]*s,e[0]*s+e[1]*o,(i=e[2])!=null?i:0]},deg:t=>Dt(t,n=>n*180/Math.PI),rad:t=>Dt(t,n=>n*Math.PI/180)};Object.assign(Ie,{asin:Ie.arcsin,acos:Ie.arccos,atan:Ie.arctan,atan2:Ie.arctan2,degrees:Ie.deg,radians:Ie.rad,absolute:Ie.abs,fabs:Ie.abs,minimum:Ie.min,maximum:Ie.max});var an={"<":(t,n)=>+(t<n),"<=":(t,n)=>+(t<=n),">":(t,n)=>+(t>n),">=":(t,n)=>+(t>=n),"==":(t,n)=>+(t===n),"!=":(t,n)=>+(t!==n)};Object.assign(an,{lt:an["<"],le:an["<="],gt:an[">"],ge:an[">="],eq:an["=="],ne:an["!="]});function Kt(t,n){var r,o,s,i,a,c;if(typeof n=="number")return n;if(typeof n=="boolean")return+n;if(xr(n)){if("$x"in n)return Kt(t,n.$x);if("$pt"in n)return Kt(t,n.$pt);if(kn(n))return Gn(Ot(t,tt(t,n)))}if(!Array.isArray(n))throw new Error("cannot evaluate "+JSON.stringify(n));if(typeof n[0]!="string")return n.map(u=>Le(Kt(t,u)));let e=u=>Kt(t,u);switch(n[0]){case"t":return At.t;case"dt":return At.dt;case"num":return Number(n[1]);case"val":return Number((o=(r=t.get(tt(t,n[1])).data)==null?void 0:r.value)!=null?o:0);case"v":return Array.isArray(n[1])?n[1].map(u=>Le(e(u))):e(n[1]);case"vec":return n.slice(1).map(u=>Le(e(u)));case"prop":return yr(t,tt(t,n[1]),String(n[2]),n.slice(3).map(e));case"var":{let u=String(n[1]);if(u==="t"&&At.homotopy)return At.alpha;if(u==="t"||u==="time")return At.t;if(u==="dt")return At.dt;if(u==="alpha")return At.alpha;let f=cn||[0,0];return u==="p"?[f[0],f[1],(s=f[2])!=null?s:0]:u==="x"||u==="u"?f[0]:u==="y"||u==="v"?f[1]:u==="z"&&(i=f[2])!=null?i:0}case"of":return _r(t,tt(t,n[1]),Array.isArray(n[2])?e(n[2]):n[2]);case"c2p":return Jr(t,tt(t,n[1]),Le(e(n[2])),Le(e(n[3])),n[4]!=null?Le(e(n[4])):0);case"p2c":{let u=cs(e(n[2])),f=Xi(t,tt(t,n[1]),u);return[f[0],f[1]]}case"get":return yr(t,tt(t,n[1]),String(n[2]),n.slice(3).map(e));case"ppf":{let u=tt(t,n[1]);return yr(t,u,"point_from_proportion",[Le(e(n[2]))])}case"graph_point":return Gn(Yi(t,tt(t,n[1]),Le(e(n[2]))));case"p":return cn?[cn[0],cn[1],(a=cn[2])!=null?a:0]:[0,0,0];case"alpha":return At.alpha;case"+":case"add":return Zt(e(n[1]),e(n[2]),(u,f)=>u+f);case"-":case"sub":return Zt(e(n[1]),e(n[2]),(u,f)=>u-f);case"*":case"mul":return Zt(e(n[1]),e(n[2]),(u,f)=>u*f);case"/":case"div":return Zt(e(n[1]),e(n[2]),(u,f)=>u/f);case"**":case"pow":return Zt(e(n[1]),e(n[2]),Math.pow);case"%":case"mod":return Zt(e(n[1]),e(n[2]),(u,f)=>(u%f+f)%f);case"//":return Zt(e(n[1]),e(n[2]),(u,f)=>Math.floor(u/f));case"neg":return Dt(e(n[1]),u=>-u);case"idx":{let u=e(n[1]);return typeof u=="number"?u:(c=u[Number(e(n[2]))])!=null?c:0}case"cmp":return Zt(e(n[2]),e(n[3]),an[n[1]]||(()=>0));case"where":return Le(e(n[1]))?e(n[2]):e(n[3]);case"fn":{let u=Ie[n[1]];if(!u)throw new Error(`the animation layer cannot evaluate ${n[1]}() yet`);return u(...n.slice(2).map(e))}}throw new Error("unknown expression "+n[0])}function Me(t,n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(o=>Me(t,o));if("$x"in n)return Kt(t,n.$x);if("$pt"in n){let o=Kt(t,n.$pt);return typeof o=="number"?[o,0,0]:o}let e=!1,r={};for(let o of Object.keys(n))r[o]=Me(t,n[o]),r[o]!==n[o]&&(e=!0);return e?r:n}function Xi(t,n,e){let r=t.get(n),o=r.data&&r.data.axes;if(!o)throw new Error("p2c needs Axes, a NumberPlane or a NumberLine");let s=Nt(le(r.m),e);return[o.sx?o.x0+(s[0]-o.ox)/o.sx:0,o.sy?o.y0+(s[1]-o.oy)/o.sy:0]}function yr(t,n,e,r=[]){var a,c,u,f,l,m,p;let o=String(e).replace(/^get_/,""),s=at(t,n),i=r[0];switch(o){case"center":return _r(t,n,"center");case"width":return s[2]-s[0];case"height":return s[3]-s[1];case"x":return Pt(s)[0];case"y":return Pt(s)[1];case"z":{let b=Ge(t,n);return(b[2]+b[5])/2}case"depth":{let b=Ge(t,n);return b[5]-b[2]}case"top":case"bottom":case"left":case"right":return Gn(as(t,n,o));case"corner":case"critical_point":case"edge_center":return Gn(as(t,n,i));case"start":case"end":{let b=t.get(n),g=b.data&&b.data[o+"3"];return Array.isArray(g)?zt((a=b.m3)!=null?a:Bt(b.m),g[0],g[1],(c=g[2])!=null?c:0):Gn(Ut(t,n,o))}case"len":case"length_of_children":case"submobject_count":return t.get(n).children.length;case"value":return Number((f=(u=t.get(n).data)==null?void 0:u.value)!=null?f:0);case"point_from_proportion":{let b=[];for(let g of dt(t,n))b.push(...ne(t.get(g).paths,t.get(g).m));return Gn(Qe(b,S(i,0)))}case"c2p":case"coords_to_point":case"n2p":case"number_to_point":{let b=Array.isArray(i)?i:[i,(l=r[1])!=null?l:0,(m=r[2])!=null?m:0];return Jr(t,n,S(b[0],0),S(b[1],0),S(b[2],0))}case"p2c":case"point_to_coords":case"p2n":case"point_to_number":{let b=Xi(t,n,Et(t,i));return o==="p2n"||o==="point_to_number"?b[0]:[b[0],b[1]]}case"color":{let b=t.get((p=dt(t,n)[0])!=null?p:n);return b.style.fo>0?b.style.fc:b.style.sc}case"length":case"arc_length":{let b=Ut(t,n,"start"),g=Ut(t,n,"end");return Math.hypot(g[0]-b[0],g[1]-b[1])}case"angle":{let b=Ut(t,n,"start"),g=Ut(t,n,"end");return Math.atan2(g[1]-b[1],g[0]-b[0])}case"unit_vector":{let b=Ut(t,n,"start"),g=Ut(t,n,"end"),x=Math.hypot(g[0]-b[0],g[1]-b[1])||1;return[(g[0]-b[0])/x,(g[1]-b[1])/x,0]}}throw new Error(`cannot read "${e}" from an object`)}function ie(t,n,e){return n==null?e:Et(t,n)}function S(t,n){if(t==null)return n;let e=Number(Array.isArray(t)?t[0]:t);return Number.isFinite(e)?e:n}var te=[0,0],Ji=[1,0];var Sn=.25,qi=.5;function ta(t,n){if(Qt(n))return at(t,tt(t,n));let e=Et(t,n);return[e[0],e[1],e[0],e[1]]}function De(t,n,e){(e[0]||e[1])&&oe(t,n,bt(e[0],e[1]))}function uo(t,n,e){if(e.about_point!=null)return Et(t,e.about_point);let r=at(t,n);return e.about_edge!=null?re(r,ie(t,e.about_edge,te)):Pt(r)}function Vn(t){return t>1e-9?1:t<-1e-9?-1:0}function kr(t,n,e){let r=0,o=0,s=1;Array.isArray(n)&&(r=Number(n[0])||0,o=Number(n[1])||0,s=Number(n[2])||0);let i=Math.hypot(r,o,s)||1;if(r/=i,o/=i,s/=i,Math.abs(Math.abs(s)-1)<1e-9)return Te(t*s,e);let a=Math.cos(t),c=Math.sin(t),u=1-a,f=a+r*r*u,l=r*o*u-s*c,m=o*r*u+s*c,p=a+o*o*u,b=[f,m,l,p,0,0];return lt(bt(e[0],e[1]),lt(b,bt(-e[0],-e[1])))}function wr(t){return Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"||Array.isArray(n))}function eu(t,n){if(t.length===1)return t[0];let e=Math.max(0,Math.min(1,n))*(t.length-1),r=Math.min(t.length-2,Math.floor(e));return en(t[r],t[r+1],e-r)}function Mr(t,n,e,r="both"){if(e==null)return;let o=(i,a)=>r==="fill"?{...i,fc:a}:r==="stroke"?{...i,sc:a}:{...i,sc:a,fc:a};if(wr(e)){let i=e.map(c=>ht(c,"#FFFFFF")),a=mt(t,n).filter(c=>Pe(t.get(c)));a.forEach((c,u)=>{let f=t.get(c);t.set({...f,style:o(f.style,eu(i,a.length>1?u/(a.length-1):0))})});return}let s=ht(e,"#FFFFFF");se(t,n,i=>o(i,s))}function Qi(t,n){for(let e of mt(t,n)){let r=t.get(e);if(Pe(r))return r.style}return t.get(n).style}function ge(t,n,e,r,o=!1){let s=at(t,n),i=e===0?s[2]-s[0]:s[3]-s[1];if(i<=1e-12)return;let a=r/i,c=Pt(s);oe(t,n,o?Jt(e===0?a:1,e===0?1:a,c):Jt(a,a,c))}function ea(t,n,e){var g,x;let r=ta(t,(g=e.mobject_or_point)!=null?g:te),o=ie(t,e.direction,Ji),s=ie(t,e.aligned_edge,te),i=S(e.buff,Sn),a=re(r,[s[0]+o[0],s[1]+o[1]]),c=re(at(t,n),[s[0]-o[0],s[1]-o[1]]),u=ms(e.direction),f=ms(e.aligned_edge),l=lo(t,(x=e.mobject_or_point)!=null?x:te),m=lo(t,n),p=(M,F)=>F>0?M[1]:F<0?M[0]:(M[0]+M[1])/2,b=p(l,f+u)-p(m,f-u)+i*u;hs(t,n,a[0]-c[0]+i*o[0],a[1]-c[1]+i*o[1],b)}function ms(t){return Array.isArray(t)&&Number(t[2])||0}function lo(t,n){if(Qt(n)){let e=Ge(t,tt(t,n));return[e[2],e[5]]}if(Array.isArray(n)&&typeof n[0]!="string"){let e=Number(n[2])||0;return[e,e]}try{let e=qt(t,n);return[e[2],e[2]]}catch(e){return[0,0]}}function hs(t,n,e,r,o){Math.abs(o)>1e-12?dn(t,n,ke(e,r,o)):De(t,n,[e,r])}function na(t,n,e){if(e.about_point!=null)return qt(t,e.about_point);let r=Ge(t,n);if(e.about_edge!=null){let o=Array.isArray(e.about_edge)?e.about_edge.map(Number):[0,0,0],s=(i,a,c)=>c>0?a:c<0?i:(i+a)/2;return[s(r[0],r[3],o[0]||0),s(r[1],r[4],o[1]||0),s(r[2],r[5],o[2]||0)]}return[(r[0]+r[3])/2,(r[1]+r[4])/2,(r[2]+r[5])/2]}function nu(t){if(!Array.isArray(t))return!0;let n=Number(t[0])||0,e=Number(t[1])||0,r=Number(t[2])||0;return Math.abs(n)<1e-12&&Math.abs(e)<1e-12&&r!==0}function us(t,n,e,r,o,s=!1){if(nu(r)&&!Ve(t,n)){oe(t,n,kr(e,r,s?te:uo(t,n,o)));return}let i=Array.isArray(r)?r.map(Number):[0,0,1];dn(t,n,Ke(i,e,s?[0,0,0]:na(t,n,o)))}var ru={three_d:!1,phi:0,theta:-Math.PI/2,gamma:0,zoom:1,focal:20,center:[0,0,0]};function ye(t){var n,e;return{...ru,...((e=(n=t.mobs.get(It))==null?void 0:n.data)==null?void 0:e.cam)||{}}}var mo={phi:"phi",theta:"theta",gamma:"gamma",zoom:"zoom",focal_distance:"focal"};function Sr(t){var e;let n=ye(t);for(let[r,o]of t.mobs){let s=o.kind==="value_tracker"&&((e=o.data)!=null&&e.camera)?mo[o.data.camera]:void 0;s&&o.data.value!==n[s]&&t.update(r,{data:{...o.data,value:n[s]}})}}function fo(t,n){var s;let e=t.get(n),r=(s=e.data)!=null&&s.camera?mo[e.data.camera]:void 0;if(!r)return;let o=t.get(It);t.update(It,{data:{...o.data||{},cam:{...ye(t),[r]:Number(e.data.value)}}})}function ds(t,n){let e={};return n.phi!=null&&(e.phi=S(n.phi,0)),n.theta!=null&&(e.theta=S(n.theta,-Math.PI/2)),n.gamma!=null&&(e.gamma=S(n.gamma,0)),n.zoom!=null&&(e.zoom=S(n.zoom,1)),n.focal_distance!=null&&(e.focal=S(n.focal_distance,20)),n.frame_center!=null&&(e.center=qt(t,n.frame_center)),e}function Zi(t,n,e,r,o){let s=[Vn(e[0])*o.fw/2,Vn(e[1])*o.fh/2],i=re(at(t,n),e);De(t,n,[(s[0]-i[0]-r*Vn(e[0]))*Math.abs(Vn(e[0])),(s[1]-i[1]-r*Vn(e[1]))*Math.abs(Vn(e[1]))])}function ou(t,n,e){let r=t.get(n).children,o=ie(t,e.direction,Ji),s=S(e.buff,Sn),i=e.aligned_edge!=null?ie(t,e.aligned_edge,te):te,a=Pt(at(t,n));for(let c=1;c<r.length;c++)ea(t,r[c],{mobject_or_point:r[c-1],direction:o,buff:s,aligned_edge:i});if(e.center!==!1){let c=Pt(at(t,n));De(t,n,[a[0]-c[0],a[1]-c[1]])}}function su(t,n,e){let r=t.get(n).children,o=r.length;if(!o)return;let s=Pt(at(t,n)),i=e.rows!=null?Number(e.rows):0,a=e.cols!=null?Number(e.cols):0;!i&&!a?(a=Math.ceil(Math.sqrt(o)),i=Math.ceil(o/a)):i?a||(a=Math.ceil(o/i)):i=Math.ceil(o/a);let c=Sn,u=Sn;Array.isArray(e.buff)?(c=S(e.buff[0],Sn),u=S(e.buff[1],Sn)):e.buff!=null&&(c=u=S(e.buff,Sn));let f=String(e.flow_order||"rd").toLowerCase(),l=A=>{let v=f[0],L=f[1]||(v==="r"||v==="l"?"d":"r");if(v==="r"||v==="l"){let K=A%a,D=Math.floor(A/a);return[L==="u"?i-1-D:D,v==="l"?a-1-K:K]}let T=A%i,O=Math.floor(A/i);return[v==="u"?i-1-T:T,L==="l"?a-1-O:O]},m=r.map((A,v)=>l(v)),p=0,b=0;for(let[A,v]of m)p=Math.max(p,A+1),b=Math.max(b,v+1);i=Math.min(i,p),a=Math.min(a,b);let g=r.map(A=>at(t,A)),x=new Array(a).fill(0),M=new Array(i).fill(0);g.forEach((A,v)=>{let[L,T]=m[v];L>=i||T>=a||(x[T]=Math.max(x[T],A[2]-A[0]),M[L]=Math.max(M[L],A[3]-A[1]))});let F=x.reduce((A,v)=>A+v,0)+c*(a-1),N=M.reduce((A,v)=>A+v,0)+u*(i-1),P=e.cell_alignment!=null?ie(t,e.cell_alignment,te):te;r.forEach((A,v)=>{let[L,T]=m[v];if(L>=i||T>=a)return;let O=-F/2+x.slice(0,T).reduce((G,U)=>G+U,0)+c*T+x[T]/2,K=N/2-M.slice(0,L).reduce((G,U)=>G+U,0)-u*L-M[L]/2,D=[s[0]+O+P[0]*x[T]/2,s[1]+K+P[1]*M[L]/2],j=re(g[v],P);De(t,A,[D[0]-j[0],D[1]-j[1]])})}var He={width:(t,n,e)=>ge(t,n,0,S(e,1)),height:(t,n,e)=>ge(t,n,1,S(e,1)),color:(t,n,e)=>Mr(t,n,e),fill_color:(t,n,e)=>{let r=ht(e,"#FFFFFF");se(t,n,o=>({...o,fc:r}))},stroke_color:(t,n,e)=>{let r=ht(e,"#FFFFFF");se(t,n,o=>({...o,sc:r}))},fill_opacity:(t,n,e)=>se(t,n,r=>({...r,fo:S(e,r.fo)})),stroke_opacity:(t,n,e)=>se(t,n,r=>({...r,so:S(e,r.so)})),stroke_width:(t,n,e)=>se(t,n,r=>({...r,sw:S(e,r.sw)})),opacity:(t,n,e)=>se(t,n,r=>({...r,fo:S(e,1),so:S(e,1)})),z_index:(t,n,e)=>{for(let r of mt(t,n))t.update(r,{z:S(e,0)})},x:(t,n,e)=>{let r=Pt(at(t,n));De(t,n,[S(e,0)-r[0],0])},y:(t,n,e)=>{let r=Pt(at(t,n));De(t,n,[0,S(e,0)-r[1]])}},bs={shift:{params:["*vectors"],run:(t,n,e)=>{let r=e.vectors||[],o=0,s=0,i=0;for(let a of r){let c=qt(t,a);o+=c[0],s+=c[1],i+=c[2]}hs(t,n,o,s,i)}},move_to:{params:["point_or_mobject","aligned_edge"],run:(t,n,e)=>{var f,l;let r=ie(t,e.aligned_edge,te),o=Qt(e.point_or_mobject)?re(at(t,tt(t,e.point_or_mobject)),r):Et(t,(f=e.point_or_mobject)!=null?f:te),s=re(at(t,n),r),i=Array.isArray(e.coor_mask)?[S(e.coor_mask[0],1),S(e.coor_mask[1],1),S(e.coor_mask[2],1)]:[1,1,1],a=ms(e.aligned_edge),c=m=>a>0?m[1]:a<0?m[0]:(m[0]+m[1])/2,u=(c(lo(t,(l=e.point_or_mobject)!=null?l:te))-c(lo(t,n)))*i[2];hs(t,n,(o[0]-s[0])*i[0],(o[1]-s[1])*i[1],u)}},center:{params:[],run:(t,n)=>{let e=Pt(at(t,n));De(t,n,[-e[0],-e[1]])}},next_to:{params:["mobject_or_point","direction","buff","aligned_edge"],run:(t,n,e)=>ea(t,n,e)},to_edge:{params:["edge","buff"],run:(t,n,e,r)=>Zi(t,n,ie(t,e.edge,[-1,0]),S(e.buff,qi),r)},to_corner:{params:["corner","buff"],run:(t,n,e,r)=>Zi(t,n,ie(t,e.corner,[-1,-1]),S(e.buff,qi),r)},align_to:{params:["mobject_or_point","direction"],run:(t,n,e)=>{let r=ie(t,e.direction,te),o=re(ta(t,e.mobject_or_point),r),s=re(at(t,n),r);De(t,n,[r[0]?o[0]-s[0]:0,r[1]?o[1]-s[1]:0])}},arrange:{params:["direction","buff","center"],run:(t,n,e)=>ou(t,n,e)},arrange_in_grid:{params:["rows","cols","buff"],run:(t,n,e)=>su(t,n,e)},scale:{params:["scale_factor","about_point","about_edge"],run:(t,n,e)=>{let r=e.scale_factor,o=Array.isArray(r)?S(r[0],1):S(r,1),s=Array.isArray(r)?S(r[1],1):o;Ve(t,n)?dn(t,n,Ys(o,s,Array.isArray(r)?S(r[2],1):o,na(t,n,e))):oe(t,n,Jt(o,s,uo(t,n,e)))}},rotate:{params:["angle","axis","about_point","about_edge"],run:(t,n,e)=>us(t,n,S(e.angle,0),e.axis,e)},rotate_about_origin:{params:["angle","axis"],run:(t,n,e)=>us(t,n,S(e.angle,0),e.axis,e,!0)},flip:{params:["axis","about_point","about_edge"],run:(t,n,e)=>{var r,o;return Ve(t,n)?us(t,n,Math.PI,(r=e.axis)!=null?r:[0,1,0],e):oe(t,n,kr(Math.PI,(o=e.axis)!=null?o:[0,1,0],uo(t,n,e)))}},set_camera_orientation:{params:["phi","theta","gamma","zoom","focal_distance","frame_center"],run:(t,n,e)=>{let r=t.get(It);t.update(It,{data:{...r.data||{},cam:{...ye(t),...ds(t,e),three_d:!0}}}),Sr(t)}},set_fill_by_checkerboard:{params:["colors","opacity"],run:(t,n,e)=>{var o;let r=(Array.isArray(e.colors)?e.colors:[e.colors]).filter(s=>s!=null).map(s=>ht(s,"#FFFFFF"));if(r.length)for(let s of mt(t,n)){let i=t.get(s),a=(o=i.data)==null?void 0:o.uv;Array.isArray(a)&&t.update(s,{style:{...i.style,fc:r[(a[0]+a[1])%r.length],fo:e.opacity!=null?S(e.opacity,i.style.fo):i.style.fo}})}}},apply_function:{params:["function"],run:(t,n,e)=>{var s,i;let r=(s=e.function)!=null?s:e.func;if(r==null)throw new Error("apply_function needs a function the preview can trace");let o=(a,c,u)=>{let f=gn([a,c,u],()=>Kt(t,r));return typeof f=="number"?[f,0,0]:[f[0]||0,f[1]||0,f[2]||0]};for(let a of mt(t,n)){let c=t.get(a);if(c.p3&&c.p3.length){let l=Ze(c),m=[];for(let p=0;p<l.length;p+=3)m.push(...o(l[p],l[p+1],l[p+2]));t.update(a,{p3:m,m3:[1,0,0,0,1,0,0,0,1,0,0,0],m:Mt});continue}if(!c.paths.length)continue;let u=(i=c.m3)!=null?i:Bt(c.m),f=c.paths.map(l=>({closed:l.closed,points:l.points.map(m=>o(...zt(u,m[0],m[1],0)))}));if(f.every(l=>l.points.every(m=>Math.abs(m[2])<1e-12)))t.update(a,{paths:f.map(l=>({closed:l.closed,points:l.points.map(m=>[m[0],m[1]])})),m:Mt,m3:void 0});else{let l=c.paths[0],m=[],p=l.points;for(let b=0;b+3<p.length;b+=3)for(let g=b===0?0:1;g<=8;g++){let x=g/8,M=1-x,F=M*M*M*p[b][0]+3*M*M*x*p[b+1][0]+3*M*x*x*p[b+2][0]+x*x*x*p[b+3][0],N=M*M*M*p[b][1]+3*M*M*x*p[b+1][1]+3*M*x*x*p[b+2][1]+x*x*x*p[b+3][1];m.push(...o(...zt(u,F,N,0)))}t.update(a,{paths:[],p3:m,closed3:!!l.closed,m3:[1,0,0,0,1,0,0,0,1,0,0,0],m:Mt})}}}},fix_in_frame:{params:[],run:(t,n)=>{for(let e of mt(t,n))t.update(e,{fixed:"frame"})}},unfix_from_frame:{params:[],run:(t,n)=>{for(let e of mt(t,n))t.update(e,{fixed:void 0})}},fix_orientation:{params:[],run:(t,n)=>{for(let e of mt(t,n))t.update(e,{fixed:"orientation"})}},unfix_orientation:{params:[],run:(t,n)=>{for(let e of mt(t,n))t.update(e,{fixed:void 0})}},set_shade_in_3d:{params:["value"],run:(t,n,e)=>{for(let r of mt(t,n))t.update(r,{shade3:e.value!==!1})}},set_fill_by_value:{params:["axes","colorscale","axis"],run:(t,n,e)=>{var f,l;let r=(e.colorscale||e.colors||[]).map((m,p,b)=>Array.isArray(m)?[ht(m[0],"#FFFFFF"),Number(m[1])]:[ht(m,"#FFFFFF"),p/Math.max(1,b.length-1)]).sort((m,p)=>m[1]-p[1]);if(!r.length)return;let o=Math.round(S(e.axis,2)),s=e.axes!=null?t.get(tt(t,e.axes)):null,i=(f=s==null?void 0:s.data)==null?void 0:f.axes,a=(l=s==null?void 0:s.data)==null?void 0:l.axes3,c=m=>{if(!i)return m[o];if(o===2)return a?a.z0+(m[2]-a.oz-(s.m3?s.m3[11]:0))/(a.sz||1):m[2];let p=Nt(le(s.m),[m[0],m[1]]);return o===0?i.x0+(p[0]-i.ox)/(i.sx||1):i.y0+(p[1]-i.oy)/(i.sy||1)},u=m=>{if(m<=r[0][1])return r[0][0];for(let p=0;p+1<r.length;p++){let[b,g]=r[p],[x,M]=r[p+1];if(m<=M)return en(b,x,(m-g)/(M-g||1))}return r[r.length-1][0]};for(let m of mt(t,n)){let p=t.get(m);if(!p.p3||!p.p3.length)continue;let b=Ze(p),g=b.length/3,x=[0,0,0];for(let F=0;F<b.length;F+=3)x[0]+=b[F]/g,x[1]+=b[F+1]/g,x[2]+=b[F+2]/g;let M=u(c(x));t.set({...p,style:{...p.style,fc:M,sc:p.style.sw>0?p.style.sc:M}})}}},stretch:{params:["factor","dim","about_point","about_edge"],run:(t,n,e)=>{let r=S(e.factor,1),o=S(e.dim,0);oe(t,n,Jt(o===0?r:1,o===1?r:1,uo(t,n,e)))}},scale_to_fit_width:{params:["width"],run:(t,n,e)=>ge(t,n,0,S(e.width,1))},scale_to_fit_height:{params:["height"],run:(t,n,e)=>ge(t,n,1,S(e.height,1))},set_width:{params:["width","stretch"],run:(t,n,e)=>ge(t,n,0,S(e.width,1),!!e.stretch)},set_height:{params:["height","stretch"],run:(t,n,e)=>ge(t,n,1,S(e.height,1),!!e.stretch)},stretch_to_fit_width:{params:["width"],run:(t,n,e)=>ge(t,n,0,S(e.width,1),!0)},stretch_to_fit_height:{params:["height"],run:(t,n,e)=>ge(t,n,1,S(e.height,1),!0)},set_x:{params:["x"],run:(t,n,e,r)=>He.x(t,n,e.x,r)},set_y:{params:["y"],run:(t,n,e,r)=>He.y(t,n,e.y,r)},set:{params:[],run:(t,n,e,r)=>{for(let o of Object.keys(e)){let s=He[o];if(!s)throw new Error(`set() does not know "${o}"`);s(t,n,e[o],r)}}},set_color:{params:["color"],run:(t,n,e)=>Mr(t,n,e.color)},set_fill:{params:["color","opacity"],run:(t,n,e)=>{wr(e.color)&&Mr(t,n,e.color,"fill");let r=e.color!=null&&!wr(e.color)?ht(e.color,"#FFFFFF"):null;se(t,n,o=>({...o,fc:r!=null?r:o.fc,fo:S(e.opacity,o.fo)}))}},set_stroke:{params:["color","width","opacity"],run:(t,n,e)=>{wr(e.color)&&Mr(t,n,e.color,"stroke");let r=e.color!=null&&!wr(e.color)?ht(e.color,"#FFFFFF"):null;se(t,n,o=>({...o,sc:r!=null?r:o.sc,sw:S(e.width,o.sw),so:S(e.opacity,o.so)}))}},set_opacity:{params:["opacity"],run:(t,n,e)=>He.opacity(t,n,e.opacity,null)},set_fill_opacity:{params:["opacity"],run:(t,n,e)=>He.fill_opacity(t,n,e.opacity,null)},set_stroke_width:{params:["width"],run:(t,n,e)=>He.stroke_width(t,n,e.width,null)},fade:{params:["darkness"],run:(t,n,e)=>{let r=1-S(e.darkness,.5);se(t,n,o=>({...o,fo:o.fo*r,so:o.so*r}))}},set_z_index:{params:["z_index"],run:(t,n,e,r)=>He.z_index(t,n,e.z_index,r)},become:{params:["mobject","match_height","match_width","match_depth","match_center","stretch"],run:(t,n,e)=>{let r=at(t,n);if(bn(t,n,tt(t,e.mobject)),e.match_height&&ge(t,n,1,r[3]-r[1],!!e.stretch),e.match_width&&ge(t,n,0,r[2]-r[0],!!e.stretch),e.match_center){let o=Pt(at(t,n)),s=Pt(r);De(t,n,[s[0]-o[0],s[1]-o[1]])}}},save_state:{params:[],run:(t,n)=>{let e=Je(t,n);t.update(n,{data:{...t.get(n).data||{},saved:e}})}},restore:{params:[],run:(t,n)=>{var o;let e=(o=t.get(n).data)==null?void 0:o.saved;if(e==null||!t.has(e))throw new Error("restore() needs save_state() first");let r=t.get(n).data;bn(t,n,e),t.update(n,{data:{...t.get(n).data||{},saved:r.saved}})}},put_start_and_end_on:{params:["start","end"],run:(t,n,e)=>{let r=Ut(t,n,"start"),o=Ut(t,n,"end"),s=Et(t,e.start),i=Et(t,e.end),a=[o[0]-r[0],o[1]-r[1]],c=[i[0]-s[0],i[1]-s[1]],u=Math.hypot(a[0],a[1])||1e-9,f=Math.hypot(c[0],c[1])/u,l=Math.atan2(c[1],c[0])-Math.atan2(a[1],a[0]),m=lt(bt(s[0],s[1]),lt(Te(l,te),lt(Jt(f,f,te),bt(-r[0],-r[1]))));oe(t,n,m)}},set_points:{params:["points","smooth"],run:(t,n,e)=>{let r=(e.points||[]).map(o=>Et(t,o));t.update(n,{paths:r.length?[e.smooth?sr(r,!1):_t(r,!1)]:[],m:Mt})}},set_z:{params:["z"],run:()=>{}},set_corner_radius:{params:["radius"],run:(t,n,e)=>ls(t,n,r=>{var o;return{...r,radius:S((o=e.radius)!=null?o:e.corner_radius,0)}})},set_border:{params:["color","width"],run:(t,n,e)=>ls(t,n,r=>{var o,s,i;return{...r,border:S((o=e.width)!=null?o:e.stroke_width,4)>0?{color:ht((s=e.color)!=null?s:"#FFFFFF","#FFFFFF"),width:S((i=e.width)!=null?i:e.stroke_width,4)}:void 0}})},crop:{params:["box"],run:(t,n,e)=>ls(t,n,r=>{var f,l;let o=(e.box||[0,0,1,1]).map(Number),s=[Math.max(0,o[0]),Math.max(0,o[1]),Math.min(1,o[2]),Math.min(1,o[3])],i=(f=r.fullW)!=null?f:r.w,a=(l=r.fullH)!=null?l:r.h,c=r.w/(i*((r.crop?r.crop[2]-r.crop[0]:1)||1)),u=r.h/(a*((r.crop?r.crop[3]-r.crop[1]:1)||1));return{...r,crop:s,w:i*(s[2]-s[0])*c,h:a*(s[3]-s[1])*u}})},set_shadow:{params:["blur","offset","color","opacity"],run:(t,n,e)=>{var i;let r=Array.isArray(e.offset)?e.offset.map(Number):[.05,-.08],o={blur:S(e.blur,.2),dx:r[0]||0,dy:r[1]||0,color:ht((i=e.color)!=null?i:"#000000","#000000"),opacity:S(e.opacity,.5)},s=o.blur<=0&&!o.dx&&!o.dy;for(let a of mt(t,n)){let c=t.get(a);Pe(c)&&t.set({...c,shadow:s?void 0:o})}}},apply_matrix:{params:["matrix","about_point"],run:(t,n,e)=>{let r=e.matrix,o=e.about_point!=null?Et(t,e.about_point):te,s=[r[0][0],r[1][0],r[0][1],r[1][1],0,0];oe(t,n,lt(bt(o[0],o[1]),lt(s,bt(-o[0],-o[1]))))}},add_coordinates:{params:["num_decimal_places"],run:(t,n,e)=>fs(t,n,{include_numbers:!0})},change_bar_values:{params:["values"],run:(t,n,e)=>fs(t,n,{values:e.values})},change_layout:{params:["layout","layout_scale","layout_config","root_vertex"],run:(t,n,e)=>fs(t,n,Object.fromEntries(Object.entries(e).filter(([,r])=>r!=null)))},set_value:{params:["value"],run:(t,n,e)=>{Ae(t,n,S(e.value,0)),fo(t,n)}},increment_value:{params:["value"],run:(t,n,e)=>{var r,o,s;Ae(t,n,Number((o=(r=t.get(n).data)==null?void 0:r.value)!=null?o:0)+S((s=e.value)!=null?s:e.d_value,0)),fo(t,n)}},surround:{params:["mobject","dim_to_match","stretch","buff","buffer_factor"],run:(t,n,e)=>{let r=at(t,tt(t,e.mobject)),o=S(e.buffer_factor,1.2),s=S(e.dim_to_match,0)===1?1:0,i=(s===0?r[2]-r[0]:r[3]-r[1])*o+2*S(e.buff,0);ge(t,n,s,i,!!e.stretch),e.stretch&&ge(t,n,s===0?1:0,(s===0?r[3]-r[1]:r[2]-r[0])*o+2*S(e.buff,0),!0);let a=Pt(at(t,n)),c=Pt(r);De(t,n,[c[0]-a[0],c[1]-a[1]])}},match_width:{params:["mobject"],run:(t,n,e)=>{let r=at(t,tt(t,e.mobject));ge(t,n,0,r[2]-r[0])}},match_height:{params:["mobject"],run:(t,n,e)=>{let r=at(t,tt(t,e.mobject));ge(t,n,1,r[3]-r[1])}},match_x:{params:["mobject"],run:(t,n,e,r)=>He.x(t,n,Pt(at(t,tt(t,e.mobject)))[0],r)},match_y:{params:["mobject"],run:(t,n,e,r)=>He.y(t,n,Pt(at(t,tt(t,e.mobject)))[1],r)},match_color:{params:["mobject"],run:(t,n,e)=>{let r=Qi(t,tt(t,e.mobject));se(t,n,o=>({...o,sc:r.sc,fc:r.fc}))}},match_style:{params:["mobject"],run:(t,n,e)=>{let r=Qi(t,tt(t,e.mobject));se(t,n,()=>({...r}))}},set_color_by_tex:{params:["tex","color","substring"],run:(t,n,e)=>{var r;for(let o of t.get(n).children){let s=(r=t.get(o).data)==null?void 0:r.tex;typeof s=="string"&&(e.substring===!1?s===e.tex:s.includes(String(e.tex)))&&Mr(t,o,e.color)}}},set_color_by_tex_to_color_map:{params:["texs_to_color_map"],run:(t,n,e)=>{let r=e.texs_to_color_map||{};for(let o of Object.keys(r))bs.set_color_by_tex.run(t,n,{tex:o,color:r[o]},null)}},add:{params:["*mobjects"],run:(t,n,e)=>{let r=(e.mobjects||[]).map(s=>tt(t,s)).filter(s=>s!==n),o=t.get(n).children.filter(s=>!r.includes(s));t.update(n,{children:[...o,...r]})}},remove:{params:["*mobjects"],run:(t,n,e)=>{let r=(e.mobjects||[]).map(o=>tt(t,o));t.update(n,{children:t.get(n).children.filter(o=>!r.includes(o))})}}},ra=Object.keys(bs);function ls(t,n,e){let r=!1;for(let o of mt(t,n)){let s=t.get(o);s.image&&(t.set({...s,image:e(s.image)}),r=!0)}if(!r)throw new Error("this works on images (ImageMobject)")}var ps=null;function oa(t){ps=t}function fs(t,n,e){var s;let r=t.get(n),o=(s=r.data)==null?void 0:s.props;if(!o||!ps)throw new Error(`this ${r.kind} cannot be rebuilt here`);ps(t,n,r.kind,{...o,...e}),oe(t,n,r.m),t.update(n,{z:r.z})}var iu={move_to:{target:"point_or_mobject"},next_to:{target:"mobject_or_point"},align_to:{target:"mobject_or_point"},scale:{factor:"scale_factor"},become:{source:"mobject"},surround:{target:"mobject"},match_width:{source:"mobject"},match_height:{source:"mobject"},match_x:{source:"mobject"},match_y:{source:"mobject"},match_color:{source:"mobject"},match_style:{source:"mobject"}};function Xe(t,n,e,r,o){let s=bs[e];if(!s)throw new Error(`"${e}" is not something the animation layer can do yet`);let i=de(r,s.params),a=iu[e];if(a)for(let c of Object.keys(a))c in i&&!(a[c]in i)&&(i[a[c]]=i[c],delete i[c]);e==="shift"&&i.vector!=null&&i.vectors==null&&(i.vectors=[i.vector]),s.run(t,n,i,o)}function au(t){return t&&typeof t=="object"&&!Array.isArray(t)&&"key"in t&&"kind"in t&&"props"in t}var cu=-1;function Un(t){let n=t[1]&&typeof t[1]=="object"?{...t[1]}:{};return Array.isArray(n.children)&&(n.children=n.children.map(e=>Pn(e)?Un(e):e)),{key:cu--,kind:String(t[0]),props:n,ops:Array.isArray(t[2])?t[2]:[]}}function Pn(t){if(!Array.isArray(t)||typeof t[0]!="string"||t.length<2||t.length>3)return!1;let n=t[1];return!n||typeof n!="object"||Array.isArray(n)||"$pt"in n||"$x"in n||"tmpl"in n||typeof n.id=="number"&&Object.keys(n).every(e=>e==="id"||e==="path")?!1:t.length===2||Array.isArray(t[2])}function Yn(t,n,e,r){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(i=>Yn(t,i,e,r));if(au(n))return po(t,n,e,r);if(Array.isArray(n.mobject)&&Pn(n.mobject)&&(n={...n,mobject:Un(n.mobject)}),Array.isArray(n.children)&&n.children.some(Pn)&&(n={...n,children:n.children.map(i=>Pn(i)?Un(i):i)}),"tmpl"in n&&Object.keys(n).every(i=>i==="tmpl"||i==="path")){let i=e.get(Number(n.tmpl));if(i==null)throw new Error("an object made inside an updater was used before it was made");return n.path&&n.path.length?{id:i,path:n.path}:i}let o=!1,s={};for(let i of Object.keys(n))s[i]=Yn(t,n[i],e,r),s[i]!==n[i]&&(o=!0);return o?s:n}function po(t,n,e,r,o){let s=e.get(n.key);if(s!=null)return s;let i=o!=null?o:t.newId();e.set(n.key,i);let a=Me(t,Yn(t,n.props,e,r));if(n.kind==="copy"?Je(t,tt(t,a.mobject),i):r.make(t,i,n.kind,a),!t.has(i))throw new Error(`${n.kind} could not be built here yet`);for(let[c,u]of n.ops||[])Xe(t,i,c,Me(t,Yn(t,u,e,r)),r.env);return i}function Er(t,n,e,r){let o=new Map,s=[];for(let i of n||[]){let[a,c,u]=i,f=u!=null?tt(t,Yn(t,u,o,r)):e;f!=null&&(Xe(t,f,String(a),Me(t,Yn(t,c,o,r)),r.env),s.push(f))}return s}var Pr=1/60,ho=class{constructor(){this.list=[];this.dtCache=new WeakMap;this.redrawCache=new Map}reset(){this.list=[],this.dtCache=new WeakMap,this.redrawCache.clear()}add(n,e,r){let o=e.uid!=null?String(e.uid):`u${this.list.length}`;this.list.push({uid:o,target:n,spec:e,from:r,to:1/0,off:[]})}remove(n,e,r){for(let o of this.list)o.target===n&&o.uid===String(e)&&o.to===1/0&&(o.to=r)}clear(n,e){for(let r of this.list)r.target===n&&r.to===1/0&&(r.to=e)}suspend(n,e){for(let r of this.list){if(r.target!==n||r.to!==1/0)continue;let o=r.off[r.off.length-1];(!o||o[1]!==1/0)&&r.off.push([e,1/0])}}resume(n,e){for(let r of this.list){let o=r.off[r.off.length-1];r.target===n&&o&&o[1]===1/0&&(o[1]=e)}}active(n){return this.list.filter(e=>e.from<=n&&n<e.to&&!e.off.some(([r,o])=>r<=n&&n<o))}apply(n,e,r,o){let s=[];for(let i of this.active(e))if(!(!n.has(i.target)&&i.spec.kind!=="redraw")){At.t=e,At.dt=0;try{if(i.spec.kind==="op"&&!i.spec.accumulate)s.push(...Er(n,i.spec.ops,i.target,o));else if(i.spec.kind==="redraw")this.redraw(n,i,o);else if((i.spec.kind==="dt"||i.spec.kind==="op")&&r)this.integrate(n,i,e,r,o);else{if(i.spec.kind==="python")continue;continue}}catch(a){continue}s.push(i.target)}return s}redraw(n,e,r){!e.spec.template&&e.spec.make&&Pn(e.spec.make)&&(e.spec.template=Un(e.spec.make));let o=e.spec.template,[s,i]=e.spec.make||[o?o.kind:"group",o||{}],a=Me(n,i),c=JSON.stringify(a),u=`${e.uid}|${e.target}`,f=this.redrawCache.get(u);if(f&&f.key===c){for(let b of f.mobs)n.set(b);return}let l=n.fork(),m=l.has(e.target)?l.get(e.target):null;if(o?po(l,o,new Map,r,e.target):r.make(l,e.target,s,a),!l.has(e.target))return;if(m&&(l.update(e.target,{z:m.z}),m.fixed))for(let b of mt(l,e.target))l.update(b,{fixed:m.fixed});let p=mt(l,e.target).map(b=>l.get(b));this.redrawCache.set(u,{key:c,mobs:p});for(let b of p)n.set(b)}integrate(n,e,r,o,s){var x,M,F,N,P,A,v,L;let i=Math.max(o.t0,e.from);if(r<=i)return;let a=this.dtCache.get(o);a||(a=new Map,this.dtCache.set(o,a));let c=`${e.uid}|${e.target}|${i}`,u=a.get(c);if(!u){let T=new Se(new Map(o.before.mobs),o.before.display.slice(),s.ids);if(!T.has(e.target))return;let O=T.get(e.target);u={states:[{m:O.m,value:Number((M=(x=O.data)==null?void 0:x.value)!=null?M:0)}],sim:T},a.set(c,u)}let f=(T,O,K)=>{At.t=K,At.dt=O,Er(T,e.spec.ops,e.target,s)},l=Math.floor((r-i)/Pr+1e-9);for(;u.states.length<=l;){f(u.sim,Pr,i+(u.states.length-1)*Pr);let T=u.sim.get(e.target);u.states.push({m:T.m,value:Number((N=(F=T.data)==null?void 0:F.value)!=null?N:0)})}let m=u.states[l],p=r-i-l*Pr;if(p>1e-9){let T=new Se(new Map(u.sim.mobs),u.sim.display.slice(),s.ids);T.update(e.target,{m:m.m,data:{...T.get(e.target).data||{},value:m.value}}),f(T,p,i+l*Pr);let O=T.get(e.target);m={m:O.m,value:Number((A=(P=O.data)==null?void 0:P.value)!=null?A:0)}}let b=u.states[0],g=lt(m.m,le(b.m));for(let T of mt(n,e.target)){let O=n.get(T);n.set({...O,m:lt(g,O.m)})}m.value!==b.value&&Ae(n,e.target,Number((L=(v=n.get(e.target).data)==null?void 0:v.value)!=null?L:0)+m.value-b.value),At.dt=0}activeUid(n,e){let r=this.list.filter(o=>o.uid===n);return r.length?r.some(o=>o.from<=e&&e<o.to&&!o.off.some(([s,i])=>s<=e&&e<i)):null}get any(){return this.list.length>0}};var uu=t=>t<0?0:t>1?1:t,sa=t=>1/(1+Math.exp(-t));function Gt(t,n=10){let e=sa(-n/2);return uu((sa(n*(t-.5))-e)/(1-2*e))}var xe=t=>t;function un(t){return Gt(t<.5?2*t:2*(1-t))}function lu(t,n){let e=t.length-1,r=0,o=1;for(let s=0;s<=e;s++)s>0&&(o=o*(e-s+1)/s),r+=o*Math.pow(1-n,e-s)*Math.pow(n,s)*t[s];return r}var Hn=Math.PI,yo=1.70158,bo=yo*1.525,ia=yo+1,aa=2*Hn/3,ca=2*Hn/4.5;function go(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}var gs={linear:xe,smooth:t=>Gt(t),smoothstep:t=>t<=0?0:t>=1?1:3*t*t-2*t*t*t,smootherstep:t=>t<=0?0:t>=1?1:t*t*t*(10-15*t+6*t*t),smoothererstep:t=>t<=0?0:t>=1?1:t**4*(35-84*t+70*t*t-20*t*t*t),rush_into:t=>2*Gt(t/2),rush_from:t=>2*Gt(t/2+.5)-1,slow_into:t=>Math.sqrt(1-(1-t)*(1-t)),double_smooth:t=>t<.5?.5*Gt(2*t):.5*(1+Gt(2*t-1)),there_and_back:un,there_and_back_with_pause:t=>{let n=.3333333333333333,e=1/n;return t<.5-n/2?Gt(e*t):t<.5+n/2?1:Gt(e-e*t)},running_start:t=>lu([0,0,-.5,-.5,1,1,1],t),not_quite_there:t=>.7*Gt(t),wiggle:t=>un(t)*Math.sin(2*Hn*t),lingering:t=>t<.8?t/.8:1,exponential_decay:t=>1-Math.exp(-t/.1),ease_in_sine:t=>1-Math.cos(t*Hn/2),ease_out_sine:t=>Math.sin(t*Hn/2),ease_in_out_sine:t=>-(Math.cos(Hn*t)-1)/2,ease_in_quad:t=>t*t,ease_out_quad:t=>1-(1-t)*(1-t),ease_in_out_quad:t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,ease_in_cubic:t=>t*t*t,ease_out_cubic:t=>1-Math.pow(1-t,3),ease_in_out_cubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,ease_in_quart:t=>t**4,ease_out_quart:t=>1-Math.pow(1-t,4),ease_in_out_quart:t=>t<.5?8*t**4:1-Math.pow(-2*t+2,4)/2,ease_in_quint:t=>t**5,ease_out_quint:t=>1-Math.pow(1-t,5),ease_in_out_quint:t=>t<.5?16*t**5:1-Math.pow(-2*t+2,5)/2,ease_in_expo:t=>t===0?0:Math.pow(2,10*t-10),ease_out_expo:t=>t===1?1:1-Math.pow(2,-10*t),ease_in_out_expo:t=>t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2,ease_in_circ:t=>1-Math.sqrt(1-t*t),ease_out_circ:t=>Math.sqrt(1-Math.pow(t-1,2)),ease_in_out_circ:t=>t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2,ease_in_back:t=>ia*t*t*t-yo*t*t,ease_out_back:t=>1+ia*Math.pow(t-1,3)+yo*Math.pow(t-1,2),ease_in_out_back:t=>t<.5?Math.pow(2*t,2)*((bo+1)*2*t-bo)/2:(Math.pow(2*t-2,2)*((bo+1)*(t*2-2)+bo)+2)/2,ease_in_elastic:t=>t===0?0:t===1?1:-Math.pow(2,10*t-10)*Math.sin((t*10-10.75)*aa),ease_out_elastic:t=>t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*aa)+1,ease_in_out_elastic:t=>t===0?0:t===1?1:t<.5?-(Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*ca))/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*ca)/2+1,ease_in_bounce:t=>1-go(1-t),ease_out_bounce:go,ease_in_out_bounce:t=>t<.5?(1-go(1-2*t))/2:(1+go(2*t-1))/2};function fu(t){let n=t.length-1;return e=>{if(e<=0)return t[0];if(e>=1)return t[n];let r=e*n,o=Math.floor(r);return t[o]+(t[o+1]-t[o])*(r-o)}}function xo(t,n=gs.smooth){if(t&&typeof t=="object"&&Array.isArray(t.samples)){let o=t.samples.map(Number);if(o.length>=2)return fu(o)}if(typeof t!="string"||!t)return n;let e=t.replace(/^rate_functions\./,"").replace(/^rate_func\./,"");e=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase();let r=gs[e];return r?e==="exponential_decay"?o=>o>1?1:r(o<0?0:o):o=>r(o<0?0:o>1?1:o):n}var ua=Object.keys(gs);var ys=[-7,-9,10];function la(t){let n=Math.cos(t),e=Math.sin(t);return[n,-e,0,e,n,0,0,0,1]}function mu(t){let n=Math.cos(t),e=Math.sin(t);return[1,0,0,0,n,-e,0,e,n]}function fa(t,n){let e=new Array(9).fill(0);for(let r=0;r<3;r++)for(let o=0;o<3;o++)for(let s=0;s<3;s++)e[r*3+o]+=t[r*3+s]*n[s*3+o];return e}function hu(t){if(!t||!t.three_d)return{three:!1,p:(a,c,u)=>[a,c,u]};let n=fa(fa(la(t.gamma),mu(-t.phi)),la(-t.theta-Math.PI/2)),[e,r,o]=t.center,s=t.focal,i=t.zoom;return{three:!0,p(a,c,u){a-=e,c-=r,u-=o;let f=n[0]*a+n[1]*c+n[2]*u,l=n[3]*a+n[4]*c+n[5]*u,m=n[6]*a+n[7]*c+n[8]*u,p=s-m>0?s/(s-m):1e6;return[f*p*i,l*p*i,m]}}}function pu(t,n,e){let r=[ys[0]-n[0],ys[1]-n[1],ys[2]-n[2]],o=Math.hypot(...r)||1,s=.5*Math.pow((e[0]*r[0]+e[1]*r[1]+e[2]*r[2])/o,3);return s<0&&(s*=.5),[t[0]+s,t[1]+s,t[2]+s]}function Xn(t,n,e){let r=Ln(t);if(!r)return t;let o=pu([r[0]/255,r[1]/255,r[2]/255],e,n),s=i=>Math.max(0,Math.min(255,Math.round(i*255))).toString(16).padStart(2,"0");return"#"+s(o[0])+s(o[1])+s(o[2])}function du(t){let n=t.length/3,e=Math.floor(4*n/6)*3,r=Math.floor(e/4)%n,o=e%4,s=(r+1)%n,i=o/3;return{start:[t[0],t[1],t[2]],end:[0,1,2].map(a=>t[3*r+a]+(t[3*s+a]-t[3*r+a])*i)}}function bu(t){let n=0,e=0,r=0,o=t.length/3;for(let i=0;i<o;i++){let a=(i+1)%o,c=t[3*i],u=t[3*i+1],f=t[3*i+2],l=t[3*a],m=t[3*a+1],p=t[3*a+2];n+=(u-m)*(f+p),e+=(f-p)*(c+l),r+=(c-l)*(u+m)}let s=Math.hypot(n,e,r)||1;return[n/s,e/s,r/s]}function gu(t,n,e,r){let o=r&&t.length>=6?[...t,t[0],t[1],t[2]]:t,s=o.length/3,i=[0];for(let m=1;m<s;m++)i.push(i[m-1]+Math.hypot(o[3*m]-o[3*m-3],o[3*m+1]-o[3*m-2],o[3*m+2]-o[3*m-1]));let a=i[s-1]||1,c=n*a,u=e*a,f=[],l=m=>{let p=1;for(;p<s-1&&i[p]<m;)p++;let b=(m-i[p-1])/(i[p]-i[p-1]||1);return[0,1,2].map(g=>o[3*(p-1)+g]+(o[3*p+g]-o[3*(p-1)+g])*b)};f.push(...l(c));for(let m=0;m<s;m++)i[m]>c&&i[m]<u&&f.push(o[3*m],o[3*m+1],o[3*m+2]);return f.push(...l(u)),f}function ln(t,n){if(!n)return;let e=he(n);if(e.every((s,i)=>Math.abs(s-t[i])<1e-12))return n;let r=e[0]*e[3]-e[1]*e[2],o=Math.abs(r)<1e-9?[1,0,0,1,t[4]-e[4],t[5]-e[5]]:lt(t,le(e));return Vt(Bt(o),n)}function ma(t,n,e,r){return t.p(n,e,r)[2]}function ha(t,n,e,r,o){var a,c;let s=hu(r),i=[];for(let u of n){if(u.fixed==="frame"&&s.three){i.push({it:u,depth:null,draw:(G,U)=>o({...u,m3:void 0},U)});continue}if(u.p3&&u.p3.length){let G=(a=u.m3)!=null?a:Bt(u.m),U=[];for(let nt=0;nt<u.p3.length;nt+=3)U.push(...zt(G,u.p3[nt],u.p3[nt+1],u.p3[nt+2]));let $=U;if(u.partial){if(u.partial[1]-u.partial[0]<=1e-9)continue;U=gu(U,u.partial[0],u.partial[1],!!u.closed3)}if(U.length<6)continue;let q=[];for(let nt=0;nt<U.length;nt+=3){let it=s.p(U[nt],U[nt+1],U[nt+2]);q.push(it[0],it[1])}let H=u.style,et=!!u.shade3&&s.three,st=null,Q=null;if(et){let nt=1/0,it=1/0,yt=1/0,Ct=-1/0,Ft=-1/0,Ht=-1/0;for(let wt=0;wt<$.length;wt+=3)nt=Math.min(nt,$[wt]),Ct=Math.max(Ct,$[wt]),it=Math.min(it,$[wt+1]),Ft=Math.max(Ft,$[wt+1]),yt=Math.min(yt,$[wt+2]),Ht=Math.max(Ht,$[wt+2]);if(st=ma(s,(nt+Ct)/2,(it+Ft)/2,(yt+Ht)/2),$.length>=9){let wt=bu($),{start:jt,end:ae}=du($);Q={a:s.p(...jt),b:s.p(...ae),fill:[Xn(H.fc,wt,jt),Xn(H.fc,wt,ae)],stroke:[Xn(H.sc,wt,jt),Xn(H.sc,wt,ae)]}}}let ot=!!u.closed3&&!u.partial;i.push({it:u,depth:st,draw:(nt,it)=>{let yt=u.alpha,Ct=ot?H.fo*yt:0,Ft=H.sw>0?H.so*yt:0;if(Ct<=0&&Ft<=0)return;nt.setTransform(it[0],it[1],it[2],it[3],it[4],it[5]),nt.beginPath(),nt.moveTo(q[0],q[1]);for(let wt=2;wt<q.length;wt+=2)nt.lineTo(q[wt],q[wt+1]);ot&&nt.closePath();let Ht=wt=>{if(!Q||wt[0]===wt[1])return wt[0];let jt=nt.createLinearGradient(Q.a[0],Q.a[1],Q.b[0],Q.b[1]);return jt.addColorStop(0,wt[0]),jt.addColorStop(1,wt[1]),jt};Ct>0&&(nt.globalAlpha=Math.min(1,Ct),nt.fillStyle=Q?Ht(Q.fill):H.fc,nt.fill()),Ft>0&&(nt.globalAlpha=Math.min(1,Ft),nt.strokeStyle=Q?Ht(Q.stroke):H.sc,nt.lineWidth=H.sw*.01*(r&&r.three_d?r.zoom:1),nt.stroke())}});continue}let f=(c=u.m3)!=null?c:Bt(u.m),l=zt(f,0,0,0),m=zt(f,1,0,0),p=zt(f,0,1,0),b,g,x;if(u.fixed==="orientation"&&s.three){b=s.p(l[0],l[1],l[2]);let G=he(f);g=[b[0]+G[0],b[1]+G[1],b[2]],x=[b[0]+G[2],b[1]+G[3],b[2]]}else b=s.p(l[0],l[1],l[2]),g=s.p(m[0],m[1],m[2]),x=s.p(p[0],p[1],p[2]);let M=[g[0]-b[0],g[1]-b[1],x[0]-b[0],x[1]-b[1],b[0],b[1]],F=m[0]-l[0],N=m[1]-l[1],P=m[2]-l[2],A=p[0]-l[0],v=p[1]-l[1],L=p[2]-l[2],T=Math.sqrt(Math.hypot(N*L-P*v,P*A-F*L,F*v-N*A))||1,O=hn(M)||1,K=u.style.sw>0?{...u.style,sw:u.style.sw*(O/T)}:u.style,D=null;if(u.shade3&&s.three){let G=1/0,U=1/0,$=-1/0,q=-1/0;for(let it of u.paths)for(let yt of it.points)G=Math.min(G,yt[0]),$=Math.max($,yt[0]),U=Math.min(U,yt[1]),q=Math.max(q,yt[1]);let H=G<=$?zt(f,(G+$)/2,(U+q)/2,0):l;D=ma(s,H[0],H[1],H[2]);let et=[m[0]-l[0],m[1]-l[1],m[2]-l[2]],st=[p[0]-l[0],p[1]-l[1],p[2]-l[2]],Q=[et[1]*st[2]-et[2]*st[1],et[2]*st[0]-et[0]*st[2],et[0]*st[1]-et[1]*st[0]],ot=Math.hypot(...Q)||1,nt=[Q[0]/ot,Q[1]/ot,Q[2]/ot];K={...K,fc:Xn(K.fc,nt,H),sc:Xn(K.sc,nt,H)}}let j={...u,m:M,m3:void 0,style:K};i.push({it:u,depth:D,draw:(G,U)=>o(j,U)})}if(s.three){let u=new Map(i.map((f,l)=>[f,l]));i.sort((f,l)=>f.depth==null||l.depth==null?f.depth==null&&l.depth==null?u.get(f)-u.get(l):f.depth==null?1:-1:f.depth-l.depth||u.get(f)-u.get(l))}for(let u of i)u.draw(t,e)}var En=class{constructor(n){this.scene=n;this.over=new Map;this.extras=[]}get(n){let e=this.over.get(n);if(e)return e;let r=this.scene.mobs.get(n);return r?(e={m:r.m,alpha:1,style:r.style,partial:null,...r.m3?{m3:r.m3}:{}},this.over.set(n,e),e):null}};function An(t,n,e){return e<=0?t:e>=1?n:{sc:en(t.sc,n.sc,e),fc:en(t.fc,n.fc,e),sw:t.sw+(n.sw-t.sw)*e,so:t.so+(n.so-t.so)*e,fo:t.fo+(n.fo-t.fo)*e}}var _a=t=>t<0?0:t>1?1:t;function Oe(t,n,e,r){if(e<=1||r<=0)return t;let o=(e-1)*r+1;return _a(t*o-n*r)}function yu(t){var o;let n=[];for(let s of t){if(s.p3&&s.p3.length){let a=Ze(s);for(let c=0;c<a.length;c+=3)n.push([a[c],a[c+1],a[c+2]]);s.closed3&&a.length>=6&&n.push([a[0],a[1],a[2]]);continue}let i=(o=s.m3)!=null?o:Bt(s.m);for(let a of s.paths){let c=a.points;for(let u=0;u+3<c.length;u+=3)for(let f=u===0?0:1;f<=16;f++){let l=f/16,m=1-l,p=m*m*m*c[u][0]+3*m*m*l*c[u+1][0]+3*m*l*l*c[u+2][0]+l*l*l*c[u+3][0],b=m*m*m*c[u][1]+3*m*m*l*c[u+1][1]+3*m*l*l*c[u+2][1]+l*l*l*c[u+3][1];n.push(zt(i,p,b,0))}}}if(!n.length)return()=>[0,0,0];let e=[0];for(let s=1;s<n.length;s++)e.push(e[s-1]+Math.hypot(n[s][0]-n[s-1][0],n[s][1]-n[s-1][1],n[s][2]-n[s-1][2]));let r=e[e.length-1];return s=>{if(r<=0)return n[0];let i=Math.max(0,Math.min(1,s))*r,a=0,c=e.length-1;for(;c-a>1;){let f=a+c>>1;e[f]<=i?a=f:c=f}let u=(i-e[a])/(e[c]-e[a]||1);return[0,1,2].map(f=>n[a][f]+(n[c][f]-n[a][f])*u)}}function fn(t,n,e){return(r,o,s,i)=>{let a=t.length;t.forEach((c,u)=>{let f=o.get(c);if(!f)return;let l=s(Oe(r,u,a,i));f.m=lt(n(l),f.m),e&&(f.alpha*=e(l))})}}function vr(t){return t.paths.length?ne(t.paths,t.m):[]}function Ms(t){var o;if(t.p3&&t.p3.length)return{pts:Ze(t),closed:!!t.closed3};let n=(o=t.m3)!=null?o:Bt(t.m),e=[],r=!1;for(let s of t.paths){let i=s.points;r=r||s.closed,i.length&&e.push(...zt(n,i[0][0],i[0][1],0));for(let a=0;a+3<i.length;a+=3)for(let c=1;c<=8;c++){let u=c/8,f=1-u,l=f*f*f*i[a][0]+3*f*f*u*i[a+1][0]+3*f*u*u*i[a+2][0]+u*u*u*i[a+3][0],m=f*f*f*i[a][1]+3*f*f*u*i[a+1][1]+3*f*u*u*i[a+2][1]+u*u*u*i[a+3][1];e.push(...zt(n,l,m,0))}}return{pts:e,closed:r}}function pa(t,n,e,r){var f;if(t.length<3){let l=[];for(let m=0;m<n;m++)l.push(r[0],r[1],(f=r[2])!=null?f:0);return l}let o=e?[...t,t[0],t[1],t[2]]:t,s=o.length/3,i=[0];for(let l=1;l<s;l++)i.push(i[l-1]+Math.hypot(o[3*l]-o[3*l-3],o[3*l+1]-o[3*l-2],o[3*l+2]-o[3*l-1]));let a=i[s-1]||1,c=[],u=1;for(let l=0;l<n;l++){let m=a*l/(e?n:Math.max(1,n-1));for(;u<s-1&&i[u]<m;)u++;let p=(m-i[u-1])/(i[u]-i[u-1]||1);for(let b=0;b<3;b++)c.push(o[3*(u-1)+b]+(o[3*u+b]-o[3*(u-1)+b])*Math.max(0,Math.min(1,p)))}return c}var _o=t=>({...t,so:0,fo:0});function Qn(t,n,e,r,o,s,i=0){let a=n.map(p=>t.mobs.get(p)),c=r.map(p=>e.mobs.get(p)),u=Math.max(a.length,c.length),f=[],l=-1,m=-1;for(let p=0;p<u;p++){let b=a.length?Math.floor(p*a.length/u):-1,g=c.length?Math.floor(p*c.length/u):-1,x=b>=0?a[b]:null,M=g>=0?c[g]:null,F=b===l,N=g===m;if(l=b,m=g,x&&(x.text||x.image)&&!x.paths.length||M&&(M.text||M.image)&&!M.paths.length){f.push({A:[],B:[],sa:x==null?void 0:x.style,sb:M==null?void 0:M.style,z:(M||x).z,fadeA:x&&!F?x:void 0,fadeB:M&&!N?M:void 0});continue}let P=M?N?_o(M.style):M.style:_o(x.style),A=x?F?_o(x.style):x.style:_o(M.style);if(x&&(x.p3||x.m3)||M&&(M.p3||M.m3)){let T=x?Ms(x):{pts:[],closed:!1},O=M?Ms(M):{pts:[],closed:!1},K=Math.max(T.pts.length/3,O.pts.length/3,4),D=(x?T.closed:O.closed)&&(M?O.closed:T.closed),j=pa(T.pts,K,D,[o[0],o[1],0]),G=pa(O.pts,K,D,[s[0],s[1],0]);f.push({A:[],B:[],A3:j,B3:G,closed3:D,shade3:!!(x!=null&&x.shade3||M!=null&&M.shade3),sa:A,sb:P,z:M?M.z:x.z});continue}let[v,L]=Vs(x?vr(x):[],M?vr(M):[],o,s);f.push({A:v,B:L,sa:A,sb:P,z:M?M.z:x.z,arc:i})}return f}function xu(t,n,e,r){if(e<=0)return t;if(e>=1)return n;let o=1/(2*Math.tan(r/2)),s=Math.cos(e*r),i=Math.sin(e*r);return t.map((a,c)=>({closed:e<.5?a.closed:n[c].closed,points:a.points.map((u,f)=>{let l=n[c].points[f],m=l[0]-u[0],p=l[1]-u[1],b=u[0]+m/2-p*o,g=u[1]+p/2+m*o,x=u[0]-b,M=u[1]-g;return[b+s*x-i*M,g+i*x+s*M]})}))}function Ar(t,n,e,r,o=[]){let s=t.length;return t.forEach((i,a)=>{let c=e(Oe(n,a,s,r));if(i.fadeA||i.fadeB){i.fadeA&&o.push(qn(i.fadeA,1-c)),i.fadeB&&o.push(qn(i.fadeB,c));return}if(i.A3){let f=c<=0?i.A3:c>=1?i.B3:i.A3.map((l,m)=>l+(i.B3[m]-l)*c);o.push({paths:[],m:Mt,m3:Xt,p3:f,closed3:i.closed3,shade3:i.shade3,style:An(i.sa,i.sb,c),alpha:1,partial:null,z:i.z});return}let u=i.arc&&Math.abs(i.arc)>1e-6?xu(i.A,i.B,c,i.arc):Oo(i.A,i.B,c);o.push({paths:u,m:Mt,style:An(i.sa,i.sb,c),alpha:1,partial:null,z:i.z})}),o}function qn(t,n){return{paths:t.paths,m:t.m,style:t.style,alpha:n,partial:null,z:t.z,text:t.text,image:t.image,shadow:t.shadow,evenodd:t.evenodd,...t.m3?{m3:t.m3}:{},...t.p3?{p3:t.p3,closed3:t.closed3}:{},...t.shade3?{shade3:!0}:{},...t.fixed?{fixed:t.fixed}:{}}}function da(t,n,e){for(let o of Array.from(t.mobs.values()))o.id!==e&&o.children.includes(n)&&t.update(o.id,{children:o.children.map(s=>s===n?e:s)});if(t.display.indexOf(n)>=0){let o=t.display.filter(s=>s!==e);o[o.indexOf(n)]=e,t.setDisplay(o)}else Ne(t,[n]),pe(t,[e])}function _u(t,n){return{sc:t.sw>0?t.sc:t.fc,fc:t.fc,sw:n,so:1,fo:0}}function xs(t,n,e,r){let o=t.get(n);if(!o)return;let s=t.scene.mobs.get(n);if(!s.paths.length&&!(s.p3&&s.p3.length)){o.alpha*=e;return}let i=_u(o.style,r);e<.5?(o.partial=[0,e*2],o.style=i):o.style=An(i,o.style,e*2-1)}function wu(t,n,e,r){let o=at(t,n),s=Pt(o);return r?[Fe(s,Math.hypot(o[2]-o[0],o[3]-o[1])/2+e)]:ne([_t($e(o[2]-o[0]+2*e,o[3]-o[1]+2*e),!0)],bt(s[0],s[1]))}function ba(t,n,e){let r=(n[2]-n[0])/(t[2]-t[0]||1),o=(n[3]-n[1])/(t[3]-t[1]||1);t[2]-t[0]<1e-9&&(r=o),t[3]-t[1]<1e-9&&(o=r),e||(r=o=Math.min(r,o));let s=[(t[0]+t[2])/2,(t[1]+t[3])/2],i=[(n[0]+n[2])/2,(n[1]+n[3])/2];return lt(bt(i[0]-s[0],i[1]-s[1]),Jt(r,o,s))}function Mu(t,n,e,r){if(Math.abs(r)<1e-6)return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e];let o=1/(2*Math.tan(r/2)),s=n[0]-t[0],i=n[1]-t[1],a=t[0]+s/2-i*o,c=t[1]+i/2+s*o,u=Math.cos(e*r),f=Math.sin(e*r),l=t[0]-a,m=t[1]-c;return[a+u*l-f*m,c+f*l+u*m]}function _s(t,n){let e=t*(1+n);return[Math.max(0,e-n),Math.min(1,e)]}var ku={apply_pointwise_function:["function"],apply_complex_function:["function"],homotopy:["homotopy"],complex_homotopy:["complex_homotopy"],apply_wave:["direction","amplitude"],swap:["*mobjects"],cyclic_replace:["*mobjects"],broadcast:["focal_point"],focus_on:["focus_point"],blink:["time_on","time_off","blinks","hide_at_end"],fade_in:["shift","target_position","scale"],fade_out:["shift","target_position","scale"],transform:["target_mobject","path_arc"],replacement_transform:["target_mobject","path_arc"],transform_from_copy:["target_mobject","path_arc"],transform_matching_tex:["target_mobject"],transform_matching_shapes:["target_mobject"],fade_transform:["target_mobject"],grow_from_point:["point"],grow_from_edge:["edge"],spin_in_from_nothing:["angle"],indicate:["scale_factor","color"],circumscribe:["shape","fade_in","fade_out","time_width","buff","color"],flash:["point","line_length","num_lines","flash_radius","line_stroke_width","color","time_width"],wiggle:["scale_value","rotation_angle","n_wiggles"],rotate:["angle","axis","about_point","about_edge"],move_along_path:["path"],animate:["ops"],change_decimal_to_value:["number"],move_camera:["phi","theta","gamma","zoom","focal_distance","frame_center"],changing_decimal:["function"],show_passing_flash:["time_width"],draw_border_then_fill:["stroke_width"]},wa=["create","uncreate","write","unwrite","draw_border_then_fill","fade_in","fade_out","transform","replacement_transform","transform_from_copy","transform_matching_tex","transform_matching_shapes","fade_transform","grow_from_center","grow_from_point","grow_from_edge","grow_arrow","shrink_to_center","spin_in_from_nothing","indicate","circumscribe","flash","wiggle","rotate","move_along_path","animate","show_passing_flash","restore","change_decimal_to_value","apply_pointwise_function","apply_complex_function","homotopy","complex_homotopy","apply_wave","show_increasing_subsets","show_submobjects_one_by_one","add_text_letter_by_letter","remove_text_letter_by_letter","swap","cyclic_replace","fade_transform_pieces","broadcast","blink","focus_on","change_speed","changing_decimal","move_camera","wait","group","lagged","succession"],Su={_animate:"animate",_method_animation:"animate",method_animation:"animate",move_to_target:"transform",rotating:"rotate",show_creation:"create",clockwise_transform:"transform",counterclockwise_transform:"transform",lagged_start:"lagged",animation_group:"group"};function Mo(t){let n=String(t||"").replace(/^\./,"_").replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase();return Su[n]||n}var Pu=new Set(["wait","flash","transform_from_copy","broadcast","focus_on","swap","cyclic_replace","fade_transform","fade_transform_pieces"]);function Eu(t,n){let e=Au(t,n),r=Mo(t.kind);if(!e.begin&&!Pu.has(r)&&t.target!=null&&t.target!==0){let o=tt(n.w,t.target);e.begin=s=>{Bo(s,o)||pe(s,[o])}}return e}function Au(t,n){var a,c,u,f,l,m,p,b,g,x,M,F,N;let e=n.w,r=Mo(t.kind),o=de(t.args,ku[r]||[]);o.to!=null&&o.target_mobject==null&&(o.target_mobject=o.to);let s=()=>tt(e,t.target),i=P=>({run:1,rate:Gt,lag:0,...P});switch(r){case"wait":return i({run:S((a=o.duration)!=null?a:t.run_time,1),apply:()=>{}});case"fade_in":case"fade_out":{let P=s(),A=dt(e,P),v=Ot(e,P),L=o.shift!=null?Et(e,o.shift):[0,0],T=S(o.scale,1);if(r==="fade_in"){let K=lt(Jt(T,T,[v[0]-L[0],v[1]-L[1]]),bt(-L[0],-L[1]));if(o.target_position!=null){let D=Qt(o.target_position)?Ot(e,tt(e,o.target_position)):Et(e,o.target_position);K=bt(D[0]-v[0],D[1]-v[1])}return i({intro:!0,target:P,apply:fn(A,D=>We(K,Mt,D),D=>D),begin:D=>pe(D,[P])})}let O=lt(Jt(T,T,[v[0]+L[0],v[1]+L[1]]),bt(L[0],L[1]));return i({apply:fn(A,K=>We(Mt,O,K),K=>1-K),end:K=>Ne(K,[P])})}case"create":case"uncreate":case"show_passing_flash":{let P=s(),A=dt(e,P),v=S(o.time_width,.1),L=r==="create"?O=>[0,O]:r==="uncreate"?O=>[0,1-O]:O=>_s(O,v),T=(O,K,D,j)=>{A.forEach((G,U)=>{let $=K.get(G);if(!$)return;let q=D(Oe(O,U,A.length,j)),H=K.scene.mobs.get(G);if(!H.paths.length&&!(H.p3&&H.p3.length)){$.alpha*=r==="create"?q:1-q;return}$.partial=L(q)})};return i(r==="create"?{lag:1,intro:!0,target:P,apply:T,begin:O=>pe(O,[P])}:r==="uncreate"?{lag:1,apply:T,end:O=>Ne(O,[P])}:{apply:T,intro:!0,target:P,begin:O=>pe(O,[P]),end:O=>Ne(O,[P])})}case"write":case"unwrite":case"draw_border_then_fill":{let P=s(),A=dt(e,P),v=A.length,L=S(o.stroke_width,2);if(r==="draw_border_then_fill")return i({run:2,rate:xo("double_smooth"),intro:!0,target:P,apply:(j,G,U,$)=>A.forEach((q,H)=>xs(G,q,U(Oe(j,H,v,$)),L)),begin:j=>pe(j,[P])});let T=0;for(let j of A){let G=e.get(j).text;T+=G?Math.max(1,Array.from(G.str).filter(U=>U.trim()).length):1}let O=T<15?1:2,K=Math.min(4/Math.max(1,T),.2),D=j=>(r==="write"?o.reverse:o.reverse!==!1)?v-1-j:j;return i(r==="write"?{run:O,rate:xe,lag:K,intro:!0,target:P,apply:(j,G,U,$)=>A.forEach((q,H)=>xs(G,q,U(Oe(j,D(H),v,$)),L)),begin:j=>pe(j,[P])}:{run:O,rate:xe,lag:K,apply:(j,G,U,$)=>A.forEach((q,H)=>xs(G,q,1-U(Oe(j,D(H),v,$)),L)),end:j=>Ne(j,[P])})}case"transform":case"replacement_transform":case"transform_from_copy":case"transform_matching_shapes":case"transform_matching_tex":{let P=s(),A=tt(e,o.target_mobject),v=Ot(e,P),L=Ot(e,A);if(r==="transform_matching_tex"||r==="transform_matching_shapes"){let j=r==="transform_matching_tex"?vu(e,P,A,v,L):Ru(e,P,A,v,L);if(j)return i({apply:(G,U,$)=>{let q=U.get(P);if(!q)return;let H=$(G),et=Ar(j.pairs,G,$,0);for(let Q of j.out)et.push(qn(U.scene.mobs.get(Q)||e.get(Q),1-H));for(let Q of j.in)et.push(qn(e.get(Q),H));q.replace=et;let st=U.get(A);st&&A!==P&&(st.hidden=!0)},end:G=>da(G,P,A)})}let T=Qn(e,dt(e,P),e,dt(e,A),L,v,S(o.path_arc,0)),O=r==="transform_from_copy"?A:P,K=mt(e,P).filter(j=>j!==P),D=(j,G,U,$)=>{let q=G.get(O);if(q){if(q.replace=Ar(T,j,U,$),r!=="transform_from_copy")for(let H of K){let et=G.get(H);et&&(et.hidden=!0)}if(r!=="transform_from_copy"&&A!==P){let H=G.get(A);H&&(H.hidden=!0)}}};return i(r==="transform"?{apply:D,end:j=>bn(j,P,A)}:r==="transform_from_copy"?{apply:D,intro:!0,target:A,begin:j=>pe(j,[A])}:{apply:D,end:j=>da(j,P,A)})}case"grow_from_center":case"grow_from_point":case"grow_from_edge":case"grow_arrow":case"spin_in_from_nothing":case"shrink_to_center":{let P=s(),A=dt(e,P),v=Ot(e,P);r==="grow_from_point"&&(v=Qt(o.point)?Ot(e,tt(e,o.point)):Et(e,(c=o.point)!=null?c:[0,0])),r==="grow_from_edge"&&(v=re(at(e,P),ie(e,o.edge,[0,-1]))),r==="grow_arrow"&&(v=Ut(e,P,"start"));let L=[0,0,0,0,v[0],v[1]];if(r==="shrink_to_center")return i({apply:fn(A,j=>We(Mt,L,j)),end:j=>oe(j,P,L)});let T=r==="spin_in_from_nothing"?S(o.angle,Math.PI/2):0,K=fn(A,j=>T?lt(Te(-(1-j)*T,v),Jt(j,j,v)):We(L,Mt,j));return i({intro:!0,target:P,apply:r!=="grow_arrow"?K:(j,G,U,$)=>{K(j,G,U,$),A.forEach((q,H)=>{let et=G.get(q);et&&(et.style={...et.style,sw:et.style.sw*U(Oe(j,H,A.length,$))})})},begin:j=>pe(j,[P])})}case"restore":{let P=s(),A=(u=e.get(P).data)==null?void 0:u.saved;if(A==null||!e.has(A))throw new Error("Restore needs save_state() first");let v=Qn(e,dt(e,P),e,dt(e,A),Ot(e,A),Ot(e,P),S(o.path_arc,0)),L=e.get(P).data;return i({apply:(T,O,K,D)=>{let j=O.get(P);j&&(j.replace=Ar(v,T,K,D))},end:T=>{bn(T,P,A),T.update(P,{data:{...T.get(P).data||{},saved:L.saved}})}})}case"indicate":{let P=s(),A=dt(e,P),v=Ot(e,P),L=S(o.scale_factor,1.2),T=ht((f=o.color)!=null?f:ar,ar);return i({rate:un,apply:(O,K,D,j)=>A.forEach((G,U)=>{let $=K.get(G);if(!$)return;let q=D(Oe(O,U,A.length,j));$.m=lt(Jt(1+(L-1)*q,1+(L-1)*q,v),$.m),$.style=An($.style,{...$.style,sc:T,fc:T},q)})})}case"circumscribe":{let P=s(),A=wu(e,P,S(o.buff,.1),String(o.shape||"").toLowerCase()==="circle"),v=ht((l=o.color)!=null?l:tn,tn),L=S(o.time_width,.3),T={sc:v,fc:v,sw:S(o.stroke_width,4),so:1,fo:0};return i({rate:xe,apply:(O,K,D)=>{let j=Gt(D(O)),G,U=1;o.fade_out?(G=[0,Math.min(1,j*2)],U=j<.5?1:2-2*j):o.fade_in?(G=[0,1],U=j<.5?2*j:2-2*j):G=_s(j,L),K.extras.push({paths:A,m:Mt,style:T,alpha:U,partial:G,z:1e6})}})}case"flash":{let P=t.target!=null?t.target:o.point,A=Qt(P)?Ot(e,tt(e,P)):Et(e,P!=null?P:[0,0]),v=Math.max(1,Math.round(S(o.num_lines,12))),L=S(o.flash_radius,.1)+.2,T=S(o.line_length,.2),O=ht((m=o.color)!=null?m:tn,tn),K=S(o.time_width,1),D={sc:O,fc:O,sw:S(o.line_stroke_width,3),so:1,fo:0},j=[];for(let G=0;G<v;G++){let U=2*Math.PI*G/v,$=Math.cos(U),q=Math.sin(U);j.push(_t([[A[0]+$*L,A[1]+q*L],[A[0]+$*(L+T),A[1]+q*(L+T)]],!1))}return i({rate:xe,apply:(G,U,$)=>{let q=_s(Gt($(G)),K);for(let H of j)U.extras.push({paths:[H],m:Mt,style:D,alpha:1,partial:q,z:1e6})}})}case"wiggle":{let P=s(),A=dt(e,P),v=Ot(e,P),L=S(o.scale_value,1.1),T=S(o.rotation_angle,.01*2*Math.PI),O=S(o.n_wiggles,6);return i({run:2,apply:fn(A,K=>{let D=1+(L-1)*un(K);return lt(Te(un(K)*Math.sin(O*Math.PI*K)*T,v),Jt(D,D,v))})})}case"rotate":{let P=s(),A=dt(e,P),v=S(o.angle,Math.PI),L=Array.isArray(o.axis)?o.axis.map(Number):[0,0,1];if(!(Math.abs(L[0])<1e-12&&Math.abs(L[1])<1e-12)||Ve(e,P)){let O=Ge(e,P),K=o.about_point!=null?qt(e,o.about_point):[(O[0]+O[3])/2,(O[1]+O[4])/2,(O[2]+O[5])/2],D=L;return i({apply:(j,G,U,$)=>A.forEach((q,H)=>{var Q,ot;let et=G.get(q);if(!et)return;let st=Ke(D,v*U(Oe(j,H,A.length,$)),K);et.m3=Vt(st,(ot=ln(et.m,(Q=et.m3)!=null?Q:G.scene.mobs.get(q).m3))!=null?ot:Bt(et.m)),et.m=he(et.m3)}),end:j=>dn(j,P,Ke(D,v,K))})}let T=o.about_point!=null?Et(e,o.about_point):o.about_edge!=null?re(at(e,P),ie(e,o.about_edge,[0,0])):Ot(e,P);return i({apply:fn(A,O=>kr(v*O,o.axis,T)),end:O=>oe(O,P,kr(v,o.axis,T))})}case"move_along_path":{let P=s(),A=dt(e,P),v=Ot(e,P),L=tt(e,o.path),T=dt(e,L).map(D=>e.get(D));if(Ve(e,P)||T.some(D=>D.p3||D.m3)){let D=_r(e,P,"center"),j=yu(T),G=U=>{let $=j(U);return ke($[0]-D[0],$[1]-D[1],$[2]-D[2])};return i({apply:(U,$,q)=>{var et,st;let H=G(q(U));for(let Q of A){let ot=$.get(Q);ot&&(ot.m3=Vt(H,(st=ln(ot.m,(et=ot.m3)!=null?et:$.scene.mobs.get(Q).m3))!=null?st:Bt(ot.m)),ot.m=he(ot.m3))}},end:U=>dn(U,P,G(1))})}let O=[];for(let D of dt(e,L))O.push(...vr(e.get(D)));let K=D=>{let j=Qe(O,D);return bt(j[0]-v[0],j[1]-v[1])};return i({apply:fn(A,K),end:D=>oe(D,P,K(1))})}case"apply_pointwise_function":case"apply_complex_function":case"homotopy":case"complex_homotopy":case"apply_wave":{let P=s(),A=dt(e,P),v=(b=(p=o.function)!=null?p:o.func)!=null?b:o.homotopy,L=A.map(G=>({id:G,mob:e.get(G),paths:vr(e.get(G))})),T=r==="apply_complex_function"||r==="complex_homotopy",O=r==="homotopy"||r==="complex_homotopy",K=(G,U)=>{At.alpha=U,At.homotopy=O;let $=gn(G,()=>Kt(e,v));return At.homotopy=!1,T&&typeof $!="number"?[$[0],$[1]]:typeof $=="number"?[$,0]:[$[0],$[1]]},D=(G,U)=>G.map($=>({closed:$.closed,points:$.points.map(U)}));if(r==="apply_wave"){let G=at(e,P),U=ie(e,o.direction,[0,1]),$=S(o.amplitude,.2),q=S(o.time_width,1),H=Math.max(1,S(o.ripples,1)),et=G[2]-G[0]||1,st=(Q,ot)=>{let nt=(Q-(ot*(1+q)-q))/q;return nt<=0||nt>=1?0:H===1?un(nt):Math.sin(H*Math.PI*nt)*un(nt)};return i({run:2,apply:(Q,ot,nt)=>{let it=nt(Q);for(let yt of L){let Ct=ot.get(yt.id);if(!Ct)continue;let Ft=D(yt.paths,Ht=>{let wt=$*st((Ht[0]-G[0])/et,it);return[Ht[0]+U[0]*wt,Ht[1]+U[1]*wt]});Ct.replace=[{paths:Ft,m:Mt,style:Ct.style,alpha:Ct.alpha,partial:null,z:yt.mob.z}]}}})}if(v==null)throw new Error(`${t.kind} needs a function the preview can trace`);if(A.some(G=>{let U=e.get(G);return!!(U.p3||U.m3)})){let G=(H,et)=>{At.alpha=et,At.homotopy=O;let st=[];for(let Q=0;Q<H.length;Q+=3){let ot=gn([H[Q],H[Q+1],H[Q+2]],()=>Kt(e,v));typeof ot=="number"?st.push(ot,0,0):st.push(ot[0]||0,ot[1]||0,T?H[Q+2]:ot[2]||0)}return At.homotopy=!1,st},U=A.map(H=>({id:H,mob:e.get(H),...Ms(e.get(H))})),$=O?null:U.map(H=>G(H.pts,1)),q=(H,et,st)=>({paths:[],m:Mt,m3:Xt,p3:et,closed3:H.closed,shade3:H.mob.shade3,style:st.style,alpha:st.alpha,partial:null,z:H.mob.z});return i({run:3,apply:(H,et,st)=>{let Q=st(H);U.forEach((ot,nt)=>{let it=et.get(ot.id);if(!it)return;let yt=O?G(ot.pts,Q):ot.pts.map((Ct,Ft)=>Ct+($[nt][Ft]-Ct)*Q);it.replace=[q(ot,yt,it)]})},end:H=>U.forEach((et,st)=>{H.has(et.id)&&H.update(et.id,{paths:[],p3:O?G(et.pts,1):$[st],closed3:et.closed,m3:Xt,m:Mt})})})}let j=O?null:L.map(G=>D(G.paths,U=>K(U,1)));return i({run:3,apply:(G,U,$)=>{let q=$(G);L.forEach((H,et)=>{let st=U.get(H.id);if(!st)return;let Q=O?D(H.paths,ot=>K(ot,q)):Oo(H.paths,j[et],q);st.replace=[{paths:Q,m:Mt,style:st.style,alpha:st.alpha,partial:null,z:H.mob.z}]})},end:G=>L.forEach((U,$)=>{if(!G.has(U.id))return;let q=O?D(U.paths,H=>K(H,1)):j[$];G.update(U.id,{paths:q,m:Mt})})})}case"show_increasing_subsets":case"show_submobjects_one_by_one":case"add_text_letter_by_letter":case"remove_text_letter_by_letter":{let P=s(),A=r.endsWith("letter_by_letter")?dt(e,P):e.get(P).children,v=A.length,L=A.map(D=>mt(e,D)),T=r==="remove_text_letter_by_letter",O=r.endsWith("letter_by_letter")?Math.max(.06,S(o.time_per_char,.1)*v):1,K=(D,j,G)=>{let U=G(D)*v,q=(o.int_func?o.int_func==="ceil":r.endsWith("letter_by_letter"))?Math.ceil(U-1e-9):Math.floor(U+1e-9);T&&(q=v-q),L.forEach((H,et)=>{if(r==="show_submobjects_one_by_one"?et!==Math.min(v-1,q):et>=q)for(let Q of H){let ot=j.get(Q);ot&&(ot.hidden=!0)}})};return i(T?{run:O,rate:xe,apply:K,end:D=>Ne(D,[P])}:{run:O,rate:r.endsWith("letter_by_letter")?xe:Gt,intro:!0,target:P,apply:K,begin:D=>pe(D,[P])})}case"swap":case"cyclic_replace":{let P=[...t.target!=null?[s()]:[],...(o.mobjects||[]).map(T=>tt(e,T))],A=S(o.path_arc,Math.PI/2),v=P.map(T=>Ot(e,T)),L=P.map((T,O)=>{let K=v[O],D=v[(O+1)%P.length];return{id:T,ids:dt(e,T),at:j=>{let G=Mu(K,D,j,A);return bt(G[0]-K[0],G[1]-K[1])}}});return i({apply:(T,O,K,D)=>{for(let j of L)fn(j.ids,j.at)(T,O,K,D)},end:T=>{for(let O of L)oe(T,O.id,O.at(1))}})}case"fade_transform":case"fade_transform_pieces":{let P=s(),A=tt(e,o.target_mobject),v=o.stretch!==!1,T=(r==="fade_transform_pieces"&&e.get(P).children.length===e.get(A).children.length&&e.get(P).children.length?e.get(P).children.map((O,K)=>[O,e.get(A).children[K]]):[[P,A]]).map(([O,K])=>{let D=at(e,O),j=at(e,K);return{s:dt(e,O),d:dt(e,K),toB:ba(D,j,v),toA:ba(j,D,v)}});return i({apply:(O,K,D)=>{let j=D(O);for(let G of T){for(let U of G.s){let $=K.get(U);$&&($.m=lt(We(Mt,G.toB,j),$.m),$.alpha*=1-j)}for(let U of G.d){let $=K.get(U);$&&($.m=lt(We(G.toA,Mt,j),$.m),$.alpha*=j)}}},begin:O=>pe(O,[A]),end:O=>Ne(O,[P])})}case"broadcast":{let P=s(),A=dt(e,P),v=Ot(e,P),L=o.focal_point!=null?Et(e,o.focal_point):v,T=Math.max(1,Math.round(S(o.n_mobs,5))),O=at(e,P),K=S(o.initial_width,0)/(O[2]-O[0]||1),D=S(o.initial_opacity,1),j=S(o.final_opacity,0),G=A.map(U=>e.get(U));return i({run:3,lag:S((g=t.lag_ratio)!=null?g:o.lag_ratio,.2),apply:(U,$,q,H)=>{for(let et=0;et<T;et++){let st=q(Oe(U,et,T,H));if(st<=0||st>=1)continue;let Q=K+(1-K)*st,ot=lt(Jt(Q,Q,L),bt(L[0]-v[0],L[1]-v[1]));for(let nt of G)$.extras.push({paths:nt.paths,m:lt(ot,nt.m),style:nt.style,alpha:D+(j-D)*st,partial:null,z:nt.z,text:nt.text})}}})}case"blink":{let P=s(),A=dt(e,P),v=S(o.time_on,.5),L=S(o.time_off,.5),T=Math.max(1,Math.round(S(o.blinks,1))),O=!!o.hide_at_end,K=v+T*(L+v)-(O?v:0);return i({run:K,rate:xe,apply:(D,j)=>{let G=D*K;if(D>=1?O:G>=v&&(G-v)%(L+v)<L)for(let $ of A){let q=j.get($);q&&(q.alpha=0)}},end:O?D=>se(D,P,j=>({...j,fo:0,so:0})):void 0})}case"focus_on":{let P=t.target!=null?t.target:o.focus_point,A=Qt(P)?Ot(e,tt(e,P)):Et(e,P!=null?P:[0,0]),v=ht((x=o.color)!=null?x:"#888888","#888888"),L=S(o.opacity,.2),T=Math.hypot(n.env.fw,n.env.fh);return i({run:2,apply:(O,K,D)=>{let j=D(O),G=Math.max(.001,T*(1-j));K.extras.push({paths:[Fe(A,G)],m:Mt,style:{sc:v,fc:v,sw:0,so:0,fo:L*j},alpha:1,partial:null,z:1e6})}})}case"animate":return xa(t,o,n);case"move_camera":{let P=ye(e),A={...P,...ds(e,o),three_d:!0};return i({apply:(v,L,T)=>{var D;let O=L.get(It);if(!O)return;let K=T(v);O.cam=Iu((D=O.cam)!=null?D:P,A,K)},end:v=>{let L=v.get(It);v.update(It,{data:{...L.data||{},cam:A}}),Sr(v)}})}case"change_decimal_to_value":return xa(t,{ops:[["set_value",[(F=(M=o.number)!=null?M:o.value)!=null?F:o.target_number]]]},n);case"changing_decimal":{let P=s(),A=(N=o.function)!=null?N:o.number_update_func,v=new Se(new Map(e.mobs),e.display.slice(),e.ids),L=T=>(At.alpha=T,Number(Kt(e,A)));return i({apply:(T,O,K)=>{let D=O.get(P);if(!D)return;let j=v.fork();Ae(j,P,L(K(T))),D.replace=dt(j,P).map(G=>qn(j.get(G),D.alpha))},end:T=>Ae(T,P,L(1))})}}throw new Error(`the animation layer cannot play "${r}" yet`)}function vu(t,n,e,r,o){let s=t.get(n).children.filter(l=>{var m;return typeof((m=t.get(l).data)==null?void 0:m.tex)=="string"}),i=t.get(e).children.filter(l=>{var m;return typeof((m=t.get(l).data)==null?void 0:m.tex)=="string"});if(!s.length||!i.length)return null;let a=new Set,c=[],u=[];for(let l of i){let m=t.get(l).data.tex.trim(),p=s.find(b=>!a.has(b)&&t.get(b).data.tex.trim()===m);p!=null?(a.add(p),c.push(...Qn(t,dt(t,p),t,dt(t,l),o,r))):u.push(...dt(t,l))}let f=[];for(let l of s)a.has(l)||f.push(...dt(t,l));return{pairs:c,in:u,out:f}}function ga(t,n,e){var u,f,l,m;let r=(p,b)=>p+(b-p)*e,o=t.crop||[0,0,1,1],s=n.crop||[0,0,1,1],i=t.border,a=n.border,c=i||a?{color:en((u=i==null?void 0:i.color)!=null?u:a.color,(f=a==null?void 0:a.color)!=null?f:i.color,e),width:r((l=i==null?void 0:i.width)!=null?l:0,(m=a==null?void 0:a.width)!=null?m:0)}:void 0;return{...n,w:r(t.w,n.w),h:r(t.h,n.h),radius:r(t.radius||0,n.radius||0),border:c,crop:t.crop||n.crop?[r(o[0],s[0]),r(o[1],s[1]),r(o[2],s[2]),r(o[3],s[3])]:void 0}}function Iu(t,n,e){let r=(o,s)=>o+(s-o)*e;return{three_d:t.three_d||n.three_d,phi:r(t.phi,n.phi),theta:r(t.theta,n.theta),gamma:r(t.gamma,n.gamma),zoom:r(t.zoom,n.zoom),focal:r(t.focal,n.focal),center:[r(t.center[0],n.center[0]),r(t.center[1],n.center[1]),r(t.center[2],n.center[2])]}}function ya(t,n){let e=vr(t.get(n)),r=ir(e);if(!r)return"";let o=r[3]-r[1]||r[2]-r[0]||1;return e.map(s=>s.points.map(i=>`${Math.round((i[0]-r[0])/o*100)},${Math.round((i[1]-r[1])/o*100)}`).join(";")).join("|")}function Ru(t,n,e,r,o){let s=dt(t,n),i=dt(t,e);if(!s.length||!i.length)return null;let a=new Map(s.map(m=>[m,ya(t,m)])),c=new Set,u=[],f=[];for(let m of i){let p=ya(t,m),b=s.find(g=>!c.has(g)&&a.get(g)===p);b!=null?(c.add(b),u.push(...Qn(t,[b],t,[m],o,r))):f.push(m)}let l=s.filter(m=>!c.has(m));return{pairs:u,in:f,out:l}}function xa(t,n,e){let r=e.w,o=tt(r,t.target),s=r.fork(),i=Array.isArray(n.ops)?n.ops:[],a=[];for(let c of i)if(Array.isArray(c)&&c[2]==null)Xe(s,o,String(c[0]),c[1],e.env);else if(c&&typeof c=="object"){let u=Array.isArray(c)?{name:c[0],args:c[1],target:c[2]}:c,f=u.target!=null?tt(s,u.target):o;f!==o&&!mt(r,o).includes(f)&&a.push(f),Xe(s,f,String(u.name),u.args,e.env)}return a.length?Tu([ws(r,s,o),...Array.from(new Set(a)).map(c=>ws(r,s,c))]):ws(r,s,o)}function Tu(t){return{run:1,rate:Gt,lag:0,apply:(n,e,r,o)=>{for(let s of t)s.apply(n,e,r,o)},end:(n,e)=>{var r;for(let o of t)(r=o.end)==null||r.call(o,n,e)}}}function ws(t,n,e){let r=mt(t,e),o=mt(n,e),s=r.length===o.length&&r.every((l,m)=>l===o[m]),i=o.map(l=>n.get(l)),a=(l,m=1)=>{var p,b;if(Math.abs(m-1)<1e-9){for(let g of i)l.set(g);return}if(!(Math.abs(m)<1e-9))for(let g of i){if(!l.has(g.id)||!t.has(g.id)){l.set(g);continue}let x=t.get(g.id),M=(p=x.data)==null?void 0:p.value,F=(b=g.data)==null?void 0:b.value;l.set({...g,m:We(x.m,g.m,m),style:An(x.style,g.style,m),...x.image&&g.image&&x.image!==g.image?{image:ga(x.image,g.image,m)}:{},data:typeof M=="number"&&typeof F=="number"?{...g.data,value:M+(F-M)*m}:g.data})}},c=t.get(e),u=n.get(e);if(_i(c)&&c.data.value!==u.data.value){let l=Number(c.data.value),m=Number(u.data.value),p=new Se(new Map(t.mobs),t.display.slice(),t.ids);return{run:1,rate:Gt,lag:0,apply:(b,g,x)=>{let M=g.get(e);if(!M)return;let F=x(b),N=p.fork();Ae(N,e,l+(m-l)*F),M.replace=dt(N,e).map(P=>qn(N.get(P),M.alpha))},end:a}}if(!s){let l=Qn(t,dt(t,e),n,dt(n,e),Ot(n,e),Ot(t,e));return{run:1,rate:Gt,lag:0,apply:(m,p,b,g)=>{let x=p.get(e);x&&(x.replace=Ar(l,m,b,g))},end:a}}let f=[];for(let l of r){let m=t.get(l),p=n.get(l);if(m===p)continue;let b={id:l,s:m,e:p,inv:le(m.m)};Pe(m)&&(m.paths!==p.paths||m.text!==p.text||!!m.image!=!!p.image)&&(b.pairs=Qn(t,[l],n,[l],Ot(n,l),Ot(t,l))),f.push(b)}return{run:1,rate:Gt,lag:0,apply:(l,m,p,b)=>{f.forEach((g,x)=>{var A,v,L,T,O,K;let M=m.get(g.id);if(!M)return;let F=p(Oe(l,x,f.length,b));if(g.pairs){M.replace=Ar(g.pairs,F,xe,0);return}if(g.s.m3||g.e.m3){let D=(A=g.s.m3)!=null?A:Bt(g.s.m),j=(v=g.e.m3)!=null?v:Bt(g.e.m);D!==j&&(M.m3=Vt(Vt(Hs(D,j,F),Xs(D)),(T=ln(M.m,(L=M.m3)!=null?L:D))!=null?T:D),M.m=he(M.m3))}else g.s.m!==g.e.m&&(M.m=lt(lt(We(g.s.m,g.e.m,F),g.inv),M.m));g.s.style!==g.e.style&&(M.style=An(M.style,g.e.style,F)),g.s.image&&g.e.image&&g.s.image!==g.e.image&&(M.image=ga(g.s.image,g.e.image,F));let N=(O=g.s.data)==null?void 0:O.value,P=(K=g.e.data)==null?void 0:K.value;typeof N=="number"&&typeof P=="number"&&N!==P&&(M.value=N+(P-N)*F)})},end:a}}function Fu(t,n,e){let r=n.run_time!=null?Math.max(0,Number(n.run_time)):t.run,o=n.rate_func!=null?xo(n.rate_func,t.rate):t.rate,s=n.lag_ratio!=null?Number(n.lag_ratio):t.lag,i=t.target!=null&&Bo(e.pre,t.target);return{run:r,intro:!!t.intro,shownBefore:i,frame:(a,c)=>t.apply(r>0?_a(a/r):1,c,o,s),events:()=>{let a=[];if(t.begin&&a.push({t:0,end:!1,fn:t.begin}),t.end){let c=o(1);a.push({t:r,end:!0,fn:u=>t.end(u,c)})}return a}}}function Ma(t,n,e,r){let o=[],s=0,i=0;for(let u of t)o.push(s),i=Math.max(i,s+u.run),s+=n*u.run;let a=e!=null?e:i,c=i>0?a/i:1;return{run:a,intro:t.some(u=>u.intro),shownBefore:t.every(u=>u.shownBefore),frame:(u,f)=>{let l=Math.max(0,Math.min(a,u));r!==xe&&a>0&&(l=a*r(l/a));let m=c>0?l/c:l;t.forEach((p,b)=>{let g=m-o[b];g<0&&!(p.intro&&!p.shownBefore)||p.frame(g,f)})},events:()=>{let u=[];return t.forEach((f,l)=>{for(let m of f.events())u.push({t:(o[l]+m.t)*c,end:m.end,fn:m.fn})}),u}}}function wo(t,n){let e=Mo(t.kind);if(e==="group"||e==="lagged"||e==="succession"){let r=t.items||[],o=t.lag_ratio!=null?Number(t.lag_ratio):e==="lagged"?.05:e==="succession"?1:0,s=t.rate_func!=null?xo(t.rate_func,xe):xe,i;if(e==="succession"){let a={...n,w:n.w.fork()};i=r.map(c=>{let u=wo(c,a),f=u.events().sort((l,m)=>l.t-m.t||Number(m.end)-Number(l.end));for(let l of f)l.fn(a.w);return u})}else i=r.map(a=>wo(a,n));return Ma(i,o,t.run_time!=null?Number(t.run_time):null,s)}return e==="change_speed"?Cu(t,n):Fu(Eu(t,n),t,n)}function Cu(t,n){let e=de(t.args,["speedinfo"]),r=wo((t.items||[])[0]||t.anim||e.anim||{kind:"wait",run_time:0},n),o=Object.entries(e.speedinfo||{}).map(([a,c])=>[Number(a),Math.max(.001,Number(c))]).sort((a,c)=>a[0]-c[0]);(!o.length||o[0][0]>0)&&o.unshift([0,1]),o[o.length-1][0]<1&&o.push([1,o[o.length-1][1]]);let s=o.slice(0,-1).map(([a,c],u)=>{let[f,l]=o[u+1];return{u0:a,u1:f,s0:c,s1:l,T:(f-a)*r.run/((c+l)/2)}}),i=s.reduce((a,c)=>a+c.T,0);return{run:i,intro:r.intro,shownBefore:r.shownBefore,frame:(a,c)=>{let u=Math.max(0,Math.min(i,a));for(let f of s){if(u<=f.T||f===s[s.length-1]){let l=Math.min(u,f.T),m=f.s0*l+(f.s1-f.s0)*l*l/(2*(f.T||1));r.frame(f.u0*r.run+m,c);return}u-=f.T}},events:()=>r.events().map(a=>({...a,t:a.t<=0?0:a.t>=r.run?i:a.t}))}}function ka(t,n,e){let r=t.map(o=>{let s={...o};n.run_time!=null&&(s.run_time=Number(n.run_time)),n.rate_func!=null&&(s.rate_func=n.rate_func);let i=Mo(s.kind);return n.lag_ratio!=null&&i!=="group"&&i!=="lagged"&&i!=="succession"&&(s.lag_ratio=Number(n.lag_ratio)),wo(s,e)});return Ma(r,0,null,xe)}function Sa(t){return t.events().sort((n,e)=>n.t-e.t||Number(e.end)-Number(n.end))}var Zn=1,Pa=new WeakMap,va=typeof Path2D!="undefined";function Ia(t){let n=new Path2D;for(let e of t){let r=e.points;if(r.length){n.moveTo(r[0][0],r[0][1]);for(let o=1;o+2<r.length;o+=3)n.bezierCurveTo(r[o][0],r[o][1],r[o+1][0],r[o+1][1],r[o+2][0],r[o+2][1]);e.closed&&n.closePath()}}return n}function Lu(t){let n=Pa.get(t);return n||(n=Ia(t),Pa.set(t,n)),n}function Ou(t,n){t.beginPath();for(let e of n){let r=e.points;if(r.length){t.moveTo(r[0][0],r[0][1]);for(let o=1;o+2<r.length;o+=3)t.bezierCurveTo(r[o][0],r[o][1],r[o+1][0],r[o+1][1],r[o+2][0],r[o+2][1]);e.closed&&t.closePath()}}}function Ss(t,n){t.setTransform(n[0],n[1],n[2],n[3],n[4],n[5])}function Ra(t,n){let e=[],r=new Set,{mobs:o}=t.scene,s=i=>{var u,f;if(r.has(i))return;r.add(i);let a=t.over.get(i);if(a&&a.hidden)return;if(a&&a.replace){for(let l of a.replace)e.push(l);return}let c=o.get(i);if(c){if(Pe(c)){let l=a?{paths:c.paths,m:a.m,style:a.style,alpha:a.alpha,partial:a.partial,z:c.z,text:c.text,image:(u=a.image)!=null?u:c.image,shadow:c.shadow,evenodd:c.evenodd}:{paths:c.paths,m:c.m,style:c.style,alpha:1,partial:null,z:c.z,text:c.text,image:c.image,shadow:c.shadow,evenodd:c.evenodd},m=a?ln(a.m,(f=a.m3)!=null?f:c.m3):c.m3;m&&(l.m3=m),c.p3&&(l.p3=c.p3,l.closed3=c.closed3),c.shade3&&(l.shade3=!0),c.fixed&&(l.fixed=c.fixed),e.push(l)}for(let l of c.children)s(l)}};for(let i of n||t.scene.display)s(i);if(!n)for(let i of t.extras)e.push(i);if(e.some(i=>i.z!==0)){let i=new Map(e.map((a,c)=>[a,c]));e.sort((a,c)=>a.z-c.z||i.get(a)-i.get(c))}return e}function Nu(t,n,e=Mt){var a,c,u,f;let r=(f=(u=(a=t.over.get(It))==null?void 0:a.m)!=null?u:(c=t.scene.mobs.get(It))==null?void 0:c.m)!=null?f:Mt,o=Nt(r,[0,0]),s=hn(r),i=Math.min(n.pxW/n.fw,n.pxH/n.fh)/s;return lt(e,[i,0,0,-i,n.pxW/2-i*o[0],n.pxH/2+i*o[1]])}function je(t,n,e){var s,i;let r=Mt;if(typeof t.getTransform=="function"){let a=t.getTransform();r=[a.a,a.b,a.c,a.d,a.e,a.f]}t.save(),e.clear!==!1&&(Ss(t,r),t.clearRect(0,0,e.pxW,e.pxH)),e.clipX&&(Ss(t,r),t.beginPath(),t.rect(e.clipX[0],0,Math.max(0,e.clipX[1]-e.clipX[0]),e.pxH),t.clip());let o=Nu(n,e,r);e.shiftX&&(o=lt(o,[1,0,0,1,e.shiftX,0])),t.lineJoin="round",t.lineCap="round",Zn=e.alpha==null?1:Math.max(0,Math.min(1,e.alpha));try{if(Zn>0){let a=Ra(n),c=(i=(s=n.over.get(It))==null?void 0:s.cam)!=null?i:ye(n.scene);if(c.three_d||a.some(u=>u.p3||u.m3)){let u=Zn;ha(t,u===1?a:a.map(f=>({...f,alpha:f.alpha*u})),o,c,(f,l)=>Aa(t,f,l))}else for(let u of a)Aa(t,Zn===1?u:{...u,alpha:u.alpha*Zn},o)}}finally{Zn=1}t.restore()}function Po(t,n,e,r){if(!n)return;let o=Ln(n.color)||[0,0,0];t.shadowColor=`rgba(${o[0]},${o[1]},${o[2]},${Math.max(0,Math.min(1,n.opacity*r))})`,t.shadowBlur=n.blur*e,t.shadowOffsetX=n.dx*e,t.shadowOffsetY=-n.dy*e}function So(t){t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}var ko=new Map;function Ta(t,n,e,r){let o=Math.max(0,Math.min(r,n/2,e/2)),s=-n/2,i=-e/2;t.moveTo(s+o,i),t.arcTo(s+n,i,s+n,i+e,o),t.arcTo(s+n,i+e,s,i+e,o),t.arcTo(s,i+e,s,i,o),t.arcTo(s,i,s+n,i,o),t.closePath()}function Bu(t,n,e){if(!va)return null;let r=`${t}|${n}|${e}`,o=ko.get(r);return o||(o=new Path2D,Ta(o,t,n,e),ko.size>500&&ko.clear(),ko.set(r,o),o)}function ks(t,n,e,r,o,s){if(n){t[s](n);return}t.beginPath(),Ta(t,e,r,o),t[s]()}var Ea=new WeakMap;function Fa(t){let n=t;return[n.naturalWidth||n.videoWidth||n.width||0,n.naturalHeight||n.videoHeight||n.height||0]}function zu(t,n){if(n>=.5||typeof document=="undefined")return{img:t,k:1};let e=Ea.get(t);if(e&&e.k>=n)return{img:e.canvas,k:e.k};let[r,o]=Fa(t),s=Math.min(1,Math.pow(2,Math.ceil(Math.log2(n*1.25))));if(s>=.5||!r||!o)return{img:t,k:1};let i=document.createElement("canvas");i.width=Math.max(1,Math.round(r*s)),i.height=Math.max(1,Math.round(o*s));let a=i.getContext("2d");return a.imageSmoothingQuality="high",a.drawImage(t,0,0,i.width,i.height),Ea.set(t,{canvas:i,k:s}),{img:i,k:s}}function Du(t,n,e,r){let o=n.image,s=n.style;if(!o.src)return;let i=Math.min(1,n.alpha*(s.fo>0?s.fo:1));if(i<=0)return;t.setTransform(e[0],e[1],-e[2],-e[3],e[4],e[5]),t.globalAlpha=i;let[a,c]=Fa(o.src),[u,f,l,m]=o.crop||[0,0,1,1],p=Math.hypot(e[0],e[1])*o.w,b=o.src,g=1;!o.live&&a&&c&&({img:b,k:g}=zu(o.src,p/(a*(l-u))));let x=u*a*g,M=(1-m)*c*g,F=(l-u)*a*g,N=(m-f)*c*g,P=o.radius||0,A=P>0||o.border?Bu(o.w,o.h,P):null,v=()=>{try{a&&c?t.drawImage(b,x,M,F,N,-o.w/2,-o.h/2,o.w,o.h):t.drawImage(b,-o.w/2,-o.h/2,o.w,o.h)}catch(L){}};if(n.shadow){if(P>0)t.save(),Po(t,n.shadow,r,i),t.fillStyle="#000",ks(t,A,o.w,o.h,P,"fill"),t.restore();else if(Po(t,n.shadow,r,i),v(),So(t),!o.border)return}P>0?(t.save(),ks(t,A,o.w,o.h,P,"clip"),v(),t.restore()):n.shadow||v(),o.border&&o.border.width>0&&(t.strokeStyle=o.border.color,t.lineWidth=o.border.width*.01/hn(n.m),ks(t,A,o.w,o.h,P,"stroke"))}function Aa(t,n,e){let r=n.style,o=n.alpha;if(o<=0)return;let s=lt(e,n.m),i=hn(e);if(n.image){Du(t,n,s,i);return}if(n.text){let m=n.text,p=r.fo*o;if(p<=0)return;let b=.01;t.setTransform(s[0]*b,s[1]*b,-s[2]*b,-s[3]*b,s[4],s[5]),t.globalAlpha=Math.min(1,p),t.fillStyle=r.fc;let g=m.family==="mono"?'Menlo, Consolas, "Liberation Mono", monospace':ti(m.family||"");t.font=`${m.slant==="italic"?"italic ":""}${m.weight==="bold"?"bold ":""}${m.em*100}px ${g}`,t.textAlign=m.left?"left":"center",t.textBaseline="middle";let x=m.str.split(`
9
+ `),M=m.left?-m.w/2*100:0;Po(t,n.shadow,i,p),x.forEach((F,N)=>t.fillText(F,M,(N-(x.length-1)/2)*m.em*120)),n.shadow&&So(t);return}let a=n.paths;if(n.partial&&(a=pn(a,n.partial[0],n.partial[1]),!a.length)||!a.length)return;let c=r.fo*o,u=r.sw>0?r.so*o:0;if(c<=0&&u<=0)return;Ss(t,s);let f=va?n.partial?Ia(a):Lu(a):null;f||Ou(t,a);let l=n.evenodd?"evenodd":"nonzero";Po(t,n.shadow,i,Math.max(c,u)),c>0&&(t.globalAlpha=Math.min(1,c),t.fillStyle=r.fc,f?t.fill(f,l):t.fill(l),n.shadow&&So(t)),u>0&&(t.globalAlpha=Math.min(1,u),t.strokeStyle=r.sc,t.lineWidth=r.sw*.01/hn(n.m),f?t.stroke(f):t.stroke()),n.shadow&&So(t)}function Ps(t,n){var f;let e=Ra(t,[n]),r=null,o=null,s=null;for(let l of e){let m=l.partial?pn(l.paths,l.partial[0],l.partial[1]):l.paths;l.partial&&!m.length&&l.paths.length&&(m=[{points:[l.paths[0].points[0]],closed:!1}]);for(let b of m)for(let g of b.points){let x=Nt(l.m,g);o||(o=x),r=r?[Math.min(r[0],x[0]),Math.min(r[1],x[1]),Math.max(r[2],x[0]),Math.max(r[3],x[1])]:[x[0],x[1],x[0],x[1]]}if(l.p3&&l.p3.length){let b=l.m3;for(let g=0;g<l.p3.length;g+=3){let x=b?[b[0]*l.p3[g]+b[1]*l.p3[g+1]+b[2]*l.p3[g+2]+b[9],b[3]*l.p3[g]+b[4]*l.p3[g+1]+b[5]*l.p3[g+2]+b[10]]:Nt(l.m,[l.p3[g],l.p3[g+1]]);o||(o=[x[0],x[1]]),r=r?[Math.min(r[0],x[0]),Math.min(r[1],x[1]),Math.max(r[2],x[0]),Math.max(r[3],x[1])]:[x[0],x[1],x[0],x[1]]}}let p=l.text||l.image;if(p&&!m.length)for(let b of[[-p.w/2,-p.h/2],[p.w/2,-p.h/2],[p.w/2,p.h/2],[-p.w/2,p.h/2]]){let g=Nt(l.m,b);r=r?[Math.min(r[0],g[0]),Math.min(r[1],g[1]),Math.max(r[2],g[0]),Math.max(r[3],g[1])]:[g[0],g[1],g[0],g[1]]}if(l===e[0]&&m.length){let b=m[m.length-1].points;s=Nt(l.m,b[b.length-1])}}let i=e[0],a=i?i.style:(f=t.scene.mobs.get(n))==null?void 0:f.style,c=r||[0,0,0,0],u=l=>l?[l[0],l[1],0]:null;return{center:[(c[0]+c[2])/2,(c[1]+c[3])/2,0],width:c[2]-c[0],height:c[3]-c[1],left:c[0],right:c[2],bottom:c[1],top:c[3],first_point:u(o),partial_end_point:u(s),stroke_width:a?a.sw:0,stroke_opacity:a&&i?a.so*i.alpha:a?a.so:0,fill_opacity:a&&i?a.fo*i.alpha:a?a.fo:0,color:a?a.fo>0?a.fc:a.sc:null,fill_color:a?a.fc:null,stroke_color:a?a.sc:null,items:e.length}}var ju=16/9,Wu=new Set(["none","crossfade","slide_left","slide","slide_right","wipe"]),$u=new Set(["add_coordinates","change_bar_values","change_layout"]),Ku=new Set(["shift","rotate","scale","stretch","flip","increment_value","rotate_about_origin"]);function Ca(t={}){var k,I;let n=new $r((k=t.base)!=null?k:null),e=new Map,r=(I=t.tex)!=null?I:null,o={frame_height:8,frame_width:null,background:"#000000"},s=new Se,i=[],a=0,c=[],u=[],f=0,l=[],m=0,p=0,b=0,g=new ho,x={ops:new Map,values:new Map,sets:new Map,adds:new Map,deltas:new Map},M=()=>x.ops.size+x.values.size+x.sets.size+x.adds.size+x.deltas.size,F=0,N=null,P=new Map,A=!1,v=!1;gi(n),oa((h,_,w,E)=>{let R=br({...K(),w:h},_,w,E);if(R&&typeof R.then=="function")throw new Error("rebuilding this needs a font first; try again after it has loaded")}),wi((h,_)=>{if(typeof document=="undefined")return null;let w=document.createElement("canvas");return w.width=h,w.height=_,w});let L=()=>o.frame_height,T=()=>{var h;return(h=o.frame_width)!=null?h:o.frame_height*ju},O=()=>({fw:T(),fh:L()}),K=()=>({w:s,fw:T(),fh:L(),text:n,tex:r,texCache:e});function D(h=Mt){return ct(It,"camera",{sc:"#FFFFFF",fc:"#FFFFFF",sw:0,so:0,fo:0},[_t($e(T(),L()),!0)],{m:h})}s.set(D());function j(){f++}let G=0,U=null,$=[],q=[];function H(h,_=m){let w=h&&h.message||String(h);l.push({message:w,line:_}),typeof console!="undefined"&&console.error("[pyctures.anim]",w)}let et=3e4,st=[];function Q(h){let _=G,w=setTimeout(()=>{_===G&&st.push({message:"still loading fonts, equations or pictures\u2026"})},et);h.then(()=>clearTimeout(w),()=>clearTimeout(w))}function ot(h,_,w=0){m=_,p=w,b=0,(_||w)&&u.push({line:_,outer:w});let E=h();if(E&&typeof E.then=="function"){let R=G;Q(E),U=E.then(()=>j(),W=>H(W,_)).then(()=>{R===G&&(U=null,nt())})}else j()}function nt(){for(;!U&&$.length;){let h=$.shift();try{ot(h.fn,h.line,h.outer)}catch(_){H(_,h.line)}}if(!U&&!$.length){let h=q;q=[];for(let _ of h)_()}}function it(h){let _=Number(y.line)||0,w=Number(y.outer_line)||0;U||$.length?$.push({fn:h,line:_,outer:w}):ot(h,_,w)}function yt(h){var w;let _=de(h,[]);if(_.frame_height!=null&&(o.frame_height=S(_.frame_height,8)),_.frame_width!=null&&(o.frame_width=S(_.frame_width,T())),(_.background!=null||_.background_color!=null)&&(o.background=String((w=_.background)!=null?w:_.background_color)),_.transition!=null&&(o.transition=String(_.transition)),_.three_d){let E=s.get(It);s.update(It,{data:{...E.data||{},cam:{...ye(s),three_d:!0}}})}_.transition_time!=null&&(o.transition_time=S(_.transition_time,.5)),(_.frame_height!=null||_.frame_width!=null)&&s.set(D(s.get(It).m))}function Ct(h,_){if(At.t=a,!_)return;if(_.kind==="redraw"&&!_.template&&_.make&&Pn(_.make)&&(_.template=Un(_.make)),_.kind==="python"||_.kind!=="redraw"||s.has(h)){tt(s,h),g.add(h,_,a);return}let w=[],E={..._e(),make:(W,C,z,V)=>{let Y=br({...K(),w:W},C,z,V);Y&&typeof Y.then=="function"&&w.push(Y)}},R=()=>{if(_.template)po(s,_.template,new Map,E,h);else{let[W,C]=_.make||["group",{}];E.make(s,h,W,Me(s,C))}};try{R()}catch(W){if(!w.length)throw W}if(w.length)return Promise.all(w).then(()=>{w.length=0,R(),g.add(h,_,a)});g.add(h,_,a)}function Ft(h){let _=w=>{if(!w||typeof w!="object")return w;let E={...w};return w.args!=null&&(E.args=Me(s,w.args)),Array.isArray(w.items)&&(E.items=w.items.map(_)),E};return Array.isArray(h)?h.map(_):_(h)}function Ht(h){return(Array.isArray(h)?h:[h]).map(w=>tt(s,w))}function wt(h,_){var V,Y,Z;let w=Array.isArray(h)?h:[h];if(!w.length)return;let E=s.snapshot(),R=ka(w,de(_,[]),{w:s.fork(),pre:E,env:O()}),W=Sa(R),C=s.fork();for(let X of W)X.end||X.fn(C);let z=C.snapshot();for(let X of W)X.fn(s);for(let[X,J]of s.mobs)J.kind==="value_tracker"&&((V=J.data)!=null&&V.camera)&&((Z=(Y=E.mobs.get(X))==null?void 0:Y.data)==null?void 0:Z.value)!==J.data.value&&fo(s,X);if(R.run>0){let X={t0:a,t1:a+R.run,before:z,node:R,...tr()};i.push(X),a+=R.run,Fr(X)}}let jt=[],ae=[];function Tr(h,_,w){let E=h;if(w)for(let R of jt){let W=Math.min(_,R.to)-Math.max(w.t0,R.from);W>0&&(E={...E,[R.about]:E[R.about]+R.rate*W})}for(let R of ae){if(_<R.from)continue;let W=Math.min(_,R.to)-R.from;E={...E,theta:R.theta0+.2*Math.sin(R.rate*W),phi:R.phi0+.1*Math.cos(R.rate*W)-.1}}return E}function ce(h){if(!jt.length&&!ae.length)return;let _=Tr(ye(s),h.t1,h),w=s.get(It);s.update(It,{data:{...w.data||{},cam:_}}),Sr(s)}function Fr(h){if(ce(h),!g.any)return;let _=s.fork();for(let w of g.apply(_,h.t1,h,_e()))for(let E of mt(_,w))_.has(E)&&s.set(_.get(E))}let _e=()=>({env:O(),ids:s.ids,make:(h,_,w,E)=>{br({...K(),w:h},_,w,E)}}),tr=()=>({line:m,outer:p,lineEnd:b,section:Math.max(0,c.length-1)}),In=null;function Cr(){let h=`${G}|${i.length}`;if(In&&In.key===h)return In.byLine;let _=new Map,w=new Map;return i.forEach((E,R)=>{var W,C,z,V;if(E.line){let Y=(W=_.get(E.line))!=null?W:[];Y.push({t0:E.t0,t1:E.t1,section:(C=E.section)!=null?C:0}),_.set(E.line,Y)}if(E.outer&&E.outer!==E.line){let Y=(z=_.get(E.outer))!=null?z:[];w.get(E.outer)===R-1&&Y.length?Y[Y.length-1].t1=E.t1:Y.push({t0:E.t0,t1:E.t1,section:(V=E.section)!=null?V:0}),_.set(E.outer,Y),w.set(E.outer,R)}}),In={key:h,byLine:_},_}function Rn(h,_){var W,C;let w=[...h].sort((z,V)=>z.t0-V.t0);if(_==null||!Number.isFinite(_))return w[0];if(w.find(z=>_>=z.t0&&_<z.t1))return w.filter(z=>_>=z.t0&&_<z.t1).pop();let R=-1;for(let z=0;z<c.length;z++)c[z].t<=_+1e-9&&(R=z);if(R>=0){let z=w.filter(V=>V.section===R);if(z.length)return(W=z.find(V=>V.t0>=_))!=null?W:z[z.length-1]}return(C=w.find(z=>z.t0>=_))!=null?C:w[0]}function Lr(h,_){let w=h&&typeof h=="object"?h:null,E=Number(w?w.line:h);if(!Number.isFinite(E)||E<=0)return null;let R=_&&typeof _=="object"?_.t:_!=null?_:w==null?void 0:w.t,W=R==null||R===""?null:Number(R),C=rt=>({t0:c[rt].t,t1:rt+1<c.length?c[rt+1].t:a,kind:"section",label:c[rt].name}),z=Cr(),V=(rt,xt)=>{if(!rt.length)return null;let Wt=Rn(rt,W);return{t0:Wt.t0,t1:Wt.t1,kind:"segment",label:xt}},Y=(rt,xt=rt)=>{var ee;if(xt===rt)return V((ee=z.get(rt))!=null?ee:[],`line ${rt}`);let Wt=[];for(let[ue,Re]of z)ue>=rt&&ue<=xt&&Wt.push(...Re);return V(Wt,`lines ${rt}\u2013${xt}`)},Z=rt=>c.findIndex(xt=>xt.line===rt||xt.outer===rt),X=Z(E);if(X>=0)return C(X);let J=w&&Number.isFinite(Number(w.end))&&Number(w.end)>E?Number(w.end):E,ft=Y(E,J);if(ft)return ft;let vt=i.filter(rt=>rt.line&&rt.lineEnd&&E>rt.line&&E<=rt.lineEnd);if(vt.length)return V(vt.map(rt=>{var xt;return{t0:rt.t0,t1:rt.t1,section:(xt=rt.section)!=null?xt:0}}),`line ${vt[0].line}`);let kt=c.find(rt=>rt.lines&&E>=rt.lines[0]&&E<=rt.lines[1]);if(!kt&&c.some(rt=>rt.lines))return null;let St=0;for(let rt of u)for(let xt of[rt.line,rt.outer])xt&&xt<=E&&xt>St&&(!kt||xt>=kt.lines[0])&&(St=xt);let Tt=u.some(rt=>[rt.line,rt.outer].some(xt=>xt>E&&(!kt||xt<=kt.lines[1]))),Yt=St&&Tt&&Z(St)<0?Y(St):null;return Yt||(X=c.findIndex(rt=>rt.lines&&E>=rt.lines[0]&&E<=rt.lines[1]),X>=0?C(X):null)}function Or(h){let _=h&&typeof h=="object"?h:{};b=Number(_.line_end)||0;let w=Number(_.outer_line)||0;w&&(p=w,u.push({line:m,outer:w}))}function Nr(h){let _=Math.max(0,S(Array.isArray(h)?h[0]:h,1));if(_<=0)return;let w={t0:a,t1:a+_,before:s.snapshot(),node:null,...tr()};i.push(w),a+=_,Fr(w)}function Br(h,_,w){var z,V;let E=String(_).replace(/^get_/,""),R=de(w,["arg"]);if(E==="frame")return{width:T(),height:L()};if(E==="camera"){let Y=ye(s);return{phi:Y.phi,theta:Y.theta,gamma:Y.gamma,zoom:Y.zoom,focal_distance:Y.focal,frame_center:Y.center,three_d:Y.three_d}}if(At.t=a,E==="point"&&(h==null||h===0)){let Y=Et(s,(z=R.arg)!=null?z:w);return[Y[0],Y[1],0]}if((E==="expr"||E==="eval"||E==="number")&&(h==null||h===0))return Kt(s,(V=R.arg)!=null?V:w);let W=tt(s,h);if(E==="describe"||E==="state")return Ps(new En(s.snapshot()),W);if(E==="point"){let Y=Qt(R.arg)?Pt(at(s,tt(s,R.arg))):Et(s,R.arg);return[Y[0],Y[1],0]}let C=Array.isArray(w)?w:w==null?[]:[w];return yr(s,W,E,C)}let qe=[],er=[];function we(h){for(let _ of er)if(h>=_.t&&h<_.t+_.dur)return _;return null}function Bs(h){if(!i.length||h>=a)return null;let _=0,w=i.length-1;for(;_<w;){let E=_+w+1>>1;i[E].t0<=h?_=E:w=E-1}return i[_]}function Tn(h,_=!0){return Ao(h,_).f}function Ao(h,_){var C,z,V,Y;h=Math.max(0,h);let w=Bs(h),E=new En(w?w.before:s.snapshot());if(w&&w.node&&w.node.frame(h-w.t0,E),w)for(let[Z,X]of[...E.over]){let J=X.value!=null?mo[(z=(C=E.scene.mobs.get(Z))==null?void 0:C.data)==null?void 0:z.camera]:void 0;if(!J)continue;let ft=E.get(It);ft&&(ft.cam={...(V=ft.cam)!=null?V:ye(E.scene),[J]:X.value})}if(w&&(jt.length||ae.length)){let Z=E.get(It);Z&&(Z.cam=Tr((Y=Z.cam)!=null?Y:ye(E.scene),h,w))}let R=_&&M()>0,W=g.any||R||v?Io(E,h,w,R):null;return{f:E,view:W}}function vo(h){var w;let _=new Map(h.scene.mobs);for(let[E,R]of h.over){let W=_.get(E);if(!W||R.m===W.m&&R.style===W.style&&R.value==null&&R.m3===W.m3)continue;let C=ln(R.m,(w=R.m3)!=null?w:W.m3);_.set(E,{...W,m:R.m,...C?{m3:C}:{},style:R.style,data:R.value!=null?{...W.data||{},value:R.value}:W.data})}return new Se(_,h.scene.display.slice(),s.ids)}function Io(h,_,w,E){var z,V;let R=vo(h),W=R.snapshot(),C=[];if(At.t=_,E){for(let[J,ft]of x.values)R.has(J)&&(Ae(R,J,ft),C.push(J));let Y=_e(),Z=J=>{try{C.push(...Er(R,J,null,Y))}catch(ft){}},X=J=>{let ft=/^[ud](\d+)$/.exec(J);return!ft||g.activeUid(ft[1],_)!==!1};for(let[J,ft]of x.sets)X(J)&&Z(ft);for(let[J,ft]of x.adds)X(J)&&Z(Array.from(ft.values()));for(let[J,ft]of x.deltas)if(X(J)){for(let[vt,kt]of ft)if(R.has(vt)){for(let St of mt(R,vt)){let Tt=R.get(St);R.set({...Tt,m:lt(kt.M,Tt.m)})}kt.dv&&Ae(R,vt,Number((V=(z=R.get(vt).data)==null?void 0:z.value)!=null?V:0)+kt.dv),C.push(vt)}}for(let J of x.ops.values())if(R.has(J.target))try{C.push(...Er(R,[[J.name,J.args,J.target]],null,Y))}catch(ft){}}if(C.push(...g.apply(R,_,w,_e())),!A)for(let Y of Array.from(R.mobs.values())){if(Y.kind!=="traced_path")continue;let Z=d(Y,_,R);R.set({...Y,paths:Z.length>=2?[_t(Z,!1)]:[]}),C.push(Y.id)}return B(h,R,W,C),R}function B(h,_,w,E){var R;for(let W of Array.from(new Set(E))){let C=mt(_,W),z=mt(w,W);if(C.length===z.length&&C.every((Y,Z)=>{if(Y!==z[Z])return!1;let X=_.get(Y),J=w.mobs.get(Y);return X.paths===J.paths&&X.p3===J.p3&&X.text===J.text&&X.image===J.image}))for(let Y of C){let Z=_.get(Y);if(Z===w.mobs.get(Y))continue;let X=h.get(Y);X&&(X.m=Z.m,Z.m3&&(X.m3=Z.m3),X.style=Z.style,((R=Z.data)==null?void 0:R.value)!=null&&(X.value=Number(Z.data.value)))}else{let Y=h.get(W);if(!Y)continue;let Z=Y.alpha;Y.replace=C.map(X=>_.get(X)).filter(Pe).map(X=>({paths:X.paths,m:X.m,style:X.style,alpha:Z,partial:null,z:X.z,text:X.text,image:X.image,shadow:X.shadow,evenodd:X.evenodd,m3:X.m3,p3:X.p3,closed3:X.closed3,shade3:X.shade3,fixed:X.fixed}))}}}function d(h,_,w){var Y,Z;let E=(Y=h.data)==null?void 0:Y.trace;if(!E||E.point==null)return[];let R=Number((Z=E.from)!=null?Z:0),W=1/30,C=P.get(h.id);(!C||C.version!==f)&&(C={version:f,pts:[]},P.set(h.id,C));let z=Math.floor((Math.min(_,a)-R)/W+1e-9);A=!0;try{for(;C.pts.length<=z&&C.pts.length<2e4;){let X=R+C.pts.length*W,J=Ao(X,!1),ft=J.view||vo(J.f);At.t=X;let vt=Et(ft,E.point);C.pts.push(vt)}}catch(X){}finally{A=!1,At.t=_}let V=C.pts.slice(0,Math.max(0,z+1));try{let X=Et(w,E.point),J=V[V.length-1];(!J||Math.hypot(X[0]-J[0],X[1]-J[1])>1e-9)&&V.push(X)}catch(X){}if(E.dissipating!=null&&E.dissipating>0){let X=Math.ceil(E.dissipating/W)+1;return V.slice(Math.max(0,V.length-X))}return V}let y={reset(h){G++,U=null,$.length=0,o={frame_height:8,frame_width:null,background:"#000000"},s=new Se,s.set(D()),i=[],a=0,c=[],u=[],l=[],st=[],g.reset(),x.ops.clear(),x.values.clear(),x.sets.clear(),x.adds.clear(),x.deltas.clear(),P.clear(),v=!1,er=[],qe=[],jt=[],ae=[],h&&yt(h),j(),nt()},config(h){it(()=>yt(h))},make(h,_,w,E){it(()=>{if(At.t=a,E!=null){let C=String(_).replace(/_/g,"").toLowerCase();C==="pycturescanvas"?w={...w,canvas:E}:C==="imagemobject"?w={...w,element:E}:C==="svgmobject"&&(w=typeof E=="string"||E.outerHTML?{...w,svg_element:E}:{...w,element:E})}let R=String(_).toLowerCase().replace(/_/g,"")==="tracedpath",W=br(K(),h,_,R?w||{}:Me(s,w||{}));if(W&&typeof W.then=="function"&&(W=W.catch(C=>{throw s.has(h)||s.set(ct(h,"group",{sc:"#FFFFFF",fc:"#FFFFFF",sw:0,so:1,fo:0},[])),C})),R&&s.has(h)){let C=s.get(h).data;s.update(h,{data:{...C,trace:{...C.trace,from:a}}}),v=!0}return W})},copy(h,_){it(()=>{Je(s,tt(s,_),h)})},op(h,_,w){it(()=>{At.t=a;let E=()=>Xe(s,tt(s,h),_,Me(s,w),O());if($u.has(_)&&n.font("normal|normal")===void 0)return n.load("normal|normal").then(E);E()})},add_updater(h,_){it(()=>Ct(h,_))},updater(h,_){it(()=>Ct(h,_))},remove_updater(h,_){it(()=>g.remove(tt(s,h),_,a))},clear_updaters(h){it(()=>g.clear(tt(s,h),a))},suspend_updating(h){it(()=>g.suspend(tt(s,h),a))},resume_updating(h){it(()=>g.resume(tt(s,h),a))},live_op(h,_,w,E){var W,C;let R=tt(s,h);if(E&&E.accumulate){y.live(`acc|${R}`,[[_,w,R]],{mode:"add"});return}if(_==="set_value"||_==="increment_value"){let z=de(w,["value"]),V=x.values.has(R)?x.values.get(R):Number((C=(W=s.get(R).data)==null?void 0:W.value)!=null?C:0);x.values.set(R,_==="set_value"?S(z.value,0):V+S(z.value,0))}else x.ops.set(`${R}|${_}`,{target:R,name:_,args:w});F++},live_set(h,_){x.values.set(tt(s,h),S(_,0)),F++},live_clear(){x.ops.clear(),x.values.clear(),x.sets.clear(),x.adds.clear(),x.deltas.clear(),F++},live(h,_,w){var C,z,V,Y;let E=String(h),R=Array.isArray(_)?_:[];if((w&&w.mode||"set")==="set")x.adds.delete(E),x.deltas.delete(E),R.length?x.sets.set(E,R):x.sets.delete(E);else{let Z=x.adds.get(E)||new Map,X=x.deltas.get(E)||new Map;for(let J of R){let[ft,vt,kt]=J,St;try{St=tt(s,kt)}catch(Tt){continue}if(Ku.has(String(ft))){let Tt=s.fork(),Yt=Tt.get(St);try{Xe(Tt,St,String(ft),Me(Tt,vt),O())}catch(ee){continue}let rt=Tt.get(St),xt=lt(rt.m,le(Yt.m)),Wt=X.get(St)||{M:Mt,dv:0};X.set(St,{M:lt(xt,Wt.M),dv:Wt.dv+(Number((z=(C=rt.data)==null?void 0:C.value)!=null?z:0)-Number((Y=(V=Yt.data)==null?void 0:V.value)!=null?Y:0))})}else Z.set(`${St}|${ft}`,J)}x.adds.set(E,Z),x.deltas.set(E,X)}F++},sound(h){it(()=>{let _=de(h,["src"]);if(_.src==null||_.src==="")throw new Error("add_sound needs a file");let w=_.kind==="music";qe.push({src:String(_.src),t0:a+S(_.time_offset,0),volume:Math.max(0,S(_.volume,w?.3:1)),fade_in:Math.max(0,S(_.fade_in,0)),fade_out:Math.max(0,S(_.fade_out,w?1:0)),loop:_.loop!=null?!!_.loop:w,kind:w?"music":"sound",..._.t1!=null?{t1:S(_.t1,0)}:{}})})},wait_sound(h){it(()=>{let _=de(h,["src","extra"]),w=_.src!=null?[...qe].reverse().find(R=>R.src===String(_.src)):qe[qe.length-1];if(!w)return;let E=globalThis.__cirSoundDuration;if(typeof E=="function")return Promise.resolve(E(w.src)).then(R=>{let W=w.t0+Math.max(0,Number(R)||0)+S(_.extra,0);W>a+1e-9&&Nr(W-a)})})},begin_ambient_camera_rotation(h,_){it(()=>{let w=String(_!=null?_:"theta");jt=jt.map(E=>E.about===w&&E.to===1/0?{...E,to:a}:E),jt.push({about:w,rate:S(h,.02),from:a,to:1/0})})},stop_ambient_camera_rotation(h){it(()=>{let _=h==null?null:String(h);jt=jt.map(w=>(_==null||w.about===_)&&w.to===1/0?{...w,to:a}:w)})},begin_3dillusion_camera_rotation(h,_,w){it(()=>{let E=ye(s);ae.push({rate:S(h,1),phi0:S(_,E.phi),theta0:S(w,E.theta),from:a,to:1/0})})},stop_3dillusion_camera_rotation(){it(()=>{ae=ae.map(h=>h.to===1/0?{...h,to:a}:h)})},trackerValues(h){return y.values_at(h)},values_at(h){var R,W;let _=`${h}|${f}|${F}`;if(N&&N.key===_)return N.out;let w=Tn(h),E={};for(let[C,z]of w.scene.mobs){if(z.kind!=="value_tracker")continue;let V=w.over.get(C);E[C]=V&&V.value!=null?V.value:Number((W=(R=z.data)==null?void 0:R.value)!=null?W:0)}return N={key:_,out:E},E},canvas_for(h){let _=s.get(tt(s,h));if(!_.image)throw new Error("that object is not a PycturesCanvas");return _.image.src},attach_canvas(h,_){let w=tt(s,h),E=s.get(w);E.image&&(E.image.src=_)},add(h){it(()=>pe(s,Ht(h)))},remove(h){it(()=>Ne(s,Ht(h)))},clear(){it(()=>{s.setDisplay([]),s.set(D())})},play(h,_){it(()=>{At.t=a,Or(_),wt(Ft(h),_)})},wait(h,_){it(()=>{Or(_),Nr(h)})},section(h,_){it(()=>{var C;let w=_&&typeof _=="object"?_:{},E=Array.isArray(w.lines)&&w.lines.length===2?[Number(w.lines[0]),Number(w.lines[1])]:void 0;c.push({name:String(h!=null?h:""),t:a,line:m,outer:p,lines:E});let R=String(w.transition||o.transition||"none");Wu.has(R)||(H(new Error(`unknown transition '${R}'; use crossfade, slide_left, slide_right or wipe`)),R="crossfade");let W=S((C=w.transition_time)!=null?C:o.transition_time,.5);R!=="none"&&W>0&&a>0&&er.push({t:a,dur:W,kind:R,out:s.snapshot()})})},value(h,_,w){return new Promise((E,R)=>{it(()=>{try{E(Br(h,_,w))}catch(W){R(W)}})})},ready(){return!U&&!$.length?Promise.resolve():new Promise(h=>q.push(h))},renderAt(h,_,w,E,R){let W={pxW:w,pxH:E,fw:T(),fh:L(),clear:R==null?void 0:R.clear},C=we(_);if(!C){je(h,Tn(_),W);return}let z=Gt((_-C.t)/C.dur),V=new En(C.out),Y=Tn(_),Z=Math.hypot(s.get(It).m[0],s.get(It).m[1])||1,X=T()*Z;C.kind==="slide_left"||C.kind==="slide"?(je(h,V,{...W,shiftX:-X*z}),je(h,Y,{...W,clear:!1,shiftX:X*(1-z)})):C.kind==="slide_right"?(je(h,V,{...W,shiftX:X*z}),je(h,Y,{...W,clear:!1,shiftX:-X*(1-z)})):C.kind==="wipe"?(je(h,V,{...W,clipX:[z*w,w]}),je(h,Y,{...W,clear:!1,clipX:[0,z*w]})):(je(h,V,{...W,alpha:1-z}),je(h,Y,{...W,clear:!1,alpha:z}))},frameAt:Tn,measure(h,_){let w=Tn(h);return Ps(w,tt(s,_))},isShown(h){let _=tt(s,h);return s.display.some(w=>mt(s,w).includes(_))},line:0,takeErrors(){let h=l;return l=[],h},takeNotices(){let h=st;return st=[],h},get errors(){return l.slice()},get duration(){return a},get sections(){return c.map(h=>({name:h.name,t:h.t}))},rangeForLine(h,_){return Lr(h,_)},segmentList(){return i.map(h=>{var _,w,E,R;return{t0:h.t0,t1:h.t1,kind:h.node?"play":"wait",line:(_=h.line)!=null?_:0,lineEnd:(w=h.lineEnd)!=null?w:0,outer:(E=h.outer)!=null?E:0,section:(R=h.section)!=null?R:0}})},get background(){return o.background},get sounds(){return qe.slice()},get version(){return f+F},get liveVersion(){return F},get frameSize(){return{width:T(),height:L()}},get hasContent(){return a>0||s.display.length>0},get busy(){return!!U||$.length>0},get capabilities(){return{kinds:Pi(),anims:wa,ops:ra,rates:ua}}};return y}var Gu="",Vu=!1;function Uu(){if(Vu)return Gu;let t=globalThis.__cirAnimBase;if(t)return t.endsWith("/")?t:t+"/";let n=typeof document!="undefined"?document.querySelector('link[href*="katex"][rel="stylesheet"]'):null;return n?n.href.replace(/[^/]*$/,""):""}function Eo(t){return Wr(Uu()+t)}var Es=new Map;function La(t,n){let e=Es.get(t);return e||(e=zo(Eo(t),n),Es.set(t,e),e.catch(()=>Es.delete(t))),e}function Yu(){let t=document.createElement("span");t.className="katex",t.style.position="absolute",t.style.visibility="hidden",document.body.appendChild(t);let n=getComputedStyle(t).fontFamily;return t.remove(),/KaTeX_Main/.test(n)}function Hu(t,n){return t.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(e,r,o)=>/^(?:[a-z][\w+.-]*:|\/|#)/i.test(o)?e:`url("${n(o)}")`)}var Ir=null;function Xu(){return Ir||(Ir=Yu()?Promise.resolve():Kr(Eo("katex.min.css")).then(t=>{let n=document.createElement("style");n.dataset.cirSrc="katex.min.css",n.textContent=Hu(new TextDecoder().decode(t),Eo),document.head.appendChild(n)}),Ir.catch(()=>Ir=null)),Ir}async function Oa(){let t=globalThis;if(await Promise.all([Xu(),t.katex?null:La("katex.min.js","katex"),Na()]),!t.katex)throw new Error("KaTeX did not load");return t.katex}async function Na(){let t=globalThis;if(t.opentype||await La("opentype.min.js","opentype"),!t.opentype)throw new Error("opentype.js did not load");return t.opentype}var qu={KaTeX_AMS:["Regular"],KaTeX_Caligraphic:["Regular","Bold"],KaTeX_Fraktur:["Regular","Bold"],KaTeX_Main:["Regular","Bold","Italic","BoldItalic"],KaTeX_Math:["Italic","BoldItalic"],KaTeX_SansSerif:["Regular","Bold","Italic"],KaTeX_Script:["Regular"],KaTeX_Size1:["Regular"],KaTeX_Size2:["Regular"],KaTeX_Size3:["Regular"],KaTeX_Size4:["Regular"],KaTeX_Typewriter:["Regular"]};function Ba(t,n,e){let r=qu[t];if(!r)return null;let i=[n&&e?"BoldItalic":n?"Bold":e?"Italic":"Regular",n?"Bold":e?"Italic":"Regular","Regular",...r].find(a=>r.includes(a));return`${t}-${i}.ttf`}var As=new Map;function za(t){let n=As.get(t);return n||(n=(async()=>{let[e,r]=await Promise.all([Na(),Kr(Eo("fonts/"+t))]);return e.parse(r)})(),As.set(t,n),n.catch(()=>As.delete(t))),n}var mn=null;function Qu(){return mn&&mn.isConnected||(mn=document.createElement("div"),mn.setAttribute("aria-hidden","true"),mn.style.cssText='position:fixed;left:0;top:0;visibility:hidden;pointer-events:none;z-index:-1;white-space:nowrap;width:max-content;font-size:100px;line-height:normal;font-variant-ligatures:none;font-feature-settings:"liga" 0,"clig" 0;',document.body.appendChild(mn)),mn}var Da=/[\s​‌‍⁠]/;function Zu(t){for(let n of Array.from(t.classList)){let e=/^cir-p(\d+)$/.exec(n);if(e)return+e[1]}return null}function Wa(t,n){let e=/^(-?[\d.]+)em$/.exec(t.trim());return e?parseFloat(e[1])*n:null}function Ju(t,n){return{x0:Math.max(t.x0,n.x0),y0:Math.max(t.y0,n.y0),x1:Math.min(t.x1,n.x1),y1:Math.min(t.y1,n.y1)}}var vs=t=>({x0:t.left,y0:t.top,x1:t.right,y1:t.bottom}),Rs=class{constructor(n){this.root=n;this.out=[];this.markers=new Map;this.markerSet=null}run(){let n=document.createTreeWalker(this.root,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode()){let r=e;if(!r.data||!Array.from(r.data).some(s=>!Da.test(s)))continue;let o=document.createElement("span");o.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0",r.parentNode.insertBefore(o,r),this.markers.set(r,o)}this.walk(this.root,0,this.out);for(let e of this.markers.values())e.remove();return this.out}walk(n,e,r){if(n.classList.contains("katex-mathml"))return;let o=Zu(n);if(o!==null&&(e=o),n instanceof SVGSVGElement){this.svg(n,e,r);return}if(n.tagName==="SPAN"&&this.markersHas(n))return;if(this.borders(n,e,r),n.classList.contains("mtable")){this.table(n,e,r);return}let s=n.classList.contains("vlist")?ja(n):Array.from(n.childNodes);for(let i of s)this.visit(i,e,r)}visit(n,e,r){n.nodeType===Node.TEXT_NODE?this.text(n,e,r):n.nodeType===Node.ELEMENT_NODE&&this.walk(n,e,r)}markersHas(n){return this.markerSet||(this.markerSet=new Set(this.markers.values())),this.markerSet.has(n)}table(n,e,r){let o=[],s=[];for(let a of Array.from(n.children)){let c=/col-align/.test(a.className)?a.querySelector(".vlist"):null;if(!c){this.walk(a,e,s);continue}this.borders(a,e,s),o.push(ja(c).map(u=>{let f=[];return this.visit(u,e,f),f}))}let i=Math.max(0,...o.map(a=>a.length));for(let a=0;a<i;a++)for(let c of o)c[a]&&r.push(...c[a]);r.push(...s)}text(n,e,r){var b,g;let o=this.markers.get(n);if(!o)return;let s=n.parentElement,i=getComputedStyle(s),a=i.fontFamily.split(",")[0].trim().replace(/^["']|["']$/g,""),c=i.fontWeight==="bold"?700:parseInt(i.fontWeight,10)||400,u=(b=Ba(a,c>=600,i.fontStyle!=="normal"))!=null?b:"KaTeX_Main-Regular.ttf",f=parseFloat(i.fontSize),l=o.getBoundingClientRect().bottom,m=document.createRange(),p=0;for(let x of Array.from(n.data)){if(!Da.test(x)){m.setStart(n,p),m.setEnd(n,p+x.length);let M=(g=m.getClientRects()[0])!=null?g:m.getBoundingClientRect();r.push({part:e,glyph:{file:u,ch:x,x:M.left,baseline:l,px:f}})}p+=x.length}}borders(n,e,r){var f;let o=getComputedStyle(n),s=["Top","Right","Bottom","Left"],i={},a=!1;for(let l of s){let m=o.getPropertyValue(`border-${l.toLowerCase()}-style`);if(m==="none"||m==="hidden")continue;let p=parseFloat(o.getPropertyValue(`border-${l.toLowerCase()}-width`))||0;if(p<=0)continue;let b=parseFloat(o.fontSize);i[l]=(f=Wa(n.style.getPropertyValue(`border-${l.toLowerCase()}-width`),b))!=null?f:p,a=!0}if(!a)return;let c=vs(n.getBoundingClientRect());if(n.classList.contains("rule")){r.push({part:e,subpaths:[$n(c)]});return}let u=[];i.Top&&u.push($n({...c,y1:c.y0+i.Top})),i.Bottom&&u.push($n({...c,y0:c.y1-i.Bottom})),i.Left&&u.push($n({...c,x1:c.x0+i.Left})),i.Right&&u.push($n({...c,x0:c.x1-i.Right}));for(let l of u)r.push({part:e,subpaths:[l]})}svg(n,e,r){let o=n.getBoundingClientRect();if(o.width<=0||o.height<=0)return;let s=n.getAttribute("viewBox"),i=s?s.trim().split(/[\s,]+/).map(Number):null,a=i?Ii(i,o.width,o.height,n.getAttribute("preserveAspectRatio")):[1,0,0,1,0,0],c=[a[0],a[1],a[2],a[3],a[4]+o.left,a[5]+o.top],u=vs(o);for(let g=n.parentElement;g&&g!==this.root;g=g.parentElement){let x=getComputedStyle(g);(x.overflowX!=="visible"||x.overflowY!=="visible")&&(u=Ju(u,vs(g.getBoundingClientRect())))}if(u.x1<=u.x0||u.y1<=u.y0)return;let f=[];for(let g of Array.from(n.querySelectorAll("path")))f.push(...vi(no(g.getAttribute("d")||""),c));for(let g of Array.from(n.querySelectorAll("line")))f.push(...tl(g,o,c));let l=eo(f),m=.01,b=l&&(l.x0<u.x0-m||l.y0<u.y0-m||l.x1>u.x1+m||l.y1>u.y1+m)?Ri(f,u):f;b.length&&r.push({part:e,subpaths:b})}};function tl(t,n,e){var M;let r=(F,N)=>{let P=t.getAttribute(F)||"0";return P.endsWith("%")?parseFloat(P)/100*N:parseFloat(P)},o=parseFloat(getComputedStyle(t).fontSize)||16,s=t.getAttribute("stroke-width")||"1",i=(M=Wa(s,o))!=null?M:parseFloat(s),a=[r("x1",n.width/e[0]),r("y1",n.height/e[3])],c=[r("x2",n.width/e[0]),r("y2",n.height/e[3])],u=[e[0]*a[0]+e[4],e[3]*a[1]+e[5]],f=[e[0]*c[0]+e[4],e[3]*c[1]+e[5]],l=f[0]-u[0],m=f[1]-u[1],p=Math.hypot(l,m)||1,b=-m/p*(i/2),g=l/p*(i/2),x=new Ye;return x.moveTo([u[0]+b,u[1]+g]),x.lineTo([f[0]+b,f[1]+g]),x.lineTo([f[0]-b,f[1]-g]),x.lineTo([u[0]-b,u[1]-g]),x.close(),x.finish()}function ja(t){return Array.from(t.children).map((e,r)=>({r:e,i:r,top:parseFloat(e.style.top)||0})).sort((e,r)=>e.top-r.top||e.i-r.i).map(e=>e.r)}function el(t,n){let e=t.charToGlyph(n.ch);if(!e||e.index===0)return null;let r=new Ye;for(let o of e.getPath(n.x,n.baseline,n.px).commands)o.type==="M"?r.moveTo([o.x,o.y]):o.type==="L"?r.lineTo([o.x,o.y]):o.type==="Q"?r.quadTo([o.x1,o.y1],[o.x,o.y]):o.type==="C"?r.cubicTo([o.x1,o.y1],[o.x2,o.y2],[o.x,o.y]):o.type==="Z"&&r.close();return r.finish()}var Is=["KaTeX_Main-Regular.ttf","KaTeX_AMS-Regular.ttf","KaTeX_Size1-Regular.ttf"];async function nl(t){let n=new Set(Is);for(let o of t)o.glyph&&n.add(o.glyph.file);let e=new Map;await Promise.all(Array.from(n).map(async o=>{try{e.set(o,await za(o))}catch(s){if(!Is.includes(o))throw s}}));let r=new Set;for(let o of t){if(!o.glyph)continue;let s=null;for(let i of[o.glyph.file,...Is]){let a=e.get(i);if(a&&(s=el(a,o.glyph)))break}s||r.add(o.glyph.ch),o.subpaths=s!=null?s:[]}r.size&&console.warn(`[pyctures.anim] TeX: no outline for ${Array.from(r).join(" ")}`)}async function rl(t){let n=new Set,e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let r=e.nextNode();r;r=e.nextNode()){let o=r.parentElement;if(!o||!r.data.trim())continue;let s=getComputedStyle(o);n.add(`${s.fontStyle} ${s.fontWeight} 16px ${s.fontFamily.split(",")[0].trim()}`)}await Promise.all(Array.from(n).map(r=>document.fonts.load(r).catch(()=>[]))),await document.fonts.ready}var Rr=class extends Error{};async function Ts(t,n,e){var o;let r=document.createElement("div");Qu().appendChild(r);try{try{t.render(n,r,{displayMode:e,output:"html",throwOnError:!0,strict:!1,trust:u=>u.command==="\\htmlClass"})}catch(u){throw new Rr(u instanceof Error?u.message:String(u))}await rl(r);let s=(o=r.querySelector(".katex"))!=null?o:r,i=parseFloat(getComputedStyle(s).fontSize),a=new Rs(s).run();return await nl(a),{items:a.filter(u=>u.subpaths&&u.subpaths.length).map(u=>({part:u.part,subpaths:u.subpaths})),emPx:i}}finally{r.remove()}}function Ka(t){return t/48*.498}function Jn(t){return t.parts&&t.parts.length?t.parts:[t.tex]}function Fs(t){return`${t.mode}${Ua(t)}${Jn(t).join("")}`}function Ga(t){return`${Fs(t)}${t.fontSize}`}function ol(t){let n=[],e="",r=()=>{e&&n.push(`\\text{${e}}`),e=""},o=0;for(;o<t.length;){let s=t[o];if(s==="\\"&&o+1<t.length){let i=t[o+1];if(i==="("||i==="["){let a=i==="("?"\\)":"\\]",c=t.indexOf(a,o+2);if(c>=0){r(),n.push(`{${t.slice(o+2,c)}}`),o=c+2;continue}}if(i==="\\"){r(),n.push("\\\\"),o+=2;continue}e+=s+i,o+=2;continue}if(s==="$"){let i=t[o+1]==="$",a=i?2:1,c=sl(t,o+a,i);if(c>=0){r(),n.push(`{${t.slice(o+a,c)}}`),o=c+a;continue}}e+=s,o++}return r(),n.join("")}function sl(t,n,e){for(let r=n;r<t.length;r++){if(t[r]==="\\"){r++;continue}if(t[r]==="$"&&(!e||t[r+1]==="$"))return r}return-1}function il(t){let n=0;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"){r++;continue}if(o==="{")n++;else if(o==="}"&&--n<0)return!1}if(n!==0)return!1;let e=r=>(t.match(r)||[]).length;return e(/\\left(?![a-zA-Z])/g)===e(/\\right(?![a-zA-Z])/g)&&e(/\\begin\s*\{/g)===e(/\\end\s*\{/g)}function Va(t){let n=Jn(t);return n.length>1&&n.every(il)}function al(t){let n=[],e=0,r=0,o=0,s=0,i=(a,c)=>{n.push(t.slice(o,a),t.slice(a,a+c)),o=a+c};for(;s<t.length;){let a=t[s];if(a==="\\"){let c=t.slice(s);if(c.startsWith("\\begin"))r++;else if(c.startsWith("\\end"))r--;else if(t[s+1]==="\\"&&e===0&&r===0){let u=/^\\\\\s*\[[^\]]*\]/.exec(c),f=u?u[0].length:2;i(s,f),s+=f;continue}s+=2;continue}a==="{"?e++:a==="}"?e--:a==="&"&&e===0&&r===0&&i(s,1),s++}return n.push(t.slice(o)),n}var $a=t=>t==="&"||t.startsWith("\\\\");function Cs(t,n){let e=Jn(t).map(a=>t.mode==="text"?ol(a):a),r=e.map(al),o=r.some(a=>a.some($a)),s=n?r.map((a,c)=>a.map(u=>$a(u)||!u.trim()?u:`\\htmlClass{cir-p${c}}{${u}}`).join("")).join(" "):e.join(" ");if(!o)return s;let i=Ua(t);return i.startsWith("array")?`\\begin{array}{${i.slice(5)}}${s}\\end{array}`:`\\begin{${i}}${s}\\end{${i}}`}function Ua(t){let n=(t.environment||"").trim().replace(/^\\begin\{|\}$/g,"");return t.mode==="text"?n==="flushleft"?"arrayl":n==="flushright"?"arrayr":"arrayc":/^(gather\*?|gathered|center)$/.test(n)?"gathered":"aligned"}var Ls=new Map,Os=new Map;function Ha(t){let n=Ga(t),e=Os.get(n);return e||(e=cl(t).then(r=>fl(r,Ka(t.fontSize))),Os.set(n,e),e.catch(()=>Os.delete(n))),e}function cl(t){let n=Fs(t),e=Ls.get(n);return e||(e=ul(t),Ls.set(n,e),e.catch(()=>Ls.delete(n))),e}async function ul(t){let n=await Oa(),e=Jn(t).length,r=t.mode==="math",o,s=Va(t);try{o=await Ts(n,Cs(t,s),r)}catch(i){if(!(i instanceof Rr))throw i;if(!s)throw Ya(t,i);try{o=await Ts(n,Cs(t,!1),r)}catch(a){throw Ya(t,a)}}return ll(o,e)}function Ya(t,n){let e=n instanceof Error?n.message:String(n),r=t.mode==="text"?"Tex":"MathTex";return new Error(`${r} could not read "${Jn(t).join(" ")}": ${e.replace(/^KaTeX parse error: /,"").replace(/\u0332/g,"")}`)}function ll(t,n){let e=Array.from({length:n},()=>[]),r=t.items.flatMap(u=>u.subpaths),o=eo(r);if(!o)return{parts:e,width:0,height:0};let s=(o.x0+o.x1)/2,i=(o.y0+o.y1)/2,a=1/t.emPx,c=u=>[(u[0]-s)*a,-(u[1]-i)*a];for(let u of t.items){let f=Math.min(Math.max(u.part,0),n-1);e[f].push(u.subpaths.map(l=>({closed:l.closed,points:l.points.map(c)})))}return{parts:e,width:(o.x1-o.x0)*a,height:(o.y1-o.y0)*a}}function fl(t,n){let e=n;return{parts:t.parts.map(r=>r.map(o=>o.map(s=>({closed:s.closed,points:s.points.map(([i,a])=>[i*e,a*e])})))),width:t.width*e,height:t.height*e}}var vn=globalThis,Ns=typeof document!="undefined"?document.currentScript:null,ml=Ns&&Ns.src?Ns.src.replace(/[^/]*$/,""):"/preview-packages/pymations/",Xa=typeof vn.__cirAnimBase=="string"&&vn.__cirAnimBase?vn.__cirAnimBase.endsWith("/")?vn.__cirAnimBase:vn.__cirAnimBase+"/":ml;vn.__cirAnimBase=Xa;vn.__cirAnim=Ca({base:Xa,tex:Ha});})();