@ninesstudios/whiteboard 0.0.1

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.
@@ -0,0 +1,54 @@
1
+ (function(ce,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],N):(ce=typeof globalThis<"u"?globalThis:ce||self,N(ce.Whiteboard={},ce.React))})(this,(function(ce,N){"use strict";function un(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Q=un(N);var Le={exports:{}},Ne={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Zt;function dn(){if(Zt)return Ne;Zt=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,o,s){var c=null;if(s!==void 0&&(c=""+s),o.key!==void 0&&(c=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:e,type:n,key:c,ref:o!==void 0?o:null,props:s}}return Ne.Fragment=t,Ne.jsx=r,Ne.jsxs=r,Ne}var Me={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Jt;function fn(){return Jt||(Jt=1,process.env.NODE_ENV!=="production"&&(function(){function e(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===oe?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case M:return"Fragment";case b:return"Profiler";case P:return"StrictMode";case T:return"Suspense";case V:return"SuspenseList";case F:return"Activity"}if(typeof x=="object")switch(typeof x.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),x.$$typeof){case j:return"Portal";case w:return x.displayName||"Context";case I:return(x._context.displayName||"Context")+".Consumer";case v:var z=x.render;return x=x.displayName,x||(x=z.displayName||z.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case B:return z=x.displayName||null,z!==null?z:e(x.type)||"Memo";case L:z=x._payload,x=x._init;try{return e(x(z))}catch{}}return null}function t(x){return""+x}function r(x){try{t(x);var z=!1}catch{z=!0}if(z){z=console;var Y=z.error,U=typeof Symbol=="function"&&Symbol.toStringTag&&x[Symbol.toStringTag]||x.constructor.name||"Object";return Y.call(z,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",U),t(x)}}function n(x){if(x===M)return"<>";if(typeof x=="object"&&x!==null&&x.$$typeof===L)return"<...>";try{var z=e(x);return z?"<"+z+">":"<...>"}catch{return"<...>"}}function o(){var x=fe.A;return x===null?null:x.getOwner()}function s(){return Error("react-stack-top-frame")}function c(x){if(Ie.call(x,"key")){var z=Object.getOwnPropertyDescriptor(x,"key").get;if(z&&z.isReactWarning)return!1}return x.key!==void 0}function a(x,z){function Y(){ke||(ke=!0,console.error("%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://react.dev/link/special-props)",z))}Y.isReactWarning=!0,Object.defineProperty(x,"key",{get:Y,configurable:!0})}function y(){var x=e(this.type);return _e[x]||(_e[x]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),x=this.props.ref,x!==void 0?x:null}function d(x,z,Y,U,Se,he){var X=Y.ref;return x={$$typeof:O,type:x,key:z,props:Y,_owner:U},(X!==void 0?X:null)!==null?Object.defineProperty(x,"ref",{enumerable:!1,get:y}):Object.defineProperty(x,"ref",{enumerable:!1,value:null}),x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(x,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(x,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Se}),Object.defineProperty(x,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:he}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x}function g(x,z,Y,U,Se,he){var X=z.children;if(X!==void 0)if(U)if(Re(X)){for(U=0;U<X.length;U++)f(X[U]);Object.freeze&&Object.freeze(X)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(X);if(Ie.call(z,"key")){X=e(x);var se=Object.keys(z).filter(function(ht){return ht!=="key"});U=0<se.length?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}",We[X+U]||(se=0<se.length?"{"+se.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,U,X,se,X),We[X+U]=!0)}if(X=null,Y!==void 0&&(r(Y),X=""+Y),c(z)&&(r(z.key),X=""+z.key),"key"in z){Y={};for(var me in z)me!=="key"&&(Y[me]=z[me])}else Y=z;return X&&a(Y,typeof x=="function"?x.displayName||x.name||"Unknown":x),d(x,X,Y,o(),Se,he)}function f(x){h(x)?x._store&&(x._store.validated=1):typeof x=="object"&&x!==null&&x.$$typeof===L&&(x._payload.status==="fulfilled"?h(x._payload.value)&&x._payload.value._store&&(x._payload.value._store.validated=1):x._store&&(x._store.validated=1))}function h(x){return typeof x=="object"&&x!==null&&x.$$typeof===O}var _=N,O=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),w=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),fe=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ie=Object.prototype.hasOwnProperty,Re=Array.isArray,Ee=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(x){return x()}};var ke,_e={},Ae=_.react_stack_bottom_frame.bind(_,s)(),ft=Ee(n(s)),We={};Me.Fragment=M,Me.jsx=function(x,z,Y){var U=1e4>fe.recentlyCreatedOwnerStacks++;return g(x,z,Y,!1,U?Error("react-stack-top-frame"):Ae,U?Ee(n(x)):ft)},Me.jsxs=function(x,z,Y){var U=1e4>fe.recentlyCreatedOwnerStacks++;return g(x,z,Y,!0,U?Error("react-stack-top-frame"):Ae,U?Ee(n(x)):ft)}})()),Me}var Qt;function hn(){return Qt||(Qt=1,process.env.NODE_ENV==="production"?Le.exports=dn():Le.exports=fn()),Le.exports}var u=hn(),Ye={exports:{}},St={};/**
23
+ * @license React
24
+ * use-sync-external-store-with-selector.production.js
25
+ *
26
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
27
+ *
28
+ * This source code is licensed under the MIT license found in the
29
+ * LICENSE file in the root directory of this source tree.
30
+ */var er;function pn(){if(er)return St;er=1;var e=N;function t(y,d){return y===d&&(y!==0||1/y===1/d)||y!==y&&d!==d}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,a=e.useDebugValue;return St.useSyncExternalStoreWithSelector=function(y,d,g,f,h){var _=o(null);if(_.current===null){var O={hasValue:!1,value:null};_.current=O}else O=_.current;_=c(function(){function M(v){if(!P){if(P=!0,b=v,v=f(v),h!==void 0&&O.hasValue){var T=O.value;if(h(T,v))return I=T}return I=v}if(T=I,r(b,v))return T;var V=f(v);return h!==void 0&&h(T,V)?(b=v,T):(b=v,I=V)}var P=!1,b,I,w=g===void 0?null:g;return[function(){return M(d())},w===null?void 0:function(){return M(w())}]},[d,g,f,h]);var j=n(y,_[0],_[1]);return s(function(){O.hasValue=!0,O.value=j},[j]),a(j),j},St}var Nt={};/**
31
+ * @license React
32
+ * use-sync-external-store-with-selector.development.js
33
+ *
34
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
35
+ *
36
+ * This source code is licensed under the MIT license found in the
37
+ * LICENSE file in the root directory of this source tree.
38
+ */var tr;function yn(){return tr||(tr=1,process.env.NODE_ENV!=="production"&&(function(){function e(y,d){return y===d&&(y!==0||1/y===1/d)||y!==y&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=N,r=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,a=t.useDebugValue;Nt.useSyncExternalStoreWithSelector=function(y,d,g,f,h){var _=o(null);if(_.current===null){var O={hasValue:!1,value:null};_.current=O}else O=_.current;_=c(function(){function M(v){if(!P){if(P=!0,b=v,v=f(v),h!==void 0&&O.hasValue){var T=O.value;if(h(T,v))return I=T}return I=v}if(T=I,r(b,v))return T;var V=f(v);return h!==void 0&&h(T,V)?(b=v,T):(b=v,I=V)}var P=!1,b,I,w=g===void 0?null:g;return[function(){return M(d())},w===null?void 0:function(){return M(w())}]},[d,g,f,h]);var j=n(y,_[0],_[1]);return s(function(){O.hasValue=!0,O.value=j},[j]),a(j),j},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Nt}var rr;function gn(){return rr||(rr=1,process.env.NODE_ENV==="production"?Ye.exports=pn():Ye.exports=yn()),Ye.exports}var mn=gn();function wn(e){e()}function vn(){let e=null,t=null;return{clear(){e=null,t=null},notify(){wn(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const o=t={callback:r,next:null,prev:t};return o.prev?o.prev.next=o:e=o,function(){!n||e===null||(n=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:e=o.next)}}}}var nr={notify(){},get:()=>[]};function bn(e,t){let r,n=nr,o=0,s=!1;function c(j){g();const M=n.subscribe(j);let P=!1;return()=>{P||(P=!0,M(),f())}}function a(){n.notify()}function y(){O.onStateChange&&O.onStateChange()}function d(){return s}function g(){o++,r||(r=e.subscribe(y),n=vn())}function f(){o--,r&&o===0&&(r(),r=void 0,n.clear(),n=nr)}function h(){s||(s=!0,g())}function _(){s&&(s=!1,f())}const O={addNestedSub:c,notifyNestedSubs:a,handleChangeWrapper:y,isSubscribed:d,trySubscribe:h,tryUnsubscribe:_,getListeners:()=>n};return O}var xn=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",En=xn(),Cn=()=>typeof navigator<"u"&&navigator.product==="ReactNative",kn=Cn(),_n=()=>En||kn?Q.useLayoutEffect:Q.useEffect,Sn=_n(),Mt=Symbol.for("react-redux-context"),jt=typeof globalThis<"u"?globalThis:{};function Nn(){if(!Q.createContext)return{};const e=jt[Mt]??(jt[Mt]=new Map);let t=e.get(Q.createContext);return t||(t=Q.createContext(null),process.env.NODE_ENV!=="production"&&(t.displayName="ReactRedux"),e.set(Q.createContext,t)),t}var ye=Nn();function Mn(e){const{children:t,context:r,serverState:n,store:o}=e,s=Q.useMemo(()=>{const y=bn(o),d={store:o,subscription:y,getServerState:n?()=>n:void 0};if(process.env.NODE_ENV==="production")return d;{const{identityFunctionCheck:g="once",stabilityCheck:f="once"}=e;return Object.assign(d,{stabilityCheck:f,identityFunctionCheck:g})}},[o,n]),c=Q.useMemo(()=>o.getState(),[o]);Sn(()=>{const{subscription:y}=s;return y.onStateChange=y.notifyNestedSubs,y.trySubscribe(),c!==o.getState()&&y.notifyNestedSubs(),()=>{y.tryUnsubscribe(),y.onStateChange=void 0}},[s,c]);const a=r||ye;return Q.createElement(a.Provider,{value:s},t)}var jn=Mn;function Ot(e=ye){return function(){const r=Q.useContext(e);if(process.env.NODE_ENV!=="production"&&!r)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return r}}var or=Ot();function ir(e=ye){const t=e===ye?or:Ot(e),r=()=>{const{store:n}=t();return n};return Object.assign(r,{withTypes:()=>r}),r}var On=ir();function Tn(e=ye){const t=e===ye?On:ir(e),r=()=>t().dispatch;return Object.assign(r,{withTypes:()=>r}),r}var Tt=Tn(),Pn=(e,t)=>e===t;function Dn(e=ye){const t=e===ye?or:Ot(e),r=(n,o={})=>{const{equalityFn:s=Pn}=typeof o=="function"?{equalityFn:o}:o;if(process.env.NODE_ENV!=="production"){if(!n)throw new Error("You must pass a selector to useSelector");if(typeof n!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof s!="function")throw new Error("You must pass a function as an equality function to useSelector")}const c=t(),{store:a,subscription:y,getServerState:d}=c,g=Q.useRef(!0),f=Q.useCallback({[n.name](_){const O=n(_);if(process.env.NODE_ENV!=="production"){const{devModeChecks:j={}}=typeof o=="function"?{}:o,{identityFunctionCheck:M,stabilityCheck:P}=c,{identityFunctionCheck:b,stabilityCheck:I}={stabilityCheck:P,identityFunctionCheck:M,...j};if(I==="always"||I==="once"&&g.current){const w=n(_);if(!s(O,w)){let v;try{throw new Error}catch(T){({stack:v}=T)}console.warn("Selector "+(n.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
39
+ Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:_,selected:O,selected2:w,stack:v})}}if((b==="always"||b==="once"&&g.current)&&O===_){let w;try{throw new Error}catch(v){({stack:w}=v)}console.warn("Selector "+(n.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
40
+ Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:w})}g.current&&(g.current=!1)}return O}}[n.name],[n]),h=mn.useSyncExternalStoreWithSelector(y.addNestedSub,a.getState,d||a.getState,f,s);return Q.useDebugValue(h),h};return Object.assign(r,{withTypes:()=>r}),r}var K=Dn();const zn={en:{pointer:"Pointer",text:"Text",image:"Image",pencil:"Pencil",rectangle:"Rectangle",circle:"Circle",eraser:"Eraser",fitToView:"Fit to view",exportAsPng:"Export as PNG",moreShapes:"More Shapes",triangle:"Triangle",diamond:"Diamond",star:"Star",heart:"Heart",hexagon:"Hexagon",octagon:"Octagon",arrow:"Arrow",fontSize:"Font Size",fontColor:"Font Color",layerOrder:"Layer Order",bringToFront:"Bring to Front",sendToBack:"Send to Back",brushColor:"Brush Color",brushSize:"Brush Size",strokeColor:"Stroke Color",fillColor:"Fill Color",strokeWidth:"Stroke Width",language:"Language",english:"English",turkish:"Turkish"},tr:{pointer:"İşaretçi",text:"Metin",image:"Resim",pencil:"Kalem",rectangle:"Dikdörtgen",circle:"Daire",eraser:"Silgi",fitToView:"Ekrana sığdır",exportAsPng:"PNG olarak dışa aktar",moreShapes:"Daha Fazla Şekil",triangle:"Üçgen",diamond:"Elmas",star:"Yıldız",heart:"Kalp",hexagon:"Altıgen",octagon:"Sekizgen",arrow:"Ok",fontSize:"Yazı Boyutu",fontColor:"Yazı Rengi",layerOrder:"Katman Sırası",bringToFront:"Öne Getir",sendToBack:"Arkaya Gönder",brushColor:"Fırça Rengi",brushSize:"Fırça Boyutu",strokeColor:"Çizgi Rengi",fillColor:"Dolgu Rengi",strokeWidth:"Çizgi Kalınlığı",language:"Dil",english:"İngilizce",turkish:"Türkçe"}},sr=N.createContext(),ar="whiteboard-language",In=()=>(navigator.language||navigator.userLanguage).startsWith("tr")?"tr":"en",Rn=()=>{const e=localStorage.getItem(ar);return e&&(e==="en"||e==="tr")?e:In()},An=({children:e})=>{const[t,r]=N.useState(Rn);N.useEffect(()=>{localStorage.setItem(ar,t)},[t]);const n=s=>zn[t][s]||s,o=s=>{(s==="en"||s==="tr")&&r(s)};return u.jsx(sr.Provider,{value:{language:t,t:n,changeLanguage:o},children:e})},cr=()=>{const e=N.useContext(sr);if(!e)throw new Error("useLanguage must be used within a LanguageProvider");return e};function G(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Wn=typeof Symbol=="function"&&Symbol.observable||"@@observable",lr=Wn,Pt=()=>Math.random().toString(36).substring(7).split("").join("."),Vn={INIT:`@@redux/INIT${Pt()}`,REPLACE:`@@redux/REPLACE${Pt()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Pt()}`},ve=Vn;function je(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Ln(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(Xn(e))return"date";if(Fn(e))return"error";const r=Yn(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Yn(e){return typeof e.constructor=="function"?e.constructor.name:null}function Fn(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function Xn(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function ge(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=Ln(e)),t}function ur(e,t,r){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?G(2):`Expected the root reducer to be a function. Instead, received: '${ge(e)}'`);if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?G(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?G(1):`Expected the enhancer to be a function. Instead, received: '${ge(r)}'`);return r(ur)(e,t)}let n=e,o=t,s=new Map,c=s,a=0,y=!1;function d(){c===s&&(c=new Map,s.forEach((M,P)=>{c.set(P,M)}))}function g(){if(y)throw new Error(process.env.NODE_ENV==="production"?G(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function f(M){if(typeof M!="function")throw new Error(process.env.NODE_ENV==="production"?G(4):`Expected the listener to be a function. Instead, received: '${ge(M)}'`);if(y)throw new Error(process.env.NODE_ENV==="production"?G(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let P=!0;d();const b=a++;return c.set(b,M),function(){if(P){if(y)throw new Error(process.env.NODE_ENV==="production"?G(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");P=!1,d(),c.delete(b),s=null}}}function h(M){if(!je(M))throw new Error(process.env.NODE_ENV==="production"?G(7):`Actions must be plain objects. Instead, the actual type was: '${ge(M)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof M.type>"u")throw new Error(process.env.NODE_ENV==="production"?G(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof M.type!="string")throw new Error(process.env.NODE_ENV==="production"?G(17):`Action "type" property must be a string. Instead, the actual type was: '${ge(M.type)}'. Value was: '${M.type}' (stringified)`);if(y)throw new Error(process.env.NODE_ENV==="production"?G(9):"Reducers may not dispatch actions.");try{y=!0,o=n(o,M)}finally{y=!1}return(s=c).forEach(b=>{b()}),M}function _(M){if(typeof M!="function")throw new Error(process.env.NODE_ENV==="production"?G(10):`Expected the nextReducer to be a function. Instead, received: '${ge(M)}`);n=M,h({type:ve.REPLACE})}function O(){const M=f;return{subscribe(P){if(typeof P!="object"||P===null)throw new Error(process.env.NODE_ENV==="production"?G(11):`Expected the observer to be an object. Instead, received: '${ge(P)}'`);function b(){const w=P;w.next&&w.next(g())}return b(),{unsubscribe:M(b)}},[lr](){return this}}}return h({type:ve.INIT}),{dispatch:h,subscribe:f,getState:g,replaceReducer:_,[lr]:O}}function dr(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function $n(e,t,r,n){const o=Object.keys(t),s=r&&r.type===ve.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(o.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!je(e))return`The ${s} has unexpected type of "${ge(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const c=Object.keys(e).filter(a=>!t.hasOwnProperty(a)&&!n[a]);if(c.forEach(a=>{n[a]=!0}),!(r&&r.type===ve.REPLACE)&&c.length>0)return`Unexpected ${c.length>1?"keys":"key"} "${c.join('", "')}" found in ${s}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`}function Bn(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:ve.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?G(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:ve.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?G(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${ve.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function Un(e){const t=Object.keys(e),r={};for(let c=0;c<t.length;c++){const a=t[c];process.env.NODE_ENV!=="production"&&typeof e[a]>"u"&&dr(`No reducer provided for key "${a}"`),typeof e[a]=="function"&&(r[a]=e[a])}const n=Object.keys(r);let o;process.env.NODE_ENV!=="production"&&(o={});let s;try{Bn(r)}catch(c){s=c}return function(a={},y){if(s)throw s;if(process.env.NODE_ENV!=="production"){const f=$n(a,r,y,o);f&&dr(f)}let d=!1;const g={};for(let f=0;f<n.length;f++){const h=n[f],_=r[h],O=a[h],j=_(O,y);if(typeof j>"u"){const M=y&&y.type;throw new Error(process.env.NODE_ENV==="production"?G(14):`When called with an action of type ${M?`"${String(M)}"`:"(unknown type)"}, the slice reducer for key "${h}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}g[h]=j,d=d||j!==O}return d=d||n.length!==Object.keys(a).length,d?g:a}}function Fe(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function Hn(...e){return t=>(r,n)=>{const o=t(r,n);let s=()=>{throw new Error(process.env.NODE_ENV==="production"?G(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const c={getState:o.getState,dispatch:(y,...d)=>s(y,...d)},a=e.map(y=>y(c));return s=Fe(...a)(o.dispatch),{...o,dispatch:s}}}function fr(e){return je(e)&&"type"in e&&typeof e.type=="string"}var hr=Symbol.for("immer-nothing"),pr=Symbol.for("immer-draftable"),q=Symbol.for("immer-state"),Gn=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function ee(e,...t){if(process.env.NODE_ENV!=="production"){const r=Gn[e],n=be(r)?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var te=Object,Ce=te.getPrototypeOf,Xe="constructor",$e="prototype",Dt="configurable",Be="enumerable",Ue="writable",Oe="value",le=e=>!!e&&!!e[q];function ie(e){var t;return e?gr(e)||qe(e)||!!e[pr]||!!((t=e[Xe])!=null&&t[pr])||Ke(e)||Ze(e):!1}var qn=te[$e][Xe].toString(),yr=new WeakMap;function gr(e){if(!e||!It(e))return!1;const t=Ce(e);if(t===null||t===te[$e])return!0;const r=te.hasOwnProperty.call(t,Xe)&&t[Xe];if(r===Object)return!0;if(!be(r))return!1;let n=yr.get(r);return n===void 0&&(n=Function.toString.call(r),yr.set(r,n)),n===qn}function He(e,t,r=!0){Te(e)===0?(r?Reflect.ownKeys(e):te.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function Te(e){const t=e[q];return t?t.type_:qe(e)?1:Ke(e)?2:Ze(e)?3:0}var mr=(e,t,r=Te(e))=>r===2?e.has(t):te[$e].hasOwnProperty.call(e,t),zt=(e,t,r=Te(e))=>r===2?e.get(t):e[t],Ge=(e,t,r,n=Te(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function Kn(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var qe=Array.isArray,Ke=e=>e instanceof Map,Ze=e=>e instanceof Set,It=e=>typeof e=="object",be=e=>typeof e=="function",Rt=e=>typeof e=="boolean";function Zn(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ue=e=>e.copy_||e.base_,At=e=>e.modified_?e.copy_:e.base_;function Wt(e,t){if(Ke(e))return new Map(e);if(Ze(e))return new Set(e);if(qe(e))return Array[$e].slice.call(e);const r=gr(e);if(t===!0||t==="class_only"&&!r){const n=te.getOwnPropertyDescriptors(e);delete n[q];let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++){const c=o[s],a=n[c];a[Ue]===!1&&(a[Ue]=!0,a[Dt]=!0),(a.get||a.set)&&(n[c]={[Dt]:!0,[Ue]:!0,[Be]:a[Be],[Oe]:e[c]})}return te.create(Ce(e),n)}else{const n=Ce(e);if(n!==null&&r)return{...e};const o=te.create(n);return te.assign(o,e)}}function Vt(e,t=!1){return Qe(e)||le(e)||!ie(e)||(Te(e)>1&&te.defineProperties(e,{set:Je,add:Je,clear:Je,delete:Je}),te.freeze(e),t&&He(e,(r,n)=>{Vt(n,!0)},!1)),e}function Jn(){ee(2)}var Je={[Oe]:Jn};function Qe(e){return e===null||!It(e)?!0:te.isFrozen(e)}var et="MapSet",Lt="Patches",wr="ArrayMethods",vr={};function xe(e){const t=vr[e];return t||ee(0,e),t}var br=e=>!!vr[e],Pe,xr=()=>Pe,Qn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:br(et)?xe(et):void 0,arrayMethodsPlugin_:br(wr)?xe(wr):void 0});function Er(e,t){t&&(e.patchPlugin_=xe(Lt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Yt(e){Ft(e),e.drafts_.forEach(eo),e.drafts_=null}function Ft(e){e===Pe&&(Pe=e.parent_)}var Cr=e=>Pe=Qn(Pe,e);function eo(e){const t=e[q];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function kr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[q].modified_&&(Yt(t),ee(4)),ie(e)&&(e=_r(t,e));const{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(r[q].base_,e,t)}else e=_r(t,r);return to(t,e,!0),Yt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hr?e:void 0}function _r(e,t){if(Qe(t))return t;const r=t[q];if(!r)return rt(t,e.handledSet_,e);if(!tt(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);Mr(r,e)}return r.copy_}function to(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Vt(t,r)}function Sr(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var tt=(e,t)=>e.scope_===t,ro=[];function Nr(e,t,r,n){const o=ue(e),s=e.type_;if(n!==void 0&&zt(o,n,s)===t){Ge(o,n,r,s);return}if(!e.draftLocations_){const a=e.draftLocations_=new Map;He(o,(y,d)=>{if(le(d)){const g=a.get(d)||[];g.push(y),a.set(d,g)}})}const c=e.draftLocations_.get(t)??ro;for(const a of c)Ge(o,a,r,s)}function no(e,t,r){e.callbacks_.push(function(o){var a;const s=t;if(!s||!tt(s,o))return;(a=o.mapSetPlugin_)==null||a.fixSetContents(s);const c=At(s);Nr(e,s.draft_??s,c,r),Mr(s,o)})}function Mr(e,t){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:o}=t;if(o){const s=o.getPath(e);s&&o.generatePatches_(e,s,t)}Sr(e)}}function oo(e,t,r){const{scope_:n}=e;if(le(r)){const o=r[q];tt(o,n)&&o.callbacks_.push(function(){ot(e);const c=At(o);Nr(e,r,c,t)})}else ie(r)&&e.callbacks_.push(function(){const s=ue(e);e.type_===3?s.has(r)&&rt(r,n.handledSet_,n):zt(s,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&rt(zt(e.copy_,t,e.type_),n.handledSet_,n)})}function rt(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||le(e)||t.has(e)||!ie(e)||Qe(e)||(t.add(e),He(e,(n,o)=>{if(le(o)){const s=o[q];if(tt(s,r)){const c=At(s);Ge(e,n,c,e.type_),Sr(s)}}else ie(o)&&rt(o,t,r)})),e}function io(e,t){const r=qe(e),n={type_:r?1:0,scope_:t?t.scope_:xr(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=n,s=nt;r&&(o=[n],s=De);const{revoke:c,proxy:a}=Proxy.revocable(o,s);return n.draft_=a,n.revoke_=c,[a,n]}var nt={get(e,t){if(t===q)return e;let r=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof t=="string";if(n&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const o=ue(e);if(!mr(o,t,e.type_))return so(e,o,t);const s=o[t];if(e.finalized_||!ie(s)||n&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&Zn(t))return s;if(s===Xt(e.base_,t)){ot(e);const c=e.type_===1?+t:t,a=Bt(e.scope_,s,e,c);return e.copy_[c]=a}return s},has(e,t){return t in ue(e)},ownKeys(e){return Reflect.ownKeys(ue(e))},set(e,t,r){const n=jr(ue(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const o=Xt(ue(e),t),s=o==null?void 0:o[q];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Kn(r,o)&&(r!==void 0||mr(e.base_,t,e.type_)))return!0;ot(e),$t(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),oo(e,t,r)),!0},deleteProperty(e,t){return ot(e),Xt(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),$t(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=ue(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[Ue]:!0,[Dt]:e.type_!==1||t!=="length",[Be]:n[Be],[Oe]:r[t]}},defineProperty(){ee(11)},getPrototypeOf(e){return Ce(e.base_)},setPrototypeOf(){ee(12)}},De={};for(let e in nt){let t=nt[e];De[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}De.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&ee(13),De.set.call(this,e,t,void 0)},De.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&ee(14),nt.set.call(this,e[0],t,r,e[0])};function Xt(e,t){const r=e[q];return(r?ue(r):e)[t]}function so(e,t,r){var o;const n=jr(t,r);return n?Oe in n?n[Oe]:(o=n.get)==null?void 0:o.call(e.draft_):void 0}function jr(e,t){if(!(t in e))return;let r=Ce(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Ce(r)}}function $t(e){e.modified_||(e.modified_=!0,e.parent_&&$t(e.parent_))}function ot(e){e.copy_||(e.assigned_=new Map,e.copy_=Wt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ao=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(be(t)&&!be(r)){const s=r;r=t;const c=this;return function(y=s,...d){return c.produce(y,g=>r.call(this,g,...d))}}be(r)||ee(6),n!==void 0&&!be(n)&&ee(7);let o;if(ie(t)){const s=Cr(this),c=Bt(s,t,void 0);let a=!0;try{o=r(c),a=!1}finally{a?Yt(s):Ft(s)}return Er(s,n),kr(o,s)}else if(!t||!It(t)){if(o=r(t),o===void 0&&(o=t),o===hr&&(o=void 0),this.autoFreeze_&&Vt(o,!0),n){const s=[],c=[];xe(Lt).generateReplacementPatches_(t,o,{patches_:s,inversePatches_:c}),n(s,c)}return o}else ee(1,t)},this.produceWithPatches=(t,r)=>{if(be(t))return(c,...a)=>this.produceWithPatches(c,y=>t(y,...a));let n,o;return[this.produce(t,r,(c,a)=>{n=c,o=a}),n,o]},Rt(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Rt(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Rt(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ie(e)||ee(8),le(e)&&(e=co(e));const t=Cr(this),r=Bt(t,e,void 0);return r[q].isManual_=!0,Ft(t),r}finishDraft(e,t){const r=e&&e[q];(!r||!r.isManual_)&&ee(9);const{scope_:n}=r;return Er(n,t),kr(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));const n=xe(Lt).applyPatches_;return le(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Bt(e,t,r,n){const[o,s]=Ke(t)?xe(et).proxyMap_(t,r):Ze(t)?xe(et).proxySet_(t,r):io(t,r);return((r==null?void 0:r.scope_)??xr()).drafts_.push(o),s.callbacks_=(r==null?void 0:r.callbacks_)??[],s.key_=n,r&&n!==void 0?no(r,s,n):s.callbacks_.push(function(y){var g;(g=y.mapSetPlugin_)==null||g.fixSetContents(s);const{patchPlugin_:d}=y;s.modified_&&d&&d.generatePatches_(s,[],y)}),o}function co(e){return le(e)||ee(10,e),Or(e)}function Or(e){if(!ie(e)||Qe(e))return e;const t=e[q];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Wt(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=Wt(e,!0);return He(r,(o,s)=>{Ge(r,o,Or(s))},n),t&&(t.finalized_=!1),r}var lo=new ao,Tr=lo.produce,uo=(e,t,r)=>{if(t.length===1&&t[0]===r){let n=!1;try{const o={};e(o)===o&&(n=!0)}catch{}if(n){let o;try{throw new Error}catch(s){({stack:o}=s)}console.warn(`The result function returned its own inputs without modification. e.g
41
+ \`createSelector([state => state.todos], todos => todos)\`
42
+ This could lead to inefficient memoization and unnecessary re-renders.
43
+ Ensure transformation logic is in the result function, and extraction logic is in the input selectors.`,{stack:o})}}},fo=(e,t,r)=>{const{memoize:n,memoizeOptions:o}=t,{inputSelectorResults:s,inputSelectorResultsCopy:c}=e,a=n(()=>({}),...o);if(!(a.apply(null,s)===a.apply(null,c))){let d;try{throw new Error}catch(g){({stack:d}=g)}console.warn(`An input selector returned a different result when passed same arguments.
44
+ This means your output selector will likely run more frequently than intended.
45
+ Avoid returning a new reference inside your input selector, e.g.
46
+ \`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)\``,{arguments:r,firstInputs:s,secondInputs:c,stack:d})}},ho={inputStabilityCheck:"once",identityFunctionCheck:"once"};function po(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function yo(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function go(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){const r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var Pr=e=>Array.isArray(e)?e:[e];function mo(e){const t=Array.isArray(e[0])?e[0]:e;return go(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Dr(e,t){const r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var wo=(e,t)=>{const{identityFunctionCheck:r,inputStabilityCheck:n}={...ho,...t};return{identityFunctionCheck:{shouldRun:r==="always"||r==="once"&&e,run:uo},inputStabilityCheck:{shouldRun:n==="always"||n==="once"&&e,run:fo}}},vo=class{constructor(e){this.value=e}deref(){return this.value}},bo=typeof WeakRef<"u"?WeakRef:vo,xo=0,zr=1;function it(){return{s:xo,v:void 0,o:null,p:null}}function Ir(e,t={}){let r=it();const{resultEqualityCheck:n}=t;let o,s=0;function c(){var f;let a=r;const{length:y}=arguments;for(let h=0,_=y;h<_;h++){const O=arguments[h];if(typeof O=="function"||typeof O=="object"&&O!==null){let j=a.o;j===null&&(a.o=j=new WeakMap);const M=j.get(O);M===void 0?(a=it(),j.set(O,a)):a=M}else{let j=a.p;j===null&&(a.p=j=new Map);const M=j.get(O);M===void 0?(a=it(),j.set(O,a)):a=M}}const d=a;let g;if(a.s===zr)g=a.v;else if(g=e.apply(null,arguments),s++,n){const h=((f=o==null?void 0:o.deref)==null?void 0:f.call(o))??o;h!=null&&n(h,g)&&(g=h,s!==0&&s--),o=typeof g=="object"&&g!==null||typeof g=="function"?new bo(g):g}return d.s=zr,d.v=g,g}return c.clearCache=()=>{r=it(),c.resetResultsCount()},c.resultsCount=()=>s,c.resetResultsCount=()=>{s=0},c}function Eo(e,...t){const r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...o)=>{let s=0,c=0,a,y={},d=o.pop();typeof d=="object"&&(y=d,d=o.pop()),po(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const g={...r,...y},{memoize:f,memoizeOptions:h=[],argsMemoize:_=Ir,argsMemoizeOptions:O=[],devModeChecks:j={}}=g,M=Pr(h),P=Pr(O),b=mo(o),I=f(function(){return s++,d.apply(null,arguments)},...M);let w=!0;const v=_(function(){c++;const V=Dr(b,arguments);if(a=I.apply(null,V),process.env.NODE_ENV!=="production"){const{identityFunctionCheck:B,inputStabilityCheck:L}=wo(w,j);if(B.shouldRun&&B.run(d,V,a),L.shouldRun){const F=Dr(b,arguments);L.run({inputSelectorResults:V,inputSelectorResultsCopy:F},{memoize:f,memoizeOptions:M},arguments)}w&&(w=!1)}return a},...P);return Object.assign(v,{resultFunc:d,memoizedResultFunc:I,dependencies:b,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>a,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:_})};return Object.assign(n,{withTypes:()=>n}),n}var Co=Eo(Ir),ko=Object.assign((e,t=Co)=>{yo(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const r=Object.keys(e),n=r.map(s=>e[s]);return t(n,(...s)=>s.reduce((c,a,y)=>(c[r[y]]=a,c),{}))},{withTypes:()=>ko});function Rr(e){return({dispatch:r,getState:n})=>o=>s=>typeof s=="function"?s(r,n,e):o(s)}var _o=Rr(),So=Rr,No=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Fe:Fe.apply(null,arguments)},Mo=e=>e&&typeof e.match=="function";function Ar(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(process.env.NODE_ENV==="production"?W(0):"prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>fr(n)&&n.type===e,r}function jo(e){return typeof e=="function"&&"type"in e&&Mo(e)}function Oo(e){const t=e?`${e}`.split("/"):[],r=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
47
+ Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${r}())\` instead of \`dispatch(${r})\`. This is necessary even if the action has no payload.`}function To(e={}){if(process.env.NODE_ENV==="production")return()=>r=>n=>r(n);const{isActionCreator:t=jo}=e;return()=>r=>n=>(t(n)&&console.warn(Oo(n.type)),r(n))}function Wr(e,t){let r=0;return{measureTime(n){const o=Date.now();try{return n()}finally{const s=Date.now();r+=s-o}},warnIfExceeded(){r>e&&console.warn(`${t} took ${r}ms, which is more than the warning threshold of ${e}ms.
48
+ If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
49
+ It is disabled in production builds, so you don't need to worry about that.`)}}}var Vr=class Ve extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Ve.prototype)}static get[Symbol.species](){return Ve}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Ve(...t[0].concat(this)):new Ve(...t.concat(this))}};function Lr(e){return ie(e)?Tr(e,()=>{}):e}function st(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function Po(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function Do(e,t,r){const n=Yr(e,t,r);return{detectMutations(){return Fr(e,t,n,r)}}}function Yr(e,t=[],r,n="",o=new Set){const s={value:r};if(!e(r)&&!o.has(r)){o.add(r),s.children={};const c=t.length>0;for(const a in r){const y=n?n+"."+a:a;c&&t.some(g=>g instanceof RegExp?g.test(y):y===g)||(s.children[a]=Yr(e,t,r[a],y))}}return s}function Fr(e,t=[],r,n,o=!1,s=""){const c=r?r.value:void 0,a=c===n;if(o&&!a&&!Number.isNaN(n))return{wasMutated:!0,path:s};if(e(c)||e(n))return{wasMutated:!1};const y={};for(let g in r.children)y[g]=!0;for(let g in n)y[g]=!0;const d=t.length>0;for(let g in y){const f=s?s+"."+g:g;if(d&&t.some(O=>O instanceof RegExp?O.test(f):f===O))continue;const h=Fr(e,t,r.children[g],n[g],a,f);if(h.wasMutated)return h}return{wasMutated:!1}}function zo(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{let t=function(a,y,d,g){return JSON.stringify(a,r(y,g),d)},r=function(a,y){let d=[],g=[];return y||(y=function(f,h){return d[0]===h?"[Circular ~]":"[Circular ~."+g.slice(0,d.indexOf(h)).join(".")+"]"}),function(f,h){if(d.length>0){var _=d.indexOf(this);~_?d.splice(_+1):d.push(this),~_?g.splice(_,1/0,f):g.push(f),~d.indexOf(h)&&(h=y.call(this,f,h))}else d.push(h);return a==null?h:a.call(this,f,h)}},{isImmutable:n=Po,ignoredPaths:o,warnAfter:s=32}=e;const c=Do.bind(null,n,o);return({getState:a})=>{let y=a(),d=c(y),g;return f=>h=>{const _=Wr(s,"ImmutableStateInvariantMiddleware");_.measureTime(()=>{if(y=a(),g=d.detectMutations(),d=c(y),g.wasMutated)throw new Error(process.env.NODE_ENV==="production"?W(19):`A state mutation was detected between dispatches, in the path '${g.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const O=f(h);return _.measureTime(()=>{if(y=a(),g=d.detectMutations(),d=c(y),g.wasMutated)throw new Error(process.env.NODE_ENV==="production"?W(20):`A state mutation was detected inside a dispatch, in the path: ${g.path||""}. Take a look at the reducer(s) handling the action ${t(h)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),_.warnIfExceeded(),O}}}}function Xr(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||je(e)}function Ut(e,t="",r=Xr,n,o=[],s){let c;if(!r(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||s!=null&&s.has(e))return!1;const a=n!=null?n(e):Object.entries(e),y=o.length>0;for(const[d,g]of a){const f=t?t+"."+d:d;if(!(y&&o.some(_=>_ instanceof RegExp?_.test(f):f===_))){if(!r(g))return{keyPath:f,value:g};if(typeof g=="object"&&(c=Ut(g,f,r,n,o,s),c))return c}}return s&&$r(e)&&s.add(e),!1}function $r(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if(!(typeof t!="object"||t===null)&&!$r(t))return!1;return!0}function Io(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{const{isSerializable:t=Xr,getEntries:r,ignoredActions:n=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:s=[],warnAfter:c=32,ignoreState:a=!1,ignoreActions:y=!1,disableCache:d=!1}=e,g=!d&&WeakSet?new WeakSet:void 0;return f=>h=>_=>{if(!fr(_))return h(_);const O=h(_),j=Wr(c,"SerializableStateInvariantMiddleware");return!y&&!(n.length&&n.indexOf(_.type)!==-1)&&j.measureTime(()=>{const M=Ut(_,"",t,r,o,g);if(M){const{keyPath:P,value:b}=M;console.error(`A non-serializable value was detected in an action, in the path: \`${P}\`. Value:`,b,`
50
+ Take a look at the logic that dispatched this action: `,_,`
51
+ (See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
52
+ (To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),a||(j.measureTime(()=>{const M=f.getState(),P=Ut(M,"",t,r,s,g);if(P){const{keyPath:b,value:I}=P;console.error(`A non-serializable value was detected in the state, in the path: \`${b}\`. Value:`,I,`
53
+ Take a look at the reducer(s) handling this action type: ${_.type}.
54
+ (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),j.warnIfExceeded()),O}}}function at(e){return typeof e=="boolean"}var Ro=()=>function(t){const{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:s=!0}=t??{};let c=new Vr;if(r&&(at(r)?c.push(_o):c.push(So(r.extraArgument))),process.env.NODE_ENV!=="production"){if(n){let a={};at(n)||(a=n),c.unshift(zo(a))}if(o){let a={};at(o)||(a=o),c.push(Io(a))}if(s){let a={};at(s)||(a=s),c.unshift(To(a))}}return c},Ao="RTK_autoBatch",Br=e=>t=>{setTimeout(t,e)},Wo=(e={type:"raf"})=>t=>(...r)=>{const n=t(...r);let o=!0,s=!1,c=!1;const a=new Set,y=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Br(10):e.type==="callback"?e.queueNotification:Br(e.timeout),d=()=>{c=!1,s&&(s=!1,a.forEach(g=>g()))};return Object.assign({},n,{subscribe(g){const f=()=>o&&g(),h=n.subscribe(f);return a.add(g),()=>{h(),a.delete(g)}},dispatch(g){var f;try{return o=!((f=g==null?void 0:g.meta)!=null&&f[Ao]),s=!o,s&&(c||(c=!0,y(d))),n.dispatch(g)}finally{o=!0}}})},Vo=e=>function(r){const{autoBatch:n=!0}=r??{};let o=new Vr(e);return n&&o.push(Wo(typeof n=="object"?n:void 0)),o};function Lo(e){const t=Ro(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:s=!0,preloadedState:c=void 0,enhancers:a=void 0}=e||{};let y;if(typeof r=="function")y=r;else if(je(r))y=Un(r);else throw new Error(process.env.NODE_ENV==="production"?W(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(process.env.NODE_ENV!=="production"&&n&&typeof n!="function")throw new Error(process.env.NODE_ENV==="production"?W(2):"`middleware` field must be a callback");let d;if(typeof n=="function"){if(d=n(t),process.env.NODE_ENV!=="production"&&!Array.isArray(d))throw new Error(process.env.NODE_ENV==="production"?W(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(process.env.NODE_ENV!=="production"&&d.some(j=>typeof j!="function"))throw new Error(process.env.NODE_ENV==="production"?W(4):"each middleware provided to configureStore must be a function");if(process.env.NODE_ENV!=="production"&&s){let j=new Set;d.forEach(M=>{if(j.has(M))throw new Error(process.env.NODE_ENV==="production"?W(42):"Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");j.add(M)})}let g=Fe;o&&(g=No({trace:process.env.NODE_ENV!=="production",...typeof o=="object"&&o}));const f=Hn(...d),h=Vo(f);if(process.env.NODE_ENV!=="production"&&a&&typeof a!="function")throw new Error(process.env.NODE_ENV==="production"?W(5):"`enhancers` field must be a callback");let _=typeof a=="function"?a(h):h();if(process.env.NODE_ENV!=="production"&&!Array.isArray(_))throw new Error(process.env.NODE_ENV==="production"?W(6):"`enhancers` callback must return an array");if(process.env.NODE_ENV!=="production"&&_.some(j=>typeof j!="function"))throw new Error(process.env.NODE_ENV==="production"?W(7):"each enhancer provided to configureStore must be a function");process.env.NODE_ENV!=="production"&&d.length&&!_.includes(f)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const O=g(..._);return ur(y,c,O)}function Ur(e){const t={},r=[];let n;const o={addCase(s,c){if(process.env.NODE_ENV!=="production"){if(r.length>0)throw new Error(process.env.NODE_ENV==="production"?W(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error(process.env.NODE_ENV==="production"?W(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const a=typeof s=="string"?s:s.type;if(!a)throw new Error(process.env.NODE_ENV==="production"?W(28):"`builder.addCase` cannot be called with an empty action type");if(a in t)throw new Error(process.env.NODE_ENV==="production"?W(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${a}'`);return t[a]=c,o},addAsyncThunk(s,c){if(process.env.NODE_ENV!=="production"&&n)throw new Error(process.env.NODE_ENV==="production"?W(43):"`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");return c.pending&&(t[s.pending.type]=c.pending),c.rejected&&(t[s.rejected.type]=c.rejected),c.fulfilled&&(t[s.fulfilled.type]=c.fulfilled),c.settled&&r.push({matcher:s.settled,reducer:c.settled}),o},addMatcher(s,c){if(process.env.NODE_ENV!=="production"&&n)throw new Error(process.env.NODE_ENV==="production"?W(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:s,reducer:c}),o},addDefaultCase(s){if(process.env.NODE_ENV!=="production"&&n)throw new Error(process.env.NODE_ENV==="production"?W(31):"`builder.addDefaultCase` can only be called once");return n=s,o}};return e(o),[t,r,n]}function Yo(e){return typeof e=="function"}function Fo(e,t){if(process.env.NODE_ENV!=="production"&&typeof t=="object")throw new Error(process.env.NODE_ENV==="production"?W(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[r,n,o]=Ur(t),s;if(Yo(e))s=()=>Lr(e());else{const a=Lr(e);s=()=>a}function c(a=s(),y){let d=[r[y.type],...n.filter(({matcher:g})=>g(y)).map(({reducer:g})=>g)];return d.filter(g=>!!g).length===0&&(d=[o]),d.reduce((g,f)=>{if(f)if(le(g)){const _=f(g,y);return _===void 0?g:_}else{if(ie(g))return Tr(g,h=>f(h,y));{const h=f(g,y);if(h===void 0){if(g===null)return g;throw Error("A case reducer on a non-draftable value must not return undefined")}return h}}return g},a)}return c.getInitialState=s,c}var Xo=Symbol.for("rtk-slice-createasyncthunk");function $o(e,t){return`${e}/${t}`}function Bo({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[Xo];return function(o){const{name:s,reducerPath:c=s}=o;if(!s)throw new Error(process.env.NODE_ENV==="production"?W(11):"`name` is a required option for createSlice");typeof process<"u"&&process.env.NODE_ENV==="development"&&o.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const a=(typeof o.reducers=="function"?o.reducers(Go()):o.reducers)||{},y=Object.keys(a),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},g={addCase(w,v){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(process.env.NODE_ENV==="production"?W(12):"`context.addCase` cannot be called with an empty action type");if(T in d.sliceCaseReducersByType)throw new Error(process.env.NODE_ENV==="production"?W(13):"`context.addCase` cannot be called with two reducers for the same action type: "+T);return d.sliceCaseReducersByType[T]=v,g},addMatcher(w,v){return d.sliceMatchers.push({matcher:w,reducer:v}),g},exposeAction(w,v){return d.actionCreators[w]=v,g},exposeCaseReducer(w,v){return d.sliceCaseReducersByName[w]=v,g}};y.forEach(w=>{const v=a[w],T={reducerName:w,type:$o(s,w),createNotation:typeof o.reducers=="function"};Ko(v)?Jo(T,v,g,t):qo(T,v,g)});function f(){if(process.env.NODE_ENV!=="production"&&typeof o.extraReducers=="object")throw new Error(process.env.NODE_ENV==="production"?W(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[w={},v=[],T=void 0]=typeof o.extraReducers=="function"?Ur(o.extraReducers):[o.extraReducers],V={...w,...d.sliceCaseReducersByType};return Fo(o.initialState,B=>{for(let L in V)B.addCase(L,V[L]);for(let L of d.sliceMatchers)B.addMatcher(L.matcher,L.reducer);for(let L of v)B.addMatcher(L.matcher,L.reducer);T&&B.addDefaultCase(T)})}const h=w=>w,_=new Map,O=new WeakMap;let j;function M(w,v){return j||(j=f()),j(w,v)}function P(){return j||(j=f()),j.getInitialState()}function b(w,v=!1){function T(B){let L=B[w];if(typeof L>"u"){if(v)L=st(O,T,P);else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?W(15):"selectSlice returned undefined for an uninjected slice reducer")}return L}function V(B=h){const L=st(_,v,()=>new WeakMap);return st(L,B,()=>{const F={};for(const[oe,fe]of Object.entries(o.selectors??{}))F[oe]=Uo(fe,B,()=>st(O,B,P),v);return F})}return{reducerPath:w,getSelectors:V,get selectors(){return V(T)},selectSlice:T}}const I={name:s,reducer:M,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:P,...b(c),injectInto(w,{reducerPath:v,...T}={}){const V=v??c;return w.inject({reducerPath:V,reducer:M},T),{...I,...b(V,!0)}}};return I}}function Uo(e,t,r,n){function o(s,...c){let a=t(s);if(typeof a>"u"){if(n)a=r();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?W(16):"selectState returned undefined for an uninjected slice reducer")}return e(a,...c)}return o.unwrapped=e,o}var Ho=Bo();function Go(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function qo({type:e,reducerName:t,createNotation:r},n,o){let s,c;if("reducer"in n){if(r&&!Zo(n))throw new Error(process.env.NODE_ENV==="production"?W(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");s=n.reducer,c=n.prepare}else s=n;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,c?Ar(e,c):Ar(e))}function Ko(e){return e._reducerDefinitionType==="asyncThunk"}function Zo(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Jo({type:e,reducerName:t},r,n,o){if(!o)throw new Error(process.env.NODE_ENV==="production"?W(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:s,fulfilled:c,pending:a,rejected:y,settled:d,options:g}=r,f=o(e,s,g);n.exposeAction(t,f),c&&n.addCase(f.fulfilled,c),a&&n.addCase(f.pending,a),y&&n.addCase(f.rejected,y),d&&n.addMatcher(f.settled,d),n.exposeCaseReducer(t,{fulfilled:c||ct,pending:a||ct,rejected:y||ct,settled:d||ct})}function ct(){}function W(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const Hr=Ho({name:"whiteboard",initialState:{grid:{size:20,color:"#ccc",enabled:!0},toolbar:{selectedTool:"pointer"},toolProperties:{pencil:{strokeColor:"#000000",lineWidth:4},rectangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},circle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},triangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},diamond:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},star:{strokeColor:"#000000",fillColor:"#ffff00",lineWidth:2},heart:{strokeColor:"#000000",fillColor:"#ff6b6b",lineWidth:2},hexagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},octagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},arrow:{strokeColor:"#000000",fillColor:"#000000",lineWidth:2},text:{fontSize:16,fontColor:"#000000"}},elements:[],selectedElementId:null,viewport:{panX:0,panY:0,zoom:1},watermark:{text:"Nines Studios",url:"https://github.com/huzeyfecoskun",visible:!0},lock:{isLocked:!0,text:"Whiteboard drawing is only for moderator"}},reducers:{toggleGrid(e){e.grid.enabled=!e.grid.enabled},setGridSize(e,t){e.grid.size=t.payload},setGridColor(e,t){e.grid.color=t.payload},setSelectedTool(e,t){e.toolbar.selectedTool=t.payload},setToolProperty(e,t){const{tool:r,property:n,value:o}=t.payload;e.toolProperties[r]&&(e.toolProperties[r][n]=o)},addElement(e,t){e.elements.push(t.payload)},updateElement(e,t){const{id:r,updates:n}=t.payload,o=e.elements.findIndex(s=>s.id===r);o!==-1&&(e.elements[o]={...e.elements[o],...n})},removeElement(e,t){const r=t.payload;e.elements=e.elements.filter(n=>n.id!==r),e.selectedElementId===r&&(e.selectedElementId=null)},setSelectedElement(e,t){e.selectedElementId=t.payload},clearElements(e){e.elements=[]},setPan(e,t){e.viewport.panX=t.payload.x,e.viewport.panY=t.payload.y},setZoom(e,t){e.viewport.zoom=Math.max(.1,Math.min(5,t.payload))},resetViewport(e){e.viewport.panX=0,e.viewport.panY=0,e.viewport.zoom=1},bringToFront(e,t){const r=t.payload,n=e.elements.findIndex(o=>o.id===r);if(n!==-1&&n<e.elements.length-1){const[o]=e.elements.splice(n,1);e.elements.push(o)}},sendToBack(e,t){const r=t.payload,n=e.elements.findIndex(o=>o.id===r);if(n>0){const[o]=e.elements.splice(n,1);e.elements.unshift(o)}},fitToView(e,t){const{canvasWidth:r,canvasHeight:n,padding:o=50}=t.payload,s=e.elements;if(s.length===0){e.viewport.panX=0,e.viewport.panY=0,e.viewport.zoom=1;return}let c=1/0,a=1/0,y=-1/0,d=-1/0;s.forEach(v=>{v.type==="rectangle"?(c=Math.min(c,v.x),a=Math.min(a,v.y),y=Math.max(y,v.x+v.width),d=Math.max(d,v.y+v.height)):v.type==="circle"?(c=Math.min(c,v.centerX-v.radius),a=Math.min(a,v.centerY-v.radius),y=Math.max(y,v.centerX+v.radius),d=Math.max(d,v.centerY+v.radius)):v.type==="pencil"&&v.points.length>0?v.points.forEach(T=>{c=Math.min(c,T.x),a=Math.min(a,T.y),y=Math.max(y,T.x),d=Math.max(d,T.y)}):v.type==="triangle"||v.type==="diamond"||v.type==="hexagon"||v.type==="octagon"?(c=Math.min(c,v.x),a=Math.min(a,v.y),y=Math.max(y,v.x+v.width),d=Math.max(d,v.y+v.height)):v.type==="star"||v.type==="heart"?(c=Math.min(c,v.centerX-v.size),a=Math.min(a,v.centerY-v.size),y=Math.max(y,v.centerX+v.size),d=Math.max(d,v.centerY+v.size)):v.type==="arrow"&&(c=Math.min(c,v.startX,v.endX),a=Math.min(a,v.startY,v.endY),y=Math.max(y,v.startX,v.endX),d=Math.max(d,v.startY,v.endY))});const g=y-c,f=d-a;if(g<=0||f<=0)return;const h=r-o*2,_=n-o*2,O=h/g,j=_/f,M=Math.min(O,j,5),P=(c+y)/2,b=(a+d)/2,I=r/2-P*M,w=n/2-b*M;e.viewport.zoom=Math.max(.1,M),e.viewport.panX=I,e.viewport.panY=w},setLocked(e,t){e.lock.isLocked=t.payload,t.payload&&(e.toolbar.selectedTool="pointer",e.selectedElementId=null)}}}),{toggleGrid:Hi,setGridSize:Gi,setGridColor:qi,setSelectedTool:de,setToolProperty:Qo,addElement:ne,updateElement:lt,removeElement:ei,setSelectedElement:ze,clearElements:Ki,setPan:ti,setZoom:ri,resetViewport:Zi,fitToView:ni,bringToFront:oi,sendToBack:ii,setLocked:Gr}=Hr.actions,qr=Hr.reducer;let Ht=null;const si=e=>{Ht=e},ai=e=>t=>r=>{var o;const n=t(r);return!((o=r.meta)!=null&&o.fromRemote)&&Ht&&Ht(r),n},Kr=Lo({reducer:{whiteboard:qr},middleware:e=>e().concat(ai)}),ci=()=>{const e=K(t=>t.whiteboard.watermark);return u.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:u.jsx("div",{className:"watermark",children:e.text})})};var Zr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Jr=N.createContext&&N.createContext(Zr),li=["attr","size","title"];function ui(e,t){if(e==null)return{};var r=di(e,t),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)n=s[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function di(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ut.apply(this,arguments)}function Qr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function dt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Qr(Object(r),!0).forEach(function(n){fi(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function fi(e,t,r){return t=hi(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hi(e){var t=pi(e,"string");return typeof t=="symbol"?t:t+""}function pi(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function en(e){return e&&e.map((t,r)=>N.createElement(t.tag,dt({key:r},t.attr),en(t.child)))}function H(e){return t=>N.createElement(yi,ut({attr:dt({},e.attr)},t),en(e.child))}function yi(e){var t=r=>{var{attr:n,size:o,title:s}=e,c=ui(e,li),a=o||r.size||"1em",y;return r.className&&(y=r.className),e.className&&(y=(y?y+" ":"")+e.className),N.createElement("svg",ut({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,n,c,{className:y,style:dt(dt({color:e.color||r.color},r.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&N.createElement("title",null,s),e.children)};return Jr!==void 0?N.createElement(Jr.Consumer,null,r=>t(r)):t(Zr)}function gi(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"},child:[]}]})(e)}function mi(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.941 273.941c18.745-18.745 18.745-49.137 0-67.882l-160-160c-18.745-18.745-49.136-18.746-67.883 0l-256 256c-18.745 18.745-18.745 49.137 0 67.882l96 96A48.004 48.004 0 0 0 144 480h356c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12H355.883l142.058-142.059zm-302.627-62.627l137.373 137.373L265.373 416H150.628l-80-80 124.686-124.686z"},child:[]}]})(e)}function wi(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"},child:[]}]})(e)}function vi(e){return H({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"},child:[]}]})(e)}function bi(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"},child:[]}]})(e)}function xi(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(e)}function Ei(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(e)}function Ci(e){return H({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M302.189 329.126H196.105l55.831 135.993c3.889 9.428-.555 19.999-9.444 23.999l-49.165 21.427c-9.165 4-19.443-.571-23.332-9.714l-53.053-129.136-86.664 89.138C18.729 472.71 0 463.554 0 447.977V18.299C0 1.899 19.921-6.096 30.277 5.443l284.412 292.542c11.472 11.179 3.007 31.141-12.5 31.141z"},child:[]}]})(e)}function ki(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"},child:[]}]})(e)}function _i(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"},child:[]}]})(e)}function Si(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(e)}function Ni(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(e)}function Mi(e){return H({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(e)}const ji=({text:e})=>u.jsxs("div",{style:{position:"absolute",top:"10px",left:"10px",backgroundColor:"rgba(255, 68, 68, 0.9)",color:"white",padding:"8px 16px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"8px",boxShadow:"0 2px 4px rgba(0,0,0,0.2)",zIndex:1e3,pointerEvents:"none",userSelect:"none",fontFamily:"sans-serif",fontSize:"14px",fontWeight:"500"},children:[u.jsx(Ei,{}),u.jsx("span",{children:e||"Locked"})]});function Oi(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"},child:[]}]})(e)}function Ti(e){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M284.3 11.7c-15.6-15.6-40.9-15.6-56.6 0l-216 216c-15.6 15.6-15.6 40.9 0 56.6l216 216c15.6 15.6 40.9 15.6 56.6 0l216-216c15.6-15.6 15.6-40.9 0-56.6l-216-216z"},child:[]}]})(e)}function Pi(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"},child:[]}]})(e)}function Di(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z"},child:[]}]})(e)}function zi(e){return H({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l128 0 0 352c0 17.7 14.3 32 32 32s32-14.3 32-32l0-352 128 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 32 32 32z"},child:[]}]})(e)}function Ii(e){return H({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144c0-44.2 35.8-80 80-80c31.9 0 59.4 18.6 72.3 45.7c7.6 16 26.7 22.8 42.6 15.2s22.8-26.7 15.2-42.6C331 33.7 281.5 0 224 0C144.5 0 80 64.5 80 144l0 48-16 0c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-192c0-35.3-28.7-64-64-64l-240 0 0-48z"},child:[]}]})(e)}function Ri(e){return H({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M8.5.134a1 1 0 0 0-1 0l-6 3.577a1 1 0 0 0-.5.866v6.846a1 1 0 0 0 .5.866l6 3.577a1 1 0 0 0 1 0l6-3.577a1 1 0 0 0 .5-.866V4.577a1 1 0 0 0-.5-.866z"},child:[]}]})(e)}function Ai(e){return H({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.107 0a.5.5 0 0 1 .353.146l4.394 4.394a.5.5 0 0 1 .146.353v6.214a.5.5 0 0 1-.146.353l-4.394 4.394a.5.5 0 0 1-.353.146H4.893a.5.5 0 0 1-.353-.146L.146 11.46A.5.5 0 0 1 0 11.107V4.893a.5.5 0 0 1 .146-.353L4.54.146A.5.5 0 0 1 4.893 0z"},child:[]}]})(e)}const Wi=({onExport:e})=>{const t=Tt(),{t:r,language:n,changeLanguage:o}=cr(),s=K(w=>w.whiteboard.toolbar.selectedTool),c=K(w=>w.whiteboard.lock.isLocked),[a,y]=N.useState(!1),[d,g]=N.useState(!1),f=N.useRef(null),h=N.useRef(null),_=N.useRef(null),O=N.useRef(null),j=N.useRef(null),M=w=>{const v=w.target.files[0];if(!v)return;const T=new FileReader;T.onload=V=>{const B=new Image;B.onload=()=>{const L=Date.now().toString();t(ne({id:L,type:"image",x:100,y:100,width:B.width,height:B.height,src:V.target.result})),t(de("pointer")),t(ze(L))},B.src=V.target.result},T.readAsDataURL(v),w.target.value=""};N.useEffect(()=>{const w=v=>{f.current&&!f.current.contains(v.target)&&h.current&&!h.current.contains(v.target)&&y(!1),O.current&&!O.current.contains(v.target)&&_.current&&!_.current.contains(v.target)&&g(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const P=[{name:"triangle",icon:u.jsx(_i,{style:{transform:"rotate(-30deg)"}})},{name:"diamond",icon:u.jsx(Ti,{})},{name:"star",icon:u.jsx(Mi,{})},{name:"heart",icon:u.jsx(bi,{})},{name:"hexagon",icon:u.jsx(Ri,{})},{name:"octagon",icon:u.jsx(Ai,{})},{name:"arrow",icon:u.jsx(Oi,{})}],b=w=>{t(de(w)),y(!1)},I=w=>{o(w),g(!1)};return u.jsxs("div",{className:"toolbar",children:[u.jsx("button",{className:s==="pointer"?"active":"",onClick:()=>t(de("pointer")),title:r("pointer"),disabled:c,children:u.jsx(Ci,{})}),u.jsx("button",{className:s==="text"?"active":"",onClick:()=>t(de("text")),title:r("text"),disabled:c,children:u.jsx(zi,{})}),u.jsx("button",{onClick:()=>{var w;return(w=j.current)==null?void 0:w.click()},title:r("image"),disabled:c,children:u.jsx(xi,{})}),u.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:M}),u.jsx("button",{className:s==="pencil"?"active":"",onClick:()=>t(de("pencil")),title:r("pencil"),disabled:c,children:u.jsx(ki,{})}),u.jsx("button",{className:s==="rectangle"?"active":"",onClick:()=>t(de("rectangle")),title:r("rectangle"),disabled:c,children:u.jsx(Ni,{})}),u.jsx("button",{className:s==="circle"?"active":"",onClick:()=>t(de("circle")),title:r("circle"),disabled:c,children:u.jsx(gi,{})}),u.jsxs("div",{className:"ellipsis-container",children:[u.jsx("button",{ref:h,className:P.some(w=>w.name===s)?"active":"",onClick:()=>y(!a),title:r("moreShapes"),disabled:c,children:u.jsx(Pi,{})}),a&&u.jsxs("div",{className:"shapes-popup",ref:f,children:[u.jsx("div",{className:"shapes-popup-header",children:r("moreShapes")}),u.jsx("div",{className:"shapes-popup-grid",children:P.map(w=>u.jsx("button",{className:s===w.name?"active":"",onClick:()=>b(w.name),title:r(w.name),children:w.icon},w.name))})]})]}),u.jsx("button",{className:s==="eraser"?"active":"",onClick:()=>t(de("eraser")),title:r("eraser"),disabled:c,children:u.jsx(mi,{})}),u.jsx("button",{onClick:()=>t(ni({canvasWidth:window.innerWidth,canvasHeight:window.innerHeight,padding:50})),title:r("fitToView"),children:u.jsx(wi,{})}),u.jsx("button",{onClick:e,title:r("exportAsPng"),children:u.jsx(Si,{})}),u.jsxs("div",{className:"language-container",children:[u.jsx("button",{ref:_,onClick:()=>g(!d),title:r("language"),children:u.jsx(vi,{})}),d&&u.jsxs("div",{className:"language-popup",ref:O,children:[u.jsx("div",{className:"language-popup-header",children:r("language")}),u.jsxs("div",{className:"language-options",children:[u.jsxs("button",{className:n==="en"?"active":"",onClick:()=>I("en"),children:["🇺🇸 ",r("english")]}),u.jsxs("button",{className:n==="tr"?"active":"",onClick:()=>I("tr"),children:["🇹🇷 ",r("turkish")]})]})]})]}),u.jsx("button",{onClick:()=>t(Gr(!c)),title:c?"Unlock":"Lock",style:{color:c?"red":"inherit"},children:c?u.jsx(Di,{}):u.jsx(Ii,{})})]})},Vi=()=>{const e=Tt(),{t}=cr(),r=K(f=>f.whiteboard.toolbar.selectedTool),n=K(f=>f.whiteboard.toolProperties),o=K(f=>f.whiteboard.selectedElementId),s=K(f=>f.whiteboard.elements),c=o?s.find(f=>f.id===o):null,a=(f,h,_)=>{e(Qo({tool:f,property:h,value:_}))},y=(f,h)=>{o&&e(lt({id:o,updates:{[f]:h}}))},d=()=>{o&&e(oi(o))},g=()=>{o&&e(ii(o))};if(r==="pointer"&&c&&c.type==="text")return u.jsxs("div",{className:"prop-tools",children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fontSize")}),u.jsxs("select",{className:"font-size-selector",value:c.fontSize||16,onChange:f=>y("fontSize",parseInt(f.target.value)),children:[u.jsx("option",{value:"12",children:"12 px"}),u.jsx("option",{value:"14",children:"14 px"}),u.jsx("option",{value:"16",children:"16 px"}),u.jsx("option",{value:"18",children:"18 px"}),u.jsx("option",{value:"24",children:"24 px"}),u.jsx("option",{value:"32",children:"32 px"}),u.jsx("option",{value:"48",children:"48 px"}),u.jsx("option",{value:"64",children:"64 px"}),u.jsx("option",{value:"72",children:"72 px"})]})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fontColor")}),u.jsx("input",{type:"color",value:c.fontColor||"#000000",onChange:f=>y("fontColor",f.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("layerOrder")}),u.jsxs("div",{className:"layer-buttons",children:[u.jsx("button",{onClick:d,title:t("bringToFront"),children:u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),u.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),u.jsx("button",{onClick:g,title:t("sendToBack"),children:u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),u.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]});if(r==="pointer"&&c){const f=["rectangle","circle","triangle","diamond","star","heart","hexagon","octagon","arrow"].includes(c.type),h=c.type==="pencil";return u.jsxs("div",{className:"prop-tools",children:[f&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("strokeColor")}),u.jsx("input",{type:"color",value:c.strokeColor,onChange:_=>y("strokeColor",_.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fillColor")}),u.jsx("input",{type:"color",value:c.fillColor,onChange:_=>y("fillColor",_.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("strokeWidth")}),u.jsxs("select",{className:"stroke-width-selector",value:c.lineWidth,onChange:_=>y("lineWidth",parseInt(_.target.value)),children:[u.jsx("option",{value:"1",children:"1 px"}),u.jsx("option",{value:"2",children:"2 px"}),u.jsx("option",{value:"4",children:"4 px"}),u.jsx("option",{value:"8",children:"8 px"})]})]})]}),h&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("brushColor")}),u.jsx("input",{type:"color",value:c.strokeColor,onChange:_=>y("strokeColor",_.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("brushSize")}),u.jsxs("select",{className:"brush-size-selector",value:c.lineWidth,onChange:_=>y("lineWidth",parseInt(_.target.value)),children:[u.jsx("option",{value:"1",children:"1 px"}),u.jsx("option",{value:"2",children:"2 px"}),u.jsx("option",{value:"4",children:"4 px"}),u.jsx("option",{value:"8",children:"8 px"}),u.jsx("option",{value:"16",children:"16 px"})]})]})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("layerOrder")}),u.jsxs("div",{className:"layer-buttons",children:[u.jsx("button",{onClick:d,title:t("bringToFront"),children:u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),u.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),u.jsx("button",{onClick:g,title:t("sendToBack"),children:u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),u.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]})}return u.jsxs("div",{className:"prop-tools",children:[r==="text"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fontSize")}),u.jsxs("select",{className:"font-size-selector",value:n.text.fontSize,onChange:f=>a("text","fontSize",parseInt(f.target.value)),children:[u.jsx("option",{value:"12",children:"12 px"}),u.jsx("option",{value:"14",children:"14 px"}),u.jsx("option",{value:"16",children:"16 px"}),u.jsx("option",{value:"18",children:"18 px"}),u.jsx("option",{value:"24",children:"24 px"}),u.jsx("option",{value:"32",children:"32 px"}),u.jsx("option",{value:"48",children:"48 px"}),u.jsx("option",{value:"64",children:"64 px"}),u.jsx("option",{value:"72",children:"72 px"})]})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fontColor")}),u.jsx("input",{type:"color",value:n.text.fontColor,onChange:f=>a("text","fontColor",f.target.value)})]})]}),r==="pencil"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("brushColor")}),u.jsx("input",{type:"color",value:n.pencil.strokeColor,onChange:f=>a("pencil","strokeColor",f.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("brushSize")}),u.jsxs("select",{className:"brush-size-selector",value:n.pencil.lineWidth,onChange:f=>a("pencil","lineWidth",parseInt(f.target.value)),children:[u.jsx("option",{value:"1",children:"1 px"}),u.jsx("option",{value:"2",children:"2 px"}),u.jsx("option",{value:"4",children:"4 px"}),u.jsx("option",{value:"8",children:"8 px"}),u.jsx("option",{value:"16",children:"16 px"})]})]})]}),(r==="rectangle"||r==="circle"||r==="triangle"||r==="diamond"||r==="star"||r==="heart"||r==="hexagon"||r==="octagon"||r==="arrow")&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("strokeColor")}),u.jsx("input",{type:"color",value:n[r].strokeColor,onChange:f=>a(r,"strokeColor",f.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("fillColor")}),u.jsx("input",{type:"color",value:n[r].fillColor,onChange:f=>a(r,"fillColor",f.target.value)})]}),u.jsxs("div",{className:"prop-tool-item",children:[u.jsx("span",{children:t("strokeWidth")}),u.jsxs("select",{className:"stroke-width-selector",value:n[r].lineWidth,onChange:f=>a(r,"lineWidth",parseInt(f.target.value)),children:[u.jsx("option",{value:"1",children:"1 px"}),u.jsx("option",{value:"2",children:"2 px"}),u.jsx("option",{value:"4",children:"4 px"}),u.jsx("option",{value:"8",children:"8 px"})]})]})]})]})},tn=N.forwardRef(({onAction:e,watermark:t,isLocked:r,lockText:n,onLockChange:o},s)=>{var ln;const c=N.useRef(null),a=Tt(),y=K(i=>i.whiteboard.grid),d=K(i=>i.whiteboard.toolbar.selectedTool),g=K(i=>i.whiteboard.elements),f=K(i=>i.whiteboard.viewport),h=K(i=>i.whiteboard.toolProperties),_=K(i=>i.whiteboard.selectedElementId),O=K(i=>i.whiteboard.lock),j=O.isLocked,[M,P]=N.useState(!1),[b,I]=N.useState({x:0,y:0}),[w,v]=N.useState({x:0,y:0}),[T,V]=N.useState([]),[B,L]=N.useState(!1),[F,oe]=N.useState({x:0,y:0}),[fe,Ie]=N.useState(!1),[Re,Ee]=N.useState(!1),[ke,_e]=N.useState(!1),[Ae,ft]=N.useState({x:0,y:0}),[We,x]=N.useState({y:0,initialZoom:1}),[z,Y]=N.useState(!1),[U,Se]=N.useState({x:0,y:0}),[he,X]=N.useState(""),[se,me]=N.useState(null);N.useEffect(()=>{e&&si(e)},[e]),N.useImperativeHandle(s,()=>({canvas:c.current,applyAction:i=>{a({...i,meta:{...i.meta,fromRemote:!0}})}})),N.useEffect(()=>{r!==void 0&&r!==j&&a(Gr(r))},[r,j,a]),N.useEffect(()=>{o&&o(j)},[j,o]);const ht=N.useCallback((i,l,m)=>{const p=i.canvas,k=p.width,C=p.height,S=Math.floor(-f.panX/f.zoom/l)*l,E=Math.floor(-f.panY/f.zoom/l)*l,D=Math.ceil((k/f.zoom-f.panX/f.zoom)/l)*l,A=Math.ceil((C/f.zoom-f.panY/f.zoom)/l)*l;i.strokeStyle=m,i.lineWidth=.5/f.zoom;for(let R=S;R<=D;R+=l)i.beginPath(),i.moveTo(R,E),i.lineTo(R,A),i.stroke();for(let R=E;R<=A;R+=l)i.beginPath(),i.moveTo(S,R),i.lineTo(D,R),i.stroke()},[f]),rn=N.useCallback((i,l,m)=>{const p=Math.min(l.x,m.x),k=Math.min(l.y,m.y),C=Math.abs(m.x-l.x),S=Math.abs(m.y-l.y);i.strokeStyle="#0066cc",i.lineWidth=1,i.setLineDash([5,5]),i.strokeRect(p,k,C,S),i.fillStyle="rgba(0, 102, 204, 0.1)",i.fillRect(p,k,C,S),i.setLineDash([])},[]),pt=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,fillColor:S="#000",strokeColor:E="#000",lineWidth:D=2}=l;i.fillStyle=S,i.fillRect(m,p,k,C),i.strokeStyle=E,i.lineWidth=D,i.strokeRect(m,p,k,C)},[]),yt=N.useCallback((i,l)=>{const{centerX:m,centerY:p,radius:k,fillColor:C="#000",strokeColor:S="#000",lineWidth:E=2}=l;i.beginPath(),i.arc(m,p,k,0,Math.PI*2),i.fillStyle=C,i.fill(),i.strokeStyle=S,i.lineWidth=E,i.stroke()},[]),gt=N.useCallback((i,l)=>{const{points:m,strokeColor:p="#000",lineWidth:k=2}=l;if(!(m.length<2)){i.strokeStyle=p,i.lineWidth=k,i.lineCap="round",i.lineJoin="round",i.beginPath(),i.moveTo(m[0].x,m[0].y);for(let C=1;C<m.length;C++)i.lineTo(m[C].x,m[C].y);i.stroke()}},[]),nn=N.useCallback((i,l)=>{const{x:m,y:p,text:k,fontSize:C=16,fontColor:S="#000"}=l;i.font=`${C}px sans-serif`,i.fillStyle=S,i.textBaseline="top",i.fillText(k,m,p)},[]),mt=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,fillColor:S="#fff",strokeColor:E="#000",lineWidth:D=2}=l;i.beginPath(),i.moveTo(m+k/2,p),i.lineTo(m+k,p+C),i.lineTo(m,p+C),i.closePath(),i.fillStyle=S,i.fill(),i.strokeStyle=E,i.lineWidth=D,i.stroke()},[]),wt=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,fillColor:S="#fff",strokeColor:E="#000",lineWidth:D=2}=l;i.beginPath(),i.moveTo(m+k/2,p),i.lineTo(m+k,p+C/2),i.lineTo(m+k/2,p+C),i.lineTo(m,p+C/2),i.closePath(),i.fillStyle=S,i.fill(),i.strokeStyle=E,i.lineWidth=D,i.stroke()},[]),vt=N.useCallback((i,l)=>{const{centerX:m,centerY:p,size:k,fillColor:C="#ffff00",strokeColor:S="#000",lineWidth:E=2}=l,D=5,A=k,R=k/2;i.beginPath();for(let Z=0;Z<D*2;Z++){const J=Z%2===0?A:R,$=Math.PI/D*Z-Math.PI/2,re=m+Math.cos($)*J,ae=p+Math.sin($)*J;Z===0?i.moveTo(re,ae):i.lineTo(re,ae)}i.closePath(),i.fillStyle=C,i.fill(),i.strokeStyle=S,i.lineWidth=E,i.stroke()},[]),bt=N.useCallback((i,l)=>{const{centerX:m,centerY:p,size:k,fillColor:C="#ff6b6b",strokeColor:S="#000",lineWidth:E=2}=l;i.beginPath();const D=p-k/2;i.moveTo(m,D+k/4),i.bezierCurveTo(m-k/2,D,m-k,D+k/2,m,p+k/2),i.bezierCurveTo(m+k,D+k/2,m+k/2,D,m,D+k/4),i.fillStyle=C,i.fill(),i.strokeStyle=S,i.lineWidth=E,i.stroke()},[]),xt=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,fillColor:S="#fff",strokeColor:E="#000",lineWidth:D=2}=l,A=m+k/2,R=p+C/2,Z=k/2,J=C/2;i.beginPath();for(let $=0;$<6;$++){const re=Math.PI/3*$-Math.PI/2,ae=A+Math.cos(re)*Z,we=R+Math.sin(re)*J;$===0?i.moveTo(ae,we):i.lineTo(ae,we)}i.closePath(),i.fillStyle=S,i.fill(),i.strokeStyle=E,i.lineWidth=D,i.stroke()},[]),Et=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,fillColor:S="#fff",strokeColor:E="#000",lineWidth:D=2}=l,A=m+k/2,R=p+C/2,Z=k/2,J=C/2;i.beginPath();for(let $=0;$<8;$++){const re=Math.PI/4*$-Math.PI/2,ae=A+Math.cos(re)*Z,we=R+Math.sin(re)*J;$===0?i.moveTo(ae,we):i.lineTo(ae,we)}i.closePath(),i.fillStyle=S,i.fill(),i.strokeStyle=E,i.lineWidth=D,i.stroke()},[]),Ct=N.useCallback((i,l)=>{const{startX:m,startY:p,endX:k,endY:C,fillColor:S="#000",strokeColor:E="#000",lineWidth:D=2}=l,A=15,R=Math.atan2(C-p,k-m);i.beginPath(),i.moveTo(m,p),i.lineTo(k,C),i.strokeStyle=E,i.lineWidth=D,i.stroke(),i.beginPath(),i.moveTo(k,C),i.lineTo(k-A*Math.cos(R-Math.PI/6),C-A*Math.sin(R-Math.PI/6)),i.lineTo(k-A*Math.cos(R+Math.PI/6),C-A*Math.sin(R+Math.PI/6)),i.closePath(),i.fillStyle=S,i.fill()},[]),kt=N.useRef({}),Gt=N.useRef(null),on=N.useCallback((i,l)=>{const{x:m,y:p,width:k,height:C,src:S}=l;if(kt.current[S]){const E=kt.current[S];E.complete&&i.drawImage(E,m,p,k,C)}else{const E=new Image;E.onload=()=>{kt.current[S]=E,Gt.current&&Gt.current()},E.src=S,kt.current[S]=E}},[]),_t=N.useCallback((i,l)=>{switch(l.type){case"rectangle":pt(i,l);break;case"circle":yt(i,l);break;case"pencil":gt(i,l);break;case"text":nn(i,l);break;case"triangle":mt(i,l);break;case"diamond":wt(i,l);break;case"star":vt(i,l);break;case"heart":bt(i,l);break;case"hexagon":xt(i,l);break;case"octagon":Et(i,l);break;case"arrow":Ct(i,l);break;case"image":on(i,l);break}},[pt,yt,gt,nn,mt,wt,vt,bt,xt,Et,Ct,on]),Yi=N.useCallback(()=>{const i=c.current;if(!i)return;const l=document.createElement("canvas");l.width=i.width,l.height=i.height;const m=l.getContext("2d");m.fillStyle="#ffffff",m.fillRect(0,0,l.width,l.height),m.save(),m.translate(f.panX,f.panY),m.scale(f.zoom,f.zoom),g.forEach(C=>{_t(m,C)}),m.restore();const p=l.toDataURL("image/png"),k=document.createElement("a");k.download=`whiteboard-${Date.now()}.png`,k.href=p,k.click()},[f,g,_t]),qt=N.useCallback((i,l)=>{for(let m=g.length-1;m>=0;m--){const p=g[m];if(p.type==="rectangle"){if(i>=p.x&&i<=p.x+p.width&&l>=p.y&&l<=p.y+p.height)return p}else if(p.type==="circle"){if(Math.sqrt(Math.pow(i-p.centerX,2)+Math.pow(l-p.centerY,2))<=p.radius)return p}else if(p.type==="pencil")for(let C=1;C<p.points.length;C++){const S=p.points[C-1],E=p.points[C];if(sn(i,l,S.x,S.y,E.x,E.y)<=5)return p}else if(p.type==="text"){const k=p.fontSize||16,C=p.text.length*k*.6,S=k;if(i>=p.x&&i<=p.x+C&&l>=p.y&&l<=p.y+S)return p}else if(p.type==="triangle"||p.type==="diamond"||p.type==="hexagon"||p.type==="octagon"){if(i>=p.x&&i<=p.x+p.width&&l>=p.y&&l<=p.y+p.height)return p}else if(p.type==="star"||p.type==="heart"){if(Math.sqrt(Math.pow(i-p.centerX,2)+Math.pow(l-p.centerY,2))<=p.size)return p}else if(p.type==="arrow"){if(sn(i,l,p.startX,p.startY,p.endX,p.endY)<=10)return p}else if(p.type==="image"&&i>=p.x&&i<=p.x+p.width&&l>=p.y&&l<=p.y+p.height)return p}return null},[g]),sn=(i,l,m,p,k,C)=>{const S=i-m,E=l-p,D=k-m,A=C-p,R=S*D+E*A,Z=D*D+A*A;let J=-1;Z!==0&&(J=R/Z);let $,re;J<0?($=m,re=p):J>1?($=k,re=C):($=m+J*D,re=p+J*A);const ae=i-$,we=l-re;return Math.sqrt(ae*ae+we*we)},an=N.useCallback((i,l)=>{if(i.strokeStyle="#0066cc",i.lineWidth=2,i.setLineDash([5,5]),l.type==="rectangle")i.strokeRect(l.x-4,l.y-4,l.width+8,l.height+8);else if(l.type==="circle")i.beginPath(),i.arc(l.centerX,l.centerY,l.radius+4,0,Math.PI*2),i.stroke();else if(l.type==="pencil"&&l.points.length>0){const m=Math.min(...l.points.map(S=>S.x)),p=Math.max(...l.points.map(S=>S.x)),k=Math.min(...l.points.map(S=>S.y)),C=Math.max(...l.points.map(S=>S.y));i.strokeRect(m-4,k-4,p-m+8,C-k+8)}else if(l.type==="text"){const m=l.fontSize||16,p=l.text.length*m*.6,k=m;i.strokeRect(l.x-4,l.y-4,p+8,k+8)}else if(l.type==="triangle"||l.type==="diamond"||l.type==="hexagon"||l.type==="octagon")i.strokeRect(l.x-4,l.y-4,l.width+8,l.height+8);else if(l.type==="star"||l.type==="heart")i.beginPath(),i.arc(l.centerX,l.centerY,l.size+4,0,Math.PI*2),i.stroke();else if(l.type==="arrow"){const m=Math.min(l.startX,l.endX),p=Math.max(l.startX,l.endX),k=Math.min(l.startY,l.endY),C=Math.max(l.startY,l.endY);i.strokeRect(m-4,k-4,p-m+8,C-k+8)}else l.type==="image"&&i.strokeRect(l.x-4,l.y-4,l.width+8,l.height+8);i.setLineDash([])},[]),pe=N.useCallback(()=>{const i=c.current;if(!i)return;const l=i.getContext("2d");l.clearRect(0,0,i.width,i.height),l.save(),l.translate(f.panX,f.panY),l.scale(f.zoom,f.zoom),y.enabled&&ht(l,y.size,y.color),g.forEach(m=>{_t(l,m),m.id===_&&an(l,m)}),l.restore()},[y,ht,g,_t,_,an,f]);N.useEffect(()=>{Gt.current=pe},[pe]),N.useEffect(()=>{const i=c.current;if(!i)return;const l=()=>{i.width=window.innerWidth,i.height=window.innerHeight,pe()};return l(),window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l)}},[pe]),N.useEffect(()=>{pe()},[pe]),N.useEffect(()=>{const i=m=>{m.target.tagName==="INPUT"||m.target.tagName==="TEXTAREA"||m.code==="Space"&&!m.repeat&&(m.preventDefault(),Ie(!0))},l=m=>{m.target.tagName==="INPUT"||m.target.tagName==="TEXTAREA"||m.code==="Space"&&(m.preventDefault(),Ie(!1),Ee(!1),_e(!1))};return window.addEventListener("keydown",i),window.addEventListener("keyup",l),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",l)}},[]);const Kt=N.useCallback((i,l)=>({x:(i-f.panX)/f.zoom,y:(l-f.panY)/f.zoom}),[f]);N.useEffect(()=>{const i=c.current;if(!i||!M)return;const l=i.getContext("2d");if(pe(),l.save(),l.translate(f.panX,f.panY),l.scale(f.zoom,f.zoom),d==="pointer")rn(l,b,w);else if(d==="rectangle"){const m=Math.min(b.x,w.x),p=Math.min(b.y,w.y),k=Math.abs(w.x-b.x),C=Math.abs(w.y-b.y);pt(l,{x:m,y:p,width:k,height:C,strokeColor:h.rectangle.strokeColor,fillColor:h.rectangle.fillColor,lineWidth:h.rectangle.lineWidth})}else if(d==="circle"){const m=b.x,p=b.y,k=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));yt(l,{centerX:m,centerY:p,radius:k,strokeColor:h.circle.strokeColor,fillColor:h.circle.fillColor,lineWidth:h.circle.lineWidth})}else if(d==="pencil")gt(l,{points:T,strokeColor:h.pencil.strokeColor,lineWidth:h.pencil.lineWidth});else if(d==="triangle"){const m=Math.min(b.x,w.x),p=Math.min(b.y,w.y),k=Math.abs(w.x-b.x),C=Math.abs(w.y-b.y);mt(l,{x:m,y:p,width:k,height:C,strokeColor:h.triangle.strokeColor,fillColor:h.triangle.fillColor,lineWidth:h.triangle.lineWidth})}else if(d==="diamond"){const m=Math.min(b.x,w.x),p=Math.min(b.y,w.y),k=Math.abs(w.x-b.x),C=Math.abs(w.y-b.y);wt(l,{x:m,y:p,width:k,height:C,strokeColor:h.diamond.strokeColor,fillColor:h.diamond.fillColor,lineWidth:h.diamond.lineWidth})}else if(d==="star"){const m=b.x,p=b.y,k=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));vt(l,{centerX:m,centerY:p,size:k,strokeColor:h.star.strokeColor,fillColor:h.star.fillColor,lineWidth:h.star.lineWidth})}else if(d==="heart"){const m=b.x,p=b.y,k=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));bt(l,{centerX:m,centerY:p,size:k,strokeColor:h.heart.strokeColor,fillColor:h.heart.fillColor,lineWidth:h.heart.lineWidth})}else if(d==="hexagon"){const m=Math.min(b.x,w.x),p=Math.min(b.y,w.y),k=Math.abs(w.x-b.x),C=Math.abs(w.y-b.y);xt(l,{x:m,y:p,width:k,height:C,strokeColor:h.hexagon.strokeColor,fillColor:h.hexagon.fillColor,lineWidth:h.hexagon.lineWidth})}else if(d==="octagon"){const m=Math.min(b.x,w.x),p=Math.min(b.y,w.y),k=Math.abs(w.x-b.x),C=Math.abs(w.y-b.y);Et(l,{x:m,y:p,width:k,height:C,strokeColor:h.octagon.strokeColor,fillColor:h.octagon.fillColor,lineWidth:h.octagon.lineWidth})}else d==="arrow"&&Ct(l,{startX:b.x,startY:b.y,endX:w.x,endY:w.y,strokeColor:h.arrow.strokeColor,fillColor:h.arrow.fillColor,lineWidth:h.arrow.lineWidth});l.restore()},[M,d,b,w,T,pe,rn,pt,yt,gt,mt,wt,vt,bt,xt,Et,Ct,f,h]);const Fi=i=>{const m=c.current.getBoundingClientRect(),p=i.clientX-m.left,k=i.clientY-m.top;if(j||z)return;if(fe){i.preventDefault(),i.button===0?(Ee(!0),ft({x:p-f.panX,y:k-f.panY})):i.button===2&&(_e(!0),x({y:k,initialZoom:f.zoom}));return}const{x:C,y:S}=Kt(p,k);if(d==="pointer"){const E=qt(C,S);if(E)if(a(ze(E.id)),L(!0),E.type==="rectangle")oe({x:C-E.x,y:S-E.y});else if(E.type==="circle")oe({x:C-E.centerX,y:S-E.centerY});else if(E.type==="pencil"){const D=Math.min(...E.points.map(R=>R.x)),A=Math.min(...E.points.map(R=>R.y));oe({x:C-D,y:S-A})}else E.type==="text"?oe({x:C-E.x,y:S-E.y}):E.type==="triangle"||E.type==="diamond"||E.type==="hexagon"||E.type==="octagon"?oe({x:C-E.x,y:S-E.y}):E.type==="star"||E.type==="heart"?oe({x:C-E.centerX,y:S-E.centerY}):E.type==="arrow"?oe({x:C-E.startX,y:S-E.startY}):E.type==="image"&&oe({x:C-E.x,y:S-E.y});else a(ze(null)),P(!0),I({x:C,y:S}),v({x:C,y:S})}else if(d==="text"){const E=Date.now().toString();a(ne({id:E,type:"text",x:C,y:S,text:"Text",fontSize:h.text.fontSize,fontColor:h.text.fontColor})),a(de("pointer")),a(ze(E))}else if(d==="eraser"){const E=qt(C,S);E&&a(ei(E.id))}else a(ze(null)),P(!0),I({x:C,y:S}),v({x:C,y:S}),d==="pencil"&&V([{x:C,y:S}])},Xi=i=>{const m=c.current.getBoundingClientRect(),p=i.clientX-m.left,k=i.clientY-m.top;if(Re){a(ti({x:p-Ae.x,y:k-Ae.y}));return}if(ke){const E=We.y-k,A=We.initialZoom*(1+E*.005);a(ri(A));return}const{x:C,y:S}=Kt(p,k);if(B&&_){const E=g.find(A=>A.id===_);if(!E)return;let D={};if(E.type==="rectangle")D={x:C-F.x,y:S-F.y};else if(E.type==="circle")D={centerX:C-F.x,centerY:S-F.y};else if(E.type==="pencil"){const A=Math.min(...E.points.map($=>$.x)),R=Math.min(...E.points.map($=>$.y)),Z=C-F.x-A,J=S-F.y-R;D={points:E.points.map($=>({x:$.x+Z,y:$.y+J}))}}else if(E.type==="text")D={x:C-F.x,y:S-F.y};else if(E.type==="triangle"||E.type==="diamond"||E.type==="hexagon"||E.type==="octagon")D={x:C-F.x,y:S-F.y};else if(E.type==="star"||E.type==="heart")D={centerX:C-F.x,centerY:S-F.y};else if(E.type==="arrow"){const A=E.endX-E.startX,R=E.endY-E.startY;D={startX:C-F.x,startY:S-F.y,endX:C-F.x+A,endY:S-F.y+R}}else E.type==="image"&&(D={x:C-F.x,y:S-F.y});a(lt({id:_,updates:D}));return}M&&(v({x:C,y:S}),d==="pencil"&&V(E=>[...E,{x:C,y:S}]))},cn=()=>{if(Re||ke){Ee(!1),_e(!1);return}if(B){L(!1);return}if(M){if(d==="pointer")pe();else if(d==="rectangle"){const i=Math.min(b.x,w.x),l=Math.min(b.y,w.y),m=Math.abs(w.x-b.x),p=Math.abs(w.y-b.y);m>0&&p>0&&a(ne({id:Date.now().toString(),type:"rectangle",x:i,y:l,width:m,height:p,strokeColor:h.rectangle.strokeColor,fillColor:h.rectangle.fillColor,lineWidth:h.rectangle.lineWidth}))}else if(d==="circle"){const i=b.x,l=b.y,m=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));m>0&&a(ne({id:Date.now().toString(),type:"circle",centerX:i,centerY:l,radius:m,strokeColor:h.circle.strokeColor,fillColor:h.circle.fillColor,lineWidth:h.circle.lineWidth}))}else if(d==="pencil")T.length>1&&a(ne({id:Date.now().toString(),type:"pencil",points:[...T],strokeColor:h.pencil.strokeColor,lineWidth:h.pencil.lineWidth})),V([]);else if(d==="triangle"){const i=Math.min(b.x,w.x),l=Math.min(b.y,w.y),m=Math.abs(w.x-b.x),p=Math.abs(w.y-b.y);m>0&&p>0&&a(ne({id:Date.now().toString(),type:"triangle",x:i,y:l,width:m,height:p,strokeColor:h.triangle.strokeColor,fillColor:h.triangle.fillColor,lineWidth:h.triangle.lineWidth}))}else if(d==="diamond"){const i=Math.min(b.x,w.x),l=Math.min(b.y,w.y),m=Math.abs(w.x-b.x),p=Math.abs(w.y-b.y);m>0&&p>0&&a(ne({id:Date.now().toString(),type:"diamond",x:i,y:l,width:m,height:p,strokeColor:h.diamond.strokeColor,fillColor:h.diamond.fillColor,lineWidth:h.diamond.lineWidth}))}else if(d==="star"){const i=b.x,l=b.y,m=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));m>0&&a(ne({id:Date.now().toString(),type:"star",centerX:i,centerY:l,size:m,strokeColor:h.star.strokeColor,fillColor:h.star.fillColor,lineWidth:h.star.lineWidth}))}else if(d==="heart"){const i=b.x,l=b.y,m=Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2));m>0&&a(ne({id:Date.now().toString(),type:"heart",centerX:i,centerY:l,size:m,strokeColor:h.heart.strokeColor,fillColor:h.heart.fillColor,lineWidth:h.heart.lineWidth}))}else if(d==="hexagon"){const i=Math.min(b.x,w.x),l=Math.min(b.y,w.y),m=Math.abs(w.x-b.x),p=Math.abs(w.y-b.y);m>0&&p>0&&a(ne({id:Date.now().toString(),type:"hexagon",x:i,y:l,width:m,height:p,strokeColor:h.hexagon.strokeColor,fillColor:h.hexagon.fillColor,lineWidth:h.hexagon.lineWidth}))}else if(d==="octagon"){const i=Math.min(b.x,w.x),l=Math.min(b.y,w.y),m=Math.abs(w.x-b.x),p=Math.abs(w.y-b.y);m>0&&p>0&&a(ne({id:Date.now().toString(),type:"octagon",x:i,y:l,width:m,height:p,strokeColor:h.octagon.strokeColor,fillColor:h.octagon.fillColor,lineWidth:h.octagon.lineWidth}))}else if(d==="arrow"){const i=w.x-b.x,l=w.y-b.y;Math.sqrt(i*i+l*l)>5&&a(ne({id:Date.now().toString(),type:"arrow",startX:b.x,startY:b.y,endX:w.x,endY:w.y,strokeColor:h.arrow.strokeColor,fillColor:h.arrow.fillColor,lineWidth:h.arrow.lineWidth}))}P(!1)}},$i=i=>{fe&&i.preventDefault()},Bi=()=>fe?Re?"grabbing":ke?"ns-resize":"grab":"default";return u.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[u.jsx("canvas",{ref:c,onMouseDown:Fi,onMouseMove:Xi,onMouseUp:cn,onMouseLeave:cn,onDoubleClick:i=>{const m=c.current.getBoundingClientRect(),p=i.clientX-m.left,k=i.clientY-m.top,{x:C,y:S}=Kt(p,k),E=qt(C,S);E&&E.type==="text"&&(me(E.id),Se({x:E.x,y:E.y}),X(E.text),Y(!0))},onContextMenu:$i,style:{cursor:Bi()}}),j&&u.jsx(ji,{text:n||((ln=t==null?void 0:t.lock)==null?void 0:ln.text)||O.text}),z&&u.jsx("input",{type:"text",value:he,onChange:i=>X(i.target.value),onKeyDown:i=>{i.key==="Enter"&&he.trim()?(se&&a(lt({id:se,updates:{text:he}})),Y(!1),X(""),me(null)):i.key==="Escape"&&(Y(!1),X(""),me(null))},onBlur:()=>{he.trim()&&se&&a(lt({id:se,updates:{text:he}})),Y(!1),X(""),me(null)},onMouseDown:i=>i.stopPropagation(),autoFocus:!0,style:{position:"absolute",left:U.x*f.zoom+f.panX,top:U.y*f.zoom+f.panY,fontSize:h.text.fontSize*f.zoom,color:h.text.fontColor,background:"white",border:"2px solid #0066cc",outline:"none",fontFamily:"sans-serif",minWidth:"150px",padding:"4px 8px",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"}}),u.jsx(Wi,{onExport:Yi}),u.jsx(Vi,{}),u.jsx(ci,{})]})}),Li=e=>u.jsx(jn,{store:Kr,children:u.jsx(An,{children:u.jsx(tn,{...e})})});ce.WhiteboardComponent=tn,ce.default=Li,ce.store=Kr,ce.whiteboardReducer=qr,Object.defineProperties(ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@ninesstudios/whiteboard",
3
+ "description": "Whiteboard drawing application",
4
+ "author": "Nines Studios",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/huzeyfecoskun/whiteboard",
7
+ "version": "0.0.1",
8
+ "type": "module",
9
+ "main": "./dist/whiteboard.umd.js",
10
+ "module": "./dist/whiteboard.es.js",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/whiteboard.es.js",
14
+ "require": "./dist/whiteboard.umd.js"
15
+ },
16
+ "./style.css": "./dist/whiteboard.css"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "vite build",
24
+ "preview": "vite preview"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "^18.0.0 || ^19.0.0",
28
+ "react-dom": "^18.0.0 || ^19.0.0"
29
+ },
30
+ "dependencies": {
31
+ "@reduxjs/toolkit": "^2.11.2",
32
+ "react-icons": "^5.5.0",
33
+ "react-redux": "^9.2.0"
34
+ },
35
+ "devDependencies": {
36
+ "@vitejs/plugin-react": "^4.3.4",
37
+ "react": "^19.0.0",
38
+ "react-dom": "^19.0.0",
39
+ "vite": "^6.0.5"
40
+ }
41
+ }