(function(L,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],b):(L=typeof globalThis<"u"?globalThis:L||self,b(L.useAnimatedCanvas={},L.React))})(this,function(L,b){"use strict";var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pe={exports:{}},me={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Je;function pr(){if(Je)return me;Je=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,u=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(c,l,g){var d,p={},h=null,v=null;g!==void 0&&(h=""+g),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(v=l.ref);for(d in l)a.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(c&&c.defaultProps)for(d in l=c.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:c,key:h,ref:v,props:p,_owner:u.current}}return me.Fragment=n,me.jsx=i,me.jsxs=i,me}var ye={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ke;function mr(){return Ke||(Ke=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),D=Symbol.iterator,j="@@iterator";function M(r){if(r===null||typeof r!="object")return null;var o=D&&r[D]||r[j];return typeof o=="function"?o:null}var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(r){{for(var o=arguments.length,f=new Array(o>1?o-1:0),m=1;m=1&&P>=0&&R[F]!==N[P];)P--;for(;F>=1&&P>=0;F--,P--)if(R[F]!==N[P]){if(F!==1||P!==1)do if(F--,P--,P<0||R[F]!==N[P]){var K=` `+R[F].replace(" at new "," at ");return r.displayName&&K.includes("")&&(K=K.replace("",r.displayName)),typeof r=="function"&&de.set(r,K),K}while(F>=1&&P>=0);break}}}finally{se=!1,ie.current=_,$(),Error.prepareStackTrace=S}var pe=r?r.displayName||r.name:"",ce=pe?re(pe):"";return typeof r=="function"&&de.set(r,ce),ce}function Me(r,o,f){return ke(r,!1)}function Ne(r){var o=r.prototype;return!!(o&&o.isReactComponent)}function he(r,o,f){if(r==null)return"";if(typeof r=="function")return ke(r,Ne(r));if(typeof r=="string")return re(r);switch(r){case g:return re("Suspense");case d:return re("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case l:return Me(r.render);case p:return he(r.type,o,f);case h:{var m=r,S=m._payload,_=m._init;try{return he(_(S),o,f)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,Oe={},Fe=k.ReactDebugCurrentFrame;function te(r){if(r){var o=r._owner,f=he(r.type,r._source,o?o.type:null);Fe.setExtraStackFrame(f)}else Fe.setExtraStackFrame(null)}function Ee(r,o,f,m,S){{var _=Function.call.bind(ve);for(var E in r)if(_(r,E)){var R=void 0;try{if(typeof r[E]!="function"){var N=Error((m||"React class")+": "+f+" type `"+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[E]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}R=r[E](o,E,m,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(F){R=F}R&&!(R instanceof Error)&&(te(S),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",m||"React class",f,E,typeof R),te(null)),R instanceof Error&&!(R.message in Oe)&&(Oe[R.message]=!0,te(S),T("Failed %s type: %s",f,R.message),te(null))}}}var Be=Array.isArray;function we(r){return Be(r)}function ht(r){{var o=typeof Symbol=="function"&&Symbol.toStringTag,f=o&&r[Symbol.toStringTag]||r.constructor.name||"Object";return f}}function vt(r){try{return or(r),!1}catch{return!0}}function or(r){return""+r}function ir(r){if(vt(r))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ht(r)),or(r)}var Se=k.ReactCurrentOwner,gt={key:!0,ref:!0,__self:!0,__source:!0},ar,sr,Ye;Ye={};function pt(r){if(ve.call(r,"ref")){var o=Object.getOwnPropertyDescriptor(r,"ref").get;if(o&&o.isReactWarning)return!1}return r.ref!==void 0}function mt(r){if(ve.call(r,"key")){var o=Object.getOwnPropertyDescriptor(r,"key").get;if(o&&o.isReactWarning)return!1}return r.key!==void 0}function yt(r,o){if(typeof r.ref=="string"&&Se.current&&o&&Se.current.stateNode!==o){var f=I(Se.current.type);Ye[f]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',I(Se.current.type),r.ref),Ye[f]=!0)}}function bt(r,o){{var f=function(){ar||(ar=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};f.isReactWarning=!0,Object.defineProperty(r,"key",{get:f,configurable:!0})}}function Rt(r,o){{var f=function(){sr||(sr=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};f.isReactWarning=!0,Object.defineProperty(r,"ref",{get:f,configurable:!0})}}var Et=function(r,o,f,m,S,_,E){var R={$$typeof:t,type:r,key:o,ref:f,props:E,_owner:_};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function wt(r,o,f,m,S){{var _,E={},R=null,N=null;f!==void 0&&(ir(f),R=""+f),mt(o)&&(ir(o.key),R=""+o.key),pt(o)&&(N=o.ref,yt(o,S));for(_ in o)ve.call(o,_)&&!gt.hasOwnProperty(_)&&(E[_]=o[_]);if(r&&r.defaultProps){var F=r.defaultProps;for(_ in F)E[_]===void 0&&(E[_]=F[_])}if(R||N){var P=typeof r=="function"?r.displayName||r.name||"Unknown":r;R&&bt(E,P),N&&Rt(E,P)}return Et(r,R,N,S,m,Se.current,E)}}var He=k.ReactCurrentOwner,cr=k.ReactDebugCurrentFrame;function ge(r){if(r){var o=r._owner,f=he(r.type,r._source,o?o.type:null);cr.setExtraStackFrame(f)}else cr.setExtraStackFrame(null)}var Ue;Ue=!1;function Ge(r){return typeof r=="object"&&r!==null&&r.$$typeof===t}function ur(){{if(He.current){var r=I(He.current.type);if(r)return` Check the render method of \``+r+"`."}return""}}function St(r){return""}var fr={};function Tt(r){{var o=ur();if(!o){var f=typeof r=="string"?r:r.displayName||r.name;f&&(o=` Check the top-level render call using <`+f+">.")}return o}}function lr(r,o){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var f=Tt(o);if(fr[f])return;fr[f]=!0;var m="";r&&r._owner&&r._owner!==He.current&&(m=" It was passed a child from "+I(r._owner.type)+"."),ge(r),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,m),ge(null)}}function dr(r,o){{if(typeof r!="object")return;if(we(r))for(var f=0;f",R=" Did you accidentally export a JSX literal instead of a component?"):F=typeof r,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,R)}var P=wt(r,o,f,S,_);if(P==null)return P;if(E){var K=o.children;if(K!==void 0)if(m)if(we(K)){for(var pe=0;pe0?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}";if(!hr[ce+Ve]){var Pt=U.length>0?"{"+U.join(": ..., ")+": ...}":"{}";T(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,Ve,ce,Pt,ce),hr[ce+Ve]=!0}}return r===a?Ct(P):_t(P),P}}function At(r,o,f){return vr(r,o,f,!0)}function kt(r,o,f){return vr(r,o,f,!1)}var Ot=kt,Ft=At;ye.Fragment=a,ye.jsx=Ot,ye.jsxs=Ft}()),ye}process.env.NODE_ENV==="production"?Pe.exports=pr():Pe.exports=mr();var Xe=Pe.exports,q=(e=>(e.Render="render",e.RenderOneFrame="one-frame",e.RenderBreak="break",e))(q||{});const ne=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date){const t=new Date;return t.setTime(e.getTime()),t}if(Array.isArray(e)){const t=[];for(let n=0;n(e.All="all",e.Any="any",e.None="none",e))(O||{});const Qe=e=>({run:t=>{let n=t;for(let a=0;a{if(typeof t=="function")return t(e);if(typeof t=="object"&&"transform"in t&&"condition"in t&&"evaluation"in t){const n=t,{evaluation:a}=n;switch(a){case"all":case"any":case"none":break;default:return e}if(typeof n.condition=="function"){const u=n.condition,s=a!=="none";if(u(e)!==s)return e}if(Array.isArray(n.condition)){let u=n.condition;switch(a){case"all":if(u.some(s=>s(e)===!1))return e;break;case"any":if(u.every(s=>s(e)===!1))return e;break;case"none":if(u.some(s=>s(e)===!0))return e;break}}if(typeof n.transform=="function"){const u=n.transform;return u(e)}if(Array.isArray(n.transform)){let u=n.transform,s=e;for(let i=0;i({condition:e,evaluation:"all",transform:t}),Rr=(e,t)=>({condition:e,evaluation:"any",transform:t}),Er=(e,t)=>({condition:e,evaluation:"none",transform:t}),wr=e=>t=>!e(t);var X=(e=>(e[e.TopLeft=0]="TopLeft",e[e.TopCenter=1]="TopCenter",e[e.TopRight=2]="TopRight",e[e.MiddleLeft=3]="MiddleLeft",e[e.Center=4]="Center",e[e.MiddleRight=5]="MiddleRight",e[e.BottomLeft=6]="BottomLeft",e[e.BottomCenter=7]="BottomCenter",e[e.BottomRight=8]="BottomRight",e))(X||{});const Sr=(e,t)=>{const{width:n,actualBoundingBoxAscent:a,actualBoundingBoxDescent:u}=e.measureText(t),s=a+u;return{width:n,height:s}},De=e=>({run:(t,n)=>{for(let a=0;a({run:(t,n)=>{const a=e??[];for(let u=0;u{if(typeof t=="function"){t(e);return}if(typeof t=="object"&&"filter"in t&&"condition"in t&&"evaluation"in t){const a=t,{evaluation:u}=a;switch(u){case O.All:case O.Any:case O.None:break;default:return}if(typeof a.condition=="function"){let s=a.condition;const i=u!==O.None;if(s(n)!==i)return}if(Array.isArray(a.condition)){let s=a.condition;switch(u){case O.All:if(s.some(i=>i(n)===!1))return;break;case O.Any:if(s.every(i=>i(n)===!1))return;break;case O.None:if(s.some(i=>i(n)===!0))return;break}}if(typeof a.filter=="function"){const s=a.filter;s(e)}if(Array.isArray(a.filter)){let s=a.filter;for(let i=0;i{if(typeof t=="function"){t(e,n);return}if(typeof t=="object"&&"render"in t&&"condition"in t&&"evaluation"in t){const a=t,{evaluation:u}=a;switch(u){case O.All:case O.Any:case O.None:break;default:return}if(typeof a.condition=="function"){const s=a.condition,i=u!==O.None;if(s(n)!==i)return}if(Array.isArray(a.condition)){let s=a.condition;switch(u){case O.All:if(s.some(i=>i(n)===!1))return;break;case O.Any:if(s.every(i=>i(n)===!1))return;break;case O.None:if(s.some(i=>i(n)===!0))return;break}}if(typeof a.render=="function"){const s=a.render;s(e,n)}if(Array.isArray(a.render)){let s=a.render;for(let i=0;i({condition:e,evaluation:O.All,render:t}),Ar=(e,t)=>({condition:e,evaluation:O.Any,render:t}),kr=(e,t)=>({condition:e,evaluation:O.None,render:t}),Or=(e,t)=>({condition:e,evaluation:O.All,filter:t}),Fr=(e,t)=>({condition:e,evaluation:O.Any,filter:t}),Pr=(e,t)=>({condition:e,evaluation:O.None,filter:t}),Dr={location:X.TopLeft,color:"#000000",opacity:1,renderFps:!0,renderSize:!0,renderClientSize:!0,renderPixelRatio:!0,renderFrameNumber:!0},je={size:50,color:"#000000",opacity:1,dashLength:0},Ce={autoStart:!0,renderEnvironmentLayer:!1,renderGridLayer:!1,maxFrame:Number.MAX_SAFE_INTEGER},jr=e=>{let t;if(t=ne(Dr),e===void 0||e===!1)return null;typeof e=="number"&&(t.location=e),typeof e=="string"&&(t.color=e);const{x:n,y:a}=e;if(n!==void 0&&a!==void 0&&(t.location={x:n,y:a}),typeof e=="object"){const{location:i,color:c,opacity:l,renderFps:g,renderSize:d,renderClientSize:p,renderPixelRatio:h,renderFrameNumber:v}=e;i!==void 0&&(t.location=i),c!==void 0&&(t.color=c),l!==void 0&&(t.opacity=l),g!==void 0&&(t.renderFps=g),d!==void 0&&(t.renderSize=d),p!==void 0&&(t.renderClientSize=p),h!==void 0&&(t.renderPixelRatio=h),v!==void 0&&(t.renderFrameNumber=v)}let u;if(typeof e=="function")return u=e,u;const s=(i,c,l)=>{let{x:g,y:d}=t.location;if(g!==void 0&&d!==void 0&&g>=0&&g<=c.width&&d>=0&&d<=c.height)return{x:g,y:d};const{width:p,height:h}=Sr(l,i),v=10,D=0+v,j=0+v+v,M=c.width/2-p/2,k=c.height/2-h/2,T=c.width-p-v,V=c.height-h;switch(t.location){case X.TopCenter:g=M,d=j;break;case X.TopRight:g=T,d=j;break;case X.MiddleLeft:g=D,d=k;break;case X.Center:g=M,d=k;break;case X.MiddleRight:g=T,d=k;break;case X.BottomLeft:g=D,d=V;break;case X.BottomCenter:g=M,d=V;break;case X.BottomRight:g=T,d=V;break;case X.TopLeft:default:g=D,d=j;break}return{x:g,y:d}};return u=(i,c)=>{const l=t.renderFps?`fps: ${c.fps}; `:"",g=t.renderSize?`size: ${c.width}x${c.height}; `:"",d=t.renderClientSize?`client: ${c.clientWidth}x${c.clientHeight}; `:"",p=t.renderPixelRatio?`ratio: ${c.pixelRatio}; `:"",h=t.renderFrameNumber?`frame: ${c.frame};`:"",v=`${l}${g}${d}${p}${h}`.trim(),{x:D,y:j}=s(v,c,i);i.fillStyle=t.color,i.globalAlpha=t.opacity,i.fillText(v,D,j)},u},xr=e=>{let t;if(t=ne(je),e===void 0||e===!1)return null;typeof e=="string"&&(t.color=e),typeof e=="number"&&(t.size={width:e,height:e});const{width:n,height:a}=e;if(n!==void 0&&a!==void 0&&(t.size={width:n,height:a}),typeof e=="object"){const{size:s,color:i,opacity:c,dashLength:l}=e;s!==void 0&&(t.size=s),i!==void 0&&(t.color=i),c!==void 0&&(t.opacity=c),l!==void 0&&(t.dashLength=l)}let u;return typeof e=="function"?(u=e,u):(u=s=>{s.strokeStyle=t.color,s.globalAlpha=t.opacity,(t.dashLength??0)>0&&s.setLineDash([t.dashLength]);const{width:i,height:c}=s.canvas;let l;typeof t.size=="number"?l={width:t.size,height:t.size}:l=t.size;let{width:g,height:d}=l;(g<=0||g>i)&&(g=je.size),(d<=0||d>c)&&(d=je.size);let p=g;for(;pwindow.requestAnimationFrame(e),Lr=e=>{window.cancelAnimationFrame(e)},zr=()=>window.devicePixelRatio||1;var Ir="Expected a function",$e=NaN,Wr="[object Symbol]",Mr=/^\s+|\s+$/g,Nr=/^[-+]0x[0-9a-f]+$/i,Br=/^0b[01]+$/i,Yr=/^0o[0-7]+$/i,Hr=parseInt,Ur=typeof Te=="object"&&Te&&Te.Object===Object&&Te,Gr=typeof self=="object"&&self&&self.Object===Object&&self,Vr=Ur||Gr||Function("return this")(),Jr=Object.prototype,Kr=Jr.toString,Xr=Math.max,Qr=Math.min,xe=function(){return Vr.Date.now()};function Zr(e,t,n){var a,u,s,i,c,l,g=0,d=!1,p=!1,h=!0;if(typeof e!="function")throw new TypeError(Ir);t=qe(t)||0,Le(n)&&(d=!!n.leading,p="maxWait"in n,s=p?Xr(qe(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h);function v(A){var y=a,w=u;return a=u=void 0,g=A,i=e.apply(w,y),i}function D(A){return g=A,c=setTimeout(k,t),d?v(A):i}function j(A){var y=A-l,w=A-g,x=t-y;return p?Qr(x,s-w):x}function M(A){var y=A-l,w=A-g;return l===void 0||y>=t||y<0||p&&w>=s}function k(){var A=xe();if(M(A))return T(A);c=setTimeout(k,j(A))}function T(A){return c=void 0,h&&a?v(A):(a=u=void 0,i)}function V(){c!==void 0&&clearTimeout(c),g=0,a=l=u=c=void 0}function Q(){return c===void 0?i:T(xe())}function B(){var A=xe(),y=M(A);if(a=arguments,u=this,l=A,y){if(c===void 0)return D(l);if(p)return c=setTimeout(k,t),v(l)}return c===void 0&&(c=setTimeout(k,t)),i}return B.cancel=V,B.flush=Q,B}function Le(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function $r(e){return!!e&&typeof e=="object"}function qr(e){return typeof e=="symbol"||$r(e)&&Kr.call(e)==Wr}function qe(e){if(typeof e=="number")return e;if(qr(e))return $e;if(Le(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Le(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(Mr,"");var n=Br.test(e);return n||Yr.test(e)?Hr(e.slice(2),n?2:8):Nr.test(e)?$e:+e}var et=Zr;const er=gr(et);var Ae=typeof window<"u"?b.useLayoutEffect:b.useEffect;function ue(e,t,n,a){const u=b.useRef(t);Ae(()=>{u.current=t},[t]),b.useEffect(()=>{const s=(n==null?void 0:n.current)??window;if(!(s&&s.addEventListener))return;const i=c=>{u.current(c)};return s.addEventListener(e,i,a),()=>{s.removeEventListener(e,i,a)}},[e,n,a])}function rr(e){const t=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return Ae(()=>{t.current=e},[e]),b.useCallback((...n)=>{var a;return(a=t.current)==null?void 0:a.call(t,...n)},[t])}var ze=typeof window>"u";function rt(e,t,n={}){const{initializeWithValue:a=!0}=n,u=b.useCallback(h=>n.serializer?n.serializer(h):JSON.stringify(h),[n]),s=b.useCallback(h=>{if(n.deserializer)return n.deserializer(h);if(h==="undefined")return;const v=t instanceof Function?t():t;let D;try{D=JSON.parse(h)}catch(j){return console.error("Error parsing JSON:",j),v}return D},[n,t]),i=b.useCallback(()=>{const h=t instanceof Function?t():t;if(ze)return h;try{const v=window.localStorage.getItem(e);return v?s(v):h}catch(v){return console.warn(`Error reading localStorage key “${e}”:`,v),h}},[t,e,s]),[c,l]=b.useState(()=>a?i():t instanceof Function?t():t),g=rr(h=>{ze&&console.warn(`Tried setting localStorage key “${e}” even though environment is not a client`);try{const v=h instanceof Function?h(i()):h;window.localStorage.setItem(e,u(v)),l(v),window.dispatchEvent(new StorageEvent("local-storage",{key:e}))}catch(v){console.warn(`Error setting localStorage key “${e}”:`,v)}}),d=rr(()=>{ze&&console.warn(`Tried removing localStorage key “${e}” even though environment is not a client`);const h=t instanceof Function?t():t;window.localStorage.removeItem(e),l(h),window.dispatchEvent(new StorageEvent("local-storage",{key:e}))});b.useEffect(()=>{l(i())},[e]);const p=b.useCallback(h=>{h.key&&h.key!==e||l(i())},[e,i]);return ue("storage",p),ue("local-storage",p),[c,g,d]}var tt=typeof window>"u";function nt(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const a=c=>tt?t:window.matchMedia(c).matches,[u,s]=b.useState(()=>n?a(e):t);function i(){s(a(e))}return Ae(()=>{const c=window.matchMedia(e);return i(),c.addListener?c.addListener(i):c.addEventListener("change",i),()=>{c.removeListener?c.removeListener(i):c.removeEventListener("change",i)}},[e]),u}var ot="(prefers-color-scheme: dark)",it="usehooks-ts-dark-mode";function at(e={}){const{defaultValue:t,localStorageKey:n=it,initializeWithValue:a=!0}=e,u=nt(ot,{initializeWithValue:a,defaultValue:t}),[s,i]=rt(n,t??u??!1,{initializeWithValue:a});return Ae(()=>{u!==s&&i(u)},[u]),{isDarkMode:s,toggle:()=>{i(c=>!c)},enable:()=>{i(!0)},disable:()=>{i(!1)},set:c=>{i(c)}}}function st(e){const t=b.useRef(e);t.current=e,b.useEffect(()=>()=>{t.current()},[])}function ct(e,t=500,n){const a=b.useRef();st(()=>{a.current&&a.current.cancel()});const u=b.useMemo(()=>{const s=er(e,t,n),i=(...c)=>s(...c);return i.cancel=()=>{s.cancel()},i.isPending=()=>!!a.current,i.flush=()=>s.flush(),i},[e,t,n]);return b.useEffect(()=>{a.current=er(e,t,n)},[e,t,n]),u}function ut(){const e=b.useRef(!1);return b.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),b.useCallback(()=>e.current,[])}var tr={width:void 0,height:void 0};function ft(e){const{ref:t,box:n="content-box"}=e,[{width:a,height:u},s]=b.useState(tr),i=ut(),c=b.useRef({...tr}),l=b.useRef(void 0);return l.current=e.onResize,b.useEffect(()=>{if(!t.current||typeof window>"u"||!("ResizeObserver"in window))return;const g=new ResizeObserver(([d])=>{const p=n==="border-box"?"borderBoxSize":n==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",h=nr(d,p,"inlineSize"),v=nr(d,p,"blockSize");if(c.current.width!==h||c.current.height!==v){const j={width:h,height:v};c.current.width=h,c.current.height=v,l.current?l.current(j):i()&&s(j)}});return g.observe(t.current,{box:n}),()=>{g.disconnect()}},[n,t,i]),{width:a,height:u}}function nr(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:t==="contentBoxSize"?e.contentRect[n==="inlineSize"?"width":"height"]:void 0}const lt=({autoStart:e=Ce.autoStart,onInit:t,onPreDraw:n,onDraw:a,onPostDraw:u,renderEnvironmentLayer:s=Ce.renderEnvironmentLayer,renderGridLayer:i=Ce.renderGridLayer,maxFrame:c=Ce.maxFrame})=>{const l=b.useRef(null),{isDarkMode:g}=at(),d=jr(s),p=xr(i),h=b.useRef({frameCount:0,fps:0,lastRender:performance.now()}),v=b.useRef({control:null,hasInitialised:!1,isPaused:!1}),D=()=>{v.current.control=null,v.current.hasInitialised=!1},j=()=>{v.current.control=q.RenderBreak},M=y=>{const w=l.current;if(w===null)return;const x={frame:h.current.frameCount,fps:h.current.fps,clientHeight:w.clientHeight,clientWidth:w.clientWidth,height:w.height,width:w.width,offsetHeight:w.offsetHeight,offsetWidth:w.offsetWidth,pixelRatio:devicePixelRatio,isDarkMode:g};y(x)===!0&&(v.current.control=q.RenderBreak)},k=()=>{v.current.control=q.Render},T=()=>{v.current.control=q.RenderOneFrame},V=(y,w)=>{const x=l.current;x!==null&&(x.width=y,x.height=w)},Q=()=>{v.current.isPaused=!1},B=()=>{v.current.isPaused=!0},A=()=>{const y=l.current;if(y===null)return;const{width:w,height:x}=y,z=y.getContext("2d");z==null||z.beginPath(),z==null||z.resetTransform(),z==null||z.clearRect(0,0,w,x)};return b.useEffect(()=>{const y=l.current;if(y===null)return;y.style.touchAction="none";const w=y.getContext("2d"),x=zr();let z;const fe=()=>v.current.isPaused,oe=()=>e===!0&&v.current.control===null?!0:e===!1&&v.current.control===null||v.current.control===q.RenderBreak?!1:(v.current.control===q.RenderOneFrame&&(v.current.control=q.RenderBreak),!0),I=()=>{const Y=performance.now(),Re=Y-h.current.lastRender,le=Math.round(1e3/Re);h.current.fps=le,h.current.lastRender=Y;let ee=h.current.frameCount;return ee=ee+1<=c?ee+1:0,h.current.frameCount=ee,le},J=()=>{if(!w||fe()||oe()===!1){z=Ze(J);return}v.current.hasInitialised===!1&&t&&t(y,{devicePixelRatio:x,isDarkMode:g}),v.current.hasInitialised=!0,A();const Y={frame:h.current.frameCount,fps:h.current.fps,clientHeight:y.clientHeight,clientWidth:y.clientWidth,height:y.height,width:y.width,offsetHeight:y.offsetHeight,offsetWidth:y.offsetWidth,pixelRatio:x,isDarkMode:g};n&&n(w,Y),a&&a(w,Y),u&&u(w,Y),p&&(w.save(),p(w),w.restore()),d&&(w.save(),d(w,Y),w.restore()),I(),z=Ze(J)};return J(),()=>{Lr(z)}}),{ref:l,utilities:{resize:V,pauseLoop:B,startLoop:Q},control:{renderBreak:j,renderBreakWhen:M,renderStart:k,renderStep:T,renderReset:D}}},be={autoStart:!0,enableDebug:!1,autoResetContext:!0,resizeDelayMs:200,protectData:!0},dt=(e,t)=>{const{initialiseData:n,preRenderTransform:a,globalFilter:u,renderBackgroundFilter:s,renderBackground:i,renderFilter:c,render:l,renderForegroundFilter:g,renderForeground:d,postRenderTransform:p,options:h={},renderEnvironmentLayer:v,renderGridLayer:D}=e,{autoStart:j=be.autoStart,enableDebug:M=be.enableDebug,autoResetContext:k=be.autoResetContext,resizeDelayMs:T=be.resizeDelayMs,protectData:V=be.protectData}=h,Q=b.useRef(t??null),B=b.useRef(null),A=(C,H)=>{n!==void 0&&(Q.current=ne(n(C,H)))};let y=null;const w=(C,H)=>{if(y=Q.current!==null&&V?ne(Q.current):Q.current,a===void 0)return;const G={drawData:H,data:y??void 0},Z=Array.isArray(a)?a:[a],{data:$}=Qe(Z).run(G);$!==void 0&&(y=$)},x=(C,H)=>{const W={drawData:H,data:y??void 0};C.save();const G=u!==void 0?Array.isArray(u)?u:[u]:[];_e(G).run(C,W),k&&C.save();const Z=s!==void 0?Array.isArray(s)?s:[s]:[];_e(Z).run(C,W);const $=i!==void 0?Array.isArray(i)?i:[i]:[];De($).run(C,W),k&&C.restore(),k&&C.save();const ie=c!==void 0?Array.isArray(c)?c:[c]:[];_e(ie).run(C,W);const ae=l!==void 0?Array.isArray(l)?l:[l]:[];De(ae).run(C,W),k&&C.restore(),k&&C.save();const re=g!==void 0?Array.isArray(g)?g:[g]:[];_e(re).run(C,W);const se=d!==void 0?Array.isArray(d)?d:[d]:[];De(se).run(C,W),k&&C.restore(),C.restore()},z=(C,H)=>{const W={drawData:H,data:y??void 0};let G=[];p===void 0?G=[]:G=Array.isArray(p)?p:[p];const{data:Z}=Qe(G).run(W);Z!==void 0&&(y=Z);const $=y!==null&&V?ne(y):y;Q.current=$},{ref:fe,utilities:oe,control:I}=lt({autoStart:j,onInit:A,onPreDraw:w,onDraw:x,onPostDraw:z,renderEnvironmentLayer:v,renderGridLayer:D});return oe.pauseLoop(),{Canvas:({className:C,onKeyDown:H,onKeyUp:W,onCanvasResize:G,onFocus:Z,onBlur:$,onClick:ie,onPointerEnter:ae,onPointerMove:re,onPointerDown:se,onPointerUp:de,onPointerOut:We})=>{const ke=H??(()=>{}),Me=W??(()=>{}),Ne=Z??(()=>{}),he=$??(()=>{});ue("keydown",ke,B),ue("keyup",Me,B),ue("focus",Ne,B),ue("blur",he,B);const Oe=ct(Fe=>{const{width:te,height:Ee}=Fe,{resize:Be,startLoop:we}=oe;fe.current&&te&&Ee&&(G&&G(te,Ee),Be(te,Ee),we())},T);return ft({ref:B,onResize:Oe}),Xe.jsx("div",{ref:B,tabIndex:0,className:C,children:Xe.jsx("canvas",{ref:fe,style:{flexGrow:1},onClick:ie,onPointerEnter:ae,onPointerMove:re,onPointerDown:se,onPointerUp:de,onPointerOut:We})})},debug:{renderBreak:()=>{M!==!1&&I.renderBreak()},renderBreakWhen:C=>{M!==!1&&I.renderBreakWhen(H=>C({drawData:H,data:y??void 0}))},renderStart:()=>{M!==!1&&I.renderStart()},renderStep:()=>{M!==!1&&I.renderStep()}}}};L.filterWhen=Or,L.filterWhenAny=Fr,L.filterWhenNot=Pr,L.not=wr,L.renderWhen=Cr,L.renderWhenAny=Ar,L.renderWhenNot=kr,L.use2dAnimatedCanvas=dt,L.when=br,L.whenAny=Rr,L.whenNot=Er,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});