pymations 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +24 -2
- package/THIRD-PARTY-NOTICES +240 -0
- package/engine/LICENSE-polygon-clipping.txt +11 -0
- package/engine/anim.js +9 -0
- package/engine/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/engine/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/engine/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/engine/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/engine/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/engine/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/engine/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/engine/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/engine/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/engine/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/engine/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/engine/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/engine/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/engine/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/engine/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/engine/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/engine/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/engine/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/engine/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/engine/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/engine/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/engine/fonts/LICENSE_KATEX_FONTS.txt +106 -0
- package/engine/fonts/LICENSE_LIBERATION.txt +102 -0
- package/engine/fonts/LiberationSans-Bold.ttf +0 -0
- package/engine/fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/engine/fonts/LiberationSans-Italic.ttf +0 -0
- package/engine/fonts/LiberationSans-Regular.ttf +0 -0
- package/engine/katex.min.css +1 -0
- package/engine/katex.min.js +1 -0
- package/engine/manifest.json +1 -0
- package/engine/opentype.min.js +2 -0
- package/package.json +34 -4
- package/pyctures.py +897 -0
- package/pymations.js +1818 -0
- package/pymations.py +5113 -0
package/engine/anim.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* Pymations engine (MIT licence, John Wylie). Built from engine/src. Loads KaTeX and opentype.js beside it. */
|
|
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(/</g,"<").replace(/>/g,">").replace(/&/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});})();
|