react-sync-board 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"react-sync-board.js","names":[],"sources":["../node_modules/nanoid/url-alphabet/index.js","../node_modules/nanoid/index.browser.js","../node_modules/wire.io/src/client.js","../src/lib/hooks/useWire.jsx","../src/lib/utils.js","../src/lib/board/store/synced.jsx","../src/lib/board/Items/useItems.js","../src/lib/board/Items/useDebouncedItems.js","../src/lib/settings.js","../src/lib/board/store/main.jsx","../src/lib/board/Items/useSelectedItems.js","../src/lib/board/Items/useGetSelectedItems.js","../src/lib/board/useDim.js","../src/lib/board/Items/useItemInteraction.js","../src/lib/board/Items/useItemActions.js","../node_modules/fast-deep-equal/es6/index.js","../src/lib/board/Items/useAvailableActions.js","../src/lib/board/useSelectionBox.js","../src/lib/users/store.jsx","../src/lib/users/useUsers.jsx","../src/lib/board/useBoardConfig.jsx","../src/lib/board/useBoardState.js","../src/lib/board/useSessionInfo.jsx","../src/lib/message/store.jsx","../src/lib/message/useMessage.js","../src/lib/BoardWrapper.jsx","../src/lib/RoomWrapper.jsx","../node_modules/goober/dist/goober.modern.js","../node_modules/fast-deep-equal/index.js","../src/lib/board/Gesture.jsx","../src/lib/board/Items/ResizeHandler.jsx","../src/lib/board/Items/Item.jsx","../src/lib/board/Items/ItemList.jsx","../src/lib/board/Selector.jsx","../src/lib/board/ActionPane.jsx","../src/lib/board/useMousePosition.js","../src/lib/board/usePositionNavigator.jsx","../src/lib/board/PanZoom.jsx","../src/lib/board/Selection.jsx","../node_modules/color2k/dist/index.exports.import.es.mjs","../src/lib/board/Cursors/Cursor.jsx","../src/lib/board/Cursors/CursorPane.jsx","../src/lib/board/background.js","../src/lib/board/WorldBackground.jsx","../src/lib/board/Board.jsx","../src/lib/index.js"],"sourcesContent":["export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","\n\nimport { urlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet }\n\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\n\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += urlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import { nanoid } from 'nanoid';\n\nconst MAX_NAME_LENGTH = 128;\nconst isValidName = (value) =>\n typeof value === 'string' &&\n value.length > 0 &&\n value.length <= MAX_NAME_LENGTH &&\n !/[\\u0000-\\u001f\\u007f]/u.test(value);\n\nconst assertValidName = (value, label) => {\n if (!isValidName(value)) throw new Error(`Invalid ${label}`);\n};\n\nclass Wire {\n constructor(socket, room, userId = null) {\n this._socket = socket;\n this.userId = userId;\n this.room = room;\n this.toUnregister = [\n () => {\n this._socket.off(`${this.room}.isMaster`);\n this._socket.off(`${this.room}.roomJoined`);\n this._socket.off(`${this.room}._call`);\n },\n ];\n this._left = false;\n\n this.registeredRPC = Object.create(null);\n\n // Receive server RPC calls\n this._socket.on(`${this.room}._call`, async ({ callId, name, params }) => {\n try {\n if (!Object.hasOwn(this.registeredRPC, name)) {\n throw new Error(`Function ${name} is not registered`);\n }\n const result = await this.registeredRPC[name](params);\n socket.emit(`${this.room}._result.${callId}`, {\n ok: result ? result : null,\n });\n } catch (err) {\n socket.emit(`${this.room}._result.${callId}`, {\n err: `${err.message}`,\n });\n }\n });\n }\n\n /**\n * Call a server procedure.\n *\n * @param {string} action name of the operation to call on the server.\n * @param {*} params the params of the action.\n * @returns the result of the call.\n */\n async _callServerRPC(name, params) {\n const callId = nanoid();\n return new Promise((resolve, reject) => {\n this._socket.once(`${this.room}._result.${callId}`, (result) => {\n if (Object.hasOwn(result, 'ok')) {\n resolve(result.ok);\n } else {\n reject(result.err);\n }\n });\n this._socket.emit(`${this.room}._call`, { callId, name, params });\n });\n }\n\n /**\n * Leave current room\n * @param {string} room name.\n */\n leave() {\n this._left = true;\n this.toUnregister.forEach((callback) => {\n callback();\n });\n this._socket.emit(`${this.room}.leave`);\n }\n\n /**\n * Send an event to all other client in room. Also to self if true.\n * @param {string} name Name of event\n * @param {*} params arguments of event\n * @param {boolean} self if true, the publish get the event too\n */\n publish(name, params, self = false) {\n assertValidName(name, 'event name');\n this._socket.emit(`${this.room}.publish`, { name, params, self });\n }\n\n /**\n * Subscribe to an event.\n * @param {string} event Name of event\n * @param {function} callback Called when the event is received. First param\n * of the function is the params sent with the event.\n */\n subscribe(event, callback) {\n assertValidName(event, 'event name');\n if (typeof callback !== 'function') throw new TypeError('Invalid callback');\n this._socket.on(`${this.room}.${event}`, callback);\n\n const unregisterCallback = () => {\n this._socket.off(`${this.room}.${event}`, callback);\n };\n\n this.toUnregister.push(unregisterCallback);\n\n return unregisterCallback;\n }\n\n /**\n * Register a new RPC function.\n * @param {string} name of function\n * @param {function} callback the function that handle the function result\n * @param {object} params the configuration of the RPC. For now only `invoke`\n * parameter is allowed with the following values:\n * - 'single' for a RPC that can be registered only once.\n * - 'first' The first registered client is called.\n * - 'last' The last registered client is called.\n * - 'random' A random RPC is called.\n */\n async register(name, callback, { invoke = 'single' } = {}) {\n assertValidName(name, 'RPC name');\n if (typeof callback !== 'function') throw new TypeError('Invalid callback');\n if (!['single', 'first', 'last', 'random'].includes(invoke)) {\n throw new Error('Invalid invoke mode');\n }\n // Add to locally registered callback\n\n this.registeredRPC[name] = callback;\n\n await this._callServerRPC('register', {\n name,\n invoke,\n });\n\n // Return unregister callback\n const unregisterCallback = () => {\n if (this.registeredRPC[name] === callback) {\n delete this.registeredRPC[name];\n return this._callServerRPC('unregister', { name });\n }\n };\n\n this.toUnregister.push(unregisterCallback);\n\n return unregisterCallback;\n }\n\n /**\n * Call a previously registered function with `params` arguments.\n * @param {string} name of function\n * @param {*} params parameters of the called function.\n */\n async call(name, params) {\n return await this._callServerRPC('call', { name, params });\n }\n}\n\n/**\n * Join a wire.io room.\n * @param {socket} socket socket.io instance.\n * @param {string} name of the room\n * @param {function} onMaster is called when the client become the master of\n * the room, i.e. the first client or the next one if the first quit.\n * @param {function} onJoined is called on each connection, reconnection after\n * wire.io is initialized.\n * @param {string} userId (optional) to force userId.\n */\nexport const joinWire = ({\n socket,\n room,\n onJoined = () => {},\n onMaster = () => {},\n userId = null,\n}) => {\n assertValidName(room, 'room name');\n if (userId !== null && userId !== undefined) {\n assertValidName(userId, 'user id');\n }\n const WireRoom = new Wire(socket, room, userId);\n return new Promise((resolve) => {\n // Avoid multiple join\n let waitForResponse = true;\n socket.on(`${room}.isMaster`, () => {\n if (WireRoom._left) {\n return;\n }\n onMaster(room);\n });\n\n socket.on(`${room}.roomJoined`, (userId) => {\n if (WireRoom._left) {\n return;\n }\n WireRoom.userId = userId;\n waitForResponse = false;\n onJoined(WireRoom);\n resolve(WireRoom);\n });\n\n // Rejoin on reconnection\n socket.on('connect', () => {\n // If joined already called or room left\n // we quit\n if (WireRoom._left || waitForResponse) {\n return;\n }\n // Restore events with same userId\n socket.emit('joinSuperSocket', {\n room,\n userId: WireRoom.userId,\n });\n });\n socket.emit('joinSuperSocket', { room, userId });\n });\n};\n\nexport default joinWire;\n","import React, { useContext } from \"react\";\nimport { joinWire } from \"wire.io\";\n\nconst Context = React.createContext();\n\nexport const DefaultLoading = () => {\n return (\n <div\n style={{\n position: \"absolute\",\n top: \"0\",\n bottom: \"0\",\n width: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h2>🌀 Loading...</h2>\n </div>\n );\n};\n\nexport const WireProvider = ({\n socket,\n room,\n channel = \"default\",\n LoadingComponent = DefaultLoading,\n children,\n}) => {\n const [joined, setJoined] = React.useState(false);\n const [isMaster, setIsMaster] = React.useState(false);\n const [wire, setWire] = React.useState(null);\n const roomRef = React.useRef(null);\n const mountedRef = React.useRef(false);\n const existingC2C = useContext(Context);\n const connectingRef = React.useRef(false);\n\n React.useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n React.useEffect(() => {\n if (!socket) {\n return null;\n }\n\n const disconnect = () => {\n console.log(`Disconnected from ${channel}…`);\n if (!mountedRef.current) return;\n setJoined(false);\n setIsMaster(false);\n };\n\n socket.on(\"disconnect\", disconnect);\n return () => {\n socket.off(\"disconnect\", disconnect);\n };\n }, [channel, socket]);\n\n React.useEffect(() => {\n // Connect\n if (!socket) {\n return null;\n }\n if (!socket.connected) {\n socket.connect();\n }\n console.log(`Try to connect to wire ${room} on channel ${channel}`);\n if (!connectingRef.current) {\n connectingRef.current = true;\n joinWire({\n socket,\n room,\n onMaster: () => {\n console.log(`Is now master on channel ${channel}…`);\n if (!mountedRef.current) return;\n setIsMaster(true);\n },\n onJoined: (newRoom) => {\n console.log(`Connected on channel ${channel}…`);\n roomRef.current = newRoom;\n\n if (!mountedRef.current) return;\n setWire(newRoom);\n setJoined(true);\n },\n });\n }\n\n return () => {\n roomRef.current?.leave();\n };\n }, [channel, room, socket]);\n\n\n if (!joined || !wire) {\n return <LoadingComponent />;\n }\n\n return (\n <Context.Provider\n value={{ ...existingC2C, [channel]: { wire, joined, isMaster, room } }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nconst useWire = (channel = \"default\") => {\n const channels = useContext(Context) || {};\n return channels[channel];\n};\n\nexport default useWire;\n","/**\n * Check if element or parent has className.\n * @param {DOMElement} element\n * @param {string} className\n */\nexport const hasClass = (element, className) =>\n element.classList && element.classList.contains(className);\n\nexport const insideClass = (element, className) => {\n if (hasClass(element, className)) {\n return element;\n }\n if (!element.parentNode) {\n return false;\n }\n return insideClass(element.parentNode, className);\n};\n\nexport const distance = ([x1, y1], [x2, y2]) => {\n const distanceX = Math.abs(x1 - x2);\n const distanceY = Math.abs(y1 - y2);\n\n return Math.hypot(distanceX, distanceY);\n};\n\nexport const rotateCoordinates = (x, y, angle) => {\n const angleInRadians = (angle * Math.PI) / 180;\n\n const xRotated = x * Math.cos(angleInRadians) - y * Math.sin(angleInRadians);\n const yRotated = x * Math.sin(angleInRadians) + y * Math.cos(angleInRadians);\n\n return [xRotated, yRotated];\n};\n\nexport const transformFrom = (\n [x, y],\n { scale, rotate, translateX, translateY }\n) => {\n const xScaled = (x - translateX) / scale;\n const yScaled = (y - translateY) / scale;\n\n return rotateCoordinates(xScaled, yScaled, -rotate);\n};\n\nexport const transformTo = (\n [x, y],\n { scale, rotate, translateX, translateY }\n) => {\n const [xInvRotated, yInvRotated] = rotateCoordinates(x, y, rotate);\n return [xInvRotated * scale + translateX, yInvRotated * scale + translateY];\n};\n\nexport const intersectSegmentCircle = (p1, p2, circle, radius) => {\n const Ax = p1.x,\n Ay = p1.y;\n const Bx = p2.x,\n By = p2.y;\n const Cx = circle.x,\n Cy = circle.y;\n\n const Dx = Bx - Ax,\n Dy = By - Ay;\n const Ex = Ax - Cx,\n Ey = Ay - Cy;\n\n const a = Dx * Dx + Dy * Dy;\n const b = 2 * (Ex * Dx + Ey * Dy);\n const c = Ex * Ex + Ey * Ey - radius * radius;\n\n const discriminant = b * b - 4 * a * c;\n\n if (discriminant < 0) {\n return []; // No intersection\n }\n\n const t1 = (-b + Math.sqrt(discriminant)) / (2 * a);\n const t2 = (-b - Math.sqrt(discriminant)) / (2 * a);\n\n const intersections = [];\n\n if (t1 >= 0 && t1 <= 1) {\n intersections.push({ x: Ax + t1 * Dx, y: Ay + t1 * Dy });\n }\n\n if (t2 >= 0 && t2 <= 1) {\n intersections.push({ x: Ax + t2 * Dx, y: Ay + t2 * Dy });\n }\n\n return intersections;\n};\n\nexport const getParent = (initialElem, selector) => {\n for (\n let elem = initialElem;\n elem && elem !== document;\n elem = elem.parentNode\n ) {\n if (selector(elem)) return elem;\n }\n return null;\n};\n\nexport const isPointInsideRect = (point, rect) =>\n point.x > rect.left &&\n point.x < rect.left + rect.width &&\n point.y > rect.top &&\n point.y < rect.top + rect.height;\n\nexport const isItemInsideRect = (itemElement, rect) => {\n const fourElem = Array.from(itemElement.querySelectorAll(\".corner\"));\n\n return fourElem.every((corner) => {\n const { top: y, left: x } = corner.getBoundingClientRect();\n return isPointInsideRect({ x, y }, rect);\n });\n};\n\nexport const isItemInsideElement = (itemElement, otherElem) => {\n const rect = otherElem.getBoundingClientRect();\n\n const result = isItemInsideRect(itemElement, rect);\n return result;\n};\n\nexport const getItemElem = (uid, itemId) => {\n try {\n const elem = document.getElementById(`${uid}__${itemId}`);\n return elem;\n } catch {\n console.error(\n `Error while getting item with id ${itemId} inside wrapper`,\n uid\n );\n return undefined;\n }\n};\n\nexport const getIdFromElem = (elem) => {\n const value = elem?.dataset?.id;\n if (!value) {\n // eslint-disable-next-line no-console\n console.error(\n \"getIdFromElem call fails\",\n elem,\n JSON.stringify(elem?.dataset),\n elem?.dataset?.id\n );\n }\n return value;\n};\n\nexport const getItemsBoundingBox = (itemIds, uid) => {\n const result = itemIds.reduce((prev, itemId) => {\n const elem = getItemElem(uid, itemId);\n\n if (!elem) {\n if (!prev) {\n return null;\n }\n return prev;\n }\n\n const { left, right, top, bottom } = elem.getBoundingClientRect();\n\n let boundingBox;\n\n if (!prev) {\n boundingBox = {\n left,\n top,\n right,\n bottom,\n };\n } else {\n boundingBox = prev;\n }\n\n boundingBox.left = Math.min(left, boundingBox.left);\n boundingBox.top = Math.min(top, boundingBox.top);\n boundingBox.right = Math.max(right, boundingBox.right);\n boundingBox.bottom = Math.max(bottom, boundingBox.bottom);\n\n return boundingBox;\n }, null);\n\n if (!result) {\n return result;\n }\n\n result.width = result.right - result.left;\n result.height = result.bottom - result.top;\n\n return result;\n};\n\nconst getLinkedItemsRecursive = (itemMap, itemIds, alreadyMet = null) => {\n if (alreadyMet === null) {\n alreadyMet = new Set();\n }\n\n if (!Array.isArray(itemIds) || itemIds.length === 0) {\n return [];\n }\n\n return itemIds\n .map((itemId) => {\n if (alreadyMet.has(itemId)) {\n return [];\n } else {\n alreadyMet.add(itemId);\n if (itemMap[itemId]) {\n // If the item has been removed but not from linked list\n return [\n itemId,\n ...getLinkedItemsRecursive(\n itemMap,\n itemMap[itemId].linkedItems,\n alreadyMet\n ),\n ];\n } else {\n return [];\n }\n }\n })\n .flat();\n};\n\nexport const getLinkedItems = (itemMap, orderedItemIds, itemIds) => {\n const linkedItems = new Set(getLinkedItemsRecursive(itemMap, itemIds));\n return orderedItemIds.filter((itemId) => linkedItems.has(itemId));\n};\n\nexport const snapToGrid = (\n { x, y, width, height },\n { type = \"grid\", size = 1, offset = { x: 0, y: 0 } }\n) => {\n const [centerX, centerY] = [\n x + width / 2 - offset.x,\n y + height / 2 - offset.y,\n ];\n\n let newX;\n let newY;\n let sizeX;\n let sizeY;\n let px1;\n let px2;\n let py1;\n let py2;\n let diff1;\n let diff2;\n const h = size / 1.1547;\n\n switch (type) {\n case \"grid\":\n newX = Math.round(centerX / size) * size;\n newY = Math.round(centerY / size) * size;\n break;\n case \"hexH\":\n sizeX = 2 * h;\n sizeY = 3 * size;\n px1 = Math.round(centerX / sizeX) * sizeX;\n py1 = Math.round(centerY / sizeY) * sizeY;\n\n px2 = px1 > centerX ? px1 - h : px1 + h;\n py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;\n\n diff1 = Math.hypot(...[px1 - centerX, py1 - centerY]);\n diff2 = Math.hypot(...[px2 - centerX, py2 - centerY]);\n\n if (diff1 < diff2) {\n newX = px1;\n newY = py1;\n } else {\n newX = px2;\n newY = py2;\n }\n break;\n case \"hexV\":\n sizeX = 3 * size;\n sizeY = 2 * h;\n px1 = Math.round(centerX / sizeX) * sizeX;\n py1 = Math.round(centerY / sizeY) * sizeY;\n\n px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;\n py2 = py1 > centerY ? py1 - h : py1 + h;\n\n diff1 = Math.hypot(...[px1 - centerX, py1 - centerY]);\n diff2 = Math.hypot(...[px2 - centerX, py2 - centerY]);\n\n if (diff1 < diff2) {\n newX = px1;\n newY = py1;\n } else {\n newX = px2;\n newY = py2;\n }\n break;\n default:\n newX = x + width / 2;\n newY = y + height / 2;\n }\n\n return {\n x: newX + offset.x - width / 2,\n y: newY + offset.y - height / 2,\n };\n};\n\nconst colors = [\n \"#037758\",\n \"#99092a\",\n \"#067070\",\n \"#c6650f\",\n \"#008726\",\n \"#3d7004\",\n \"#348402\",\n \"#057f58\",\n \"#b58612\",\n \"#c44c01\",\n \"#0a7704\",\n \"#0e910e\",\n \"#027377\",\n \"#c99e02\",\n \"#054160\",\n \"#157a01\",\n \"#b10de2\",\n \"#0d6289\",\n \"#bc5d03\",\n \"#ba0cd1\",\n \"#d39f10\",\n \"#0c4c7a\",\n \"#460782\",\n \"#a51f10\",\n \"#cecb10\",\n \"#9b0943\",\n \"#607f0c\",\n \"#007a4b\",\n \"#bf0daa\",\n \"#af0ad8\",\n];\n\nexport const getRandomColor = () =>\n colors[Math.floor(Math.random() * colors.length)];\n\nconst debug = false;\n\nexport const syncMiddleware =\n ({ wire, storeName, noSync = [], defaultValue }, config) =>\n (set, get, api) => {\n set({ ready: false });\n const unsubs = [];\n const init = async () => {\n try {\n // Try to get the initial value from a peer\n const newValue = await wire.call(`${storeName}_getValue`);\n if (debug) console.log(\"init from peer with value\", newValue);\n set((state) => ({ ...state, ...newValue }));\n } catch {\n //console.log(`No peers for ${storeName}...`);\n if (defaultValue !== undefined) {\n set(defaultValue);\n }\n }\n unsubs.push(\n await wire.register(\n `${storeName}_getValue`,\n () => {\n return Object.fromEntries(\n Object.entries(get()).filter(\n ([key, value]) =>\n typeof value !== \"function\" && !noSync.includes(key)\n )\n );\n },\n { invoke: \"first\" }\n )\n );\n // Register the sync callback\n unsubs.push(\n wire.subscribe(`${storeName}_call`, ([methodName, args]) => {\n if (debug) console.log(\"receive\", methodName, args);\n previousFn[methodName](...args);\n })\n );\n set({ ready: true });\n };\n init();\n\n const result = config(set, get, api);\n const previousFn = { ...result };\n\n const syncResult = Object.fromEntries(\n // Send the update message on all method calls\n Object.entries(result).map(([key, fn]) => {\n if (\n typeof fn === \"function\" &&\n !key.startsWith(\"get\") &&\n !noSync.includes(key)\n ) {\n const newFn = (...args) => {\n if (debug) console.log(\"call\", key, args);\n const result = fn(...args);\n wire.publish(`${storeName}_call`, [key, args]);\n return result;\n };\n return [key, newFn];\n }\n return [key, fn];\n })\n );\n\n syncResult.unsub = () => {\n unsubs.forEach((unsub) => unsub());\n };\n\n return syncResult;\n };\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nexport const itemsStore = (set, get) => ({\n items: {},\n getItems: () => get().items,\n setItems: (newItems) => set({ items: newItems }),\n updateItems: (toUpdate, patch = false) =>\n set((state) => {\n if (patch) {\n const newItems = Object.fromEntries(\n Object.entries(state.items).map(([id, item]) => {\n if (toUpdate[id]) {\n return [id, { ...item, ...toUpdate[id] }];\n } else {\n return [id, item];\n }\n })\n );\n return { items: newItems };\n } else {\n return { items: { ...state.items, ...toUpdate } };\n }\n }),\n moveItems: (itemIds, posDelta) =>\n set(({ items: prevItems }) => {\n const newItems = { ...prevItems };\n itemIds.forEach((id) => {\n const item = prevItems[id];\n\n if (!item) {\n return;\n }\n\n newItems[id] = {\n ...item,\n x: (item.x || 0) + posDelta.x,\n y: (item.y || 0) + posDelta.y,\n moving: true,\n };\n });\n\n return { items: newItems };\n }),\n});\n\nexport const itemIdsStore = (set, get) => ({\n itemIds: [],\n setItemIds: (newValue) => set({ itemIds: newValue }),\n getItemIds: () => get().itemIds,\n insert: (position, value) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue.splice(position, 0, value);\n return { itemIds: newValue };\n }),\n remove: (position) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue.splice(position, 1);\n return { itemIds: newValue };\n }),\n updateItemIds: (position, value) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue[position] = value;\n return { itemIds: newValue };\n }),\n updateManyItemIds: (toUpdate) =>\n set((state) => {\n return {\n itemIds: state.itemIds.map((value, index) => {\n if (toUpdate[index] !== undefined) {\n return toUpdate[index];\n } else {\n return value;\n }\n }),\n };\n }),\n});\n\nconst commonStore = (set, get) => ({\n removeItemsById: (itemIdsToRemove) =>\n set((state) => {\n return {\n itemIds: state.itemIds.filter((id) => !itemIdsToRemove.includes(id)),\n items: Object.fromEntries(\n Object.entries(state.items).filter(\n ([id]) => !itemIdsToRemove.includes(id)\n )\n ),\n };\n }),\n getItemList: () => {\n const items = get().items;\n return get().itemIds.map((id) => items[id]);\n },\n setItemList: (itemList) =>\n set({\n items: Object.fromEntries(itemList.map((item) => [item.id, item])),\n itemIds: itemList.map(({ id }) => id),\n }),\n insertItems: (newItems, beforeId) =>\n set((state) => {\n let newItemIds;\n const itemIdsToAdd = newItems.map(({ id }) => id);\n if (beforeId) {\n const insertAt = state.itemIds.findIndex((id) => id === beforeId);\n newItemIds = [...state.itemIds];\n newItemIds.splice(insertAt, 0, ...itemIdsToAdd);\n } else {\n newItemIds = [...state.itemIds, ...itemIdsToAdd];\n }\n\n return {\n items: {\n ...state.items,\n ...Object.fromEntries(newItems.map((item) => [item.id, item])),\n },\n itemIds: newItemIds,\n };\n }),\n});\n\nconst boardStore = (set, get) => ({\n boardConfig: {},\n getBoardConfig: () => get().boardConfig,\n setBoardConfig: (newBoardConfig) => set({ boardConfig: newBoardConfig }),\n updateBoardConfig: (toUpdate) =>\n set((state) => ({ boardConfig: { ...state.boardConfig, ...toUpdate } })),\n});\n\nconst sessionInfoStore = (set, get) => ({\n session: {},\n getSessionInfo: () => get().session,\n setSessionInfo: (newSession) => set({ session: newSession }),\n updateSessionInfo: (toUpdate) =>\n set((state) => ({ session: { ...state.session, ...toUpdate } })),\n});\n\nexport const SyncedStoreProvider = ({ storeName, children, defaultValue }) => {\n const { wire } = useWire(\"room\");\n const [ready, setReady] = React.useState(false);\n const [store] = React.useState(() =>\n createStore(\n syncMiddleware({ wire, storeName, defaultValue }, (...args) => ({\n ...itemsStore(...args),\n ...itemIdsStore(...args),\n ...commonStore(...args),\n ...boardStore(...args),\n ...sessionInfoStore(...args),\n }))\n )\n );\n\n React.useEffect(() => {\n let mounted = true;\n // Wait for ready event\n const unsubscribe = store.subscribe((newValue) => {\n if (newValue.ready) {\n // No need to listen anymore\n unsubscribe();\n if (mounted) {\n setReady(true);\n }\n }\n });\n () => {\n mounted = false;\n unsubscribe();\n };\n }, [store]);\n\n if (!ready) {\n return null;\n }\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedStore = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useItems = () => {\n const [itemIds, items] = useSyncedStore((state) => [\n state.itemIds,\n state.items,\n ]);\n\n const itemList = React.useMemo(\n () => itemIds.map((id) => items[id]),\n [itemIds, items]\n );\n\n return itemList;\n};\n\nexport default useItems;\n","import React from \"react\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useDebouncedItems = () => {\n const [items, itemIds, getItemList] = useSyncedStore((state) => [\n state.items,\n state.itemIds,\n state.getItemList,\n ]);\n const [debouncedItems, setDebouncedItems] = React.useState(getItemList());\n const [, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n const currentItemList = getItemList();\n startTransition(() => {\n setDebouncedItems(currentItemList);\n });\n }, [items, itemIds, getItemList]);\n\n return debouncedItems;\n};\n\nexport default useDebouncedItems;\n","export const DEFAULT_BOARD_MAX_SIZE = 50000;\n\nexport default { DEFAULT_BOARD_MAX_SIZE };\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { DEFAULT_BOARD_MAX_SIZE } from \"@/settings\";\n\nconst Context = React.createContext();\n\nconst configuration = (set, get) => ({\n config: {\n itemTemplates: {},\n actions: {},\n uid: null,\n itemExtent: { x: 0, y: 0, radius: 0 },\n boardWrapperRect: {},\n boardSize: DEFAULT_BOARD_MAX_SIZE,\n },\n // TODO optimize when same values as before\n updateConfiguration: (toUpdate) =>\n set((state) => ({ config: { ...state.config, ...toUpdate } })),\n getConfiguration: () => get().config,\n});\nconst boardState = (set, get) => ({\n boardState: {\n movingItems: false,\n selecting: false,\n zooming: false,\n panning: false,\n translateX: 0,\n translateY: 0,\n scale: 1,\n rotate: 0,\n },\n // TODO optimize when same values as before\n updateBoardState: (toUpdate) =>\n set((state) => ({ boardState: { ...state.boardState, ...toUpdate } })),\n getBoardState: () => get().boardState,\n});\n\nconst itemInteractions = (set, get) => ({\n interactions: {},\n getInteractions: () => get().interactions,\n register: (interaction, callback) =>\n set((state) => {\n const nextInteraction = [...(state.interactions[interaction] || [])];\n nextInteraction.push(callback);\n return {\n interactions: { ...state.interactions, [interaction]: nextInteraction },\n };\n }),\n unregister: (interaction, callback) =>\n set((state) => {\n const nextInteraction = (state.interactions[interaction] || []).filter(\n (c) => c !== callback\n );\n return {\n interactions: { ...state.interactions, [interaction]: nextInteraction },\n };\n }),\n callInteractions: (interaction, itemIds) => {\n if (!get().interactions[interaction]) return;\n get().interactions[interaction].forEach((callback) => {\n setTimeout(() => callback(itemIds), 0);\n });\n },\n});\n\nconst selection = (set, get) => ({\n selection: [],\n setSelection: (idsToSelect) =>\n set((state) => {\n if (JSON.stringify(state.selection) !== JSON.stringify(idsToSelect)) {\n return { selection: idsToSelect };\n }\n return {};\n }),\n getSelection: () => get().selection,\n select: (idsToAdd) =>\n set((state) => ({\n selection: [...state.selection, ...idsToAdd],\n })),\n unselect: (itemsIdToRemove) =>\n set((state) => ({\n selection: state.selection.filter((id) => !itemsIdToRemove.includes(id)),\n })),\n clear: () =>\n set((state) => {\n if (state.selection.length > 0) {\n return { selection: [] };\n } else {\n return {};\n }\n }),\n reverse: () =>\n set((state) => {\n const reversed = [...state.selection];\n reversed.reverse();\n return { selection: reversed };\n }),\n selectionBox: null,\n setSelectionBox: (newSelectionBox) =>\n set((state) => {\n const prevBB = state.selectionBox;\n if (\n !prevBB ||\n !newSelectionBox ||\n prevBB.top !== newSelectionBox.top ||\n prevBB.left !== newSelectionBox.left ||\n prevBB.width !== newSelectionBox.width ||\n prevBB.height !== newSelectionBox.height\n ) {\n return { selectionBox: newSelectionBox };\n }\n return {};\n }),\n});\n\nexport const MainStoreProvider = ({ children }) => {\n const [store] = React.useState(() =>\n createStore((...args) => ({\n ...configuration(...args),\n ...boardState(...args),\n ...itemInteractions(...args),\n ...selection(...args),\n }))\n );\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useMainStore = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n\nexport default useMainStore;\n","import useMainStore from \"../store/main\";\n\nconst useSelectedItems = () => {\n const [selection] = useMainStore((state) => [state.selection]);\n return selection;\n};\n\nexport default useSelectedItems;\n","import useMainStore from \"../store/main\";\n\nconst useGetSelectedItems = () => {\n const [getSelection] = useMainStore((state) => [state.getSelection]);\n return getSelection;\n};\n\nexport default useGetSelectedItems;\n","import React from \"react\";\nimport { useDebouncedCallback } from \"@react-hookz/web\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport {\n distance,\n getItemElem,\n transformFrom,\n transformTo,\n} from \"@/utils\";\nimport useMainStore from \"./store/main\";\n\nconst MIN_SIZE = 1000;\nconst SCALE_TOLERANCE = 0.8;\n\nlet debug = false;\n\n/**\n * Return new board positions fixed to fit inside the board and not too far from the\n * item extent.\n */\nconst useDim = () => {\n const [\n getBoardState,\n updateBoardState,\n itemExtentGlobal,\n getConfiguration,\n updateConfiguration,\n ] = useMainStore((state) => [\n state.getBoardState,\n state.updateBoardState,\n state.config.itemExtent,\n state.getConfiguration,\n state.updateConfiguration,\n ]);\n const scaleBoundariesRef = React.useRef([0.15, 5]);\n\n const [getItemList] = useSyncedStore((state) => [state.getItemList]);\n\n const getDim = React.useCallback(() => {\n const { translateX, translateY, scale, rotate } = getBoardState();\n return { translateX, translateY, scale, rotate };\n }, [getBoardState]);\n\n const fromWrapperToBoard = React.useCallback(\n (x, y) => {\n return transformFrom([x, y], getBoardState());\n },\n [getBoardState]\n );\n\n const fromBoardToWrapper = React.useCallback(\n (x, y) => {\n return transformTo([x, y], getBoardState());\n },\n [getBoardState]\n );\n\n const vectorFromWrapperToBoard = React.useCallback(\n (x, y) => {\n const { scale, rotate } = getBoardState();\n\n return transformFrom([x, y], {\n translateX: 0,\n translateY: 0,\n rotate,\n scale,\n });\n },\n [getBoardState]\n );\n\n /**\n * Clamp scale to boundaries limits.\n */\n const clampScale = React.useCallback((scale) => {\n if (scale > scaleBoundariesRef.current[1]) {\n return scaleBoundariesRef.current[1];\n }\n\n if (scale < scaleBoundariesRef.current[0]) {\n return scaleBoundariesRef.current[0];\n }\n return scale;\n }, []);\n\n /**\n * Set board position safely by avoiding to go out of the dedicated space.\n */\n const setDimSafe = React.useCallback(\n (fn) => {\n const prev = getBoardState();\n\n const {\n translateX,\n translateY,\n scale,\n rotate: newRotate,\n } = {\n ...prev,\n ...fn(prev),\n };\n\n if (debug) console.log(\"New expected values: \", translateX, translateY, scale, newRotate);\n\n const newScale = clampScale(scale);\n\n const newX = translateX;\n const newY = translateY;\n\n if (debug) console.log(\"New fixed values: \", newX, newY, newScale, newRotate);\n\n updateBoardState({\n translateX: Number.isFinite(newX) ? newX : prev.translateX,\n translateY: Number.isFinite(newY) ? newY : prev.translateY,\n scale: Number.isFinite(newScale) ? newScale : clampScale(1),\n rotate: Number.isFinite(newRotate) ? newRotate : prev.rotate,\n });\n },\n [clampScale, getBoardState, updateBoardState]\n );\n\n /**\n * Move the board to the given coordinates.\n */\n const moveBoard = React.useCallback(\n (newTranslatOrFn) => {\n let translateFn = (prev) => ({ ...prev, ...newTranslatOrFn });\n if (typeof newTranslatOrFn === \"function\") {\n translateFn = newTranslatOrFn;\n }\n\n setDimSafe((prev) => ({\n ...prev,\n ...translateFn({\n translateX: prev.translateX,\n translateY: prev.translateY,\n }),\n }));\n },\n [setDimSafe]\n );\n\n /**\n * Zoom to factor centered on the given zoomCenter coordinates.\n *\n * zoomCenter is screen coordinates.\n */\n const zoomToCenter = React.useCallback(\n ({ to, factor }) => {\n const { boardWrapperRect } = getConfiguration();\n\n let center = to;\n\n if (!center) {\n center = {\n x: boardWrapperRect.left + boardWrapperRect.width / 2,\n y: boardWrapperRect.top + boardWrapperRect.height / 2,\n };\n }\n\n const prev = getBoardState();\n\n const newScale = clampScale(prev.scale * factor);\n\n const centerX = center.x - boardWrapperRect.left;\n const centerY = center.y - boardWrapperRect.top;\n\n const newTx =\n centerX - ((centerX - prev.translateX) * newScale) / prev.scale;\n const newTy =\n centerY - ((centerY - prev.translateY) * newScale) / prev.scale;\n\n setDimSafe((prev) => ({\n ...prev,\n translateX: newTx,\n translateY: newTy,\n scale: newScale,\n }));\n },\n [clampScale, getBoardState, getConfiguration, setDimSafe]\n );\n\n /**\n * Zoom to the given extent. The full extent will be included in the viewport.\n */\n const zoomToExtent = React.useCallback(\n ({ x, y, radius }) => {\n const { rotate } = getBoardState();\n const { boardWrapperRect } = getConfiguration();\n\n const [safeX, safeY, safeRadius] = [x || 0, y||0, radius || 2000]\n\n const scaleX = boardWrapperRect.width / (safeRadius * 2);\n const scaleY = boardWrapperRect.height / (safeRadius * 2);\n\n // The scale that fits in all dimensions with a border around\n const scale = clampScale(Math.min(scaleX, scaleY) * SCALE_TOLERANCE);\n\n\n // We apply the board transformations\n const [translateX, translateY] = transformTo(\n [-safeX, -safeY],\n {\n translateX: boardWrapperRect.width / 2,\n translateY: boardWrapperRect.height / 2,\n scale,\n rotate,\n }\n );\n\n setDimSafe((prev) => ({ ...prev, translateX, translateY, scale }));\n },\n [clampScale, getBoardState, getConfiguration, setDimSafe]\n );\n\n /**\n * Get the board coordinates pointed by the center of the screen.\n */\n const getCenterCoordinates = React.useCallback(() => {\n const { boardWrapperRect } = getConfiguration();\n const [x, y] = fromWrapperToBoard(\n boardWrapperRect.width / 2,\n boardWrapperRect.height / 2\n );\n return {\n x,\n y,\n };\n }, [fromWrapperToBoard, getConfiguration]);\n\n /**\n * Update the extent of all board items.\n */\n const updateItemExtent = React.useCallback(() => {\n // Update item extent\n const items = getItemList();\n const { uid } = getConfiguration();\n\n const newRes = items.reduce(\n (boundingBox, item) => {\n const elem = getItemElem(uid, item.id);\n\n if (elem) {\n boundingBox.left = Math.min(item.x, boundingBox.left);\n boundingBox.top = Math.min(item.y, boundingBox.top);\n\n boundingBox.right = Math.max(\n item.x + elem.offsetWidth,\n boundingBox.right\n );\n boundingBox.bottom = Math.max(\n item.y + elem.offsetHeight,\n boundingBox.bottom\n );\n }\n\n return boundingBox;\n },\n {\n left: Infinity,\n top: Infinity,\n right: -Infinity,\n bottom: -Infinity,\n }\n );\n\n if (!Number.isFinite(newRes.left)) {\n updateConfiguration({ itemExtent: { x: 0, y: 0, radius: MIN_SIZE } });\n return;\n }\n\n const final = {\n x: (newRes.right + newRes.left) / 2,\n y: (newRes.bottom + newRes.top) / 2,\n };\n\n final.radius = Math.max(\n distance([final.x, final.y], [newRes.left, newRes.top]),\n MIN_SIZE\n );\n\n updateConfiguration({ itemExtent: final });\n }, [getConfiguration, getItemList, updateConfiguration]);\n\n /**\n * Rotate the board to the given angle in degrees. If a function is given, it is\n * called with the previous angle as parameter and should return a new angle.\n */\n const rotateBoard = React.useCallback(\n (newAngleOrFn) => {\n let applyRotate = () => newAngleOrFn;\n if (typeof newAngleOrFn === \"function\") {\n applyRotate = newAngleOrFn;\n }\n\n setDimSafe((prev) => ({ ...prev, rotate: applyRotate(prev.rotate) }));\n\n // Zoom to new extent to not being lost\n updateItemExtent();\n zoomToExtent(itemExtentGlobal);\n },\n [itemExtentGlobal, setDimSafe, updateItemExtent, zoomToExtent]\n );\n\n const debouncedUpdateItemExtent = useDebouncedCallback(\n () => updateItemExtent(),\n [updateItemExtent],\n 200\n );\n\n React.useEffect(() => {\n window.debugUpdateExtent = () => updateItemExtent();\n window.debugDisplayExtent = () =>\n console.log(getConfiguration().itemExtent);\n window.debugSetDebug = () => {\n debug = true;\n }\n }, [getConfiguration, updateItemExtent]);\n\n return {\n setDim: setDimSafe,\n rotateBoard,\n moveBoard,\n getDim,\n zoomTo: zoomToCenter,\n zoomToCenter,\n zoomToExtent,\n getCenter: getCenterCoordinates,\n updateItemExtent: debouncedUpdateItemExtent,\n vectorFromWrapperToBoard,\n fromWrapperToBoard,\n fromBoardToWrapper,\n };\n};\n\nexport default useDim;\n","import React from \"react\";\nimport useMainStore from \"../store/main\";\n\nconst useItemInteraction = (interaction) => {\n const [registerInStore, unregister, callInteractions] = useMainStore(\n ({ register, unregister, callInteractions }) => [\n register,\n unregister,\n callInteractions,\n ]\n );\n\n const register = React.useCallback(\n (callback) => {\n registerInStore(interaction, callback);\n return () => {\n unregister(interaction, callback);\n };\n },\n [interaction, registerInStore, unregister]\n );\n\n const call = React.useCallback(\n (itemIds) => {\n callInteractions(interaction, itemIds);\n },\n [callInteractions, interaction]\n );\n\n return { register, call };\n};\n\nexport default useItemInteraction;\n","import React from \"react\";\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nimport useDim from \"../useDim\";\n\nimport {\n getItemElem,\n isPointInsideRect,\n insideClass,\n hasClass,\n snapToGrid,\n getLinkedItems,\n} from \"@/utils\";\n\nimport useItemInteraction from \"./useItemInteraction\";\nimport useMainStore from \"../store/main\";\n\nconst useItemActions = () => {\n const { call: callPlaceInteractions } = useItemInteraction(\"place\");\n const { call: callDeleteInteractions } = useItemInteraction(\"delete\");\n const { getCenter, updateItemExtent } = useDim();\n\n const [clearSelection, reverseSelection, unselect, getConfiguration] =\n useMainStore((state) => [\n state.clear,\n state.reverse,\n state.unselect,\n state.getConfiguration,\n ]);\n\n const {\n getItems: getStoreItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems: moveStoreItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n } = useSyncedStore(\n ({\n getItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n }) => ({\n getItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n })\n );\n\n const batchUpdateItems = React.useCallback(\n (itemIds, callbackOrItem, patch = false) => {\n let callback = callbackOrItem;\n if (typeof callbackOrItem === \"object\") {\n callback = () => callbackOrItem;\n }\n\n const orderedItemIds = getItemIds().filter((id) => itemIds.includes(id));\n\n const prevMap = getStoreItems();\n\n const updateList = orderedItemIds\n .map((id) => {\n const prevItem = prevMap[id];\n if (patch) {\n return [id, callback(prevItem)];\n } else {\n return [id, callback({ ...prevItem })];\n }\n })\n .filter(([, value]) => value);\n\n // If the update list is empty then we are patching and no modifications are\n // applied\n if (updateList.length === 0) {\n return;\n }\n\n const toUpdate = Object.fromEntries(updateList);\n\n updateItems(toUpdate, patch);\n\n updateItemExtent();\n },\n [getItemIds, getStoreItems, updateItemExtent, updateItems]\n );\n\n const setItemListFull = React.useCallback(\n (itemList) => {\n setItemList(itemList);\n\n // Reset item selection as we are changing all items\n clearSelection();\n updateItemExtent();\n },\n [clearSelection, setItemList, updateItemExtent]\n );\n\n const updateItem = React.useCallback(\n (id, callbackOrItem, patch = false) => {\n batchUpdateItems([id], callbackOrItem, patch);\n },\n [batchUpdateItems]\n );\n\n const moveItems = React.useCallback(\n (itemIds, posDelta) => {\n moveStoreItems(\n getLinkedItems(getStoreItems(), getItemIds(), itemIds),\n posDelta\n );\n },\n [getItemIds, getStoreItems, moveStoreItems]\n );\n\n const putItemsOnTop = React.useCallback(\n (itemIdsToMove) => {\n const prevItemIds = getItemIds();\n const filtered = prevItemIds.filter((id) => !itemIdsToMove.includes(id));\n const toBePutOnTop = prevItemIds.filter((id) =>\n itemIdsToMove.includes(id)\n );\n\n setItemIds([...filtered, ...toBePutOnTop]);\n },\n [getItemIds, setItemIds]\n );\n\n const stickOnGrid = React.useCallback(\n (itemIds, { type: globalType, size: globalSize } = {}) => {\n const { uid } = getConfiguration();\n\n batchUpdateItems(\n itemIds,\n (item) => {\n const elem = getItemElem(uid, item.id);\n\n if (!elem) {\n return;\n }\n\n const gridConfig = {\n type: globalType || \"grid\",\n size: globalSize || 1,\n offset: { x: 0, y: 0 },\n ...item.grid,\n };\n\n const newPos = snapToGrid(\n {\n x: item.x,\n y: item.y,\n width: elem.clientWidth,\n height: elem.clientHeight,\n },\n gridConfig\n );\n\n return newPos;\n },\n true\n );\n },\n [getConfiguration, batchUpdateItems]\n );\n\n const placeItems = React.useCallback(\n (itemIds, gridConfig) => {\n // Put all moved items on top\n const itemIdsWithLinkedItems = getLinkedItems(\n getStoreItems(),\n getItemIds(),\n itemIds\n );\n\n putItemsOnTop(itemIdsWithLinkedItems);\n\n // Remove moving state\n batchUpdateItems(itemIdsWithLinkedItems, { moving: false }, true);\n\n stickOnGrid(itemIdsWithLinkedItems, gridConfig);\n callPlaceInteractions(itemIds);\n\n updateItemExtent();\n },\n [\n batchUpdateItems,\n callPlaceInteractions,\n getItemIds,\n getStoreItems,\n putItemsOnTop,\n stickOnGrid,\n updateItemExtent,\n ]\n );\n\n const updateItemOrder = React.useCallback(\n (newOrder) => {\n setItemIds(newOrder);\n },\n [setItemIds]\n );\n\n const reverseItemsOrder = React.useCallback(\n (itemIdsToReverse) => {\n const prevItemIds = getItemIds();\n\n const toBeReversed = prevItemIds.filter((id) =>\n itemIdsToReverse.includes(id)\n );\n const newOrder = prevItemIds.map((itemId) => {\n if (itemIdsToReverse.includes(itemId)) {\n return toBeReversed.pop();\n }\n return itemId;\n });\n\n setItemIds(newOrder);\n\n reverseSelection();\n },\n [getItemIds, reverseSelection, setItemIds]\n );\n\n const swapItems = React.useCallback(\n (fromIds, toIds) => {\n const prevItemMap = getStoreItems();\n\n const newCoordinatesMap = Object.fromEntries(\n toIds.map((toItemId, index) => {\n const replaceWith = prevItemMap[fromIds[index]];\n return [\n toItemId,\n {\n x: replaceWith.x,\n y: replaceWith.y,\n },\n ];\n })\n );\n\n batchUpdateItems(\n fromIds,\n (item) => {\n return newCoordinatesMap[item.id];\n },\n true\n );\n\n const replaceMap = Object.fromEntries(\n fromIds.map((id, index) => [id, toIds[index]])\n );\n\n // swap also the item order\n const reorderedItemIds = getItemIds().map((itemId) => {\n if (fromIds.includes(itemId)) {\n return replaceMap[itemId];\n }\n return itemId;\n });\n\n setItemIds(reorderedItemIds);\n },\n [getStoreItems, batchUpdateItems, getItemIds, setItemIds]\n );\n\n const pushItems = React.useCallback(\n (itemsToInsert, beforeId) => {\n const center = getCenter();\n\n const itemsWithPosition = itemsToInsert.map((item, index) => {\n if (item.x === undefined || item.x === null || item.y === undefined || item.y === null) {\n return { ...item, x: center.x + 2 * index, y: center.y + 2 * index };\n }\n return item;\n });\n\n insertItems(itemsWithPosition, beforeId);\n // Wait for React to render the inserted items before measuring their DOM\n // elements in placeItems/stickOnGrid.\n requestAnimationFrame(() => {\n placeItems(itemsToInsert.map(({ id }) => id));\n });\n },\n [getCenter, insertItems, placeItems]\n );\n\n const pushItem = React.useCallback(\n (itemToInsert, beforeId) => {\n pushItems([itemToInsert], beforeId);\n },\n [pushItems]\n );\n\n const removeItems = React.useCallback(\n (itemsIdToRemove) => {\n // Remove from selected items first\n unselect(itemsIdToRemove);\n\n removeItemsById(itemsIdToRemove);\n callDeleteInteractions(itemsIdToRemove);\n },\n [unselect, removeItemsById, callDeleteInteractions]\n );\n\n const getItems = React.useCallback(\n (itemIds) => {\n const itemMap = getStoreItems();\n return itemIds.map((id) => itemMap[id]);\n },\n [getStoreItems]\n );\n\n const findElementUnderPointer = React.useCallback(\n (\n { target, clientX, clientY },\n { returnLocked = false, passLocked = false } = {}\n ) => {\n // Allow text selection instead of moving\n if ([\"INPUT\", \"TEXTAREA\"].includes(target.tagName)) return null;\n\n const foundElement = insideClass(target, \"item\");\n\n if (foundElement) {\n if (hasClass(foundElement, \"selected\")) {\n return foundElement;\n }\n\n if (\n !passLocked &&\n hasClass(foundElement, \"locked\") &&\n !hasClass(target, \"passthrough\")\n ) {\n return returnLocked ? foundElement : null;\n }\n\n // Is it a passthrough element?\n if (hasClass(target, \"passthrough\")) {\n // Get current value\n const itemList = getItemIds();\n const { uid } = getConfiguration();\n\n // Found element under the cursor\n const elements = itemList.reduce((prev, itemId) => {\n const elem = getItemElem(uid, itemId);\n const itemRect = elem.getBoundingClientRect();\n if (isPointInsideRect({ x: clientX, y: clientY }, itemRect)) {\n prev.unshift(elem);\n }\n return prev;\n }, []);\n\n // Figure out if one can be returned\n for (let i = 0; i < elements.length; i += 1) {\n const elem = elements[i];\n if (\n elem !== foundElement &&\n (passLocked || !hasClass(elem, \"locked\"))\n ) {\n return elem;\n }\n }\n // Here there is no available elements\n return null;\n }\n }\n return foundElement;\n },\n [getConfiguration, getItemIds]\n );\n\n return {\n putItemsOnTop,\n batchUpdateItems,\n updateItemOrder,\n moveItems,\n placeItems,\n updateItem,\n swapItems,\n reverseItemsOrder,\n setItemList: setItemListFull,\n pushItem,\n pushItems,\n removeItems,\n getItemList,\n findElementUnderPointer,\n getItems,\n };\n};\n\nexport default useItemActions;\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n if ((a instanceof Map) && (b instanceof Map)) {\n if (a.size !== b.size) return false;\n for (i of a.entries())\n if (!b.has(i[0])) return false;\n for (i of a.entries())\n if (!equal(i[1], b.get(i[0]))) return false;\n return true;\n }\n\n if ((a instanceof Set) && (b instanceof Set)) {\n if (a.size !== b.size) return false;\n for (i of a.entries())\n if (!b.has(i[0])) return false;\n return true;\n }\n\n if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (a[i] !== b[i]) return false;\n return true;\n }\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import React, { useCallback } from \"react\";\nimport deepEqual from \"fast-deep-equal/es6\";\n\nimport { useDebouncedEffect } from \"@react-hookz/web\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"../store/main\";\n\n/**\n * Returns the default actions of an item\n * @param {object} item to consider\n * @param {object} itemMap item template map with default actions\n * @returns An array of default action for this item\n */\nconst getDefaultActionsFromItem = (item, itemMap) => {\n if (item.type in itemMap) {\n const actions = itemMap[item.type].defaultActions;\n if (typeof actions === \"function\") {\n return actions(item);\n }\n return actions;\n }\n\n return [];\n};\n\n/**\n * Returns actual actions from an item ordered by the configured available\n * actions. If no action is defined, default actions are returned.\n * @param {object} item item to use\n * @param {object} itemMap item template map with available action for this item\n * @returns the array of actions for this item\n */\nconst getActionsFromItem = (item, itemMap) => {\n const { actions = getDefaultActionsFromItem(item, itemMap) } = item;\n return actions.map((action) => {\n if (typeof action === \"string\") {\n return { name: action };\n }\n return action;\n });\n};\n\nconst useAvailableActions = () => {\n const [items, getItems] = useSyncedStore((state) => [\n state.items,\n state.getItems,\n ]);\n const [itemTemplates, selection, getSelection] = useMainStore((state) => [\n state.config.itemTemplates,\n state.selection,\n state.getSelection,\n ]);\n const [availableActions, setAvailableActions] = React.useState([]);\n const isMountedRef = React.useRef(false);\n const [, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n // Mounted guard\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n const getItemListOrSelected = React.useCallback(\n (itemIds) => {\n const currentItemMap = getItems();\n if (itemIds) {\n return [itemIds, itemIds.map((id) => currentItemMap[id])];\n }\n const selectedItems = getSelection();\n return [selectedItems, selectedItems.map((id) => currentItemMap[id])];\n },\n [getItems, getSelection]\n );\n\n /**\n * Returns available actions for selected items. An action is kept only if all\n * items have this exact same action with same parameters.\n */\n const updateAvailableActions = useCallback(() => {\n const [selectedItemIds, selectedItemList] = getItemListOrSelected();\n if (selectedItemIds.length > 0) {\n // Prevent set state on unmounted component\n if (!isMountedRef.current) return;\n\n const allActions = selectedItemList.reduce((acc, item) => {\n const itemActions = getActionsFromItem(item, itemTemplates);\n\n return acc.filter((value) =>\n itemActions.some((itemAction) => deepEqual(value, itemAction))\n );\n }, getActionsFromItem(selectedItemList[0], itemTemplates));\n\n startTransition(() => {\n setAvailableActions(allActions);\n });\n } else {\n startTransition(() => {\n setAvailableActions([]);\n });\n }\n }, [getItemListOrSelected, itemTemplates]);\n\n // Debounced update available actions when items or selection change\n useDebouncedEffect(\n () => updateAvailableActions(),\n [items, selection, updateAvailableActions],\n 100\n );\n\n return {\n availableActions,\n };\n};\n\nexport default useAvailableActions;\n","import useMainStore from \"./store/main\";\n\nconst useSelectionBox = () => {\n const [selectionBox] = useMainStore((state) => [state.selectionBox]);\n return selectionBox;\n};\n\nexport default useSelectionBox;\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { getRandomColor } from \"@/utils\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nexport const persistUser = (user) => {\n localStorage.setItem(\"user\", JSON.stringify(user));\n};\n\nexport const restoreUser = () => {\n if (localStorage.user) {\n // Add some mandatory info if missing\n const localUser = {\n name: \"Player\",\n color: getRandomColor(),\n uid: nanoid(),\n ...JSON.parse(localStorage.user),\n };\n // Id is given by server\n // delete localUser.id;\n persistUser(localUser);\n return localUser;\n }\n const newUser = {\n name: \"Player\",\n color: getRandomColor(),\n uid: nanoid(),\n };\n persistUser(newUser);\n return newUser;\n};\n\nconst usersStore = (curentUserId) => (set, get) => ({\n isSpaceMaster: false,\n users: {},\n getUser: () => get().users[curentUserId],\n getUsers: () => {\n return get().users;\n },\n getUserList: () => Object.values(get().users),\n getLocalUsers: () => {\n if (!get().users[curentUserId]) {\n return [];\n }\n const { space: currentUserSpace } = get().users[curentUserId];\n return get()\n .getUserList()\n .filter(({ space }) => space === currentUserSpace);\n },\n addUser: (newUser) =>\n set((state) => ({ users: { ...state.users, [newUser.id]: newUser } })),\n updateUser: (userId, toUpdate) =>\n set((state) => {\n if (!state.users[userId]) {\n return {};\n }\n const newUser = {\n ...state.users[userId],\n ...toUpdate,\n id: userId,\n uid: state.users[userId].uid,\n };\n if (newUser.id === curentUserId) {\n persistUser(newUser);\n }\n setTimeout(() => get().electSpaceMaster(), 100);\n return {\n users: {\n ...state.users,\n [userId]: newUser,\n },\n };\n }),\n removeUser: (userId) =>\n set((state) => {\n const newUsers = { ...state.users };\n delete newUsers[userId];\n setTimeout(() => get().electSpaceMaster(), 100);\n return { users: newUsers };\n }),\n // Not synchronized methods\n updateCurrentUser: (toUpdate) => get().updateUser(curentUserId, toUpdate),\n joinSpace: (space) =>\n get().updateUser(curentUserId, { space, spaceJoinedTimestamp: Date.now() }),\n electSpaceMaster: () => {\n const localUsers = get().getLocalUsers();\n const master = {\n uid: null,\n timestamp: Date.now(),\n };\n Object.values(localUsers).forEach(({ spaceJoinedTimestamp, id }) => {\n if (spaceJoinedTimestamp < master.timestamp) {\n master.id = id;\n master.timestamp = spaceJoinedTimestamp;\n }\n });\n\n set({ isSpaceMaster: master.id === curentUserId });\n },\n});\n\nconst cursorsStore = (set) => ({\n cursors: {},\n moveCursor: (userId, newPos) =>\n set((state) => ({ cursors: { ...state.cursors, [userId]: newPos } })),\n removeCursor: (userId) =>\n set((state) => {\n const newCursors = { ...state.cursors };\n delete newCursors[userId];\n return { cursors: newCursors };\n }),\n});\n\nexport const SyncedUsersProvider = ({ storeName, children }) => {\n const { wire, isMaster } = useWire(\"room\");\n const [store, setStore] = React.useState(null);\n const [ready, setReady] = React.useState(false);\n const storeRef = React.useRef(false);\n\n React.useEffect(() => {\n let mounted = true;\n const unsubs = [];\n if (!store && !storeRef.current) {\n storeRef.current = true;\n const init = () => {\n // Create store\n const localStore = createStore(\n syncMiddleware(\n {\n wire,\n storeName,\n noSync: [\n \"updateCurrentUser\",\n \"joinSpace\",\n \"isSpaceMaster\",\n \"electSpaceMaster\",\n ],\n },\n (...args) => ({\n ...usersStore(wire.userId)(...args),\n ...cursorsStore(...args),\n }),\n wire,\n storeName\n )\n );\n // Wait for ready event\n const unsubscribe = localStore.subscribe((newValue) => {\n if (newValue.ready) {\n // No need to listen anymore\n unsubscribe();\n if (mounted) {\n setStore(localStore);\n }\n }\n });\n };\n init();\n return () => {\n mounted = false;\n storeRef.current = false;\n unsubs.forEach((unsub) => unsub());\n };\n }\n }, [store, storeName, wire, wire.userId]);\n\n React.useEffect(() => {\n if (store) {\n store.getState().addUser({\n ...restoreUser(),\n id: wire.userId,\n });\n setReady(true);\n return () => {\n store.getState().removeUser(wire.userId);\n };\n }\n }, [isMaster, store, wire]);\n\n React.useEffect(() => {\n if (store) {\n // Listen for userLeave events\n const unsubscribe = wire.subscribe(\"userLeave\", (userId) => {\n store.getState().removeUser(userId);\n });\n return () => {\n unsubscribe();\n };\n }\n }, [isMaster, store, wire]);\n\n React.useEffect(() => {\n if (isMaster && store) {\n // Set master\n store.getState().updateCurrentUser({ isMaster: isMaster });\n }\n }, [isMaster, store, wire]);\n\n if (!ready) {\n return null;\n }\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedUsers = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedUsers } from \"@/users/store\";\n\nconst useUsers = () => {\n const [isSpaceMaster, currentUser, userMap, updateCurrentUser, joinSpace] =\n useSyncedUsers((state) => [\n state.isSpaceMaster,\n state.getUser(),\n state.users,\n state.updateCurrentUser,\n state.joinSpace,\n ]);\n\n const users = React.useMemo(() => Object.values(userMap), [userMap]);\n\n const localUsers = React.useMemo(() => {\n const { space: currentUserSpace } = currentUser;\n return users.filter(({ space }) => space === currentUserSpace);\n }, [currentUser, users]);\n\n return {\n isSpaceMaster,\n currentUser,\n updateCurrentUser,\n users,\n localUsers,\n joinSpace,\n };\n};\n\nexport default useUsers;\n","import React from \"react\";\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useBoardConfig = () => {\n const [boardConfig, getBoardConfig, setBoardConfig] = useSyncedStore(\n (state) => [state.boardConfig, state.getBoardConfig, state.setBoardConfig]\n );\n\n const setSyncBoardConfig = React.useCallback(\n (callbackOrConfig) => {\n let callback = callbackOrConfig;\n if (typeof callbackOrConfig === \"object\") {\n callback = () => callbackOrConfig;\n }\n\n const currentConfig = getBoardConfig();\n const newConfig = callback(currentConfig);\n setBoardConfig(newConfig);\n },\n [getBoardConfig, setBoardConfig]\n );\n\n return [boardConfig, setSyncBoardConfig];\n};\n\nexport default useBoardConfig;\n","import useMainStore from \"./store/main\";\n\nconst useBoardState = () => {\n const [boardState] = useMainStore((state) => [state.boardState]);\n return boardState;\n};\n\nexport default useBoardState;\n","import { useSyncedStore } from \"./store/synced\";\n\nconst useSessionInfo = () => {\n const [getSessionInfo, setSessionInfo, updateSessionInfo, sessionInfo] =\n useSyncedStore((state) => [\n state.getSessionInfo,\n state.setSessionInfo,\n state.updateSessionInfo,\n state.session,\n ]);\n\n return { getSessionInfo, setSessionInfo, sessionInfo, updateSessionInfo };\n};\n\nexport default useSessionInfo;\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nconst generateMsg = ({ user: { name, uid, color }, content }) => {\n const newMessage = {\n type: \"message\",\n user: { name, uid, color },\n content,\n uid: nanoid(),\n timestamp: new Date().toISOString(),\n };\n return newMessage;\n};\n\nconst messageStore = (set, get) => ({\n messages: [],\n setMessages: (newMessages) =>\n set({\n messages: newMessages.map((m) => ({\n ...m,\n timestamp: Date.parse(m.timestamp),\n })),\n }),\n addMessage: (newMessage) =>\n set((state) => ({\n messages: [\n ...state.messages,\n { ...newMessage, timestamp: Date.parse(newMessage.timestamp) },\n ],\n })),\n sendMessage: (user, content) => {\n const newMessage = generateMsg({\n user,\n content,\n });\n if (newMessage) get().addMessage(newMessage);\n },\n});\n\nexport const SyncedMessageProvider = ({\n storeName,\n children,\n defaultValue = [],\n}) => {\n const { wire } = useWire(\"room\");\n const [store] = React.useState(() =>\n createStore(\n syncMiddleware(\n { wire, storeName, defaultValue, noSync: [\"sendMessage\"] },\n (...args) => ({\n ...messageStore(...args),\n })\n )\n )\n );\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedMessage = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedMessage } from \"@/message/store\";\nimport { useSyncedUsers } from \"@/users/store\";\n\nconst noop = () => {};\n\nconst useMessage = (onMessage = noop) => {\n const currentUser = useSyncedUsers((state) => state.getUser());\n const [messages, setMessages, sendMessage] = useSyncedMessage((state) => [\n state.messages,\n state.setMessages,\n state.sendMessage,\n ]);\n\n React.useEffect(() => {\n // React on new message\n if (messages.length) {\n onMessage();\n }\n }, [messages, onMessage]);\n\n const sendMessageWithUser = React.useCallback(\n (messageContent) => {\n sendMessage(currentUser, messageContent);\n },\n [currentUser, sendMessage]\n );\n\n return { messages, setMessages, sendMessage: sendMessageWithUser };\n};\n\nexport default useMessage;\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire, { WireProvider } from \"@/hooks/useWire\";\n\nimport { SyncedStoreProvider } from \"@/board/store/synced\";\nimport { MainStoreProvider } from \"@/board/store/main\";\n\nimport { SyncedUsersProvider, useSyncedUsers } from \"./users/store\";\nimport { SyncedMessageProvider } from \"./message/store\";\n\nconst SyncBoard = ({ children, session }) => {\n const joinSpace = useSyncedUsers((state) => state.joinSpace);\n\n // Set user space\n React.useEffect(() => {\n joinSpace(session);\n return () => {\n joinSpace(null);\n };\n }, [joinSpace, session]);\n\n return children;\n};\n\nconst ConnectedSyncBoard = ({\n socket,\n room,\n session,\n items = [],\n messages = [],\n LoadingComponent,\n ...props\n}) => {\n const [stableRoom] = React.useState(room || nanoid());\n const [stableSession] = React.useState(session || nanoid());\n const [defaultItemsValue] = React.useState(() => {\n return {\n itemIds: items.map(({ id }) => id),\n items: Object.fromEntries(items.map((item) => [item.id, item])),\n };\n });\n\n const roomChannel = useWire(\"room\");\n\n if (!roomChannel) {\n // No room declared so we create one\n return (\n <WireProvider\n room={stableRoom}\n channel=\"room\"\n socket={socket}\n LoadingComponent={LoadingComponent}\n >\n <SyncedUsersProvider storeName={`${stableRoom}_users`}>\n <SyncedMessageProvider\n storeName={`${stableSession}_messages`}\n defaultValue={messages}\n >\n <MainStoreProvider>\n <SyncedStoreProvider\n storeName={`${stableSession}_item`}\n defaultValue={defaultItemsValue}\n >\n <SyncBoard {...props} session={stableSession} />\n </SyncedStoreProvider>\n </MainStoreProvider>\n </SyncedMessageProvider>\n </SyncedUsersProvider>\n </WireProvider>\n );\n }\n return (\n <SyncedMessageProvider\n storeName={`${stableSession}_messages`}\n defaultValue={messages}\n >\n <MainStoreProvider>\n <SyncedStoreProvider\n storeName={`${stableSession}_item`}\n defaultValue={defaultItemsValue}\n >\n <SyncBoard {...props} session={stableSession} />\n </SyncedStoreProvider>\n </MainStoreProvider>\n </SyncedMessageProvider>\n );\n};\n\nexport default ConnectedSyncBoard;\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport { WireProvider } from \"@/hooks/useWire\";\nimport { SyncedUsersProvider } from \"@/users/store\";\n\nconst ConnectedSyncRoom = ({ socket, room, children, LoadingComponent }) => {\n const [stableRoom] = React.useState(room || nanoid());\n\n return (\n <WireProvider\n room={stableRoom}\n channel=\"room\"\n socket={socket}\n LoadingComponent={LoadingComponent}\n >\n <SyncedUsersProvider storeName={`${stableRoom}_users`}>\n {children}\n </SyncedUsersProvider>\n </WireProvider>\n );\n};\n\nexport default ConnectedSyncRoom;\n","let e={data:\"\"},t=t=>{if(\"object\"==typeof window){let e=(t?t.querySelector(\"#_goober\"):window._goober)||Object.assign(document.createElement(\"style\"),{innerHTML:\" \",id:\"_goober\"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||e},r=e=>{let r=t(e),a=r.data;return r.data=\"\",a},a=/(?:([\\u0080-\\uFFFF\\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\\s*)/g,l=/\\/\\*[^]*?\\*\\/| +/g,n=/\\n+/g,o=(e,t)=>{let r=\"\",a=\"\",l=\"\";for(let n in e){let c=e[n];\"@\"==n[0]?\"i\"==n[1]?r=n+\" \"+c+\";\":a+=\"f\"==n[1]?o(c,n):n+\"{\"+o(c,\"k\"==n[1]?\"\":t)+\"}\":\"object\"==typeof c?a+=o(c,t?t.replace(/([^,])+/g,e=>n.replace(/([^,]*:\\S+\\([^)]*\\))|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+\" \"+t:t)):n):null!=c&&(n=\"-\"==n[1]?n:n.replace(/[A-Z]/g,\"-$&\").toLowerCase(),l+=o.p?o.p(n,c):n+\":\"+c+\";\")}return r+(t&&l?t+\"{\"+l+\"}\":l)+a},c={},i=e=>{if(\"object\"==typeof e){let t=\"\";for(let r in e)t+=r+i(e[r]);return t}return e},s=(e,t,r,s,p)=>{let u=i(e),d=c[u]||(c[u]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return\"go\"+r})(u));if(!c[d]){let t=u!==e?e:(e=>{let t,r,o=[{}];for(;t=a.exec(e.replace(l,\"\"));)t[4]?o.shift():t[3]?(r=t[3].replace(n,\" \").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n,\" \").trim();return o[0]})(e);c[d]=o(p?{[\"@keyframes \"+d]:t}:t,r?\"\":\".\"+d)}let f=r&&c.g;return r&&(c.g=c[d]),((e,t,r,a)=>{a?t.data=t.data.replace(a,e):-1===t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e)})(c[d],t,s,f),d},p=(e,t,r)=>e.reduce((e,a,l)=>{let n=t[l];if(n&&n.call){let e=n(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;n=t?\".\"+t:e&&\"object\"==typeof e?e.props?\"\":o(e,\"\"):!1===e?\"\":e}return e+a+(null==n?\"\":n)},\"\");function u(e){let r=this||{},a=e.call?e(r.p):e;return s(a.unshift?a.raw?p(a,[].slice.call(arguments,1),r.p):a.reduce((e,t)=>Object.assign(e,t&&t.call?t(r.p):t),{}):a,t(r.target),r.g,r.o,r.k)}let d,f,g,b=u.bind({g:1}),h=u.bind({k:1});function m(e,t,r,a){o.p=t,d=e,f=r,g=a}function w(e,t){let r=this||{};return function(){let a=arguments;function l(n,o){let c=Object.assign({},n),i=c.className||l.className;r.p=Object.assign({theme:f&&f()},c),r.o=/go\\d/.test(i),c.className=u.apply(r,a)+(i?\" \"+i:\"\"),t&&(c.ref=o);let s=e;return e[0]&&(s=c.as||e,delete c.as),g&&s[0]&&g(c),d(s,c)}return t?t(l):l}}export{u as css,r as extractCss,b as glob,h as keyframes,m as setup,w as styled};\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import React from \"react\";\n\nexport const isMacOS = () => {\n const userAgent = navigator.userAgent.toLowerCase();\n return /mac os ?x 10/.test(userAgent);\n};\n\n// From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\nconst getScrollLineHeight = () => {\n const iframe = document.createElement(\"iframe\");\n iframe.src = \"#\";\n document.body.appendChild(iframe);\n\n // Write content in Iframe\n const idoc = iframe.contentWindow.document;\n idoc.open();\n idoc.write(\n \"<!DOCTYPE html><html><head></head><body><span>a</span></body></html>\"\n );\n idoc.close();\n\n const scrollLineHeight = idoc.body.firstElementChild.offsetHeight;\n document.body.removeChild(iframe);\n\n return scrollLineHeight;\n};\n\nconst LINE_HEIGHT = getScrollLineHeight();\n// Reasonable default from https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js\nconst PAGE_HEIGHT = 800;\n\nconst otherPointer = (pointers, currentPointer) => {\n const p2 = Object.keys(pointers)\n .map((p) => Number(p))\n .find((pointer) => pointer !== currentPointer);\n return pointers[p2];\n};\n\nconst computeDistance = ([x1, y1], [x2, y2]) => {\n const distanceX = Math.abs(x1 - x2);\n const distanceY = Math.abs(y1 - y2);\n\n return Math.hypot(distanceX, distanceY);\n};\n\nconst empty = () => {};\n\nconst stopPropagation = (fn) => (arg) => {\n const { event } = arg;\n if (!event.isPropagationStopped()) {\n return fn(arg);\n }\n return null;\n};\n\nconst protect =\n (fn) =>\n async (...args) => {\n try {\n await fn(...args);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e);\n }\n };\n\nclass PromiseQueue {\n lastPromise = Promise.resolve(true);\n\n add(operation, ...args) {\n return new Promise((resolve, reject) => {\n this.lastPromise = this.lastPromise\n .then(() => stopPropagation(protect(operation))(...args))\n .then(resolve)\n .catch(reject);\n });\n }\n}\n\nconst promiseQueue = new PromiseQueue();\n\nconst Gesture = ({\n children,\n onDrag = empty,\n onDragStart = empty,\n onDragEnd = empty,\n onPan = empty,\n onTap = empty,\n onLongTap = empty,\n onDoubleTap = empty,\n onZoom,\n mainAction = \"drag\",\n fill = false,\n}) => {\n const wrapperRef = React.useRef(null);\n const stateRef = React.useRef({\n moving: false,\n pointers: {},\n mainPointer: undefined,\n });\n\n const onWheel = (event) => {\n const {\n deltaX,\n deltaY,\n clientX,\n clientY,\n deltaMode,\n ctrlKey,\n altKey,\n metaKey,\n target,\n } = event;\n\n // On a MacOs trackpad, the pinch gesture sets the ctrlKey to true.\n // In that situation, we want to use the custom scaling, not the browser default zoom.\n // Hence in this situation we avoid to return immediately.\n if (altKey || (ctrlKey && !isMacOS())) {\n return;\n }\n\n // On a trackpad, the pinch and pan events are differentiated by the crtlKey value.\n // On a pinch gesture, the ctrlKey is set to true, so we want to have a scaling effect.\n // If we are only moving the fingers in the same direction, a pan is needed.\n // Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e\n if (isMacOS() && !ctrlKey) {\n promiseQueue.add(onPan, {\n deltaX: -2 * deltaX,\n deltaY: -2 * deltaY,\n button: 1,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n } else {\n // Quit if onZoom is not set\n if (onZoom === undefined || !deltaY) return;\n\n let scale = deltaY;\n\n switch (deltaMode) {\n case 1: // Pixel\n scale *= LINE_HEIGHT;\n break;\n case 2:\n scale *= PAGE_HEIGHT;\n break;\n default:\n }\n\n if (isMacOS()) {\n scale *= 2;\n }\n\n promiseQueue.add(onZoom, { scale, clientX, clientY, event });\n }\n };\n\n const onPointerDown = (event) => {\n const {\n target,\n button,\n clientX,\n clientY,\n pointerId,\n altKey,\n ctrlKey,\n metaKey,\n isPrimary,\n } = event;\n\n // Add pointer to map\n stateRef.current.pointers[pointerId] = { clientX, clientY };\n\n if (isPrimary) {\n // Clean mainPoint on primary pointer\n stateRef.current.mainPointer = undefined;\n }\n\n if (stateRef.current.mainPointer !== undefined) {\n if (stateRef.current.mainPointer !== pointerId) {\n // This is not the main pointer\n try {\n const { clientX: clientX2, clientY: clientY2 } = otherPointer(\n stateRef.current.pointers,\n pointerId\n );\n const newClientX = (clientX2 + clientX) / 2;\n const newClientY = (clientY2 + clientY) / 2;\n\n const distance = computeDistance(\n [clientX2, clientY2],\n [clientX, clientY]\n );\n\n // We update previous position as the new position is the center between both fingers\n Object.assign(stateRef.current, {\n pressed: true,\n moving: false,\n gestureStart: false,\n startX: clientX,\n startY: clientY,\n prevX: newClientX,\n prevY: newClientY,\n startDistance: distance,\n prevDistance: distance,\n });\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Error while getting other pointer. Ignoring\", e);\n // eslint-disable-next-line no-unused-expressions\n stateRef.current.mainPointer === undefined;\n }\n }\n\n return;\n }\n\n // We set the mainpointer\n stateRef.current.mainPointer = pointerId;\n\n // And prepare move\n Object.assign(stateRef.current, {\n pressed: true,\n moving: false,\n gestureStart: false,\n startX: clientX,\n startY: clientY,\n prevX: clientX,\n prevY: clientY,\n currentButton: button,\n pointerDownEvent: event,\n startDistance: 0,\n prevDistance: 0,\n target,\n timeStart: Date.now(),\n longTapTimeout: setTimeout(async () => {\n stateRef.current.noTap = true;\n promiseQueue.add(onLongTap, {\n clientX,\n clientY,\n altKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n }, 750),\n });\n\n try {\n // Nested handlers capture the same target so events continue to bubble\n // through item, pan and selection handlers.\n target.setPointerCapture(pointerId);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Fail to capture pointer\", e);\n }\n };\n\n const onPointerMove = (event) => {\n if (stateRef.current.pressed) {\n const {\n pointerId,\n clientX: eventClientX,\n clientY: eventClientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n buttons,\n } = event;\n\n // Update pointer coordinates in the map\n stateRef.current.pointers[pointerId] = {\n clientX: eventClientX,\n clientY: eventClientY,\n };\n\n stateRef.current.moving = true;\n\n // Do we have two pointers ?\n const twoPointers = Object.keys(stateRef.current.pointers).length === 2;\n\n let clientX;\n let clientY;\n let distanceBetweenTwoPointers = 0;\n\n if (twoPointers) {\n // Find other pointerId\n const { clientX: clientX2, clientY: clientY2 } = otherPointer(\n stateRef.current.pointers,\n pointerId\n );\n\n // Update client X with the center of each touch\n clientX = (clientX2 + eventClientX) / 2;\n clientY = (clientY2 + eventClientY) / 2;\n distanceBetweenTwoPointers = computeDistance(\n [clientX2, clientY2],\n [eventClientX, eventClientY]\n );\n } else {\n clientX = eventClientX;\n clientY = eventClientY;\n }\n\n // We drag if\n // On non touch device\n // - Only button is pressed (1)\n // - any special key is no pressed\n // or on touch devices\n // - We use only one finger\n let altAction = shiftKey || altKey || ctrlKey || metaKey || buttons !== 1;\n if (mainAction !== \"drag\") {\n altAction = !altAction;\n }\n\n const shouldDrag = !altAction;\n const shouldPan = altAction;\n\n if (shouldDrag) {\n // Send drag start on first move\n if (!stateRef.current.gestureStart) {\n wrapperRef.current.style.cursor = \"move\";\n stateRef.current.gestureStart = true;\n // Clear tap timeout\n clearTimeout(stateRef.current.longTapTimeout);\n\n promiseQueue.add(onDragStart, {\n deltaX: 0,\n deltaY: 0,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX: stateRef.current.startX,\n clientY: stateRef.current.startY,\n distanceX: 0,\n distanceY: 0,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target: stateRef.current.target,\n event: stateRef.current.pointerDownEvent,\n });\n }\n\n const deltaX = clientX - stateRef.current.prevX;\n const deltaY = clientY - stateRef.current.prevY;\n const distanceX = clientX - stateRef.current.startX;\n const distanceY = clientY - stateRef.current.startY;\n\n // Drag event\n promiseQueue.add(onDrag, {\n deltaX,\n deltaY,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX,\n clientY,\n distanceX,\n distanceY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target: stateRef.current.target,\n event,\n });\n }\n\n if (shouldPan) {\n if (!stateRef.current.gestureStart) {\n wrapperRef.current.style.cursor = \"move\";\n stateRef.current.gestureStart = true;\n // Clear tap timeout on first move\n clearTimeout(stateRef.current.longTapTimeout);\n }\n\n // Create closure\n const deltaX = clientX - stateRef.current.prevX;\n const deltaY = clientY - stateRef.current.prevY;\n const { target } = stateRef.current;\n\n // Pan event\n promiseQueue.add(onPan, {\n deltaX,\n deltaY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n\n if (\n distanceBetweenTwoPointers !== stateRef.current.prevDistance &&\n onZoom\n ) {\n const scale =\n stateRef.current.prevDistance - distanceBetweenTwoPointers;\n\n if (Math.abs(scale) > 0) {\n promiseQueue.add(onZoom, {\n scale: scale * 3,\n clientX,\n clientY,\n event,\n });\n stateRef.current.prevDistance = distanceBetweenTwoPointers;\n }\n }\n }\n\n stateRef.current.prevX = clientX;\n stateRef.current.prevY = clientY;\n }\n };\n\n const onPointerUp = (event) => {\n const {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n pointerId,\n } = event;\n\n if (!stateRef.current.pointers[pointerId]) {\n // Pointer already gone previously with another event\n // ignoring it\n return;\n }\n\n // Remove pointer from map\n delete stateRef.current.pointers[pointerId];\n\n // If this is not the main pointer we quit here\n if (stateRef.current.mainPointer !== pointerId) {\n const { clientX: clientX2, clientY: clientY2 } =\n stateRef.current.pointers[stateRef.current.mainPointer];\n Object.assign(stateRef.current, {\n prevX: clientX2,\n prevY: clientY2,\n prevDistance: 0,\n startDistance: 0,\n });\n return;\n }\n\n // It was the main pointer so we need to replace it with another if any\n while (Object.keys(stateRef.current.pointers).length > 0) {\n // If was main pointer but we have another one, this one become main\n stateRef.current.mainPointer = Number(\n Object.keys(stateRef.current.pointers)[0]\n );\n\n try {\n stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);\n\n const { clientX: clientX2, clientY: clientY2 } =\n stateRef.current.pointers[stateRef.current.mainPointer];\n Object.assign(stateRef.current, {\n prevX: clientX2,\n prevY: clientY2,\n prevDistance: 0,\n startDistance: 0,\n });\n\n return;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(\"Fails to set pointer capture\", error);\n stateRef.current.mainPointer = undefined;\n delete stateRef.current.pointers[\n Object.keys(stateRef.current.pointers)[0]\n ];\n }\n }\n\n // From here we have removed the last pointer.\n\n stateRef.current.mainPointer = undefined;\n stateRef.current.pressed = false;\n\n // Clear longTap\n clearTimeout(stateRef.current.longTapTimeout);\n\n if (stateRef.current.moving) {\n // If we were moving, send drag end event\n stateRef.current.moving = false;\n promiseQueue.add(onDragEnd, {\n deltaX: clientX - stateRef.current.prevX,\n deltaY: clientY - stateRef.current.prevY,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX,\n clientY,\n distanceX: clientX - stateRef.current.startX,\n distanceY: clientY - stateRef.current.startY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n event,\n });\n wrapperRef.current.style.cursor = \"auto\";\n } else {\n const now = Date.now();\n\n if (stateRef.current.noTap) {\n stateRef.current.noTap = false;\n }\n // Send tap event only if time less than 300ms\n else if (stateRef.current.timeStart - now < 300) {\n promiseQueue.add(onTap, {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n }\n }\n };\n\n const onDoubleTapHandler = (event) => {\n const { clientX, clientY, altKey, shiftKey, ctrlKey, metaKey, target } =\n event;\n promiseQueue.add(onDoubleTap, {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n };\n\n return (\n <div\n onWheel={onWheel}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onDoubleClick={onDoubleTapHandler}\n style={{\n touchAction: \"none\",\n ...(fill ? { position: \"absolute\", inset: 0 } : {}),\n }}\n ref={wrapperRef}\n >\n {children}\n </div>\n );\n};\n\nexport default Gesture;\n","import React from \"react\";\nimport Gesture from \"../Gesture\";\nimport useMainStore from \"../store/main\";\n\nconst ResizeHandler = ({ onResize, ...rest }) => {\n const [getBoardState] = useMainStore((state) => [state.getBoardState]);\n\n const onDrag = ({ deltaX, deltaY, event }) => {\n event.stopPropagation();\n const { scale } = getBoardState();\n onResize({\n width: deltaX / scale,\n height: deltaY / scale,\n });\n };\n\n return (\n <Gesture onDrag={onDrag}>\n <div {...rest} />\n </Gesture>\n );\n};\n\nexport default ResizeHandler;\n","import React, { memo } from \"react\";\n\nimport { css } from \"goober\";\nimport deepEqual from \"fast-deep-equal\";\n\nimport ResizeHandler from \"./ResizeHandler\";\nimport useMainStore from \"../store/main\";\n\nconst itemClass = css`\n display: inline-block;\n transition: transform 150ms;\n user-select: none;\n padding: 2px;\n box-sizing: border-box;\n`;\n\nconst selectedItemClass = css`\n border: 2px dashed #db5034;\n padding: 0px;\n cursor: pointer;\n`;\n\nconst itemMark = css`\n position: absolute;\n width: 0px;\n height: 0px;\n`;\n\nconst itemMarkTopLeft = css`\n top: 0;\n left: 0;\n`;\n\nconst itemMarkTopRight = css`\n top: 0;\n right: 0;\n`;\n\nconst itemMarkBottomLeft = css`\n bottom: 0;\n left: 0;\n`;\n\nconst itemMarkBottomRight = css`\n bottom: 0;\n right: 0;\n`;\n\nconst itemMarkCenter = css`\n top: 50%;\n left: 50%;\n`;\n\nconst itemResize = css`\n position: absolute;\n\n width: 10px;\n height: 10px;\n border: 2px solid #db5034;\n background-color: #db5034;\n cursor: move;\n`;\n\nconst itemResizeWidth = css`\n cursor: ew-resize;\n right: -6px;\n top: calc(50% - 5px);\n`;\n\nconst itemResizeHeight = css`\n cursor: ns-resize;\n bottom: -6px;\n left: calc(50% - 5px);\n`;\n\nconst itemResizeRatio = css`\n cursor: nwse-resize;\n bottom: -6px;\n right: -6px;\n`;\n\nconst DefaultErrorComponent = ({ onReload }) => (\n <div\n className={`syncboard-error-item ${css({\n width: \"100px\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n textAlign: \"center\",\n color: \"red\",\n })}`}\n >\n Sorry, this item seems broken.\n <button onClick={onReload}>Reload it</button>\n </div>\n);\n\n/* Error boundary for broken item */\nclass ItemErrorBoundary extends React.Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false, itemId: props.itemId };\n this.onReload = this.onReload.bind(this);\n }\n\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n componentDidCatch(error) {\n // eslint-disable-next-line no-console\n console.error(\n `Error for item ${this.state.itemId}`,\n error,\n this.props.state\n );\n }\n\n onReload() {\n this.setState({ hasError: false });\n }\n\n render() {\n const { ErrorComponent } = this.props;\n if (this.state.hasError) {\n return <ErrorComponent onReload={this.onReload} />;\n }\n return this.props.children;\n }\n}\n\nconst removeClass = (e) => {\n e.target.className = \"\";\n};\n\nconst defaultResize = ({\n width,\n height,\n actualWidth,\n actualHeight,\n prevState,\n keepRatio,\n}) => {\n let { width: currentWidth, height: currentHeight } = prevState;\n\n // Parse text values if any\n [currentWidth, currentHeight] = [\n parseFloat(currentWidth),\n parseFloat(currentHeight),\n ];\n if (!currentWidth || Number.isNaN(Number(currentWidth))) {\n currentWidth = actualWidth;\n }\n if (!currentHeight || Number.isNaN(Number(currentHeight))) {\n currentHeight = actualHeight;\n }\n\n if (keepRatio) {\n const ratio = currentWidth / currentHeight;\n return {\n ...prevState,\n width: (currentWidth + width).toFixed(1),\n height: (currentHeight + height / ratio).toFixed(1),\n };\n }\n\n return {\n ...prevState,\n width: (currentWidth + width).toFixed(1),\n height: (currentHeight + height).toFixed(1),\n };\n};\n\nconst defaultResizeDirection = {\n w: true,\n h: true,\n b: true,\n};\n\nconst Item = ({\n setState,\n state: { type, rotation = 0, id, locked, extraClasses, ...rest } = {},\n animate = \"hvr-pop\",\n isSelected,\n itemMap,\n showResizeHandle = true,\n}) => {\n const itemWrapperRef = React.useRef(null);\n const [uid] = useMainStore((state) => [state.config.uid]);\n\n const {\n component: Component = () => null,\n resizeDirections = defaultResizeDirection,\n resize = defaultResize,\n } = itemMap[type];\n\n const updateState = React.useCallback(\n (callbackOrItem, patch = false) => setState(id, callbackOrItem, patch),\n [setState, id]\n );\n\n React.useEffect(() => {\n itemWrapperRef.current.className = animate;\n }, [animate]);\n\n const classes = [\"item\", id, itemClass];\n if (locked) {\n classes.push(\"locked\");\n }\n if (isSelected) {\n classes.push(\"selected\");\n classes.push(selectedItemClass);\n }\n if (Array.isArray(extraClasses)) {\n classes.concat(extraClasses);\n }\n\n const className = classes.join(\" \");\n\n const onResize = ({ width = 0, height = 0, keepRatio }) => {\n updateState((prev) => {\n const { offsetWidth, offsetHeight } = itemWrapperRef.current;\n return resize({\n prevState: prev,\n width,\n height,\n actualHeight: offsetHeight,\n actualWidth: offsetWidth,\n keepRatio,\n });\n });\n };\n\n const onResizeWidth = ({ width }) => {\n onResize({ width });\n };\n\n const onResizeHeight = ({ height }) => {\n onResize({ height });\n };\n\n const onResizeRatio = ({ width }) => {\n onResize({ height: width, width, keepRatio: true });\n };\n\n return (\n <div\n style={{ transform: `rotate(${rotation}deg` }}\n data-id={id}\n id={`${uid}__${id}`}\n className={className}\n >\n <div\n style={{ display: \"flex\" }}\n ref={itemWrapperRef}\n onAnimationEnd={removeClass}\n onKeyDown={(e) => e.stopPropagation()}\n onKeyUp={(e) => e.stopPropagation()}\n >\n <ItemErrorBoundary\n itemId={id}\n state={rest}\n ErrorComponent={itemMap?.error?.component || DefaultErrorComponent}\n >\n <Component {...rest} id={id} setState={updateState} />\n </ItemErrorBoundary>\n <div className={`corner ${itemMark} ${itemMarkTopLeft}`} />\n <div className={`corner ${itemMark} ${itemMarkTopRight}`} />\n <div className={`corner ${itemMark} ${itemMarkBottomRight}`} />\n <div className={`corner ${itemMark} ${itemMarkBottomLeft}`} />\n <div className={`center ${itemMark} ${itemMarkCenter}`} />\n {showResizeHandle && (\n <>\n {resizeDirections.b && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeRatio}`}\n onResize={onResizeRatio}\n />\n )}\n\n {resizeDirections.h && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeHeight}`}\n onResize={onResizeHeight}\n />\n )}\n\n {resizeDirections.w && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeWidth}`}\n onResize={onResizeWidth}\n />\n )}\n </>\n )}\n </div>\n </div>\n );\n};\n\nconst MemoizedItem = memo(\n Item,\n (\n {\n state: prevState,\n setState: prevSetState,\n isSelected: prevIsSelected,\n showResizeHandle: prevShowResizeHandle,\n },\n {\n state: nextState,\n setState: nextSetState,\n isSelected: nextIsSelected,\n showResizeHandle: nextShowResizeHandle,\n }\n ) =>\n prevIsSelected === nextIsSelected &&\n prevShowResizeHandle === nextShowResizeHandle &&\n prevSetState === nextSetState &&\n deepEqual(prevState, nextState)\n);\n\nconst identity = (x) => x;\n\n// Exclude positioning from memoization\nconst PositionedItem = ({ state = {}, getCurrentUser, className, ...rest }) => {\n if (!rest.itemMap[state.type]) {\n return null;\n }\n\n const { stateHook = identity } = rest.itemMap[state.type];\n\n const {\n x = 0,\n y = 0,\n layer = 0,\n moving,\n ...stateRest\n } = stateHook(state, {\n currentUser: getCurrentUser?.(),\n });\n\n const zIndex = (layer + 4) * 10 + 100 + (moving ? 5 : 0); // Items z-index between 100 and 200\n\n return (\n <div\n className={className}\n style={{\n transform: `translate(${x}px, ${y}px)`,\n zIndex,\n }}\n >\n <MemoizedItem\n {...rest}\n // Helps to prevent render\n showResizeHandle={rest.isSelected && rest.showResizeHandle}\n state={stateRest}\n />\n </div>\n );\n};\n\nconst MemoizedPositionedItem = memo(PositionedItem);\n\nexport default MemoizedPositionedItem;\n","import Item from \"./Item\";\nimport useItemActions from \"./useItemActions\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"../store/main\";\nimport { useSyncedUsers } from \"@/users/store\";\nimport { css } from \"goober\";\n\nconst ItemList = () => {\n const { updateItem } = useItemActions();\n\n const [itemList, itemMap] = useSyncedStore((state) => [\n state.itemIds,\n state.items,\n ]);\n\n const [showResizeHandle, itemTemplates, selection] = useMainStore(\n (state) => [\n state.config.showResizeHandle,\n state.config.itemTemplates,\n state.selection,\n ]\n );\n const [getCurrentUser] = useSyncedUsers((state) => [state.getUser]);\n\n const itemClassName = css({\n position: \"absolute\",\n top: 0,\n left: 0,\n pointerEvents: \"auto\",\n display: \"inline-block\",\n lineHeight: 0,\n });\n\n return itemList.map((itemId) => (\n <Item\n key={itemId}\n state={itemMap[itemId]}\n setState={updateItem}\n isSelected={selection.includes(itemId)}\n itemMap={itemTemplates}\n getCurrentUser={getCurrentUser}\n showResizeHandle={showResizeHandle}\n className={itemClassName}\n />\n ));\n};\n\nexport default ItemList;\n","import React from \"react\";\nimport { css } from \"goober\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport { insideClass, isItemInsideElement, getIdFromElem } from \"@/utils\";\n\nimport Gesture from \"./Gesture\";\nimport { useItemActions } from \"./Items\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"./store/main\";\n\nconst defaultSelectorClass = css({\n zIndex: 210,\n position: \"absolute\",\n backgroundColor: \"hsla(0, 40%, 50%, 10%)\",\n border: \"2px solid hsl(0, 55%, 40%)\",\n});\n\n/**\n * Find selected element by using their visible screen dimensions.\n *\n * @param {Array} itemMap\n * @param {DomObject} wrapper\n * @param {boolean} ignoreLocked\n * @returns\n */\nconst findSelected = (itemMap, wrapper, ignoreLocked = false) => {\n const selectors = wrapper.getElementsByClassName(\"selector\");\n if (!selectors.length) {\n return [];\n }\n\n const selector = selectors[0];\n\n return Array.from(wrapper.getElementsByClassName(\"item\"))\n .filter((elem) => {\n const id = getIdFromElem(elem);\n\n const item = itemMap[id];\n if (!item || (!ignoreLocked && item.locked)) {\n return false;\n }\n return isItemInsideElement(elem, selector);\n })\n .map((elem) => getIdFromElem(elem));\n};\n\nconst Selector = ({ children, moveFirst }) => {\n const [\n getSelection,\n clearSelection,\n setSelection,\n select,\n getConfiguration,\n updateBoardState,\n ] = useMainStore((state) => [\n state.getSelection,\n state.clear,\n state.setSelection,\n state.select,\n state.getConfiguration,\n state.updateBoardState,\n ]);\n const { findElementUnderPointer } = useItemActions();\n const [getItems] = useSyncedStore((state) => [state.getItems]);\n\n const [selector, setSelector] = React.useState({});\n const [, startTransition] = React.useTransition();\n const [ignoreLocked, setIgnoreLocked] = React.useState(false);\n\n const wrapperRef = React.useRef(null);\n const stateRef = React.useRef({\n moving: false,\n });\n\n useEventListener(document, \"keydown\", (e) => {\n if (e.key === \"l\") {\n setIgnoreLocked(true);\n }\n });\n\n useEventListener(document, \"keyup\", (e) => {\n if (e.key === \"l\") {\n setIgnoreLocked(false);\n }\n });\n\n // Reset selection on board loading\n React.useEffect(() => {\n clearSelection();\n return () => {\n clearSelection();\n };\n }, [clearSelection]);\n\n React.useEffect(() => {\n if (stateRef.current.moving) {\n const itemMap = getItems();\n const { boardWrapper } = getConfiguration();\n const selected = findSelected(itemMap, boardWrapper, ignoreLocked);\n startTransition(() => {\n setSelection(selected);\n });\n }\n }, [getConfiguration, getItems, selector, setSelection, ignoreLocked]);\n\n const onDragStart = async (event) => {\n const foundElement = await findElementUnderPointer(event);\n\n if (!foundElement) {\n stateRef.current.moving = true;\n startTransition(() => {\n updateBoardState({ selecting: true });\n });\n wrapperRef.current.style.cursor = \"crosshair\";\n }\n };\n\n const onDrag = ({ distanceY, distanceX, startX, startY }) => {\n if (stateRef.current.moving) {\n const { top, left } = wrapperRef.current.getBoundingClientRect();\n\n const relativeX = startX - left;\n const relativeY = startY - top;\n\n if (distanceX > 0) {\n stateRef.current.left = relativeX;\n stateRef.current.width = distanceX;\n } else {\n stateRef.current.left = relativeX + distanceX;\n stateRef.current.width = -distanceX;\n }\n if (distanceY > 0) {\n stateRef.current.top = relativeY;\n stateRef.current.height = distanceY;\n } else {\n stateRef.current.top = relativeY + distanceY;\n stateRef.current.height = -distanceY;\n }\n\n setSelector({ ...stateRef.current, moving: true });\n }\n };\n\n const onDragEnd = () => {\n if (stateRef.current.moving) {\n startTransition(() => {\n updateBoardState({ selecting: false });\n });\n stateRef.current.moving = false;\n setSelector({ moving: false });\n wrapperRef.current.style.cursor = \"auto\";\n }\n };\n\n const onLongTap = ({ target }) => {\n const foundElement = insideClass(target, \"item\");\n if (foundElement) {\n const id = getIdFromElem(foundElement);\n setSelection([id]);\n }\n };\n\n const onTap = (event) => {\n const { ctrlKey, metaKey } = event;\n\n const foundElement = findElementUnderPointer(event);\n\n if (!foundElement) {\n clearSelection();\n } else {\n const itemId = getIdFromElem(foundElement);\n\n // Being defensive here to avoid bug\n if (!itemId) {\n clearSelection();\n return;\n }\n\n const selectedItems = getSelection();\n if (foundElement && !selectedItems.includes(itemId)) {\n if (ctrlKey || metaKey) {\n select([itemId]);\n } else {\n setSelection([itemId]);\n }\n }\n }\n };\n\n return (\n <Gesture\n fill\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragEnd={onDragEnd}\n onTap={onTap}\n onLongTap={onLongTap}\n mainAction={moveFirst ? \"pan\" : \"drag\"}\n >\n <div ref={wrapperRef} style={{ position: \"absolute\", inset: 0 }}>\n {selector.moving && (\n <div\n style={{\n transform: `translate(${selector.left}px, ${selector.top}px)`,\n height: `${selector.height}px`,\n width: `${selector.width}px`,\n }}\n className={`selector ${defaultSelectorClass}`}\n />\n )}\n {children}\n </div>\n </Gesture>\n );\n};\n\nexport default Selector;\n","import React from \"react\";\n\nimport { useItemActions } from \"./Items\";\nimport { getIdFromElem } from \"@/utils\";\n\nimport Gesture from \"./Gesture\";\nimport useMainStore from \"./store/main\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport { useEventListener } from \"@react-hookz/web\";\nimport useDim from \"./useDim\";\n\n/**\n * This component handles the move of items when dragging them or with the keyboard.\n */\nconst ActionPane = ({ children }) => {\n const { moveItems, placeItems, findElementUnderPointer } = useItemActions();\n const { vectorFromWrapperToBoard } = useDim();\n\n const [select, setSelection, getSelection, getBoardState, updateBoardState] =\n useMainStore((state) => [\n state.select,\n state.setSelection,\n state.getSelection,\n state.getBoardState,\n state.updateBoardState,\n ]);\n const [getBoardConfig] = useSyncedStore((state) => [state.getBoardConfig]);\n\n const actionRef = React.useRef({});\n\n // Use ref because pointer events are faster than react state management\n const selectedItemRef = React.useRef({\n items: [],\n });\n\n const onDragStart = (event) => {\n const { ctrlKey, metaKey, event: originalEvent } = event;\n const foundElement = findElementUnderPointer(event);\n\n if (foundElement) {\n originalEvent.stopPropagation();\n const selectedItems = getSelection();\n\n selectedItemRef.current.items = selectedItems;\n\n const itemId = getIdFromElem(foundElement);\n\n if (!selectedItems.includes(itemId)) {\n if (ctrlKey || metaKey) {\n selectedItemRef.current.items = [...selectedItems, itemId];\n select([itemId]);\n } else {\n selectedItemRef.current.items = [itemId];\n setSelection([itemId]);\n }\n }\n\n Object.assign(actionRef.current, {\n moving: true,\n });\n }\n };\n\n const onDrag = ({ deltaX, deltaY, event: originalEvent }) => {\n if (actionRef.current.moving) {\n originalEvent.stopPropagation();\n const { movingItems } = getBoardState();\n\n const [newX, newY] = vectorFromWrapperToBoard(deltaX, deltaY);\n\n moveItems(\n selectedItemRef.current.items,\n {\n x: newX,\n y: newY,\n },\n true\n );\n\n if (!movingItems) {\n updateBoardState({ movingItems: true });\n }\n }\n };\n\n const onDragEnd = () => {\n if (actionRef.current.moving) {\n const { gridSize: boardGridSize = 1 } = getBoardConfig();\n const gridSize = boardGridSize || 1; // avoid 0 grid size\n\n actionRef.current = { moving: false };\n placeItems(selectedItemRef.current.items, {\n type: \"grid\",\n size: gridSize,\n });\n updateBoardState({ movingItems: false });\n }\n };\n\n const onKeyDown = (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n const selectedItems = getSelection();\n\n if (selectedItems.length) {\n const { gridSize: boardGridSize = 1 } = getBoardConfig();\n let moveX = 0;\n let moveY = 0;\n switch (e.key) {\n case \"ArrowLeft\":\n // Left pressed\n moveX = -10;\n break;\n case \"ArrowRight\":\n moveX = 10;\n // Right pressed\n break;\n case \"ArrowUp\":\n // Up pressed\n moveY = -10;\n break;\n case \"ArrowDown\":\n // Down pressed\n moveY = 10;\n break;\n default:\n }\n if (moveX || moveY) {\n if (e.shiftKey) {\n moveX *= 5;\n moveY *= 5;\n }\n if (e.ctrlKey || e.altKey || e.metaKey) {\n moveX /= 10;\n moveY /= 10;\n }\n\n const [newX, newY] = vectorFromWrapperToBoard(moveX, moveY);\n\n moveItems(\n selectedItems,\n {\n x: newX,\n y: newY,\n },\n true\n );\n const gridSize = boardGridSize || 1; // avoid 0 grid size\n\n placeItems(selectedItems, {\n type: \"grid\",\n size: gridSize,\n });\n e.preventDefault();\n }\n }\n };\n\n useEventListener(document, \"keydown\", onKeyDown);\n\n return (\n <Gesture fill onDragStart={onDragStart} onDrag={onDrag} onDragEnd={onDragEnd}>\n {children}\n </Gesture>\n );\n};\n\nexport default ActionPane;\n","import { useEventListener } from \"@react-hookz/web\";\nimport React from \"react\";\n\nconst useMousePosition = (ref) => {\n const mouseRef = React.useRef({ hover: false, x: 0, y: 0 });\n\n useEventListener(ref, \"mousemove\", (e) => {\n const { clientX, clientY } = e;\n mouseRef.current.x = clientX;\n mouseRef.current.y = clientY;\n });\n useEventListener(ref, \"mouseenter\", () => {\n mouseRef.current.hover = true;\n });\n useEventListener(ref, \"mouseleave\", () => {\n mouseRef.current.hover = false;\n });\n\n const getMouseInfo = React.useCallback(() => mouseRef.current, []);\n\n return getMouseInfo;\n};\n\nexport default useMousePosition;\n","import React from \"react\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport useMainStore from \"./store/main\";\n\nconst digitCodes = [...Array(5).keys()].map((id) => `Digit${id + 1}`);\n\nconst usePositionNavigator = () => {\n const [positions, setPositions] = React.useState({});\n const [getBoardState, updateBoardState] = useMainStore((state) => [\n state.getBoardState,\n state.updateBoardState,\n ]);\n\n useEventListener(document, \"keydown\", (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n if (digitCodes.includes(e.code)) {\n const positionKey = e.code;\n const { translateX, translateY, scale } = getBoardState();\n\n if (e.altKey || e.metaKey || e.ctrlKey || e.shiftKey) {\n setPositions((prev) => ({\n ...prev,\n [positionKey]: { translateX, translateY, scale },\n }));\n } else if (positions[positionKey]) {\n updateBoardState(positions[positionKey]);\n }\n e.preventDefault();\n }\n });\n\n return null;\n};\n\nexport default usePositionNavigator;\n","import React from \"react\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport Gesture from \"./Gesture\";\nimport useDim from \"./useDim\";\nimport useMousePosition from \"./useMousePosition\";\nimport usePositionNavigator from \"./usePositionNavigator\";\nimport useMainStore from \"./store/main\";\nimport { hasClass, insideClass } from \"@/utils\";\n\nconst PanZoom = ({ children, moveFirst = false }) => {\n const wrappedRef = React.useRef(null);\n const [\n itemExtentGlobal,\n getConfiguration,\n updateBoardState,\n getSelection,\n ] = useMainStore((state) => [\n state.config.itemExtent,\n state.getConfiguration,\n state.updateBoardState,\n state.getSelection,\n ]);\n const { zoomToCenter, zoomToExtent, moveBoard } = useDim();\n\n const [centered, setCentered] = React.useState(false);\n const timeoutRef = React.useRef({});\n\n // Get mouse position and hover status\n const getMouseInfo = useMousePosition(wrappedRef);\n\n // Hooks to save/restore position\n usePositionNavigator();\n\n /**\n * Center board on startup\n */\n const centerBoard = React.useCallback(() => {\n const { itemExtent } = getConfiguration();\n zoomToExtent(itemExtent);\n }, [getConfiguration, zoomToExtent]);\n\n React.useEffect(() => {\n if (!centered && itemExtentGlobal.radius) {\n // Center board on first valid extent\n centerBoard();\n setCentered(true);\n }\n }, [centerBoard, centered, itemExtentGlobal]);\n\n const onZoom = ({ clientX, clientY, scale }) => {\n zoomToCenter({ to: { x: clientX, y: clientY }, factor: 1 - scale / 500 });\n\n // Update the board zooming state\n clearTimeout(timeoutRef.current.zoom);\n timeoutRef.current.zoom = setTimeout(() => {\n updateBoardState({ zooming: false });\n }, 200);\n updateBoardState({ zooming: true });\n };\n\n const onPan = ({ deltaX, deltaY, target }) => {\n const item = insideClass(target, \"item\");\n if (item && hasClass(item, \"selected\")) {\n return;\n }\n\n moveBoard(({ translateX, translateY }) => ({\n translateX: translateX + deltaX,\n translateY: translateY + deltaY,\n }));\n\n // update the board panning state\n clearTimeout(timeoutRef.current.pan);\n timeoutRef.current.pan = setTimeout(() => {\n updateBoardState({ panning: false });\n }, 200);\n updateBoardState({ panning: true });\n };\n\n const onKeyDown = (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n let moveX = 0;\n let moveY = 0;\n let zoom = 1;\n switch (e.key) {\n case \"ArrowLeft\":\n moveX = -10;\n break;\n case \"ArrowRight\":\n moveX = 10;\n break;\n case \"ArrowUp\":\n moveY = -10;\n break;\n case \"ArrowDown\":\n moveY = 10;\n break;\n case \"PageUp\":\n zoom = 1.2;\n break;\n case \"PageDown\":\n zoom = 0.8;\n break;\n default:\n }\n if (moveX || moveY || zoom !== 1) {\n // Don't move board if moving item\n const selectedItems = getSelection();\n if (zoom === 1 && selectedItems.length) {\n return;\n }\n if (e.shiftKey) {\n moveX *= 5;\n moveY *= 5;\n }\n if (e.ctrlKey || e.altKey || e.metaKey) {\n moveX /= 5;\n moveY /= 5;\n }\n\n moveBoard(({ translateX, translateY }) => ({\n translateX: translateX + moveX,\n translateY: translateY + moveY,\n }));\n\n zoomToCenter({ factor: zoom });\n\n e.preventDefault();\n }\n // Temporary zoom\n if (e.key === \" \" && !e.repeat) {\n if (getMouseInfo().hover) {\n zoomToCenter({ factor: 3, to: getMouseInfo() });\n }\n }\n };\n\n const onKeyUp = (e) => {\n // Ignore text in Input or Textarea\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n // Zoom out on release\n if (e.key === \" \" && getMouseInfo().hover) {\n zoomToCenter({ factor: 1 / 3, to: getMouseInfo() });\n }\n };\n\n useEventListener(document, \"keydown\", onKeyDown);\n useEventListener(document, \"keyup\", onKeyUp);\n\n return (\n <Gesture\n fill\n onPan={onPan}\n onZoom={onZoom}\n mainAction={moveFirst ? \"pan\" : \"drag\"}\n >\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n }}\n className=\"board\"\n ref={wrappedRef}\n >\n {children}\n </div>\n </Gesture>\n );\n};\n\nexport default PanZoom;\n","import React from \"react\";\nimport { css } from \"goober\";\nimport { useDebouncedCallback } from \"@react-hookz/web\";\n\nimport { getItemsBoundingBox } from \"@/utils\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"./store/main\";\n\nconst defaultZoneStyle = css({\n position: \"absolute\",\n top: 0,\n left: 0,\n zIndex: 210,\n backgroundColor: \"hsla(0, 40%, 50%, 0%)\",\n border: \"2px dashed hsl(20, 55%, 40%)\",\n pointerEvents: \"none\",\n});\n\n/**\n * Show a bounding box around all selected items.\n */\nconst BoundingBox = () => {\n const [\n selection,\n getSelection,\n selectionBox,\n setSelectionBox,\n getConfiguration,\n { translateX, translateY, scale },\n ] = useMainStore((state) => [\n state.selection,\n state.getSelection,\n state.selectionBox,\n state.setSelectionBox,\n state.getConfiguration,\n {\n translateX: state.boardState.translateX,\n translateY: state.boardState.translateY,\n scale: state.boardState.scale,\n },\n ]);\n\n const [items] = useSyncedStore((state) => [state.items]);\n\n // Update selection bounding box\n const updateBox = React.useCallback(() => {\n const currentSelectedItems = getSelection();\n const { boardWrapperRect, uid } = getConfiguration();\n\n if (currentSelectedItems.length === 0) {\n setSelectionBox(null);\n return;\n }\n\n const boundingBox = getItemsBoundingBox(currentSelectedItems, uid);\n\n if (!boundingBox) {\n setSelectionBox(null);\n return;\n }\n\n const { left, top, width, height } = boundingBox;\n\n const newBB = {\n left: left - boardWrapperRect.left,\n top: top - boardWrapperRect.top,\n height,\n width,\n };\n setSelectionBox(newBB);\n }, [getConfiguration, getSelection, setSelectionBox]);\n\n // Debounced version of update box\n const updateBoxDelay = useDebouncedCallback(updateBox, [updateBox], 300);\n\n React.useEffect(() => {\n // Update selected elements bounding box\n updateBox();\n updateBoxDelay(); // Delay to update after board item animation like tap/untap.\n }, [\n selection,\n items,\n translateX,\n translateY,\n scale,\n updateBox,\n updateBoxDelay,\n ]);\n\n if (!selectionBox || selection.length < 2) return null;\n\n return (\n <div\n style={{\n transform: `translate(${selectionBox.left}px, ${selectionBox.top}px)`,\n height: `${selectionBox.height}px`,\n width: `${selectionBox.width}px`,\n }}\n className={`selection ${defaultZoneStyle}`}\n />\n );\n};\n\nconst Selection = () => {\n const [movingItems] = useMainStore((state) => [state.boardState.movingItems]);\n\n if (movingItems) {\n return null;\n }\n\n return <BoundingBox />;\n};\n\nexport default Selection;\n","/**\n * Clamps a number between a lower and upper bound.\n *\n * ```js\n * guard(0, 1, 2); // 1\n * ```\n *\n * @param low The lower bound.\n * @param high The upper bound.\n * @param value The number to clamp.\n * @returns The clamped number.\n */\nfunction guard(low, high, value) {\n return Math.min(Math.max(low, value), high);\n}\n\n/**\n * Error thrown when color2k cannot parse an input color.\n *\n * ```js\n * new ColorError('nope').message; // 'Failed to parse color: \"nope\"'\n * ```\n *\n * @param color The color value that failed to parse.\n */\nclass ColorError extends Error {\n constructor(color) {\n super(`Failed to parse color: \"${color}\"`);\n }\n}\n\n/**\n * Parses a color into red, green, blue, and alpha channel values.\n *\n * Supports hex, RGB, RGBA, HSL, HSLA, CSS named colors, and `transparent`.\n *\n * ```js\n * parseToRgba('rgba(255, 0, 0, 0.5)'); // [255, 0, 0, 0.5]\n * ```\n *\n * @param color The input color.\n * @returns A tuple of red, green, blue, and alpha channel values.\n */\nfunction parseToRgba(color) {\n if (typeof color !== 'string') throw new ColorError(color);\n if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];\n let normalizedColor = color.trim();\n normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;\n const reducedHexMatch = reducedHexRegex.exec(normalizedColor);\n if (reducedHexMatch) {\n const arr = Array.from(reducedHexMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(r(x, 2), 16)), parseInt(r(arr[3] || 'f', 2), 16) / 255];\n }\n const hexMatch = hexRegex.exec(normalizedColor);\n if (hexMatch) {\n const arr = Array.from(hexMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(x, 16)), parseInt(arr[3] || 'ff', 16) / 255];\n }\n const rgbaMatch = rgbaRegex.exec(normalizedColor);\n if (rgbaMatch) {\n const arr = Array.from(rgbaMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(x, 10)), parseFloat(arr[3] || '1')];\n }\n const hslaMatch = hslaRegex.exec(normalizedColor);\n if (hslaMatch) {\n const [h, s, l, a] = Array.from(hslaMatch).slice(1).map(parseFloat);\n if (guard(0, 100, s) !== s) throw new ColorError(color);\n if (guard(0, 100, l) !== l) throw new ColorError(color);\n return [...hslToRgb(h, s, l), Number.isNaN(a) ? 1 : a];\n }\n throw new ColorError(color);\n}\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n while (i) {\n hash = hash * 33 ^ str.charCodeAt(--i);\n }\n\n /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed\n * integers. Since we want the results to be always positive, convert the\n * signed int to an unsigned by doing an unsigned bitshift. */\n return (hash >>> 0) % 2341;\n}\nconst colorToInt = x => parseInt(x.replace(/_/g, ''), 36);\nconst compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce((acc, next) => {\n const key = colorToInt(next.substring(0, 3));\n const hex = colorToInt(next.substring(3)).toString(16);\n\n // NOTE: padStart could be used here but it breaks Node 6 compat\n // https://github.com/ricokahler/color2k/issues/351\n let prefix = '';\n for (let i = 0; i < 6 - hex.length; i++) {\n prefix += '0';\n }\n acc[key] = `${prefix}${hex}`;\n return acc;\n}, {});\n\n/**\n * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.\n */\nfunction nameToHex(color) {\n const normalizedColorName = color.toLowerCase().trim();\n const result = compressedColorMap[hash(normalizedColorName)];\n if (!result) throw new ColorError(color);\n return `#${result}`;\n}\nconst r = (str, amount) => Array.from(Array(amount)).map(() => str).join('');\nconst reducedHexRegex = new RegExp(`^#${r('([a-f0-9])', 3)}([a-f0-9])?$`, 'i');\nconst hexRegex = new RegExp(`^#${r('([a-f0-9]{2})', 3)}([a-f0-9]{2})?$`, 'i');\nconst rgbaRegex = new RegExp(`^rgba?\\\\(\\\\s*(\\\\d+)\\\\s*${r(',\\\\s*(\\\\d+)\\\\s*', 2)}(?:,\\\\s*([\\\\d.]+))?\\\\s*\\\\)$`, 'i');\nconst hslaRegex = /^hsla?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)%\\s*,\\s*([\\d.]+)%(?:\\s*,\\s*([\\d.]+))?\\s*\\)$/i;\nconst namedColorRegex = /^[a-z]+$/i;\nconst roundColor = color => {\n return Math.round(color * 255);\n};\nconst hslToRgb = (hue, saturation, lightness) => {\n let l = lightness / 100;\n if (saturation === 0) {\n // achromatic\n return [l, l, l].map(roundColor);\n }\n\n // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV\n const huePrime = (hue % 360 + 360) % 360 / 60;\n const chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);\n const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));\n let red = 0;\n let green = 0;\n let blue = 0;\n if (huePrime >= 0 && huePrime < 1) {\n red = chroma;\n green = secondComponent;\n } else if (huePrime >= 1 && huePrime < 2) {\n red = secondComponent;\n green = chroma;\n } else if (huePrime >= 2 && huePrime < 3) {\n green = chroma;\n blue = secondComponent;\n } else if (huePrime >= 3 && huePrime < 4) {\n green = secondComponent;\n blue = chroma;\n } else if (huePrime >= 4 && huePrime < 5) {\n red = secondComponent;\n blue = chroma;\n } else if (huePrime >= 5 && huePrime < 6) {\n red = chroma;\n blue = secondComponent;\n }\n const lightnessModification = l - chroma / 2;\n const finalRed = red + lightnessModification;\n const finalGreen = green + lightnessModification;\n const finalBlue = blue + lightnessModification;\n return [finalRed, finalGreen, finalBlue].map(roundColor);\n};\n\n// taken from:\n// https://github.com/styled-components/polished/blob/a23a6a2bb26802b3d922d9c3b67bac3f3a54a310/src/internalHelpers/_rgbToHsl.js\n\n/**\n * Parses a color into hue, saturation, lightness, and alpha channel values.\n *\n * Hue is a number between 0 and 360. Saturation, lightness, and alpha are\n * decimal percentages between 0 and 1.\n *\n * ```js\n * parseToHsla('red'); // [0, 1, 0.5, 1]\n * ```\n *\n * @param color The input color.\n * @returns A tuple of hue, saturation, lightness, and alpha values.\n */\nfunction parseToHsla(color) {\n const [red, green, blue, alpha] = parseToRgba(color).map((value, index) =>\n // 3rd index is alpha channel which is already normalized\n index === 3 ? value : value / 255);\n const max = Math.max(red, green, blue);\n const min = Math.min(red, green, blue);\n const lightness = (max + min) / 2;\n\n // achromatic\n if (max === min) return [0, 0, lightness, alpha];\n const delta = max - min;\n const saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);\n const hue = 60 * (red === max ? (green - blue) / delta + (green < blue ? 6 : 0) : green === max ? (blue - red) / delta + 2 : (red - green) / delta + 4);\n return [hue, saturation, lightness, alpha];\n}\n\n/**\n * Builds an `hsla` color string from hue, saturation, lightness, and alpha\n * channel values.\n *\n * ```js\n * hsla(0, 1, 0.5, 1); // 'hsla(0, 100%, 50%, 1)'\n * ```\n *\n * @param hue The color wheel angle from 0 to 360.\n * @param saturation The saturation as a decimal between 0 and 1.\n * @param lightness The lightness as a decimal between 0 and 1.\n * @param alpha The opacity as a decimal between 0 and 1.\n * @returns An `hsla` color string.\n */\nfunction hsla(hue, saturation, lightness, alpha) {\n return `hsla(${(hue % 360).toFixed()}, ${guard(0, 100, saturation * 100).toFixed()}%, ${guard(0, 100, lightness * 100).toFixed()}%, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;\n}\n\n/**\n * Rotates a color's hue by the given number of degrees and returns the result\n * as an `hsla` string. Hue values wrap around the 0 to 360 degree color wheel.\n *\n * ```js\n * adjustHue('red', 180); // 'hsla(180, 100%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param degrees The number of degrees to rotate the hue.\n * @returns The adjusted color as an `hsla` string.\n */\nfunction adjustHue(color, degrees) {\n const [h, s, l, a] = parseToHsla(color);\n return hsla(h + degrees, s, l, a);\n}\n\n/**\n * Darkens a color by subtracting from the lightness channel in HSL space.\n *\n * ```js\n * darken('white', 0.1); // 'hsla(0, 0%, 90%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to darken, given as a decimal between 0 and 1.\n * @returns The darkened color as an `hsla` string.\n */\nfunction darken(color, amount) {\n const [hue, saturation, lightness, alpha] = parseToHsla(color);\n return hsla(hue, saturation, lightness - amount, alpha);\n}\n\n/**\n * Desaturates a color by subtracting from the saturation channel in HSL space.\n *\n * ```js\n * desaturate('red', 0.5); // 'hsla(0, 50%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to desaturate, given as a decimal between 0 and 1.\n * @returns The desaturated color as an `hsla` string.\n */\nfunction desaturate(color, amount) {\n const [h, s, l, a] = parseToHsla(color);\n return hsla(h, s - amount, l, a);\n}\n\n// taken from:\n// https://github.com/styled-components/polished/blob/0764c982551b487469043acb56281b0358b3107b/src/color/getLuminance.js\n\n/**\n * Returns the relative luminance of a color using the WCAG formula.\n *\n * ```js\n * getLuminance('papayawhip'); // 0.877971001998354\n * ```\n *\n * @param color The input color.\n * @returns A number between 0 for darkest black and 1 for lightest white.\n */\nfunction getLuminance(color) {\n if (color === 'transparent') return 0;\n function f(x) {\n const channel = x / 255;\n return channel <= 0.04045 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);\n }\n const [r, g, b] = parseToRgba(color);\n return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);\n}\n\n// taken from:\n// https://github.com/styled-components/polished/blob/0764c982551b487469043acb56281b0358b3107b/src/color/getContrast.js\n\n/**\n * Returns the contrast ratio between two colors based on the WCAG contrast\n * ratio formula.\n *\n * ```js\n * getContrast('#444', '#fff'); // 9.739769120526205\n * ```\n *\n * @param color1 The first color.\n * @param color2 The second color.\n * @returns The contrast ratio between the two colors.\n */\nfunction getContrast(color1, color2) {\n const luminance1 = getLuminance(color1);\n const luminance2 = getLuminance(color2);\n return luminance1 > luminance2 ? (luminance1 + 0.05) / (luminance2 + 0.05) : (luminance2 + 0.05) / (luminance1 + 0.05);\n}\n\n/**\n * Builds an `rgba` color string from red, green, blue, and alpha channel\n * values.\n *\n * ```js\n * rgba(255, 0, 0, 1); // 'rgba(255, 0, 0, 1)'\n * ```\n *\n * @param red The red channel value from 0 to 255.\n * @param green The green channel value from 0 to 255.\n * @param blue The blue channel value from 0 to 255.\n * @param alpha The opacity as a decimal between 0 and 1.\n * @returns An `rgba` color string.\n */\nfunction rgba(red, green, blue, alpha) {\n return `rgba(${guard(0, 255, red).toFixed()}, ${guard(0, 255, green).toFixed()}, ${guard(0, 255, blue).toFixed()}, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;\n}\n\n/**\n * Mixes two colors together using the Sass mix algorithm and returns an `rgba`\n * color string.\n *\n * ```js\n * mix('red', 'blue', 0.5); // 'rgba(128, 0, 128, 1)'\n * ```\n *\n * @param color1 The first color.\n * @param color2 The second color.\n * @param weight The mix weight as a decimal between 0 and 1.\n * @returns The mixed color as an `rgba` string.\n */\nfunction mix(color1, color2, weight) {\n const normalize = (n, index) =>\n // 3rd index is alpha channel which is already normalized\n index === 3 ? n : n / 255;\n const [r1, g1, b1, a1] = parseToRgba(color1).map(normalize);\n const [r2, g2, b2, a2] = parseToRgba(color2).map(normalize);\n\n // The formula is copied from the original Sass implementation:\n // http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method\n const alphaDelta = a2 - a1;\n const normalizedWeight = weight * 2 - 1;\n const combinedWeight = normalizedWeight * alphaDelta === -1 ? normalizedWeight : normalizedWeight + alphaDelta / (1 + normalizedWeight * alphaDelta);\n const weight2 = (combinedWeight + 1) / 2;\n const weight1 = 1 - weight2;\n const r = (r1 * weight1 + r2 * weight2) * 255;\n const g = (g1 * weight1 + g2 * weight2) * 255;\n const b = (b1 * weight1 + b2 * weight2) * 255;\n const a = a2 * weight + a1 * (1 - weight);\n return rgba(r, g, b, a);\n}\n\n/**\n * Returns a scale function that interpolates through a list of colors.\n *\n * The returned function accepts a decimal between 0 and 1 and returns the color\n * at that percentage in the scale.\n *\n * ```js\n * const scale = getScale('red', 'yellow', 'green');\n * console.log(scale(0)); // rgba(255, 0, 0, 1)\n * console.log(scale(0.5)); // rgba(255, 255, 0, 1)\n * console.log(scale(1)); // rgba(0, 128, 0, 1)\n * ```\n *\n * If you'd like to limit the domain and range like chroma-js, we recommend\n * wrapping scale again.\n *\n * ```js\n * const _scale = getScale('red', 'yellow', 'green');\n * const scale = x => _scale(x / 100);\n *\n * console.log(scale(0)); // rgba(255, 0, 0, 1)\n * console.log(scale(50)); // rgba(255, 255, 0, 1)\n * console.log(scale(100)); // rgba(0, 128, 0, 1)\n * ```\n *\n * @param colors The colors to interpolate through.\n * @returns A function that maps a decimal percentage to an `rgba` color.\n */\nfunction getScale(...colors) {\n return n => {\n const lastIndex = colors.length - 1;\n const lowIndex = guard(0, lastIndex, Math.floor(n * lastIndex));\n const highIndex = guard(0, lastIndex, Math.ceil(n * lastIndex));\n const color1 = colors[lowIndex];\n const color2 = colors[highIndex];\n const unit = 1 / lastIndex;\n const weight = (n - unit * lowIndex) / unit;\n return mix(color1, color2, weight);\n };\n}\n\nconst guidelines = {\n decorative: 1.5,\n readable: 3,\n aa: 4.5,\n aaa: 7\n};\n\n/**\n * Returns whether a color fails a contrast threshold against a background.\n *\n * The supported standards are `decorative`, `readable`, `aa`, and `aaa`.\n *\n * ```js\n * hasBadContrast('red', 'aa'); // true\n * ```\n *\n * @param color The foreground color.\n * @param standard The contrast standard to test against.\n * @param background The background color.\n * @returns `true` when the contrast ratio is below the selected standard.\n */\nfunction hasBadContrast(color, standard = 'aa', background = '#fff') {\n return getContrast(color, background) < guidelines[standard];\n}\n\n/**\n * Lightens a color by adding to the lightness channel in HSL space.\n *\n * This is equivalent to `darken(color, -amount)`.\n *\n * ```js\n * lighten('black', 0.1); // 'hsla(0, 0%, 10%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to lighten, given as a decimal between 0 and 1.\n * @returns The lightened color as an `hsla` string.\n */\nfunction lighten(color, amount) {\n return darken(color, -amount);\n}\n\n/**\n * Makes a color more transparent by decreasing the alpha channel.\n *\n * ```js\n * transparentize('white', 0.1); // 'rgba(255, 255, 255, 0.9)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to increase transparency by, given as a decimal between 0 and 1.\n * @returns The more transparent color as an `rgba` string.\n */\nfunction transparentize(color, amount) {\n const [r, g, b, a] = parseToRgba(color);\n return rgba(r, g, b, a - amount);\n}\n\n/**\n * Makes a color more opaque by increasing the alpha channel.\n *\n * This is equivalent to `transparentize(color, -amount)`.\n *\n * ```js\n * opacify('rgba(255, 255, 255, 0.5)', 0.1); // 'rgba(255, 255, 255, 0.6)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to increase opacity by, given as a decimal between 0 and 1.\n * @returns The more opaque color as an `rgba` string.\n */\nfunction opacify(color, amount) {\n return transparentize(color, -amount);\n}\n\n/**\n * Returns whether black is the more readable color to place on top of the\n * input color.\n *\n * This is the boolean form of `readableColor`.\n *\n * ```js\n * readableColorIsBlack('white'); // true\n * ```\n *\n * @param color The background color.\n * @returns `true` when black is the more readable foreground color.\n */\nfunction readableColorIsBlack(color) {\n return getLuminance(color) > 0.179;\n}\n\n/**\n * Returns black or white, whichever has better contrast against the given\n * color.\n *\n * ```js\n * readableColor('white'); // '#000'\n * ```\n *\n * @param color The background color.\n * @returns `#000` or `#fff`.\n */\nfunction readableColor(color) {\n return readableColorIsBlack(color) ? '#000' : '#fff';\n}\n\n/**\n * Saturates a color by adding to the saturation channel in HSL space.\n *\n * This is equivalent to `desaturate(color, -amount)`.\n *\n * ```js\n * saturate('hsl(0, 50%, 50%)', 0.1); // 'hsla(0, 60%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to saturate, given as a decimal between 0 and 1.\n * @returns The saturated color as an `hsla` string.\n */\nfunction saturate(color, amount) {\n return desaturate(color, -amount);\n}\n\n/**\n * Converts a color to a hex color string.\n *\n * Includes an alpha channel when the input color is not fully opaque.\n *\n * ```js\n * toHex('palevioletred'); // '#db7093'\n * ```\n *\n * @param color The input color.\n * @returns A hex color string.\n */\nfunction toHex(color) {\n const [r, g, b, a] = parseToRgba(color);\n let hex = x => {\n const h = guard(0, 255, x).toString(16);\n // NOTE: padStart could be used here but it breaks Node 6 compat\n // https://github.com/ricokahler/color2k/issues/351\n return h.length === 1 ? `0${h}` : h;\n };\n return `#${hex(r)}${hex(g)}${hex(b)}${a < 1 ? hex(Math.round(a * 255)) : ''}`;\n}\n\n/**\n * Converts a color to an `rgba` color string.\n *\n * ```js\n * toRgba('midnightblue'); // 'rgba(25, 25, 112, 1)'\n * ```\n *\n * @param color The input color.\n * @returns An `rgba` color string.\n */\nfunction toRgba(color) {\n return rgba(...parseToRgba(color));\n}\n\n/**\n * Converts a color to an `hsla` color string.\n *\n * ```js\n * toHsla('peachpuff'); // 'hsla(28, 100%, 86%, 1)'\n * ```\n *\n * @param color The input color.\n * @returns An `hsla` color string.\n */\nfunction toHsla(color) {\n return hsla(...parseToHsla(color));\n}\n\nexport { ColorError, adjustHue, darken, desaturate, getContrast, getLuminance, getScale, guard, hasBadContrast, hsla, lighten, mix, opacify, parseToHsla, parseToRgba, readableColor, readableColorIsBlack, rgba, saturate, toHex, toHsla, toRgba, transparentize };\n//# sourceMappingURL=index.exports.import.es.mjs.map\n","import React from \"react\";\nimport { css } from \"goober\";\n\nimport { readableColorIsBlack } from \"color2k\";\n\nconst cursorClass = css({\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n zIndex: 210,\n pointerEvents: \"none\",\n});\n\nconst cursorLabelClass = css({\n fontWeight: \"bold\",\n padding: \"0 0.5em\",\n borderRadius: \"2px\",\n maxWidth: \"5em\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n marginLeft: \"-0.5em\",\n marginTop: \"1.7em\",\n whitespace: \"nowrap\",\n pointerEvents: \"none\",\n});\n\nconst Cursor = ({ color = \"#666\", size = 40, text }) => {\n const textColor = readableColorIsBlack(color) ? \"#222\" : \"#EEE\";\n return (\n <div className={cursorClass}>\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"1064.7701 445.5539 419.8101 717.0565\"\n width={size}\n height={size}\n >\n <path\n d=\"m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z\"\n style={{\n fill: textColor,\n }}\n />\n <path\n d=\"m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z\"\n style={{\n fill: \"white\",\n stroke: \"#111\",\n strokeWidth: 20,\n }}\n />\n </svg>\n <div\n style={{\n color: textColor,\n backgroundColor: color,\n }}\n className={cursorLabelClass}\n >\n {text}\n </div>\n </div>\n );\n};\n\nconst MemoizedCursor = React.memo(Cursor);\n\nconst defaultPositionedCursorClass = css({\n top: 0,\n left: 0,\n zIndex: 210,\n position: \"fixed\",\n pointerEvents: \"none\",\n});\n\nconst PositionedCursor = ({ pos, ...rest }) => {\n return (\n <div\n className={defaultPositionedCursorClass}\n style={{\n transform: `translate(${pos.x - 6}px, ${pos.y - 15}px)`,\n }}\n >\n <MemoizedCursor {...rest} />\n </div>\n );\n};\n\nexport default PositionedCursor;\n","import React from \"react\";\nimport Cursor from \"./Cursor\";\nimport { useSyncedUsers } from \"@/users/store\";\nimport useDim from \"@/board/useDim\";\nimport { isPointInsideRect } from \"@/utils\";\nimport useMainStore from \"@/board/store/main\";\n\nconst CursorPane = ({ children }) => {\n const [getConfiguration] = useMainStore((state) => [\n state.getConfiguration,\n state.boardState.scale, // We want to update this component when the scale changes\n ]);\n const { fromWrapperToBoard, fromBoardToWrapper } = useDim();\n const [currentUser, localUsers, cursors, usersById] = useSyncedUsers(\n (state) => [\n state.getUser(),\n state.getLocalUsers(),\n state.cursors,\n state.users,\n ]\n );\n const [moveCursor, removeCursor] = useSyncedUsers((state) => [\n state.moveCursor,\n state.removeCursor,\n ]);\n\n const { boardWrapperRect } = getConfiguration();\n\n const onMouseMove = ({ clientX, clientY }) => {\n const [x, y] = fromWrapperToBoard(\n clientX - boardWrapperRect.left,\n clientY - boardWrapperRect.top\n );\n moveCursor(currentUser.id, { x, y });\n };\n\n const onLeave = () => {\n removeCursor(currentUser.id);\n };\n\n // Prevent race condition when removing user\n const currentCursors = localUsers.reduce((acc, user) => {\n if (user.id !== currentUser.id && cursors[user.id]) {\n acc[user.id] = cursors[user.id];\n }\n return acc;\n }, {});\n\n return (\n <div onPointerMove={onMouseMove} onPointerLeave={onLeave}>\n {children}\n {Object.entries(currentCursors).map(([userId, pos]) => {\n const [x, y] = fromBoardToWrapper(pos.x, pos.y);\n const coord = {\n x: x + boardWrapperRect.left,\n y: y + boardWrapperRect.top,\n };\n if (!isPointInsideRect(coord, boardWrapperRect)) {\n return null;\n }\n return (\n <Cursor\n key={userId}\n pos={coord}\n text={usersById[userId].name}\n color={usersById[userId].color}\n />\n );\n })}\n </div>\n );\n};\n\nexport default CursorPane;\n","import { transformFrom, transformTo } from \"@/utils\";\n\nconst CSS_LENGTH_RE = /[+-]?(?:\\d*\\.)?\\d+(?:e[+-]?\\d+)?(?:px|%)/gi;\n\n/**\n * Splits a CSS list while ignoring separators inside strings and parentheses.\n * This keeps gradients, URLs, and calc() expressions together.\n *\n * @param {string} value CSS list to split.\n * @param {string} [separator=\",\"] Character separating list items.\n * @returns {string[]} Trimmed, non-empty list items.\n */\nexport function splitCSS(value, separator = \",\") {\n let depth = 0;\n let quote = \"\";\n let partStart = 0;\n const parts = [];\n\n for (const [index, char] of value.split(\"\").entries()) {\n if (quote) {\n if (char === quote && value[index - 1] !== \"\\\\\") quote = \"\";\n } else if (char === '\"' || char === \"'\") quote = char;\n else if (char === \"(\") depth++;\n else if (char === \")\") depth--;\n else if (depth === 0 && char === separator) {\n const part = value.slice(partStart, index).trim();\n if (part) parts.push(part);\n partStart = index + 1;\n }\n }\n\n const finalPart = value.slice(partStart).trim();\n if (finalPart) parts.push(finalPart);\n return parts;\n}\n\n/**\n * Converts CSS pixel and percentage lengths into pixels.\n * Percentage values are resolved against the supplied reference dimension.\n *\n * @param {string} value CSS length or calc() expression.\n * @param {number} reference Dimension used to resolve percentages.\n * @returns {number} Resolved pixel value.\n */\nexport function cssLength(value, reference) {\n return [...value.replace(/\\s/g, \"\").matchAll(CSS_LENGTH_RE)].reduce(\n (sum, [term]) =>\n sum +\n Number.parseFloat(term) * (term.endsWith(\"%\") ? reference / 100 : 1),\n 0\n );\n}\n\n/**\n * Calculates the rendered width and height of a background tile.\n * Supports explicit lengths, auto dimensions, cover, and contain sizing.\n *\n * @param {string} size CSS background-size value.\n * @param {number} width Available width in pixels.\n * @param {number} height Available height in pixels.\n * @param {{ width?: number, height?: number }} [intrinsic] Source dimensions.\n * @returns {[number, number]} Tile width and height in pixels.\n */\nexport function tileSize(size, width, height, intrinsic) {\n const [x, y = \"auto\"] = splitCSS(size, \" \");\n const iw = intrinsic?.width;\n const ih = intrinsic?.height;\n if (x === \"cover\" || x === \"contain\") {\n if (!iw || !ih) return [width, height];\n const factor = Math[x === \"cover\" ? \"max\" : \"min\"](width / iw, height / ih);\n return [iw * factor, ih * factor];\n }\n let w = x === \"auto\" ? null : cssLength(x, width);\n let h = y === \"auto\" ? null : cssLength(y, height);\n if (w === null && h === null) return [iw || width, ih || height];\n if (w === null) w = iw && ih ? (h * iw) / ih : width;\n if (h === null) h = iw && ih ? (w * ih) / iw : height;\n return [w, h];\n}\n\n/**\n * Finds a world-space rectangle covering the transformed viewport.\n * The extra padding prevents visible gaps at the edges during transforms.\n *\n * @param {number} width Viewport width in pixels.\n * @param {number} height Viewport height in pixels.\n * @param {object} camera Current pan, scale, and rotation.\n * @returns {{ left: number, top: number, width: number, height: number, x: number, y: number }}\n * World bounds and their screen-space origin.\n */\nexport function backgroundWindow(width, height, camera) {\n const corners = [\n [0, 0],\n [width, 0],\n [0, height],\n [width, height],\n ].map((corner) => transformFrom(corner, camera));\n const xs = corners.map(([x]) => x);\n const ys = corners.map(([, y]) => y);\n const left = Math.floor(Math.min(...xs)) - 2;\n const top = Math.floor(Math.min(...ys)) - 2;\n const right = Math.ceil(Math.max(...xs)) + 2;\n const bottom = Math.ceil(Math.max(...ys)) + 2;\n const [x, y] = transformTo([left, top], camera);\n return { left, top, width: right - left, height: bottom - top, x, y };\n}\n\n/**\n * Returns a position wrapped into a repeating interval.\n * Unlike the remainder operator, this also works for negative coordinates.\n *\n * @param {number} position Position to wrap.\n * @param {number} start Start of the interval.\n * @param {number} size Interval length.\n * @returns {number} Wrapped position offset.\n */\nexport const repeatOffset = (position, start, size) =>\n (((position - start) % size) + size) % size;\n\n/**\n * Generates the world-space background tiles intersecting the viewport.\n * It adds a one-tile buffer around the visible bounds for smooth panning.\n *\n * @param {number} width Viewport width in pixels.\n * @param {number} height Viewport height in pixels.\n * @param {object} camera Current pan, scale, and rotation.\n * @param {number} [tileSizeOverride] Fixed tile size in world pixels.\n * @returns {{ tiles: Array<{ key: string, left: number, top: number }>, size: number, left: number, top: number, x: number, y: number }}\n * Tile descriptors and the transformed grid origin.\n */\nexport function visibleTiles(width, height, camera, tileSizeOverride) {\n const bounds = backgroundWindow(width, height, camera);\n // Coarser tiles when zoomed out keep the mounted count bounded.\n const size =\n Number.isFinite(tileSizeOverride) && tileSizeOverride > 0\n ? tileSizeOverride\n : 512 * 2 ** Math.max(0, Math.ceil(Math.log2(1 / camera.scale)));\n const firstColumn = Math.floor(bounds.left / size) - 1;\n const lastColumn = Math.floor((bounds.left + bounds.width) / size) + 1;\n const firstRow = Math.floor(bounds.top / size) - 1;\n const lastRow = Math.floor((bounds.top + bounds.height) / size) + 1;\n const left = firstColumn * size;\n const top = firstRow * size;\n const [x, y] = transformTo([left, top], camera);\n const tiles = Array.from(\n { length: lastRow - firstRow + 1 },\n (_, rowIndex) => {\n const row = firstRow + rowIndex;\n return Array.from(\n { length: lastColumn - firstColumn + 1 },\n (_, columnIndex) => {\n const column = firstColumn + columnIndex;\n return {\n key: `${size}:${column}:${row}`,\n left: column * size,\n top: row * size,\n };\n }\n );\n }\n ).flat();\n\n return { tiles, size, left, top, x, y };\n}\n","import React from \"react\";\nimport useMainStore from \"./store/main\";\nimport {\n visibleTiles,\n cssLength,\n repeatOffset,\n splitCSS,\n tileSize,\n} from \"./background\";\n\nconst fill = { position: \"absolute\", inset: 0, pointerEvents: \"none\" };\n\nexport default function WorldBackground({ style, tileSizeOverride }) {\n const [camera, rect] = useMainStore((state) => [\n state.boardState,\n state.config.boardWrapperRect,\n ]);\n const width = rect.width || 1;\n const height = rect.height || 1;\n const probe = React.useRef(null);\n const [background, setBackground] = React.useState({\n color: \"#333\",\n layers: [],\n });\n const [images, setImages] = React.useState({});\n\n React.useLayoutEffect(() => {\n const css = getComputedStyle(probe.current);\n const read = (key) => splitCSS(css[key]);\n const sizes = read(\"backgroundSize\");\n const xs = read(\"backgroundPositionX\");\n const ys = read(\"backgroundPositionY\");\n const repeats = read(\"backgroundRepeat\");\n const blends = read(\"backgroundBlendMode\");\n setBackground({\n color: css.backgroundColor,\n layers: read(\"backgroundImage\").map((image, i) => ({\n image,\n size: sizes[i % sizes.length],\n x: xs[i % xs.length],\n y: ys[i % ys.length],\n repeat: repeats[i % repeats.length],\n blend: blends[i % blends.length],\n })),\n });\n }, [style, width, height]);\n\n React.useEffect(() => {\n let active = true;\n background.layers.forEach(({ image }) => {\n if (!image.startsWith(\"url(\")) return;\n const img = new Image();\n img.onload = () => {\n if (active)\n setImages((prev) => ({\n ...prev,\n [image]: { width: img.naturalWidth, height: img.naturalHeight },\n }));\n };\n img.src = image.slice(4, -1).replace(/^[\"']|[\"']$/g, \"\");\n });\n return () => {\n active = false;\n };\n }, [background.layers]);\n\n const grid = visibleTiles(width, height, camera, tileSizeOverride);\n const layers = background.layers.map((layer) => {\n const [w, h] = tileSize(layer.size, width, height, images[layer.image]);\n const repeatX =\n [\"repeat\", \"repeat-x\"].includes(layer.repeat) ||\n layer.repeat.startsWith(\"repeat \");\n const repeatY =\n [\"repeat\", \"repeat-y\"].includes(layer.repeat) ||\n layer.repeat.endsWith(\" repeat\");\n const x = cssLength(layer.x, width - w);\n const y = cssLength(layer.y, height - h);\n return {\n ...layer,\n size: `${w}px ${h}px`,\n position: (left, top) =>\n `${repeatX && w ? repeatOffset(x, left, w) : x - left}px ${repeatY && h ? repeatOffset(y, top, h) : y - top}px`,\n };\n });\n\n return (\n <div\n className=\"world-background\"\n aria-hidden=\"true\"\n style={{ ...fill, overflow: \"hidden\", backgroundColor: background.color }}\n >\n <div\n ref={probe}\n style={{\n backgroundColor: \"#333\",\n ...style,\n position: \"absolute\",\n width,\n height,\n visibility: \"hidden\",\n pointerEvents: \"none\",\n }}\n />\n <div\n className=\"world-background-tiles\"\n style={{\n position: \"absolute\",\n transformOrigin: \"0 0\",\n transform: `translate(${grid.x}px, ${grid.y}px) rotate(${camera.rotate}deg) scale(${camera.scale})`,\n }}\n >\n {grid.tiles.map((tile) => (\n <div\n key={tile.key}\n className=\"world-background-tile\"\n data-tile={tile.key}\n style={{\n position: \"absolute\",\n left: tile.left - grid.left,\n top: tile.top - grid.top,\n width: grid.size,\n height: grid.size,\n backgroundImage: layers.map((l) => l.image).join(\", \"),\n backgroundSize: layers.map((l) => l.size).join(\", \"),\n backgroundPosition: layers\n .map((l) => l.position(tile.left, tile.top))\n .join(\", \"),\n backgroundRepeat: layers.map((l) => l.repeat).join(\", \"),\n backgroundBlendMode: layers.map((l) => l.blend).join(\", \"),\n }}\n />\n ))}\n </div>\n </div>\n );\n}\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport { ItemList } from \"./Items\";\nimport Selector from \"./Selector\";\nimport ActionPane from \"./ActionPane\";\nimport PanZoom from \"./PanZoom\";\nimport Selection from \"./Selection\";\nimport { DEFAULT_BOARD_MAX_SIZE } from \"@/settings\";\nimport useDim from \"./useDim\";\nimport useMainStore from \"./store/main\";\n\nimport { useResizeObserver } from \"@react-hookz/web\";\nimport { css } from \"goober\";\nimport CursorPane from \"./Cursors/CursorPane\";\nimport WorldBackground from \"./WorldBackground\";\n\nconst NullWrapper = ({ children }) => children;\nconst emptyTemplates = {};\n\nconst defaultStyle = {\n overflow: \"hidden\",\n position: \"absolute\",\n inset: 0,\n};\n\nconst Board = ({\n moveFirst = true,\n style,\n wrapperStyle,\n itemTemplates = emptyTemplates,\n // Deprecated compatibility prop. The logical canvas is unbounded.\n boardSize = DEFAULT_BOARD_MAX_SIZE,\n backgroundTileSize,\n children,\n showResizeHandle = false,\n Wrapper = NullWrapper,\n}) => {\n const boardWrapperRef = React.useRef(null);\n const [uid, updateConfiguration] = useMainStore((state) => [\n state.config.uid,\n state.updateConfiguration,\n ]);\n const [translateX, translateY, scale, rotate] = useMainStore(\n (state) => [\n state.boardState.translateX,\n state.boardState.translateY,\n state.boardState.scale,\n state.boardState.rotate,\n ]\n );\n const { updateItemExtent } = useDim();\n\n const boardStyle = {\n userSelect: \"none\",\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n transformOrigin: \"0 0\",\n transform: `translate(${translateX}px, ${translateY}px) rotate(${rotate}deg) scale(${scale})`,\n pointerEvents: \"none\",\n };\n\n\n React.useEffect(() => {\n // Chrome-related issue.\n // Making the wheel event non-passive, which allows to use preventDefault() to prevent\n // the browser original zoom and therefore allowing our custom one.\n // More detail at https://github.com/facebook/react/issues/14856\n const cancelWheel = (event) => {\n if (boardWrapperRef.current?.contains(event.target)) event.preventDefault();\n };\n\n document.body.addEventListener(\"wheel\", cancelWheel, { passive: false });\n\n return () => {\n document.body.removeEventListener(\"wheel\", cancelWheel);\n };\n }, []);\n\n React.useEffect(() => {\n updateConfiguration({\n boardWrapper: boardWrapperRef.current,\n });\n }, [updateConfiguration]);\n\n React.useEffect(() => {\n if (!uid) {\n updateConfiguration({\n uid: nanoid(),\n });\n }\n }, [uid, updateConfiguration]);\n\n React.useEffect(() => {\n updateConfiguration({\n itemTemplates,\n boardSize,\n showResizeHandle,\n });\n }, [itemTemplates, boardSize, showResizeHandle, updateConfiguration]);\n\n React.useEffect(() => {\n updateConfiguration({\n boardWrapperRect: boardWrapperRef.current.getBoundingClientRect(),\n });\n updateItemExtent();\n // Hack to update item extent on load\n setTimeout(updateItemExtent, 2000);\n }, [updateConfiguration, updateItemExtent]);\n\n useResizeObserver(boardWrapperRef, () => {\n if (!boardWrapperRef.current) {\n return;\n }\n updateConfiguration({\n boardWrapperRect: boardWrapperRef.current.getBoundingClientRect(),\n });\n });\n\n const boardWrapperClass = css({ ...defaultStyle, ...wrapperStyle });\n\n return (\n <div\n ref={boardWrapperRef}\n id={uid}\n className={`sync-board ${boardWrapperClass}`}\n >\n <WorldBackground style={style} tileSizeOverride={backgroundTileSize} />\n <CursorPane>\n <Selector moveFirst={moveFirst}>\n <PanZoom moveFirst={moveFirst}>\n <ActionPane moveFirst={moveFirst}>\n <Wrapper>\n <div\n onContextMenu={(e) => {\n e.preventDefault();\n }}\n style={boardStyle}\n className={`board-pane${scale < 0.5 ? \" board-pane__far\" : \"\"}`}\n >\n <ItemList />\n <div style={{ pointerEvents: \"auto\" }}>{children}</div>\n </div>\n </Wrapper>\n </ActionPane>\n </PanZoom>\n </Selector>\n </CursorPane>\n <Selection />\n </div>\n );\n};\n\nexport default Board;\n","export { default as useWire } from \"@/hooks/useWire\";\n\nexport { default as useItems } from \"@/board/Items/useItems\";\nexport { default as useDebouncedItems } from \"@/board/Items/useDebouncedItems\";\nexport { default as useSelectedItems } from \"@/board/Items/useSelectedItems\";\nexport { default as useGetSelectedItems } from \"@/board/Items/useGetSelectedItems\";\nexport { default as useItemActions } from \"@/board/Items/useItemActions\";\nexport { default as useItemInteraction } from \"@/board/Items/useItemInteraction\";\nexport { default as useAvailableActions } from \"@/board/Items/useAvailableActions\";\n\nexport { default as useSelectionBox } from \"@/board/useSelectionBox\";\n\nexport { useUsers } from \"@/users\";\n\nexport { default as useBoardConfig } from \"@/board/useBoardConfig\";\nexport { default as useBoardState } from \"@/board/useBoardState\";\nexport { default as useBoardPosition } from \"@/board/useDim\";\nexport { default as useSessionInfo } from \"@/board/useSessionInfo\";\n\nexport { default as useMessage } from \"@/message/useMessage\";\n\nexport { default as BoardWrapper } from \"@/BoardWrapper\";\nexport { default as RoomWrapper } from \"@/RoomWrapper\";\nexport { default as Board } from \"@/board/Board\";\n\nimport React from \"react\";\nimport { setup } from \"goober\";\n\nsetup(React.createElement);\n"],"x_google_ignoreList":[0,1,2,15,27,28,39],"mappings":";;;;;;;;;;;;;;;;aAAW,IACT,oECgDS,KAAU,IAAO,OAAO;CACjC,IAAI,IAAK,IACL,IAAQ,OAAO,gBAAgB,IAAI,WAAY,KAAQ,CAAE,CAAC;CAC9D,OAAO,MACL,KAAM,EAAY,EAAM,KAAQ;CAElC,OAAO;AACT,GCtDM,KAAkB,KAClB,KAAe,MACnB,OAAO,KAAU,YACjB,EAAM,SAAS,KACf,EAAM,UAAU,MAChB,CAAC,yBAAyB,KAAK,CAAK,GAEhC,KAAmB,GAAO,MAAU;CACxC,IAAI,CAAC,EAAY,CAAK,GAAG,MAAU,MAAM,WAAW,GAAO;AAC7D,GAEM,IAAN,MAAW;CACT,YAAY,GAAQ,GAAM,IAAS,MAAM;EAgBvC,AAfA,KAAK,UAAU,GACf,KAAK,SAAS,GACd,KAAK,OAAO,GACZ,KAAK,eAAe,OACZ;GAGJ,AAFA,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,UAAU,GACxC,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,YAAY,GAC1C,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,OAAO;EACvC,CACF,GACA,KAAK,QAAQ,IAEb,KAAK,gBAAgB,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AE,GAAG;EAAc,GAAG;CAAa,CAAC;CAElE,OACE,kBAAC,OAAD;EACE,KAAK;EACL,IAAI;EACJ,WAAW,cAAc;EAH3B,UAAA;GAKE,kBAAC,IAAD;IAAwB;IAAO,kBAAkB;GAAqB,CAAA;GACtE,kBAAC,IAAD,EAAA,UACE,kBAAC,IAAD;IAAqB;IACnB,UAAA,kBAAC,IAAD;KAAoB;KAClB,UAAA,kBAAC,IAAD;MAAuB;MACrB,UAAA,kBAAC,GAAD,EAAA,UACE,kBAAC,OAAD;OACE,gBAAgB,MAAM;QACpB,EAAE,eAAe;OACnB;OACA,OAAO;OACP,WAAW,aAAa,IAAQ,KAAM,qBAAqB;OAL7D,UAAA,CAOE,kBAAC,IAAD,CAAW,CAAA,GACX,kBAAC,OAAD;QAAK,OAAO,EAAE,eAAe,OAAO;QAAI;OAAc,CAAA,CACnD;MACE,CAAA,EAAA,CAAA;KACC,CAAA;IACL,CAAA;GACD,CAAA,EACA,CAAA;GACZ,kBAAC,IAAD,CAAY,CAAA;EACT;;AAET;;;AC7HA,GAAM,EAAM,aAAa"}
1
+ {"version":3,"file":"react-sync-board.js","names":[],"sources":["../node_modules/nanoid/url-alphabet/index.js","../node_modules/nanoid/index.browser.js","../node_modules/wire.io/src/client.js","../src/lib/hooks/useWire.jsx","../src/lib/utils.js","../src/lib/board/store/synced.jsx","../src/lib/board/Items/useItems.js","../src/lib/board/Items/useDebouncedItems.js","../src/lib/settings.js","../src/lib/board/store/main.jsx","../src/lib/board/Items/useSelectedItems.js","../src/lib/board/Items/useGetSelectedItems.js","../src/lib/board/useDim.js","../src/lib/board/Items/useItemInteraction.js","../src/lib/board/Items/useItemActions.js","../node_modules/fast-deep-equal/es6/index.js","../src/lib/board/Items/useAvailableActions.js","../src/lib/board/useSelectionBox.js","../src/lib/users/store.jsx","../src/lib/users/useUsers.jsx","../src/lib/board/useBoardConfig.jsx","../src/lib/board/useBoardState.js","../src/lib/board/useSessionInfo.jsx","../src/lib/message/store.jsx","../src/lib/message/useMessage.js","../src/lib/BoardWrapper.jsx","../src/lib/RoomWrapper.jsx","../node_modules/goober/dist/goober.modern.js","../node_modules/fast-deep-equal/index.js","../src/lib/board/Gesture.jsx","../src/lib/board/Items/ResizeHandler.jsx","../src/lib/board/Items/Item.jsx","../src/lib/board/Items/ItemList.jsx","../src/lib/board/Selector.jsx","../src/lib/board/ActionPane.jsx","../src/lib/board/useMousePosition.js","../src/lib/board/usePositionNavigator.jsx","../src/lib/board/PanZoom.jsx","../src/lib/board/Selection.jsx","../node_modules/color2k/dist/index.exports.import.es.mjs","../src/lib/board/Cursors/Cursor.jsx","../src/lib/board/Cursors/CursorPane.jsx","../src/lib/board/background.js","../src/lib/board/WorldBackground.jsx","../src/lib/board/Board.jsx","../src/lib/index.js"],"sourcesContent":["export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","\n\nimport { urlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet }\n\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\n\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += urlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import { nanoid } from 'nanoid';\n\nconst MAX_NAME_LENGTH = 128;\nconst isValidName = (value) =>\n typeof value === 'string' &&\n value.length > 0 &&\n value.length <= MAX_NAME_LENGTH &&\n !/[\\u0000-\\u001f\\u007f]/u.test(value);\n\nconst assertValidName = (value, label) => {\n if (!isValidName(value)) throw new Error(`Invalid ${label}`);\n};\n\nclass Wire {\n constructor(socket, room, userId = null) {\n this._socket = socket;\n this.userId = userId;\n this.room = room;\n this.toUnregister = [\n () => {\n this._socket.off(`${this.room}.isMaster`);\n this._socket.off(`${this.room}.roomJoined`);\n this._socket.off(`${this.room}._call`);\n },\n ];\n this._left = false;\n\n this.registeredRPC = Object.create(null);\n\n // Receive server RPC calls\n this._socket.on(`${this.room}._call`, async ({ callId, name, params }) => {\n try {\n if (!Object.hasOwn(this.registeredRPC, name)) {\n throw new Error(`Function ${name} is not registered`);\n }\n const result = await this.registeredRPC[name](params);\n socket.emit(`${this.room}._result.${callId}`, {\n ok: result ? result : null,\n });\n } catch (err) {\n socket.emit(`${this.room}._result.${callId}`, {\n err: `${err.message}`,\n });\n }\n });\n }\n\n /**\n * Call a server procedure.\n *\n * @param {string} action name of the operation to call on the server.\n * @param {*} params the params of the action.\n * @returns the result of the call.\n */\n async _callServerRPC(name, params) {\n const callId = nanoid();\n return new Promise((resolve, reject) => {\n this._socket.once(`${this.room}._result.${callId}`, (result) => {\n if (Object.hasOwn(result, 'ok')) {\n resolve(result.ok);\n } else {\n reject(result.err);\n }\n });\n this._socket.emit(`${this.room}._call`, { callId, name, params });\n });\n }\n\n /**\n * Leave current room\n * @param {string} room name.\n */\n leave() {\n this._left = true;\n this.toUnregister.forEach((callback) => {\n callback();\n });\n this._socket.emit(`${this.room}.leave`);\n }\n\n /**\n * Send an event to all other client in room. Also to self if true.\n * @param {string} name Name of event\n * @param {*} params arguments of event\n * @param {boolean} self if true, the publish get the event too\n */\n publish(name, params, self = false) {\n assertValidName(name, 'event name');\n this._socket.emit(`${this.room}.publish`, { name, params, self });\n }\n\n /**\n * Subscribe to an event.\n * @param {string} event Name of event\n * @param {function} callback Called when the event is received. First param\n * of the function is the params sent with the event.\n */\n subscribe(event, callback) {\n assertValidName(event, 'event name');\n if (typeof callback !== 'function') throw new TypeError('Invalid callback');\n this._socket.on(`${this.room}.${event}`, callback);\n\n const unregisterCallback = () => {\n this._socket.off(`${this.room}.${event}`, callback);\n };\n\n this.toUnregister.push(unregisterCallback);\n\n return unregisterCallback;\n }\n\n /**\n * Register a new RPC function.\n * @param {string} name of function\n * @param {function} callback the function that handle the function result\n * @param {object} params the configuration of the RPC. For now only `invoke`\n * parameter is allowed with the following values:\n * - 'single' for a RPC that can be registered only once.\n * - 'first' The first registered client is called.\n * - 'last' The last registered client is called.\n * - 'random' A random RPC is called.\n */\n async register(name, callback, { invoke = 'single' } = {}) {\n assertValidName(name, 'RPC name');\n if (typeof callback !== 'function') throw new TypeError('Invalid callback');\n if (!['single', 'first', 'last', 'random'].includes(invoke)) {\n throw new Error('Invalid invoke mode');\n }\n // Add to locally registered callback\n\n this.registeredRPC[name] = callback;\n\n await this._callServerRPC('register', {\n name,\n invoke,\n });\n\n // Return unregister callback\n const unregisterCallback = () => {\n if (this.registeredRPC[name] === callback) {\n delete this.registeredRPC[name];\n return this._callServerRPC('unregister', { name });\n }\n };\n\n this.toUnregister.push(unregisterCallback);\n\n return unregisterCallback;\n }\n\n /**\n * Call a previously registered function with `params` arguments.\n * @param {string} name of function\n * @param {*} params parameters of the called function.\n */\n async call(name, params) {\n return await this._callServerRPC('call', { name, params });\n }\n}\n\n/**\n * Join a wire.io room.\n * @param {socket} socket socket.io instance.\n * @param {string} name of the room\n * @param {function} onMaster is called when the client become the master of\n * the room, i.e. the first client or the next one if the first quit.\n * @param {function} onJoined is called on each connection, reconnection after\n * wire.io is initialized.\n * @param {string} userId (optional) to force userId.\n */\nexport const joinWire = ({\n socket,\n room,\n onJoined = () => {},\n onMaster = () => {},\n userId = null,\n}) => {\n assertValidName(room, 'room name');\n if (userId !== null && userId !== undefined) {\n assertValidName(userId, 'user id');\n }\n const WireRoom = new Wire(socket, room, userId);\n return new Promise((resolve) => {\n // Avoid multiple join\n let waitForResponse = true;\n socket.on(`${room}.isMaster`, () => {\n if (WireRoom._left) {\n return;\n }\n onMaster(room);\n });\n\n socket.on(`${room}.roomJoined`, (userId) => {\n if (WireRoom._left) {\n return;\n }\n WireRoom.userId = userId;\n waitForResponse = false;\n onJoined(WireRoom);\n resolve(WireRoom);\n });\n\n // Rejoin on reconnection\n socket.on('connect', () => {\n // If joined already called or room left\n // we quit\n if (WireRoom._left || waitForResponse) {\n return;\n }\n // Restore events with same userId\n socket.emit('joinSuperSocket', {\n room,\n userId: WireRoom.userId,\n });\n });\n socket.emit('joinSuperSocket', { room, userId });\n });\n};\n\nexport default joinWire;\n","import React, { useContext } from \"react\";\nimport { joinWire } from \"wire.io\";\n\nconst Context = React.createContext();\n\nexport const DefaultLoading = () => {\n return (\n <div\n style={{\n position: \"absolute\",\n top: \"0\",\n bottom: \"0\",\n width: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h2>🌀 Loading...</h2>\n </div>\n );\n};\n\nexport const WireProvider = ({\n socket,\n room,\n channel = \"default\",\n LoadingComponent = DefaultLoading,\n children,\n}) => {\n const [joined, setJoined] = React.useState(false);\n const [isMaster, setIsMaster] = React.useState(false);\n const [wire, setWire] = React.useState(null);\n const roomRef = React.useRef(null);\n const mountedRef = React.useRef(false);\n const existingC2C = useContext(Context);\n const connectingRef = React.useRef(false);\n\n React.useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n React.useEffect(() => {\n if (!socket) {\n return;\n }\n\n const disconnect = () => {\n console.log(`Disconnected from ${channel}…`);\n if (!mountedRef.current) return;\n setJoined(false);\n setIsMaster(false);\n };\n\n socket.on(\"disconnect\", disconnect);\n return () => {\n socket.off(\"disconnect\", disconnect);\n };\n }, [channel, socket]);\n\n React.useEffect(() => {\n // Connect\n if (!socket) {\n return;\n }\n if (!socket.connected) {\n socket.connect();\n }\n console.log(`Try to connect to wire ${room} on channel ${channel}`);\n if (!connectingRef.current) {\n connectingRef.current = true;\n joinWire({\n socket,\n room,\n onMaster: () => {\n console.log(`Is now master on channel ${channel}…`);\n if (!mountedRef.current) return;\n setIsMaster(true);\n },\n onJoined: (newRoom) => {\n console.log(`Connected on channel ${channel}…`);\n roomRef.current = newRoom;\n\n if (!mountedRef.current) return;\n setWire(newRoom);\n setJoined(true);\n },\n });\n }\n\n return () => {\n roomRef.current?.leave();\n };\n }, [channel, room, socket]);\n\n\n if (!joined || !wire) {\n return <LoadingComponent />;\n }\n\n return (\n <Context.Provider\n value={{ ...existingC2C, [channel]: { wire, joined, isMaster, room } }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nconst useWire = (channel = \"default\") => {\n const channels = useContext(Context) || {};\n return channels[channel];\n};\n\nexport default useWire;\n","/**\n * Check if element or parent has className.\n * @param {DOMElement} element\n * @param {string} className\n */\nexport const hasClass = (element, className) =>\n element.classList && element.classList.contains(className);\n\nexport const insideClass = (element, className) => {\n if (hasClass(element, className)) {\n return element;\n }\n if (!element.parentNode) {\n return false;\n }\n return insideClass(element.parentNode, className);\n};\n\nexport const distance = ([x1, y1], [x2, y2]) => {\n const distanceX = Math.abs(x1 - x2);\n const distanceY = Math.abs(y1 - y2);\n\n return Math.hypot(distanceX, distanceY);\n};\n\nexport const rotateCoordinates = (x, y, angle) => {\n const angleInRadians = (angle * Math.PI) / 180;\n\n const xRotated = x * Math.cos(angleInRadians) - y * Math.sin(angleInRadians);\n const yRotated = x * Math.sin(angleInRadians) + y * Math.cos(angleInRadians);\n\n return [xRotated, yRotated];\n};\n\nexport const transformFrom = (\n [x, y],\n { scale, rotate, translateX, translateY }\n) => {\n const xScaled = (x - translateX) / scale;\n const yScaled = (y - translateY) / scale;\n\n return rotateCoordinates(xScaled, yScaled, -rotate);\n};\n\nexport const transformTo = (\n [x, y],\n { scale, rotate, translateX, translateY }\n) => {\n const [xInvRotated, yInvRotated] = rotateCoordinates(x, y, rotate);\n return [xInvRotated * scale + translateX, yInvRotated * scale + translateY];\n};\n\nexport const intersectSegmentCircle = (p1, p2, circle, radius) => {\n const Ax = p1.x,\n Ay = p1.y;\n const Bx = p2.x,\n By = p2.y;\n const Cx = circle.x,\n Cy = circle.y;\n\n const Dx = Bx - Ax,\n Dy = By - Ay;\n const Ex = Ax - Cx,\n Ey = Ay - Cy;\n\n const a = Dx * Dx + Dy * Dy;\n const b = 2 * (Ex * Dx + Ey * Dy);\n const c = Ex * Ex + Ey * Ey - radius * radius;\n\n const discriminant = b * b - 4 * a * c;\n\n if (discriminant < 0) {\n return []; // No intersection\n }\n\n const t1 = (-b + Math.sqrt(discriminant)) / (2 * a);\n const t2 = (-b - Math.sqrt(discriminant)) / (2 * a);\n\n const intersections = [];\n\n if (t1 >= 0 && t1 <= 1) {\n intersections.push({ x: Ax + t1 * Dx, y: Ay + t1 * Dy });\n }\n\n if (t2 >= 0 && t2 <= 1) {\n intersections.push({ x: Ax + t2 * Dx, y: Ay + t2 * Dy });\n }\n\n return intersections;\n};\n\nexport const getParent = (initialElem, selector) => {\n for (\n let elem = initialElem;\n elem && elem !== document;\n elem = elem.parentNode\n ) {\n if (selector(elem)) return elem;\n }\n return null;\n};\n\nexport const isPointInsideRect = (point, rect) =>\n point.x > rect.left &&\n point.x < rect.left + rect.width &&\n point.y > rect.top &&\n point.y < rect.top + rect.height;\n\nexport const isItemInsideRect = (itemElement, rect) => {\n const fourElem = Array.from(itemElement.querySelectorAll(\".corner\"));\n\n return fourElem.every((corner) => {\n const { top: y, left: x } = corner.getBoundingClientRect();\n return isPointInsideRect({ x, y }, rect);\n });\n};\n\nexport const isItemInsideElement = (itemElement, otherElem) => {\n const rect = otherElem.getBoundingClientRect();\n\n const result = isItemInsideRect(itemElement, rect);\n return result;\n};\n\nexport const getItemElem = (uid, itemId) => {\n try {\n const elem = document.getElementById(`${uid}__${itemId}`);\n return elem;\n } catch {\n console.error(\n `Error while getting item with id ${itemId} inside wrapper`,\n uid\n );\n return undefined;\n }\n};\n\nexport const getIdFromElem = (elem) => {\n const value = elem?.dataset?.id;\n if (!value) {\n // eslint-disable-next-line no-console\n console.error(\n \"getIdFromElem call fails\",\n elem,\n JSON.stringify(elem?.dataset),\n elem?.dataset?.id\n );\n }\n return value;\n};\n\nexport const getItemsBoundingBox = (itemIds, uid) => {\n const result = itemIds.reduce((prev, itemId) => {\n const elem = getItemElem(uid, itemId);\n\n if (!elem) {\n if (!prev) {\n return null;\n }\n return prev;\n }\n\n const { left, right, top, bottom } = elem.getBoundingClientRect();\n\n let boundingBox;\n\n if (!prev) {\n boundingBox = {\n left,\n top,\n right,\n bottom,\n };\n } else {\n boundingBox = prev;\n }\n\n boundingBox.left = Math.min(left, boundingBox.left);\n boundingBox.top = Math.min(top, boundingBox.top);\n boundingBox.right = Math.max(right, boundingBox.right);\n boundingBox.bottom = Math.max(bottom, boundingBox.bottom);\n\n return boundingBox;\n }, null);\n\n if (!result) {\n return result;\n }\n\n result.width = result.right - result.left;\n result.height = result.bottom - result.top;\n\n return result;\n};\n\nconst getLinkedItemsRecursive = (itemMap, itemIds, alreadyMet = null) => {\n if (alreadyMet === null) {\n alreadyMet = new Set();\n }\n\n if (!Array.isArray(itemIds) || itemIds.length === 0) {\n return [];\n }\n\n return itemIds\n .map((itemId) => {\n if (alreadyMet.has(itemId)) {\n return [];\n } else {\n alreadyMet.add(itemId);\n if (itemMap[itemId]) {\n // If the item has been removed but not from linked list\n return [\n itemId,\n ...getLinkedItemsRecursive(\n itemMap,\n itemMap[itemId].linkedItems,\n alreadyMet\n ),\n ];\n } else {\n return [];\n }\n }\n })\n .flat();\n};\n\nexport const getLinkedItems = (itemMap, orderedItemIds, itemIds) => {\n const linkedItems = new Set(getLinkedItemsRecursive(itemMap, itemIds));\n return orderedItemIds.filter((itemId) => linkedItems.has(itemId));\n};\n\nexport const snapToGrid = (\n { x, y, width, height },\n { type = \"grid\", size = 1, offset = { x: 0, y: 0 } }\n) => {\n const [centerX, centerY] = [\n x + width / 2 - offset.x,\n y + height / 2 - offset.y,\n ];\n\n let newX;\n let newY;\n let sizeX;\n let sizeY;\n let px1;\n let px2;\n let py1;\n let py2;\n let diff1;\n let diff2;\n const h = size / 1.1547;\n\n switch (type) {\n case \"grid\":\n newX = Math.round(centerX / size) * size;\n newY = Math.round(centerY / size) * size;\n break;\n case \"hexH\":\n sizeX = 2 * h;\n sizeY = 3 * size;\n px1 = Math.round(centerX / sizeX) * sizeX;\n py1 = Math.round(centerY / sizeY) * sizeY;\n\n px2 = px1 > centerX ? px1 - h : px1 + h;\n py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;\n\n diff1 = Math.hypot(...[px1 - centerX, py1 - centerY]);\n diff2 = Math.hypot(...[px2 - centerX, py2 - centerY]);\n\n if (diff1 < diff2) {\n newX = px1;\n newY = py1;\n } else {\n newX = px2;\n newY = py2;\n }\n break;\n case \"hexV\":\n sizeX = 3 * size;\n sizeY = 2 * h;\n px1 = Math.round(centerX / sizeX) * sizeX;\n py1 = Math.round(centerY / sizeY) * sizeY;\n\n px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;\n py2 = py1 > centerY ? py1 - h : py1 + h;\n\n diff1 = Math.hypot(...[px1 - centerX, py1 - centerY]);\n diff2 = Math.hypot(...[px2 - centerX, py2 - centerY]);\n\n if (diff1 < diff2) {\n newX = px1;\n newY = py1;\n } else {\n newX = px2;\n newY = py2;\n }\n break;\n default:\n newX = x + width / 2;\n newY = y + height / 2;\n }\n\n return {\n x: newX + offset.x - width / 2,\n y: newY + offset.y - height / 2,\n };\n};\n\nexport const gridTypes = new Set([\"grid\", \"hexH\", \"hexV\"]);\n\nexport const resolveGridConfig = (boardGrid, itemGrid) => {\n if (itemGrid && gridTypes.has(itemGrid.type)) {\n return itemGrid;\n }\n\n if (boardGrid && gridTypes.has(boardGrid.type)) {\n return boardGrid;\n }\n\n return null;\n};\n\nconst colors = [\n \"#037758\",\n \"#99092a\",\n \"#067070\",\n \"#c6650f\",\n \"#008726\",\n \"#3d7004\",\n \"#348402\",\n \"#057f58\",\n \"#b58612\",\n \"#c44c01\",\n \"#0a7704\",\n \"#0e910e\",\n \"#027377\",\n \"#c99e02\",\n \"#054160\",\n \"#157a01\",\n \"#b10de2\",\n \"#0d6289\",\n \"#bc5d03\",\n \"#ba0cd1\",\n \"#d39f10\",\n \"#0c4c7a\",\n \"#460782\",\n \"#a51f10\",\n \"#cecb10\",\n \"#9b0943\",\n \"#607f0c\",\n \"#007a4b\",\n \"#bf0daa\",\n \"#af0ad8\",\n];\n\nexport const getRandomColor = () =>\n colors[Math.floor(Math.random() * colors.length)];\n\nconst debug = false;\n\nexport const syncMiddleware =\n ({ wire, storeName, noSync = [], defaultValue }, config) =>\n (set, get, api) => {\n set({ ready: false });\n const unsubs = [];\n const init = async () => {\n try {\n // Try to get the initial value from a peer\n const newValue = await wire.call(`${storeName}_getValue`);\n if (debug) console.log(\"init from peer with value\", newValue);\n set((state) => ({ ...state, ...newValue }));\n } catch {\n //console.log(`No peers for ${storeName}...`);\n if (defaultValue !== undefined) {\n set(defaultValue);\n }\n }\n unsubs.push(\n await wire.register(\n `${storeName}_getValue`,\n () => {\n return Object.fromEntries(\n Object.entries(get()).filter(\n ([key, value]) =>\n typeof value !== \"function\" && !noSync.includes(key)\n )\n );\n },\n { invoke: \"first\" }\n )\n );\n // Register the sync callback\n unsubs.push(\n wire.subscribe(`${storeName}_call`, ([methodName, args]) => {\n if (debug) console.log(\"receive\", methodName, args);\n previousFn[methodName](...args);\n })\n );\n set({ ready: true });\n };\n init();\n\n const result = config(set, get, api);\n const previousFn = { ...result };\n\n const syncResult = Object.fromEntries(\n // Send the update message on all method calls\n Object.entries(result).map(([key, fn]) => {\n if (\n typeof fn === \"function\" &&\n !key.startsWith(\"get\") &&\n !noSync.includes(key)\n ) {\n const newFn = (...args) => {\n if (debug) console.log(\"call\", key, args);\n const result = fn(...args);\n wire.publish(`${storeName}_call`, [key, args]);\n return result;\n };\n return [key, newFn];\n }\n return [key, fn];\n })\n );\n\n syncResult.unsub = () => {\n unsubs.forEach((unsub) => unsub());\n };\n\n return syncResult;\n };\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nexport const itemsStore = (set, get) => ({\n items: {},\n getItems: () => get().items,\n setItems: (newItems) => set({ items: newItems }),\n updateItems: (toUpdate, patch = false) =>\n set((state) => {\n if (patch) {\n const newItems = Object.fromEntries(\n Object.entries(state.items).map(([id, item]) => {\n if (toUpdate[id]) {\n return [id, { ...item, ...toUpdate[id] }];\n } else {\n return [id, item];\n }\n })\n );\n return { items: newItems };\n } else {\n return { items: { ...state.items, ...toUpdate } };\n }\n }),\n moveItems: (itemIds, posDelta) =>\n set(({ items: prevItems }) => {\n const newItems = { ...prevItems };\n itemIds.forEach((id) => {\n const item = prevItems[id];\n\n if (!item) {\n return;\n }\n\n newItems[id] = {\n ...item,\n x: (item.x || 0) + posDelta.x,\n y: (item.y || 0) + posDelta.y,\n moving: true,\n };\n });\n\n return { items: newItems };\n }),\n});\n\nexport const itemIdsStore = (set, get) => ({\n itemIds: [],\n setItemIds: (newValue) => set({ itemIds: newValue }),\n getItemIds: () => get().itemIds,\n insert: (position, value) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue.splice(position, 0, value);\n return { itemIds: newValue };\n }),\n remove: (position) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue.splice(position, 1);\n return { itemIds: newValue };\n }),\n updateItemIds: (position, value) =>\n set((state) => {\n const newValue = [...state.itemIds];\n newValue[position] = value;\n return { itemIds: newValue };\n }),\n updateManyItemIds: (toUpdate) =>\n set((state) => {\n return {\n itemIds: state.itemIds.map((value, index) => {\n if (toUpdate[index] !== undefined) {\n return toUpdate[index];\n } else {\n return value;\n }\n }),\n };\n }),\n});\n\nconst commonStore = (set, get) => ({\n removeItemsById: (itemIdsToRemove) =>\n set((state) => {\n return {\n itemIds: state.itemIds.filter((id) => !itemIdsToRemove.includes(id)),\n items: Object.fromEntries(\n Object.entries(state.items).filter(\n ([id]) => !itemIdsToRemove.includes(id)\n )\n ),\n };\n }),\n getItemList: () => {\n const items = get().items;\n return get().itemIds.map((id) => items[id]);\n },\n setItemList: (itemList) =>\n set({\n items: Object.fromEntries(itemList.map((item) => [item.id, item])),\n itemIds: itemList.map(({ id }) => id),\n }),\n insertItems: (newItems, beforeId) =>\n set((state) => {\n let newItemIds;\n const itemIdsToAdd = newItems.map(({ id }) => id);\n if (beforeId) {\n const insertAt = state.itemIds.findIndex((id) => id === beforeId);\n newItemIds = [...state.itemIds];\n newItemIds.splice(insertAt, 0, ...itemIdsToAdd);\n } else {\n newItemIds = [...state.itemIds, ...itemIdsToAdd];\n }\n\n return {\n items: {\n ...state.items,\n ...Object.fromEntries(newItems.map((item) => [item.id, item])),\n },\n itemIds: newItemIds,\n };\n }),\n});\n\nconst boardStore = (set, get) => ({\n boardConfig: {},\n getBoardConfig: () => get().boardConfig,\n setBoardConfig: (newBoardConfig) => set({ boardConfig: newBoardConfig }),\n updateBoardConfig: (toUpdate) =>\n set((state) => ({ boardConfig: { ...state.boardConfig, ...toUpdate } })),\n});\n\nconst sessionInfoStore = (set, get) => ({\n session: {},\n getSessionInfo: () => get().session,\n setSessionInfo: (newSession) => set({ session: newSession }),\n updateSessionInfo: (toUpdate) =>\n set((state) => ({ session: { ...state.session, ...toUpdate } })),\n});\n\nexport const SyncedStoreProvider = ({ storeName, children, defaultValue }) => {\n const { wire } = useWire(\"room\");\n const [ready, setReady] = React.useState(false);\n const [store] = React.useState(() =>\n createStore(\n syncMiddleware({ wire, storeName, defaultValue }, (...args) => ({\n ...itemsStore(...args),\n ...itemIdsStore(...args),\n ...commonStore(...args),\n ...boardStore(...args),\n ...sessionInfoStore(...args),\n }))\n )\n );\n\n React.useEffect(() => {\n let mounted = true;\n // Wait for ready event\n const unsubscribe = store.subscribe((newValue) => {\n if (newValue.ready) {\n // No need to listen anymore\n unsubscribe();\n if (mounted) {\n setReady(true);\n }\n }\n });\n () => {\n mounted = false;\n unsubscribe();\n };\n }, [store]);\n\n if (!ready) {\n return null;\n }\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedStore = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useItems = () => {\n const [itemIds, items] = useSyncedStore((state) => [\n state.itemIds,\n state.items,\n ]);\n\n const itemList = React.useMemo(\n () => itemIds.map((id) => items[id]),\n [itemIds, items]\n );\n\n return itemList;\n};\n\nexport default useItems;\n","import React from \"react\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useDebouncedItems = () => {\n const [items, itemIds, getItemList] = useSyncedStore((state) => [\n state.items,\n state.itemIds,\n state.getItemList,\n ]);\n const [debouncedItems, setDebouncedItems] = React.useState(getItemList());\n const [, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n const currentItemList = getItemList();\n startTransition(() => {\n setDebouncedItems(currentItemList);\n });\n }, [items, itemIds, getItemList]);\n\n return debouncedItems;\n};\n\nexport default useDebouncedItems;\n","export const DEFAULT_BOARD_MAX_SIZE = 50000;\n\nexport default { DEFAULT_BOARD_MAX_SIZE };\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { DEFAULT_BOARD_MAX_SIZE } from \"@/settings\";\n\nconst Context = React.createContext();\n\nconst configuration = (set, get) => ({\n config: {\n itemTemplates: {},\n actions: {},\n uid: null,\n itemExtent: { x: 0, y: 0, radius: 0 },\n boardWrapperRect: {},\n boardSize: DEFAULT_BOARD_MAX_SIZE,\n },\n // TODO optimize when same values as before\n updateConfiguration: (toUpdate) =>\n set((state) => ({ config: { ...state.config, ...toUpdate } })),\n getConfiguration: () => get().config,\n});\nconst boardState = (set, get) => ({\n boardState: {\n movingItems: false,\n selecting: false,\n zooming: false,\n panning: false,\n translateX: 0,\n translateY: 0,\n scale: 1,\n rotate: 0,\n },\n // TODO optimize when same values as before\n updateBoardState: (toUpdate) =>\n set((state) => ({ boardState: { ...state.boardState, ...toUpdate } })),\n getBoardState: () => get().boardState,\n});\n\nconst itemInteractions = (set, get) => ({\n interactions: {},\n getInteractions: () => get().interactions,\n register: (interaction, callback) =>\n set((state) => {\n const nextInteraction = [...(state.interactions[interaction] || [])];\n nextInteraction.push(callback);\n return {\n interactions: { ...state.interactions, [interaction]: nextInteraction },\n };\n }),\n unregister: (interaction, callback) =>\n set((state) => {\n const nextInteraction = (state.interactions[interaction] || []).filter(\n (c) => c !== callback\n );\n return {\n interactions: { ...state.interactions, [interaction]: nextInteraction },\n };\n }),\n callInteractions: (interaction, itemIds) => {\n if (!get().interactions[interaction]) return;\n get().interactions[interaction].forEach((callback) => {\n setTimeout(() => callback(itemIds), 0);\n });\n },\n});\n\nconst selection = (set, get) => ({\n selection: [],\n setSelection: (idsToSelect) =>\n set((state) => {\n if (JSON.stringify(state.selection) !== JSON.stringify(idsToSelect)) {\n return { selection: idsToSelect };\n }\n return {};\n }),\n getSelection: () => get().selection,\n select: (idsToAdd) =>\n set((state) => ({\n selection: [...state.selection, ...idsToAdd],\n })),\n unselect: (itemsIdToRemove) =>\n set((state) => ({\n selection: state.selection.filter((id) => !itemsIdToRemove.includes(id)),\n })),\n clear: () =>\n set((state) => {\n if (state.selection.length > 0) {\n return { selection: [] };\n } else {\n return {};\n }\n }),\n reverse: () =>\n set((state) => {\n const reversed = [...state.selection];\n reversed.reverse();\n return { selection: reversed };\n }),\n selectionBox: null,\n setSelectionBox: (newSelectionBox) =>\n set((state) => {\n const prevBB = state.selectionBox;\n if (\n !prevBB ||\n !newSelectionBox ||\n prevBB.top !== newSelectionBox.top ||\n prevBB.left !== newSelectionBox.left ||\n prevBB.width !== newSelectionBox.width ||\n prevBB.height !== newSelectionBox.height\n ) {\n return { selectionBox: newSelectionBox };\n }\n return {};\n }),\n});\n\nexport const MainStoreProvider = ({ children }) => {\n const [store] = React.useState(() =>\n createStore((...args) => ({\n ...configuration(...args),\n ...boardState(...args),\n ...itemInteractions(...args),\n ...selection(...args),\n }))\n );\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useMainStore = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n\nexport default useMainStore;\n","import useMainStore from \"../store/main\";\n\nconst useSelectedItems = () => {\n const [selection] = useMainStore((state) => [state.selection]);\n return selection;\n};\n\nexport default useSelectedItems;\n","import useMainStore from \"../store/main\";\n\nconst useGetSelectedItems = () => {\n const [getSelection] = useMainStore((state) => [state.getSelection]);\n return getSelection;\n};\n\nexport default useGetSelectedItems;\n","import React from \"react\";\nimport { useDebouncedCallback } from \"@react-hookz/web\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport {\n distance,\n getItemElem,\n transformFrom,\n transformTo,\n} from \"@/utils\";\nimport useMainStore from \"./store/main\";\n\nconst MIN_SIZE = 1000;\nconst SCALE_TOLERANCE = 0.8;\n\nlet debug = false;\n\n/**\n * Return new board positions fixed to fit inside the board and not too far from the\n * item extent.\n */\nconst useDim = () => {\n const [\n getBoardState,\n updateBoardState,\n itemExtentGlobal,\n getConfiguration,\n updateConfiguration,\n ] = useMainStore((state) => [\n state.getBoardState,\n state.updateBoardState,\n state.config.itemExtent,\n state.getConfiguration,\n state.updateConfiguration,\n ]);\n const scaleBoundariesRef = React.useRef([0.15, 5]);\n\n const [getItemList] = useSyncedStore((state) => [state.getItemList]);\n\n const getDim = React.useCallback(() => {\n const { translateX, translateY, scale, rotate } = getBoardState();\n return { translateX, translateY, scale, rotate };\n }, [getBoardState]);\n\n const fromWrapperToBoard = React.useCallback(\n (x, y) => {\n return transformFrom([x, y], getBoardState());\n },\n [getBoardState]\n );\n\n const fromBoardToWrapper = React.useCallback(\n (x, y) => {\n return transformTo([x, y], getBoardState());\n },\n [getBoardState]\n );\n\n const vectorFromWrapperToBoard = React.useCallback(\n (x, y) => {\n const { scale, rotate } = getBoardState();\n\n return transformFrom([x, y], {\n translateX: 0,\n translateY: 0,\n rotate,\n scale,\n });\n },\n [getBoardState]\n );\n\n /**\n * Clamp scale to boundaries limits.\n */\n const clampScale = React.useCallback((scale) => {\n if (scale > scaleBoundariesRef.current[1]) {\n return scaleBoundariesRef.current[1];\n }\n\n if (scale < scaleBoundariesRef.current[0]) {\n return scaleBoundariesRef.current[0];\n }\n return scale;\n }, []);\n\n /**\n * Set board position safely by avoiding to go out of the dedicated space.\n */\n const setDimSafe = React.useCallback(\n (fn) => {\n const prev = getBoardState();\n\n const {\n translateX,\n translateY,\n scale,\n rotate: newRotate,\n } = {\n ...prev,\n ...fn(prev),\n };\n\n if (debug) console.log(\"New expected values: \", translateX, translateY, scale, newRotate);\n\n const newScale = clampScale(scale);\n\n const newX = translateX;\n const newY = translateY;\n\n if (debug) console.log(\"New fixed values: \", newX, newY, newScale, newRotate);\n\n updateBoardState({\n translateX: Number.isFinite(newX) ? newX : prev.translateX,\n translateY: Number.isFinite(newY) ? newY : prev.translateY,\n scale: Number.isFinite(newScale) ? newScale : clampScale(1),\n rotate: Number.isFinite(newRotate) ? newRotate : prev.rotate,\n });\n },\n [clampScale, getBoardState, updateBoardState]\n );\n\n /**\n * Move the board to the given coordinates.\n */\n const moveBoard = React.useCallback(\n (newTranslatOrFn) => {\n let translateFn = (prev) => ({ ...prev, ...newTranslatOrFn });\n if (typeof newTranslatOrFn === \"function\") {\n translateFn = newTranslatOrFn;\n }\n\n setDimSafe((prev) => ({\n ...prev,\n ...translateFn({\n translateX: prev.translateX,\n translateY: prev.translateY,\n }),\n }));\n },\n [setDimSafe]\n );\n\n /**\n * Zoom to factor centered on the given zoomCenter coordinates.\n *\n * zoomCenter is screen coordinates.\n */\n const zoomToCenter = React.useCallback(\n ({ to, factor }) => {\n const { boardWrapperRect } = getConfiguration();\n\n let center = to;\n\n if (!center) {\n center = {\n x: boardWrapperRect.left + boardWrapperRect.width / 2,\n y: boardWrapperRect.top + boardWrapperRect.height / 2,\n };\n }\n\n const prev = getBoardState();\n\n const newScale = clampScale(prev.scale * factor);\n\n const centerX = center.x - boardWrapperRect.left;\n const centerY = center.y - boardWrapperRect.top;\n\n const newTx =\n centerX - ((centerX - prev.translateX) * newScale) / prev.scale;\n const newTy =\n centerY - ((centerY - prev.translateY) * newScale) / prev.scale;\n\n setDimSafe((prev) => ({\n ...prev,\n translateX: newTx,\n translateY: newTy,\n scale: newScale,\n }));\n },\n [clampScale, getBoardState, getConfiguration, setDimSafe]\n );\n\n /**\n * Zoom to the given extent. The full extent will be included in the viewport.\n */\n const zoomToExtent = React.useCallback(\n ({ x, y, radius }) => {\n const { rotate } = getBoardState();\n const { boardWrapperRect } = getConfiguration();\n\n const [safeX, safeY, safeRadius] = [x || 0, y||0, radius || 2000]\n\n const scaleX = boardWrapperRect.width / (safeRadius * 2);\n const scaleY = boardWrapperRect.height / (safeRadius * 2);\n\n // The scale that fits in all dimensions with a border around\n const scale = clampScale(Math.min(scaleX, scaleY) * SCALE_TOLERANCE);\n\n\n // We apply the board transformations\n const [translateX, translateY] = transformTo(\n [-safeX, -safeY],\n {\n translateX: boardWrapperRect.width / 2,\n translateY: boardWrapperRect.height / 2,\n scale,\n rotate,\n }\n );\n\n setDimSafe((prev) => ({ ...prev, translateX, translateY, scale }));\n },\n [clampScale, getBoardState, getConfiguration, setDimSafe]\n );\n\n /**\n * Get the board coordinates pointed by the center of the screen.\n */\n const getCenterCoordinates = React.useCallback(() => {\n const { boardWrapperRect } = getConfiguration();\n const [x, y] = fromWrapperToBoard(\n boardWrapperRect.width / 2,\n boardWrapperRect.height / 2\n );\n return {\n x,\n y,\n };\n }, [fromWrapperToBoard, getConfiguration]);\n\n /**\n * Update the extent of all board items.\n */\n const updateItemExtent = React.useCallback(() => {\n // Update item extent\n const items = getItemList();\n const { uid } = getConfiguration();\n\n const newRes = items.reduce(\n (boundingBox, item) => {\n const elem = getItemElem(uid, item.id);\n\n if (elem) {\n boundingBox.left = Math.min(item.x, boundingBox.left);\n boundingBox.top = Math.min(item.y, boundingBox.top);\n\n boundingBox.right = Math.max(\n item.x + elem.offsetWidth,\n boundingBox.right\n );\n boundingBox.bottom = Math.max(\n item.y + elem.offsetHeight,\n boundingBox.bottom\n );\n }\n\n return boundingBox;\n },\n {\n left: Infinity,\n top: Infinity,\n right: -Infinity,\n bottom: -Infinity,\n }\n );\n\n if (!Number.isFinite(newRes.left)) {\n updateConfiguration({ itemExtent: { x: 0, y: 0, radius: MIN_SIZE } });\n return;\n }\n\n const final = {\n x: (newRes.right + newRes.left) / 2,\n y: (newRes.bottom + newRes.top) / 2,\n };\n\n final.radius = Math.max(\n distance([final.x, final.y], [newRes.left, newRes.top]),\n MIN_SIZE\n );\n\n updateConfiguration({ itemExtent: final });\n }, [getConfiguration, getItemList, updateConfiguration]);\n\n /**\n * Rotate the board to the given angle in degrees. If a function is given, it is\n * called with the previous angle as parameter and should return a new angle.\n */\n const rotateBoard = React.useCallback(\n (newAngleOrFn) => {\n let applyRotate = () => newAngleOrFn;\n if (typeof newAngleOrFn === \"function\") {\n applyRotate = newAngleOrFn;\n }\n\n setDimSafe((prev) => ({ ...prev, rotate: applyRotate(prev.rotate) }));\n\n // Zoom to new extent to not being lost\n updateItemExtent();\n zoomToExtent(itemExtentGlobal);\n },\n [itemExtentGlobal, setDimSafe, updateItemExtent, zoomToExtent]\n );\n\n const debouncedUpdateItemExtent = useDebouncedCallback(\n () => updateItemExtent(),\n [updateItemExtent],\n 200\n );\n\n React.useEffect(() => {\n window.debugUpdateExtent = () => updateItemExtent();\n window.debugDisplayExtent = () =>\n console.log(getConfiguration().itemExtent);\n window.debugSetDebug = () => {\n debug = true;\n }\n }, [getConfiguration, updateItemExtent]);\n\n return {\n setDim: setDimSafe,\n rotateBoard,\n moveBoard,\n getDim,\n zoomTo: zoomToCenter,\n zoomToCenter,\n zoomToExtent,\n getCenter: getCenterCoordinates,\n updateItemExtent: debouncedUpdateItemExtent,\n vectorFromWrapperToBoard,\n fromWrapperToBoard,\n fromBoardToWrapper,\n };\n};\n\nexport default useDim;\n","import React from \"react\";\nimport useMainStore from \"../store/main\";\n\nconst useItemInteraction = (interaction) => {\n const [registerInStore, unregister, callInteractions] = useMainStore(\n ({ register, unregister, callInteractions }) => [\n register,\n unregister,\n callInteractions,\n ]\n );\n\n const register = React.useCallback(\n (callback) => {\n registerInStore(interaction, callback);\n return () => {\n unregister(interaction, callback);\n };\n },\n [interaction, registerInStore, unregister]\n );\n\n const call = React.useCallback(\n (itemIds) => {\n callInteractions(interaction, itemIds);\n },\n [callInteractions, interaction]\n );\n\n return { register, call };\n};\n\nexport default useItemInteraction;\n","import React from \"react\";\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nimport useDim from \"../useDim\";\n\nimport {\n getItemElem,\n isPointInsideRect,\n insideClass,\n hasClass,\n snapToGrid,\n resolveGridConfig,\n getLinkedItems,\n} from \"@/utils\";\n\nimport useItemInteraction from \"./useItemInteraction\";\nimport useMainStore from \"../store/main\";\n\nconst useItemActions = () => {\n const { call: callPlaceInteractions } = useItemInteraction(\"place\");\n const { call: callDeleteInteractions } = useItemInteraction(\"delete\");\n const { getCenter, updateItemExtent } = useDim();\n\n const [clearSelection, reverseSelection, unselect, getConfiguration] =\n useMainStore((state) => [\n state.clear,\n state.reverse,\n state.unselect,\n state.getConfiguration,\n ]);\n\n const {\n getItems: getStoreItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems: moveStoreItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n } = useSyncedStore(\n ({\n getItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n }) => ({\n getItems,\n getItemIds,\n setItemIds,\n updateItems,\n moveItems,\n removeItemsById,\n getItemList,\n insertItems,\n setItemList,\n })\n );\n\n const batchUpdateItems = React.useCallback(\n (itemIds, callbackOrItem, patch = false) => {\n let callback = callbackOrItem;\n if (typeof callbackOrItem === \"object\") {\n callback = () => callbackOrItem;\n }\n\n const orderedItemIds = getItemIds().filter((id) => itemIds.includes(id));\n\n const prevMap = getStoreItems();\n\n const updateList = orderedItemIds\n .map((id) => {\n const prevItem = prevMap[id];\n if (patch) {\n return [id, callback(prevItem)];\n } else {\n return [id, callback({ ...prevItem })];\n }\n })\n .filter(([, value]) => value);\n\n // If the update list is empty then we are patching and no modifications are\n // applied\n if (updateList.length === 0) {\n return;\n }\n\n const toUpdate = Object.fromEntries(updateList);\n\n updateItems(toUpdate, patch);\n\n updateItemExtent();\n },\n [getItemIds, getStoreItems, updateItemExtent, updateItems]\n );\n\n const setItemListFull = React.useCallback(\n (itemList) => {\n setItemList(itemList);\n\n // Reset item selection as we are changing all items\n clearSelection();\n updateItemExtent();\n },\n [clearSelection, setItemList, updateItemExtent]\n );\n\n const updateItem = React.useCallback(\n (id, callbackOrItem, patch = false) => {\n batchUpdateItems([id], callbackOrItem, patch);\n },\n [batchUpdateItems]\n );\n\n const moveItems = React.useCallback(\n (itemIds, posDelta) => {\n moveStoreItems(\n getLinkedItems(getStoreItems(), getItemIds(), itemIds),\n posDelta\n );\n },\n [getItemIds, getStoreItems, moveStoreItems]\n );\n\n const putItemsOnTop = React.useCallback(\n (itemIdsToMove) => {\n const prevItemIds = getItemIds();\n const filtered = prevItemIds.filter((id) => !itemIdsToMove.includes(id));\n const toBePutOnTop = prevItemIds.filter((id) =>\n itemIdsToMove.includes(id)\n );\n\n setItemIds([...filtered, ...toBePutOnTop]);\n },\n [getItemIds, setItemIds]\n );\n\n const stickOnGrid = React.useCallback(\n (itemIds, boardGrid) => {\n const { uid } = getConfiguration();\n\n batchUpdateItems(\n itemIds,\n (item) => {\n const elem = getItemElem(uid, item.id);\n\n if (!elem) {\n return;\n }\n\n const gridConfig = resolveGridConfig(boardGrid, item.grid);\n\n if (!gridConfig) {\n return;\n }\n\n const newPos = snapToGrid(\n {\n x: item.x,\n y: item.y,\n width: elem.clientWidth,\n height: elem.clientHeight,\n },\n gridConfig\n );\n\n return newPos;\n },\n true\n );\n },\n [getConfiguration, batchUpdateItems]\n );\n\n const placeItems = React.useCallback(\n (itemIds, gridConfig) => {\n // Put all moved items on top\n const itemIdsWithLinkedItems = getLinkedItems(\n getStoreItems(),\n getItemIds(),\n itemIds\n );\n\n putItemsOnTop(itemIdsWithLinkedItems);\n\n // Remove moving state\n batchUpdateItems(itemIdsWithLinkedItems, { moving: false }, true);\n\n stickOnGrid(itemIdsWithLinkedItems, gridConfig);\n callPlaceInteractions(itemIds);\n\n updateItemExtent();\n },\n [\n batchUpdateItems,\n callPlaceInteractions,\n getItemIds,\n getStoreItems,\n putItemsOnTop,\n stickOnGrid,\n updateItemExtent,\n ]\n );\n\n const updateItemOrder = React.useCallback(\n (newOrder) => {\n setItemIds(newOrder);\n },\n [setItemIds]\n );\n\n const reverseItemsOrder = React.useCallback(\n (itemIdsToReverse) => {\n const prevItemIds = getItemIds();\n\n const toBeReversed = prevItemIds.filter((id) =>\n itemIdsToReverse.includes(id)\n );\n const newOrder = prevItemIds.map((itemId) => {\n if (itemIdsToReverse.includes(itemId)) {\n return toBeReversed.pop();\n }\n return itemId;\n });\n\n setItemIds(newOrder);\n\n reverseSelection();\n },\n [getItemIds, reverseSelection, setItemIds]\n );\n\n const swapItems = React.useCallback(\n (fromIds, toIds) => {\n const prevItemMap = getStoreItems();\n\n const newCoordinatesMap = Object.fromEntries(\n toIds.map((toItemId, index) => {\n const replaceWith = prevItemMap[fromIds[index]];\n return [\n toItemId,\n {\n x: replaceWith.x,\n y: replaceWith.y,\n },\n ];\n })\n );\n\n batchUpdateItems(\n fromIds,\n (item) => {\n return newCoordinatesMap[item.id];\n },\n true\n );\n\n const replaceMap = Object.fromEntries(\n fromIds.map((id, index) => [id, toIds[index]])\n );\n\n // swap also the item order\n const reorderedItemIds = getItemIds().map((itemId) => {\n if (fromIds.includes(itemId)) {\n return replaceMap[itemId];\n }\n return itemId;\n });\n\n setItemIds(reorderedItemIds);\n },\n [getStoreItems, batchUpdateItems, getItemIds, setItemIds]\n );\n\n const pushItems = React.useCallback(\n (itemsToInsert, beforeId) => {\n const center = getCenter();\n\n const itemsWithPosition = itemsToInsert.map((item, index) => {\n if (item.x === undefined || item.x === null || item.y === undefined || item.y === null) {\n return { ...item, x: center.x + 2 * index, y: center.y + 2 * index };\n }\n return item;\n });\n\n insertItems(itemsWithPosition, beforeId);\n // Wait for React to render the inserted items before measuring their DOM\n // elements in placeItems/stickOnGrid.\n requestAnimationFrame(() => {\n placeItems(itemsToInsert.map(({ id }) => id));\n });\n },\n [getCenter, insertItems, placeItems]\n );\n\n const pushItem = React.useCallback(\n (itemToInsert, beforeId) => {\n pushItems([itemToInsert], beforeId);\n },\n [pushItems]\n );\n\n const removeItems = React.useCallback(\n (itemsIdToRemove) => {\n // Remove from selected items first\n unselect(itemsIdToRemove);\n\n removeItemsById(itemsIdToRemove);\n callDeleteInteractions(itemsIdToRemove);\n },\n [unselect, removeItemsById, callDeleteInteractions]\n );\n\n const getItems = React.useCallback(\n (itemIds) => {\n const itemMap = getStoreItems();\n return itemIds.map((id) => itemMap[id]);\n },\n [getStoreItems]\n );\n\n const findElementUnderPointer = React.useCallback(\n (\n { target, clientX, clientY },\n { returnLocked = false, passLocked = false } = {}\n ) => {\n // Allow text selection instead of moving\n if ([\"INPUT\", \"TEXTAREA\"].includes(target.tagName)) return null;\n\n const foundElement = insideClass(target, \"item\");\n\n if (foundElement) {\n if (hasClass(foundElement, \"selected\")) {\n return foundElement;\n }\n\n if (\n !passLocked &&\n hasClass(foundElement, \"locked\") &&\n !hasClass(target, \"passthrough\")\n ) {\n return returnLocked ? foundElement : null;\n }\n\n // Is it a passthrough element?\n if (hasClass(target, \"passthrough\")) {\n // Get current value\n const itemList = getItemIds();\n const { uid } = getConfiguration();\n\n // Found element under the cursor\n const elements = itemList.reduce((prev, itemId) => {\n const elem = getItemElem(uid, itemId);\n const itemRect = elem.getBoundingClientRect();\n if (isPointInsideRect({ x: clientX, y: clientY }, itemRect)) {\n prev.unshift(elem);\n }\n return prev;\n }, []);\n\n // Figure out if one can be returned\n for (let i = 0; i < elements.length; i += 1) {\n const elem = elements[i];\n if (\n elem !== foundElement &&\n (passLocked || !hasClass(elem, \"locked\"))\n ) {\n return elem;\n }\n }\n // Here there is no available elements\n return null;\n }\n }\n return foundElement;\n },\n [getConfiguration, getItemIds]\n );\n\n return {\n putItemsOnTop,\n batchUpdateItems,\n updateItemOrder,\n moveItems,\n placeItems,\n updateItem,\n swapItems,\n reverseItemsOrder,\n setItemList: setItemListFull,\n pushItem,\n pushItems,\n removeItems,\n getItemList,\n findElementUnderPointer,\n getItems,\n };\n};\n\nexport default useItemActions;\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n if ((a instanceof Map) && (b instanceof Map)) {\n if (a.size !== b.size) return false;\n for (i of a.entries())\n if (!b.has(i[0])) return false;\n for (i of a.entries())\n if (!equal(i[1], b.get(i[0]))) return false;\n return true;\n }\n\n if ((a instanceof Set) && (b instanceof Set)) {\n if (a.size !== b.size) return false;\n for (i of a.entries())\n if (!b.has(i[0])) return false;\n return true;\n }\n\n if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (a[i] !== b[i]) return false;\n return true;\n }\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import React, { useCallback } from \"react\";\nimport deepEqual from \"fast-deep-equal/es6\";\n\nimport { useDebouncedEffect } from \"@react-hookz/web\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"../store/main\";\n\n/**\n * Returns the default actions of an item\n * @param {object} item to consider\n * @param {object} itemMap item template map with default actions\n * @returns An array of default action for this item\n */\nconst getDefaultActionsFromItem = (item, itemMap) => {\n if (item.type in itemMap) {\n const actions = itemMap[item.type].defaultActions;\n if (typeof actions === \"function\") {\n return actions(item);\n }\n return actions;\n }\n\n return [];\n};\n\n/**\n * Returns actual actions from an item ordered by the configured available\n * actions. If no action is defined, default actions are returned.\n * @param {object} item item to use\n * @param {object} itemMap item template map with available action for this item\n * @returns the array of actions for this item\n */\nconst getActionsFromItem = (item, itemMap) => {\n const { actions = getDefaultActionsFromItem(item, itemMap) } = item;\n return actions.map((action) => {\n if (typeof action === \"string\") {\n return { name: action };\n }\n return action;\n });\n};\n\nconst useAvailableActions = () => {\n const [items, getItems] = useSyncedStore((state) => [\n state.items,\n state.getItems,\n ]);\n const [itemTemplates, selection, getSelection] = useMainStore((state) => [\n state.config.itemTemplates,\n state.selection,\n state.getSelection,\n ]);\n const [availableActions, setAvailableActions] = React.useState([]);\n const isMountedRef = React.useRef(false);\n const [, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n // Mounted guard\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n const getItemListOrSelected = React.useCallback(\n (itemIds) => {\n const currentItemMap = getItems();\n if (itemIds) {\n return [itemIds, itemIds.map((id) => currentItemMap[id])];\n }\n const selectedItems = getSelection();\n return [selectedItems, selectedItems.map((id) => currentItemMap[id])];\n },\n [getItems, getSelection]\n );\n\n /**\n * Returns available actions for selected items. An action is kept only if all\n * items have this exact same action with same parameters.\n */\n const updateAvailableActions = useCallback(() => {\n const [selectedItemIds, selectedItemList] = getItemListOrSelected();\n if (selectedItemIds.length > 0) {\n // Prevent set state on unmounted component\n if (!isMountedRef.current) return;\n\n const allActions = selectedItemList.reduce((acc, item) => {\n const itemActions = getActionsFromItem(item, itemTemplates);\n\n return acc.filter((value) =>\n itemActions.some((itemAction) => deepEqual(value, itemAction))\n );\n }, getActionsFromItem(selectedItemList[0], itemTemplates));\n\n startTransition(() => {\n setAvailableActions(allActions);\n });\n } else {\n startTransition(() => {\n setAvailableActions([]);\n });\n }\n }, [getItemListOrSelected, itemTemplates]);\n\n // Debounced update available actions when items or selection change\n useDebouncedEffect(\n () => updateAvailableActions(),\n [items, selection, updateAvailableActions],\n 100\n );\n\n return {\n availableActions,\n };\n};\n\nexport default useAvailableActions;\n","import useMainStore from \"./store/main\";\n\nconst useSelectionBox = () => {\n const [selectionBox] = useMainStore((state) => [state.selectionBox]);\n return selectionBox;\n};\n\nexport default useSelectionBox;\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { getRandomColor } from \"@/utils\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nexport const persistUser = (user) => {\n localStorage.setItem(\"user\", JSON.stringify(user));\n};\n\nexport const restoreUser = () => {\n if (localStorage.user) {\n // Add some mandatory info if missing\n const localUser = {\n name: \"Player\",\n color: getRandomColor(),\n uid: nanoid(),\n ...JSON.parse(localStorage.user),\n };\n // Id is given by server\n // delete localUser.id;\n persistUser(localUser);\n return localUser;\n }\n const newUser = {\n name: \"Player\",\n color: getRandomColor(),\n uid: nanoid(),\n };\n persistUser(newUser);\n return newUser;\n};\n\nconst usersStore = (curentUserId) => (set, get) => ({\n isSpaceMaster: false,\n users: {},\n getUser: () => get().users[curentUserId],\n getUsers: () => {\n return get().users;\n },\n getUserList: () => Object.values(get().users),\n getLocalUsers: () => {\n if (!get().users[curentUserId]) {\n return [];\n }\n const { space: currentUserSpace } = get().users[curentUserId];\n return get()\n .getUserList()\n .filter(({ space }) => space === currentUserSpace);\n },\n addUser: (newUser) =>\n set((state) => ({ users: { ...state.users, [newUser.id]: newUser } })),\n updateUser: (userId, toUpdate) =>\n set((state) => {\n if (!state.users[userId]) {\n return {};\n }\n const newUser = {\n ...state.users[userId],\n ...toUpdate,\n id: userId,\n uid: state.users[userId].uid,\n };\n if (newUser.id === curentUserId) {\n persistUser(newUser);\n }\n setTimeout(() => get().electSpaceMaster(), 100);\n return {\n users: {\n ...state.users,\n [userId]: newUser,\n },\n };\n }),\n removeUser: (userId) =>\n set((state) => {\n const newUsers = { ...state.users };\n delete newUsers[userId];\n setTimeout(() => get().electSpaceMaster(), 100);\n return { users: newUsers };\n }),\n // Not synchronized methods\n updateCurrentUser: (toUpdate) => get().updateUser(curentUserId, toUpdate),\n joinSpace: (space) =>\n get().updateUser(curentUserId, { space, spaceJoinedTimestamp: Date.now() }),\n electSpaceMaster: () => {\n const localUsers = get().getLocalUsers();\n const master = {\n uid: null,\n timestamp: Date.now(),\n };\n Object.values(localUsers).forEach(({ spaceJoinedTimestamp, id }) => {\n if (spaceJoinedTimestamp < master.timestamp) {\n master.id = id;\n master.timestamp = spaceJoinedTimestamp;\n }\n });\n\n set({ isSpaceMaster: master.id === curentUserId });\n },\n});\n\nconst cursorsStore = (set) => ({\n cursors: {},\n moveCursor: (userId, newPos) =>\n set((state) => ({ cursors: { ...state.cursors, [userId]: newPos } })),\n removeCursor: (userId) =>\n set((state) => {\n const newCursors = { ...state.cursors };\n delete newCursors[userId];\n return { cursors: newCursors };\n }),\n});\n\nexport const SyncedUsersProvider = ({ storeName, children }) => {\n const { wire, isMaster } = useWire(\"room\");\n const [store, setStore] = React.useState(null);\n const [ready, setReady] = React.useState(false);\n const storeRef = React.useRef(false);\n\n React.useEffect(() => {\n let mounted = true;\n const unsubs = [];\n if (!store && !storeRef.current) {\n storeRef.current = true;\n const init = () => {\n // Create store\n const localStore = createStore(\n syncMiddleware(\n {\n wire,\n storeName,\n noSync: [\n \"updateCurrentUser\",\n \"joinSpace\",\n \"isSpaceMaster\",\n \"electSpaceMaster\",\n ],\n },\n (...args) => ({\n ...usersStore(wire.userId)(...args),\n ...cursorsStore(...args),\n }),\n wire,\n storeName\n )\n );\n // Wait for ready event\n const unsubscribe = localStore.subscribe((newValue) => {\n if (newValue.ready) {\n // No need to listen anymore\n unsubscribe();\n if (mounted) {\n setStore(localStore);\n }\n }\n });\n };\n init();\n return () => {\n mounted = false;\n storeRef.current = false;\n unsubs.forEach((unsub) => unsub());\n };\n }\n }, [store, storeName, wire, wire.userId]);\n\n React.useEffect(() => {\n if (store) {\n store.getState().addUser({\n ...restoreUser(),\n id: wire.userId,\n });\n setReady(true);\n return () => {\n store.getState().removeUser(wire.userId);\n };\n }\n }, [isMaster, store, wire]);\n\n React.useEffect(() => {\n if (store) {\n // Listen for userLeave events\n const unsubscribe = wire.subscribe(\"userLeave\", (userId) => {\n store.getState().removeUser(userId);\n });\n return () => {\n unsubscribe();\n };\n }\n }, [isMaster, store, wire]);\n\n React.useEffect(() => {\n if (isMaster && store) {\n // Set master\n store.getState().updateCurrentUser({ isMaster: isMaster });\n }\n }, [isMaster, store, wire]);\n\n if (!ready) {\n return null;\n }\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedUsers = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedUsers } from \"@/users/store\";\n\nconst useUsers = () => {\n const [isSpaceMaster, currentUser, userMap, updateCurrentUser, joinSpace] =\n useSyncedUsers((state) => [\n state.isSpaceMaster,\n state.getUser(),\n state.users,\n state.updateCurrentUser,\n state.joinSpace,\n ]);\n\n const users = React.useMemo(() => Object.values(userMap), [userMap]);\n\n const localUsers = React.useMemo(() => {\n const { space: currentUserSpace } = currentUser;\n return users.filter(({ space }) => space === currentUserSpace);\n }, [currentUser, users]);\n\n return {\n isSpaceMaster,\n currentUser,\n updateCurrentUser,\n users,\n localUsers,\n joinSpace,\n };\n};\n\nexport default useUsers;\n","import React from \"react\";\nimport { useSyncedStore } from \"@/board/store/synced\";\n\nconst useBoardConfig = () => {\n const [boardConfig, getBoardConfig, setBoardConfig] = useSyncedStore(\n (state) => [state.boardConfig, state.getBoardConfig, state.setBoardConfig]\n );\n\n const setSyncBoardConfig = React.useCallback(\n (callbackOrConfig) => {\n let callback = callbackOrConfig;\n if (typeof callbackOrConfig === \"object\") {\n callback = () => callbackOrConfig;\n }\n\n const currentConfig = getBoardConfig();\n const newConfig = callback(currentConfig);\n setBoardConfig(newConfig);\n },\n [getBoardConfig, setBoardConfig]\n );\n\n return [boardConfig, setSyncBoardConfig];\n};\n\nexport default useBoardConfig;\n","import useMainStore from \"./store/main\";\n\nconst useBoardState = () => {\n const [boardState] = useMainStore((state) => [state.boardState]);\n return boardState;\n};\n\nexport default useBoardState;\n","import { useSyncedStore } from \"./store/synced\";\n\nconst useSessionInfo = () => {\n const [getSessionInfo, setSessionInfo, updateSessionInfo, sessionInfo] =\n useSyncedStore((state) => [\n state.getSessionInfo,\n state.setSessionInfo,\n state.updateSessionInfo,\n state.session,\n ]);\n\n return { getSessionInfo, setSessionInfo, sessionInfo, updateSessionInfo };\n};\n\nexport default useSessionInfo;\n","import React, { useContext } from \"react\";\nimport { createStore } from \"zustand\";\nimport { useStoreWithEqualityFn } from \"zustand/traditional\";\nimport { shallow } from \"zustand/shallow\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire from \"@/hooks/useWire\";\nimport { syncMiddleware } from \"@/utils\";\n\nconst Context = React.createContext();\n\nconst generateMsg = ({ user: { name, uid, color }, content }) => {\n const newMessage = {\n type: \"message\",\n user: { name, uid, color },\n content,\n uid: nanoid(),\n timestamp: new Date().toISOString(),\n };\n return newMessage;\n};\n\nconst messageStore = (set, get) => ({\n messages: [],\n setMessages: (newMessages) =>\n set({\n messages: newMessages.map((m) => ({\n ...m,\n timestamp: Date.parse(m.timestamp),\n })),\n }),\n addMessage: (newMessage) =>\n set((state) => ({\n messages: [\n ...state.messages,\n { ...newMessage, timestamp: Date.parse(newMessage.timestamp) },\n ],\n })),\n sendMessage: (user, content) => {\n const newMessage = generateMsg({\n user,\n content,\n });\n if (newMessage) get().addMessage(newMessage);\n },\n});\n\nexport const SyncedMessageProvider = ({\n storeName,\n children,\n defaultValue = [],\n}) => {\n const { wire } = useWire(\"room\");\n const [store] = React.useState(() =>\n createStore(\n syncMiddleware(\n { wire, storeName, defaultValue, noSync: [\"sendMessage\"] },\n (...args) => ({\n ...messageStore(...args),\n })\n )\n )\n );\n\n return <Context.Provider value={store}>{children}</Context.Provider>;\n};\n\nexport const useSyncedMessage = (selector) => {\n const store = useContext(Context);\n return useStoreWithEqualityFn(store, selector, shallow);\n};\n","import React from \"react\";\n\nimport { useSyncedMessage } from \"@/message/store\";\nimport { useSyncedUsers } from \"@/users/store\";\n\nconst noop = () => {};\n\nconst useMessage = (onMessage = noop) => {\n const currentUser = useSyncedUsers((state) => state.getUser());\n const [messages, setMessages, sendMessage] = useSyncedMessage((state) => [\n state.messages,\n state.setMessages,\n state.sendMessage,\n ]);\n\n React.useEffect(() => {\n // React on new message\n if (messages.length) {\n onMessage();\n }\n }, [messages, onMessage]);\n\n const sendMessageWithUser = React.useCallback(\n (messageContent) => {\n sendMessage(currentUser, messageContent);\n },\n [currentUser, sendMessage]\n );\n\n return { messages, setMessages, sendMessage: sendMessageWithUser };\n};\n\nexport default useMessage;\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport useWire, { WireProvider } from \"@/hooks/useWire\";\n\nimport { SyncedStoreProvider } from \"@/board/store/synced\";\nimport { MainStoreProvider } from \"@/board/store/main\";\n\nimport { SyncedUsersProvider, useSyncedUsers } from \"./users/store\";\nimport { SyncedMessageProvider } from \"./message/store\";\n\nconst SyncBoard = ({ children, session }) => {\n const joinSpace = useSyncedUsers((state) => state.joinSpace);\n\n // Set user space\n React.useEffect(() => {\n joinSpace(session);\n return () => {\n joinSpace(null);\n };\n }, [joinSpace, session]);\n\n return children;\n};\n\nconst ConnectedSyncBoard = ({\n socket,\n room,\n session,\n items = [],\n messages = [],\n LoadingComponent,\n ...props\n}) => {\n const [stableRoom] = React.useState(room || nanoid());\n const [stableSession] = React.useState(session || nanoid());\n const [defaultItemsValue] = React.useState(() => {\n return {\n itemIds: items.map(({ id }) => id),\n items: Object.fromEntries(items.map((item) => [item.id, item])),\n };\n });\n\n const roomChannel = useWire(\"room\");\n\n if (!roomChannel) {\n // No room declared so we create one\n return (\n <WireProvider\n room={stableRoom}\n channel=\"room\"\n socket={socket}\n LoadingComponent={LoadingComponent}\n >\n <SyncedUsersProvider storeName={`${stableRoom}_users`}>\n <SyncedMessageProvider\n storeName={`${stableSession}_messages`}\n defaultValue={messages}\n >\n <MainStoreProvider>\n <SyncedStoreProvider\n storeName={`${stableSession}_item`}\n defaultValue={defaultItemsValue}\n >\n <SyncBoard {...props} session={stableSession} />\n </SyncedStoreProvider>\n </MainStoreProvider>\n </SyncedMessageProvider>\n </SyncedUsersProvider>\n </WireProvider>\n );\n }\n return (\n <SyncedMessageProvider\n storeName={`${stableSession}_messages`}\n defaultValue={messages}\n >\n <MainStoreProvider>\n <SyncedStoreProvider\n storeName={`${stableSession}_item`}\n defaultValue={defaultItemsValue}\n >\n <SyncBoard {...props} session={stableSession} />\n </SyncedStoreProvider>\n </MainStoreProvider>\n </SyncedMessageProvider>\n );\n};\n\nexport default ConnectedSyncBoard;\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport { WireProvider } from \"@/hooks/useWire\";\nimport { SyncedUsersProvider } from \"@/users/store\";\n\nconst ConnectedSyncRoom = ({ socket, room, children, LoadingComponent }) => {\n const [stableRoom] = React.useState(room || nanoid());\n\n return (\n <WireProvider\n room={stableRoom}\n channel=\"room\"\n socket={socket}\n LoadingComponent={LoadingComponent}\n >\n <SyncedUsersProvider storeName={`${stableRoom}_users`}>\n {children}\n </SyncedUsersProvider>\n </WireProvider>\n );\n};\n\nexport default ConnectedSyncRoom;\n","let e={data:\"\"},t=t=>{if(\"object\"==typeof window){let e=(t?t.querySelector(\"#_goober\"):window._goober)||Object.assign(document.createElement(\"style\"),{innerHTML:\" \",id:\"_goober\"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||e},r=e=>{let r=t(e),a=r.data;return r.data=\"\",a},a=/(?:([\\u0080-\\uFFFF\\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\\s*)/g,l=/\\/\\*[^]*?\\*\\/| +/g,n=/\\n+/g,o=(e,t)=>{let r=\"\",a=\"\",l=\"\";for(let n in e){let c=e[n];\"@\"==n[0]?\"i\"==n[1]?r=n+\" \"+c+\";\":a+=\"f\"==n[1]?o(c,n):n+\"{\"+o(c,\"k\"==n[1]?\"\":t)+\"}\":\"object\"==typeof c?a+=o(c,t?t.replace(/([^,])+/g,e=>n.replace(/([^,]*:\\S+\\([^)]*\\))|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+\" \"+t:t)):n):null!=c&&(n=\"-\"==n[1]?n:n.replace(/[A-Z]/g,\"-$&\").toLowerCase(),l+=o.p?o.p(n,c):n+\":\"+c+\";\")}return r+(t&&l?t+\"{\"+l+\"}\":l)+a},c={},i=e=>{if(\"object\"==typeof e){let t=\"\";for(let r in e)t+=r+i(e[r]);return t}return e},s=(e,t,r,s,p)=>{let u=i(e),d=c[u]||(c[u]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return\"go\"+r})(u));if(!c[d]){let t=u!==e?e:(e=>{let t,r,o=[{}];for(;t=a.exec(e.replace(l,\"\"));)t[4]?o.shift():t[3]?(r=t[3].replace(n,\" \").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n,\" \").trim();return o[0]})(e);c[d]=o(p?{[\"@keyframes \"+d]:t}:t,r?\"\":\".\"+d)}let f=r&&c.g;return r&&(c.g=c[d]),((e,t,r,a)=>{a?t.data=t.data.replace(a,e):-1===t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e)})(c[d],t,s,f),d},p=(e,t,r)=>e.reduce((e,a,l)=>{let n=t[l];if(n&&n.call){let e=n(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;n=t?\".\"+t:e&&\"object\"==typeof e?e.props?\"\":o(e,\"\"):!1===e?\"\":e}return e+a+(null==n?\"\":n)},\"\");function u(e){let r=this||{},a=e.call?e(r.p):e;return s(a.unshift?a.raw?p(a,[].slice.call(arguments,1),r.p):a.reduce((e,t)=>Object.assign(e,t&&t.call?t(r.p):t),{}):a,t(r.target),r.g,r.o,r.k)}let d,f,g,b=u.bind({g:1}),h=u.bind({k:1});function m(e,t,r,a){o.p=t,d=e,f=r,g=a}function w(e,t){let r=this||{};return function(){let a=arguments;function l(n,o){let c=Object.assign({},n),i=c.className||l.className;r.p=Object.assign({theme:f&&f()},c),r.o=/go\\d/.test(i),c.className=u.apply(r,a)+(i?\" \"+i:\"\"),t&&(c.ref=o);let s=e;return e[0]&&(s=c.as||e,delete c.as),g&&s[0]&&g(c),d(s,c)}return t?t(l):l}}export{u as css,r as extractCss,b as glob,h as keyframes,m as setup,w as styled};\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import React from \"react\";\n\nexport const isMacOS = () => {\n const userAgent = navigator.userAgent.toLowerCase();\n return /mac os ?x 10/.test(userAgent);\n};\n\n// From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\nconst getScrollLineHeight = () => {\n const iframe = document.createElement(\"iframe\");\n iframe.src = \"#\";\n document.body.appendChild(iframe);\n\n // Write content in Iframe\n const idoc = iframe.contentWindow.document;\n idoc.open();\n idoc.write(\n \"<!DOCTYPE html><html><head></head><body><span>a</span></body></html>\"\n );\n idoc.close();\n\n const scrollLineHeight = idoc.body.firstElementChild.offsetHeight;\n document.body.removeChild(iframe);\n\n return scrollLineHeight;\n};\n\nconst LINE_HEIGHT = getScrollLineHeight();\n// Reasonable default from https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js\nconst PAGE_HEIGHT = 800;\n\nconst otherPointer = (pointers, currentPointer) => {\n const p2 = Object.keys(pointers)\n .map((p) => Number(p))\n .find((pointer) => pointer !== currentPointer);\n return pointers[p2];\n};\n\nconst computeDistance = ([x1, y1], [x2, y2]) => {\n const distanceX = Math.abs(x1 - x2);\n const distanceY = Math.abs(y1 - y2);\n\n return Math.hypot(distanceX, distanceY);\n};\n\nconst empty = () => {};\n\nconst stopPropagation = (fn) => (arg) => {\n const { event } = arg;\n if (!event.isPropagationStopped()) {\n return fn(arg);\n }\n return null;\n};\n\nconst protect =\n (fn) =>\n async (...args) => {\n try {\n await fn(...args);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e);\n }\n };\n\nclass PromiseQueue {\n lastPromise = Promise.resolve(true);\n\n add(operation, ...args) {\n return new Promise((resolve, reject) => {\n this.lastPromise = this.lastPromise\n .then(() => stopPropagation(protect(operation))(...args))\n .then(resolve)\n .catch(reject);\n });\n }\n}\n\nconst promiseQueue = new PromiseQueue();\n\nconst Gesture = ({\n children,\n onDrag = empty,\n onDragStart = empty,\n onDragEnd = empty,\n onPan = empty,\n onTap = empty,\n onLongTap = empty,\n onDoubleTap = empty,\n onZoom,\n mainAction = \"drag\",\n fill = false,\n}) => {\n const wrapperRef = React.useRef(null);\n const stateRef = React.useRef({\n moving: false,\n pointers: {},\n mainPointer: undefined,\n });\n\n const onWheel = (event) => {\n const {\n deltaX,\n deltaY,\n clientX,\n clientY,\n deltaMode,\n ctrlKey,\n altKey,\n metaKey,\n target,\n } = event;\n\n // On a MacOs trackpad, the pinch gesture sets the ctrlKey to true.\n // In that situation, we want to use the custom scaling, not the browser default zoom.\n // Hence in this situation we avoid to return immediately.\n if (altKey || (ctrlKey && !isMacOS())) {\n return;\n }\n\n // On a trackpad, the pinch and pan events are differentiated by the crtlKey value.\n // On a pinch gesture, the ctrlKey is set to true, so we want to have a scaling effect.\n // If we are only moving the fingers in the same direction, a pan is needed.\n // Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e\n if (isMacOS() && !ctrlKey) {\n promiseQueue.add(onPan, {\n deltaX: -2 * deltaX,\n deltaY: -2 * deltaY,\n button: 1,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n } else {\n // Quit if onZoom is not set\n if (onZoom === undefined || !deltaY) return;\n\n let scale = deltaY;\n\n switch (deltaMode) {\n case 1: // Pixel\n scale *= LINE_HEIGHT;\n break;\n case 2:\n scale *= PAGE_HEIGHT;\n break;\n default:\n }\n\n if (isMacOS()) {\n scale *= 2;\n }\n\n promiseQueue.add(onZoom, { scale, clientX, clientY, event });\n }\n };\n\n const onPointerDown = (event) => {\n const {\n target,\n button,\n clientX,\n clientY,\n pointerId,\n altKey,\n ctrlKey,\n metaKey,\n isPrimary,\n } = event;\n\n // Add pointer to map\n stateRef.current.pointers[pointerId] = { clientX, clientY };\n\n if (isPrimary) {\n // Clean mainPoint on primary pointer\n stateRef.current.mainPointer = undefined;\n }\n\n if (stateRef.current.mainPointer !== undefined) {\n if (stateRef.current.mainPointer !== pointerId) {\n // This is not the main pointer\n try {\n const { clientX: clientX2, clientY: clientY2 } = otherPointer(\n stateRef.current.pointers,\n pointerId\n );\n const newClientX = (clientX2 + clientX) / 2;\n const newClientY = (clientY2 + clientY) / 2;\n\n const distance = computeDistance(\n [clientX2, clientY2],\n [clientX, clientY]\n );\n\n // We update previous position as the new position is the center between both fingers\n Object.assign(stateRef.current, {\n pressed: true,\n moving: false,\n gestureStart: false,\n startX: clientX,\n startY: clientY,\n prevX: newClientX,\n prevY: newClientY,\n startDistance: distance,\n prevDistance: distance,\n });\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Error while getting other pointer. Ignoring\", e);\n // eslint-disable-next-line no-unused-expressions\n stateRef.current.mainPointer === undefined;\n }\n }\n\n return;\n }\n\n // We set the mainpointer\n stateRef.current.mainPointer = pointerId;\n\n // And prepare move\n Object.assign(stateRef.current, {\n pressed: true,\n moving: false,\n gestureStart: false,\n startX: clientX,\n startY: clientY,\n prevX: clientX,\n prevY: clientY,\n currentButton: button,\n pointerDownEvent: event,\n startDistance: 0,\n prevDistance: 0,\n target,\n timeStart: Date.now(),\n longTapTimeout: setTimeout(async () => {\n stateRef.current.noTap = true;\n promiseQueue.add(onLongTap, {\n clientX,\n clientY,\n altKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n }, 750),\n });\n\n try {\n // Nested handlers capture the same target so events continue to bubble\n // through item, pan and selection handlers.\n target.setPointerCapture(pointerId);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Fail to capture pointer\", e);\n }\n };\n\n const onPointerMove = (event) => {\n if (stateRef.current.pressed) {\n const {\n pointerId,\n clientX: eventClientX,\n clientY: eventClientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n buttons,\n } = event;\n\n // Update pointer coordinates in the map\n stateRef.current.pointers[pointerId] = {\n clientX: eventClientX,\n clientY: eventClientY,\n };\n\n stateRef.current.moving = true;\n\n // Do we have two pointers ?\n const twoPointers = Object.keys(stateRef.current.pointers).length === 2;\n\n let clientX;\n let clientY;\n let distanceBetweenTwoPointers = 0;\n\n if (twoPointers) {\n // Find other pointerId\n const { clientX: clientX2, clientY: clientY2 } = otherPointer(\n stateRef.current.pointers,\n pointerId\n );\n\n // Update client X with the center of each touch\n clientX = (clientX2 + eventClientX) / 2;\n clientY = (clientY2 + eventClientY) / 2;\n distanceBetweenTwoPointers = computeDistance(\n [clientX2, clientY2],\n [eventClientX, eventClientY]\n );\n } else {\n clientX = eventClientX;\n clientY = eventClientY;\n }\n\n // We drag if\n // On non touch device\n // - Only button is pressed (1)\n // - any special key is no pressed\n // or on touch devices\n // - We use only one finger\n let altAction = shiftKey || altKey || ctrlKey || metaKey || buttons !== 1;\n if (mainAction !== \"drag\") {\n altAction = !altAction;\n }\n\n const shouldDrag = !altAction;\n const shouldPan = altAction;\n\n if (shouldDrag) {\n // Send drag start on first move\n if (!stateRef.current.gestureStart) {\n wrapperRef.current.style.cursor = \"move\";\n stateRef.current.gestureStart = true;\n // Clear tap timeout\n clearTimeout(stateRef.current.longTapTimeout);\n\n promiseQueue.add(onDragStart, {\n deltaX: 0,\n deltaY: 0,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX: stateRef.current.startX,\n clientY: stateRef.current.startY,\n distanceX: 0,\n distanceY: 0,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target: stateRef.current.target,\n event: stateRef.current.pointerDownEvent,\n });\n }\n\n const deltaX = clientX - stateRef.current.prevX;\n const deltaY = clientY - stateRef.current.prevY;\n const distanceX = clientX - stateRef.current.startX;\n const distanceY = clientY - stateRef.current.startY;\n\n // Drag event\n promiseQueue.add(onDrag, {\n deltaX,\n deltaY,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX,\n clientY,\n distanceX,\n distanceY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target: stateRef.current.target,\n event,\n });\n }\n\n if (shouldPan) {\n if (!stateRef.current.gestureStart) {\n wrapperRef.current.style.cursor = \"move\";\n stateRef.current.gestureStart = true;\n // Clear tap timeout on first move\n clearTimeout(stateRef.current.longTapTimeout);\n }\n\n // Create closure\n const deltaX = clientX - stateRef.current.prevX;\n const deltaY = clientY - stateRef.current.prevY;\n const { target } = stateRef.current;\n\n // Pan event\n promiseQueue.add(onPan, {\n deltaX,\n deltaY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n\n if (\n distanceBetweenTwoPointers !== stateRef.current.prevDistance &&\n onZoom\n ) {\n const scale =\n stateRef.current.prevDistance - distanceBetweenTwoPointers;\n\n if (Math.abs(scale) > 0) {\n promiseQueue.add(onZoom, {\n scale: scale * 3,\n clientX,\n clientY,\n event,\n });\n stateRef.current.prevDistance = distanceBetweenTwoPointers;\n }\n }\n }\n\n stateRef.current.prevX = clientX;\n stateRef.current.prevY = clientY;\n }\n };\n\n const onPointerUp = (event) => {\n const {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n pointerId,\n } = event;\n\n if (!stateRef.current.pointers[pointerId]) {\n // Pointer already gone previously with another event\n // ignoring it\n return;\n }\n\n // Remove pointer from map\n delete stateRef.current.pointers[pointerId];\n\n // If this is not the main pointer we quit here\n if (stateRef.current.mainPointer !== pointerId) {\n const { clientX: clientX2, clientY: clientY2 } =\n stateRef.current.pointers[stateRef.current.mainPointer];\n Object.assign(stateRef.current, {\n prevX: clientX2,\n prevY: clientY2,\n prevDistance: 0,\n startDistance: 0,\n });\n return;\n }\n\n // It was the main pointer so we need to replace it with another if any\n while (Object.keys(stateRef.current.pointers).length > 0) {\n // If was main pointer but we have another one, this one become main\n stateRef.current.mainPointer = Number(\n Object.keys(stateRef.current.pointers)[0]\n );\n\n try {\n stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);\n\n const { clientX: clientX2, clientY: clientY2 } =\n stateRef.current.pointers[stateRef.current.mainPointer];\n Object.assign(stateRef.current, {\n prevX: clientX2,\n prevY: clientY2,\n prevDistance: 0,\n startDistance: 0,\n });\n\n return;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(\"Fails to set pointer capture\", error);\n stateRef.current.mainPointer = undefined;\n delete stateRef.current.pointers[\n Object.keys(stateRef.current.pointers)[0]\n ];\n }\n }\n\n // From here we have removed the last pointer.\n\n stateRef.current.mainPointer = undefined;\n stateRef.current.pressed = false;\n\n // Clear longTap\n clearTimeout(stateRef.current.longTapTimeout);\n\n if (stateRef.current.moving) {\n // If we were moving, send drag end event\n stateRef.current.moving = false;\n promiseQueue.add(onDragEnd, {\n deltaX: clientX - stateRef.current.prevX,\n deltaY: clientY - stateRef.current.prevY,\n startX: stateRef.current.startX,\n startY: stateRef.current.startY,\n clientX,\n clientY,\n distanceX: clientX - stateRef.current.startX,\n distanceY: clientY - stateRef.current.startY,\n button: stateRef.current.currentButton,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n event,\n });\n wrapperRef.current.style.cursor = \"auto\";\n } else {\n const now = Date.now();\n\n if (stateRef.current.noTap) {\n stateRef.current.noTap = false;\n }\n // Send tap event only if time less than 300ms\n else if (stateRef.current.timeStart - now < 300) {\n promiseQueue.add(onTap, {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n }\n }\n };\n\n const onDoubleTapHandler = (event) => {\n const { clientX, clientY, altKey, shiftKey, ctrlKey, metaKey, target } =\n event;\n promiseQueue.add(onDoubleTap, {\n clientX,\n clientY,\n altKey,\n shiftKey,\n ctrlKey,\n metaKey,\n target,\n event,\n });\n };\n\n return (\n <div\n onWheel={onWheel}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onDoubleClick={onDoubleTapHandler}\n style={{\n touchAction: \"none\",\n ...(fill ? { position: \"absolute\", inset: 0 } : {}),\n }}\n ref={wrapperRef}\n >\n {children}\n </div>\n );\n};\n\nexport default Gesture;\n","import React from \"react\";\nimport Gesture from \"../Gesture\";\nimport useMainStore from \"../store/main\";\n\nconst ResizeHandler = ({ onResize, ...rest }) => {\n const [getBoardState] = useMainStore((state) => [state.getBoardState]);\n\n const onDrag = ({ deltaX, deltaY, event }) => {\n event.stopPropagation();\n const { scale } = getBoardState();\n onResize({\n width: deltaX / scale,\n height: deltaY / scale,\n });\n };\n\n return (\n <Gesture onDrag={onDrag}>\n <div {...rest} />\n </Gesture>\n );\n};\n\nexport default ResizeHandler;\n","import React, { memo } from \"react\";\n\nimport { css } from \"goober\";\nimport deepEqual from \"fast-deep-equal\";\n\nimport ResizeHandler from \"./ResizeHandler\";\nimport useMainStore from \"../store/main\";\n\nconst itemClass = css`\n display: inline-block;\n transition: transform 150ms;\n user-select: none;\n padding: 2px;\n box-sizing: border-box;\n`;\n\nconst selectedItemClass = css`\n border: 2px dashed #db5034;\n padding: 0px;\n cursor: pointer;\n`;\n\nconst itemMark = css`\n position: absolute;\n width: 0px;\n height: 0px;\n`;\n\nconst itemMarkTopLeft = css`\n top: 0;\n left: 0;\n`;\n\nconst itemMarkTopRight = css`\n top: 0;\n right: 0;\n`;\n\nconst itemMarkBottomLeft = css`\n bottom: 0;\n left: 0;\n`;\n\nconst itemMarkBottomRight = css`\n bottom: 0;\n right: 0;\n`;\n\nconst itemMarkCenter = css`\n top: 50%;\n left: 50%;\n`;\n\nconst itemResize = css`\n position: absolute;\n\n width: 10px;\n height: 10px;\n border: 2px solid #db5034;\n background-color: #db5034;\n cursor: move;\n`;\n\nconst itemResizeWidth = css`\n cursor: ew-resize;\n right: -6px;\n top: calc(50% - 5px);\n`;\n\nconst itemResizeHeight = css`\n cursor: ns-resize;\n bottom: -6px;\n left: calc(50% - 5px);\n`;\n\nconst itemResizeRatio = css`\n cursor: nwse-resize;\n bottom: -6px;\n right: -6px;\n`;\n\nconst DefaultErrorComponent = ({ onReload }) => (\n <div\n className={`syncboard-error-item ${css({\n width: \"100px\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n textAlign: \"center\",\n color: \"red\",\n })}`}\n >\n Sorry, this item seems broken.\n <button onClick={onReload}>Reload it</button>\n </div>\n);\n\n/* Error boundary for broken item */\nclass ItemErrorBoundary extends React.Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false, itemId: props.itemId };\n this.onReload = this.onReload.bind(this);\n }\n\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n componentDidCatch(error) {\n // eslint-disable-next-line no-console\n console.error(\n `Error for item ${this.state.itemId}`,\n error,\n this.props.state\n );\n }\n\n onReload() {\n this.setState({ hasError: false });\n }\n\n render() {\n const { ErrorComponent } = this.props;\n if (this.state.hasError) {\n return <ErrorComponent onReload={this.onReload} />;\n }\n return this.props.children;\n }\n}\n\nconst removeClass = (e) => {\n e.target.className = \"\";\n};\n\nconst defaultResize = ({\n width,\n height,\n actualWidth,\n actualHeight,\n prevState,\n keepRatio,\n}) => {\n let { width: currentWidth, height: currentHeight } = prevState;\n\n // Parse text values if any\n [currentWidth, currentHeight] = [\n parseFloat(currentWidth),\n parseFloat(currentHeight),\n ];\n if (!currentWidth || Number.isNaN(Number(currentWidth))) {\n currentWidth = actualWidth;\n }\n if (!currentHeight || Number.isNaN(Number(currentHeight))) {\n currentHeight = actualHeight;\n }\n\n if (keepRatio) {\n const ratio = currentWidth / currentHeight;\n return {\n ...prevState,\n width: (currentWidth + width).toFixed(1),\n height: (currentHeight + height / ratio).toFixed(1),\n };\n }\n\n return {\n ...prevState,\n width: (currentWidth + width).toFixed(1),\n height: (currentHeight + height).toFixed(1),\n };\n};\n\nconst defaultResizeDirection = {\n w: true,\n h: true,\n b: true,\n};\n\nconst Item = ({\n setState,\n state: { type, rotation = 0, id, locked, extraClasses, ...rest } = {},\n animate = \"hvr-pop\",\n isSelected,\n itemMap,\n showResizeHandle = true,\n}) => {\n const itemWrapperRef = React.useRef(null);\n const [uid] = useMainStore((state) => [state.config.uid]);\n\n const {\n component: Component = () => null,\n resizeDirections = defaultResizeDirection,\n resize = defaultResize,\n } = itemMap[type];\n\n const updateState = React.useCallback(\n (callbackOrItem, patch = false) => setState(id, callbackOrItem, patch),\n [setState, id]\n );\n\n React.useEffect(() => {\n itemWrapperRef.current.className = animate;\n }, [animate]);\n\n const classes = [\"item\", id, itemClass];\n if (locked) {\n classes.push(\"locked\");\n }\n if (isSelected) {\n classes.push(\"selected\");\n classes.push(selectedItemClass);\n }\n if (Array.isArray(extraClasses)) {\n classes.concat(extraClasses);\n }\n\n const className = classes.join(\" \");\n\n const onResize = ({ width = 0, height = 0, keepRatio }) => {\n updateState((prev) => {\n const { offsetWidth, offsetHeight } = itemWrapperRef.current;\n return resize({\n prevState: prev,\n width,\n height,\n actualHeight: offsetHeight,\n actualWidth: offsetWidth,\n keepRatio,\n });\n });\n };\n\n const onResizeWidth = ({ width }) => {\n onResize({ width });\n };\n\n const onResizeHeight = ({ height }) => {\n onResize({ height });\n };\n\n const onResizeRatio = ({ width }) => {\n onResize({ height: width, width, keepRatio: true });\n };\n\n return (\n <div\n style={{ transform: `rotate(${rotation}deg` }}\n data-id={id}\n id={`${uid}__${id}`}\n className={className}\n >\n <div\n style={{ display: \"flex\" }}\n ref={itemWrapperRef}\n onAnimationEnd={removeClass}\n onKeyDown={(e) => e.stopPropagation()}\n onKeyUp={(e) => e.stopPropagation()}\n >\n <ItemErrorBoundary\n itemId={id}\n state={rest}\n ErrorComponent={itemMap?.error?.component || DefaultErrorComponent}\n >\n <Component {...rest} id={id} setState={updateState} />\n </ItemErrorBoundary>\n <div className={`corner ${itemMark} ${itemMarkTopLeft}`} />\n <div className={`corner ${itemMark} ${itemMarkTopRight}`} />\n <div className={`corner ${itemMark} ${itemMarkBottomRight}`} />\n <div className={`corner ${itemMark} ${itemMarkBottomLeft}`} />\n <div className={`center ${itemMark} ${itemMarkCenter}`} />\n {showResizeHandle && (\n <>\n {resizeDirections.b && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeRatio}`}\n onResize={onResizeRatio}\n />\n )}\n\n {resizeDirections.h && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeHeight}`}\n onResize={onResizeHeight}\n />\n )}\n\n {resizeDirections.w && (\n <ResizeHandler\n className={`${itemResize} ${itemResizeWidth}`}\n onResize={onResizeWidth}\n />\n )}\n </>\n )}\n </div>\n </div>\n );\n};\n\nconst MemoizedItem = memo(\n Item,\n (\n {\n state: prevState,\n setState: prevSetState,\n isSelected: prevIsSelected,\n showResizeHandle: prevShowResizeHandle,\n },\n {\n state: nextState,\n setState: nextSetState,\n isSelected: nextIsSelected,\n showResizeHandle: nextShowResizeHandle,\n }\n ) =>\n prevIsSelected === nextIsSelected &&\n prevShowResizeHandle === nextShowResizeHandle &&\n prevSetState === nextSetState &&\n deepEqual(prevState, nextState)\n);\n\nconst identity = (x) => x;\n\n// Exclude positioning from memoization\nconst PositionedItem = ({ state = {}, getCurrentUser, className, ...rest }) => {\n if (!rest.itemMap[state.type]) {\n return null;\n }\n\n const { stateHook = identity } = rest.itemMap[state.type];\n\n const {\n x = 0,\n y = 0,\n layer = 0,\n moving,\n ...stateRest\n } = stateHook(state, {\n currentUser: getCurrentUser?.(),\n });\n\n const zIndex = (layer + 4) * 10 + 100 + (moving ? 5 : 0); // Items z-index between 100 and 200\n\n return (\n <div\n className={className}\n style={{\n transform: `translate(${x}px, ${y}px)`,\n zIndex,\n }}\n >\n <MemoizedItem\n {...rest}\n // Helps to prevent render\n showResizeHandle={rest.isSelected && rest.showResizeHandle}\n state={stateRest}\n />\n </div>\n );\n};\n\nconst MemoizedPositionedItem = memo(PositionedItem);\n\nexport default MemoizedPositionedItem;\n","import Item from \"./Item\";\nimport useItemActions from \"./useItemActions\";\n\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"../store/main\";\nimport { useSyncedUsers } from \"@/users/store\";\nimport { css } from \"goober\";\n\nconst ItemList = () => {\n const { updateItem } = useItemActions();\n\n const [itemList, itemMap] = useSyncedStore((state) => [\n state.itemIds,\n state.items,\n ]);\n\n const [showResizeHandle, itemTemplates, selection] = useMainStore(\n (state) => [\n state.config.showResizeHandle,\n state.config.itemTemplates,\n state.selection,\n ]\n );\n const [getCurrentUser] = useSyncedUsers((state) => [state.getUser]);\n\n const itemClassName = css({\n position: \"absolute\",\n top: 0,\n left: 0,\n pointerEvents: \"auto\",\n display: \"inline-block\",\n lineHeight: 0,\n });\n\n return itemList.map((itemId) => (\n <Item\n key={itemId}\n state={itemMap[itemId]}\n setState={updateItem}\n isSelected={selection.includes(itemId)}\n itemMap={itemTemplates}\n getCurrentUser={getCurrentUser}\n showResizeHandle={showResizeHandle}\n className={itemClassName}\n />\n ));\n};\n\nexport default ItemList;\n","import React from \"react\";\nimport { css } from \"goober\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport { insideClass, isItemInsideElement, getIdFromElem } from \"@/utils\";\n\nimport Gesture from \"./Gesture\";\nimport { useItemActions } from \"./Items\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"./store/main\";\n\nconst defaultSelectorClass = css({\n zIndex: 210,\n position: \"absolute\",\n backgroundColor: \"hsla(0, 40%, 50%, 10%)\",\n border: \"2px solid hsl(0, 55%, 40%)\",\n});\n\n/**\n * Find selected element by using their visible screen dimensions.\n *\n * @param {Array} itemMap\n * @param {DomObject} wrapper\n * @param {boolean} ignoreLocked\n * @returns\n */\nconst findSelected = (itemMap, wrapper, ignoreLocked = false) => {\n const selectors = wrapper.getElementsByClassName(\"selector\");\n if (!selectors.length) {\n return [];\n }\n\n const selector = selectors[0];\n\n return Array.from(wrapper.getElementsByClassName(\"item\"))\n .filter((elem) => {\n const id = getIdFromElem(elem);\n\n const item = itemMap[id];\n if (!item || (!ignoreLocked && item.locked)) {\n return false;\n }\n return isItemInsideElement(elem, selector);\n })\n .map((elem) => getIdFromElem(elem));\n};\n\nconst Selector = ({ children, moveFirst }) => {\n const [\n getSelection,\n clearSelection,\n setSelection,\n select,\n getConfiguration,\n updateBoardState,\n ] = useMainStore((state) => [\n state.getSelection,\n state.clear,\n state.setSelection,\n state.select,\n state.getConfiguration,\n state.updateBoardState,\n ]);\n const { findElementUnderPointer } = useItemActions();\n const [getItems] = useSyncedStore((state) => [state.getItems]);\n\n const [selector, setSelector] = React.useState({});\n const [, startTransition] = React.useTransition();\n const [ignoreLocked, setIgnoreLocked] = React.useState(false);\n\n const wrapperRef = React.useRef(null);\n const stateRef = React.useRef({\n moving: false,\n });\n\n useEventListener(document, \"keydown\", (e) => {\n if (e.key === \"l\") {\n setIgnoreLocked(true);\n }\n });\n\n useEventListener(document, \"keyup\", (e) => {\n if (e.key === \"l\") {\n setIgnoreLocked(false);\n }\n });\n\n // Reset selection on board loading\n React.useEffect(() => {\n clearSelection();\n return () => {\n clearSelection();\n };\n }, [clearSelection]);\n\n React.useEffect(() => {\n if (stateRef.current.moving) {\n const itemMap = getItems();\n const { boardWrapper } = getConfiguration();\n const selected = findSelected(itemMap, boardWrapper, ignoreLocked);\n startTransition(() => {\n setSelection(selected);\n });\n }\n }, [getConfiguration, getItems, selector, setSelection, ignoreLocked]);\n\n const onDragStart = async (event) => {\n const foundElement = await findElementUnderPointer(event);\n\n if (!foundElement) {\n stateRef.current.moving = true;\n startTransition(() => {\n updateBoardState({ selecting: true });\n });\n wrapperRef.current.style.cursor = \"crosshair\";\n }\n };\n\n const onDrag = ({ distanceY, distanceX, startX, startY }) => {\n if (stateRef.current.moving) {\n const { top, left } = wrapperRef.current.getBoundingClientRect();\n\n const relativeX = startX - left;\n const relativeY = startY - top;\n\n if (distanceX > 0) {\n stateRef.current.left = relativeX;\n stateRef.current.width = distanceX;\n } else {\n stateRef.current.left = relativeX + distanceX;\n stateRef.current.width = -distanceX;\n }\n if (distanceY > 0) {\n stateRef.current.top = relativeY;\n stateRef.current.height = distanceY;\n } else {\n stateRef.current.top = relativeY + distanceY;\n stateRef.current.height = -distanceY;\n }\n\n setSelector({ ...stateRef.current, moving: true });\n }\n };\n\n const onDragEnd = () => {\n if (stateRef.current.moving) {\n startTransition(() => {\n updateBoardState({ selecting: false });\n });\n stateRef.current.moving = false;\n setSelector({ moving: false });\n wrapperRef.current.style.cursor = \"auto\";\n }\n };\n\n const onLongTap = ({ target }) => {\n const foundElement = insideClass(target, \"item\");\n if (foundElement) {\n const id = getIdFromElem(foundElement);\n setSelection([id]);\n }\n };\n\n const onTap = (event) => {\n const { ctrlKey, metaKey } = event;\n\n const foundElement = findElementUnderPointer(event);\n\n if (!foundElement) {\n clearSelection();\n } else {\n const itemId = getIdFromElem(foundElement);\n\n // Being defensive here to avoid bug\n if (!itemId) {\n clearSelection();\n return;\n }\n\n const selectedItems = getSelection();\n if (foundElement && !selectedItems.includes(itemId)) {\n if (ctrlKey || metaKey) {\n select([itemId]);\n } else {\n setSelection([itemId]);\n }\n }\n }\n };\n\n return (\n <Gesture\n fill\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragEnd={onDragEnd}\n onTap={onTap}\n onLongTap={onLongTap}\n mainAction={moveFirst ? \"pan\" : \"drag\"}\n >\n <div ref={wrapperRef} style={{ position: \"absolute\", inset: 0 }}>\n {selector.moving && (\n <div\n style={{\n transform: `translate(${selector.left}px, ${selector.top}px)`,\n height: `${selector.height}px`,\n width: `${selector.width}px`,\n }}\n className={`selector ${defaultSelectorClass}`}\n />\n )}\n {children}\n </div>\n </Gesture>\n );\n};\n\nexport default Selector;\n","import React from \"react\";\n\nimport { useItemActions } from \"./Items\";\nimport { getIdFromElem } from \"@/utils\";\n\nimport Gesture from \"./Gesture\";\nimport useMainStore from \"./store/main\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport { useEventListener } from \"@react-hookz/web\";\nimport useDim from \"./useDim\";\n\n/**\n * This component handles the move of items when dragging them or with the keyboard.\n */\nconst ActionPane = ({ children }) => {\n const { moveItems, placeItems, findElementUnderPointer } = useItemActions();\n const { vectorFromWrapperToBoard } = useDim();\n\n const [select, setSelection, getSelection, getBoardState, updateBoardState] =\n useMainStore((state) => [\n state.select,\n state.setSelection,\n state.getSelection,\n state.getBoardState,\n state.updateBoardState,\n ]);\n const [getBoardConfig] = useSyncedStore((state) => [state.getBoardConfig]);\n\n const getBoardGrid = () => {\n const { grid, gridType, gridSize = 1 } = getBoardConfig();\n const configuredGrid = grid || {\n type: gridType === undefined ? (gridSize ? \"grid\" : \"none\") : gridType,\n size: gridSize,\n };\n\n return {\n type: configuredGrid.type || \"none\",\n size: Number(configuredGrid.size) || 1,\n offset: {\n x: Number(configuredGrid.offset?.x) || 0,\n y: Number(configuredGrid.offset?.y) || 0,\n },\n };\n };\n\n const actionRef = React.useRef({});\n\n // Use ref because pointer events are faster than react state management\n const selectedItemRef = React.useRef({\n items: [],\n });\n\n const onDragStart = (event) => {\n const { ctrlKey, metaKey, event: originalEvent } = event;\n const foundElement = findElementUnderPointer(event);\n\n if (foundElement) {\n originalEvent.stopPropagation();\n const selectedItems = getSelection();\n\n selectedItemRef.current.items = selectedItems;\n\n const itemId = getIdFromElem(foundElement);\n\n if (!selectedItems.includes(itemId)) {\n if (ctrlKey || metaKey) {\n selectedItemRef.current.items = [...selectedItems, itemId];\n select([itemId]);\n } else {\n selectedItemRef.current.items = [itemId];\n setSelection([itemId]);\n }\n }\n\n Object.assign(actionRef.current, {\n moving: true,\n });\n }\n };\n\n const onDrag = ({ deltaX, deltaY, event: originalEvent }) => {\n if (actionRef.current.moving) {\n originalEvent.stopPropagation();\n const { movingItems } = getBoardState();\n\n const [newX, newY] = vectorFromWrapperToBoard(deltaX, deltaY);\n\n moveItems(\n selectedItemRef.current.items,\n {\n x: newX,\n y: newY,\n },\n true\n );\n\n if (!movingItems) {\n updateBoardState({ movingItems: true });\n }\n }\n };\n\n const onDragEnd = () => {\n if (actionRef.current.moving) {\n actionRef.current = { moving: false };\n placeItems(selectedItemRef.current.items, getBoardGrid());\n updateBoardState({ movingItems: false });\n }\n };\n\n const onKeyDown = (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n const selectedItems = getSelection();\n\n if (selectedItems.length) {\n let moveX = 0;\n let moveY = 0;\n switch (e.key) {\n case \"ArrowLeft\":\n // Left pressed\n moveX = -10;\n break;\n case \"ArrowRight\":\n moveX = 10;\n // Right pressed\n break;\n case \"ArrowUp\":\n // Up pressed\n moveY = -10;\n break;\n case \"ArrowDown\":\n // Down pressed\n moveY = 10;\n break;\n default:\n }\n if (moveX || moveY) {\n if (e.shiftKey) {\n moveX *= 5;\n moveY *= 5;\n }\n if (e.ctrlKey || e.altKey || e.metaKey) {\n moveX /= 10;\n moveY /= 10;\n }\n\n const [newX, newY] = vectorFromWrapperToBoard(moveX, moveY);\n\n moveItems(\n selectedItems,\n {\n x: newX,\n y: newY,\n },\n true\n );\n placeItems(selectedItems, getBoardGrid());\n e.preventDefault();\n }\n }\n };\n\n useEventListener(document, \"keydown\", onKeyDown);\n\n return (\n <Gesture fill onDragStart={onDragStart} onDrag={onDrag} onDragEnd={onDragEnd}>\n {children}\n </Gesture>\n );\n};\n\nexport default ActionPane;\n","import { useEventListener } from \"@react-hookz/web\";\nimport React from \"react\";\n\nconst useMousePosition = (ref) => {\n const mouseRef = React.useRef({ hover: false, x: 0, y: 0 });\n\n useEventListener(ref, \"mousemove\", (e) => {\n const { clientX, clientY } = e;\n mouseRef.current.x = clientX;\n mouseRef.current.y = clientY;\n });\n useEventListener(ref, \"mouseenter\", () => {\n mouseRef.current.hover = true;\n });\n useEventListener(ref, \"mouseleave\", () => {\n mouseRef.current.hover = false;\n });\n\n const getMouseInfo = React.useCallback(() => mouseRef.current, []);\n\n return getMouseInfo;\n};\n\nexport default useMousePosition;\n","import React from \"react\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport useMainStore from \"./store/main\";\n\nconst digitCodes = [...Array(5).keys()].map((id) => `Digit${id + 1}`);\n\nconst usePositionNavigator = () => {\n const [positions, setPositions] = React.useState({});\n const [getBoardState, updateBoardState] = useMainStore((state) => [\n state.getBoardState,\n state.updateBoardState,\n ]);\n\n useEventListener(document, \"keydown\", (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n if (digitCodes.includes(e.code)) {\n const positionKey = e.code;\n const { translateX, translateY, scale } = getBoardState();\n\n if (e.altKey || e.metaKey || e.ctrlKey || e.shiftKey) {\n setPositions((prev) => ({\n ...prev,\n [positionKey]: { translateX, translateY, scale },\n }));\n } else if (positions[positionKey]) {\n updateBoardState(positions[positionKey]);\n }\n e.preventDefault();\n }\n });\n\n return null;\n};\n\nexport default usePositionNavigator;\n","import React from \"react\";\nimport { useEventListener } from \"@react-hookz/web\";\n\nimport Gesture from \"./Gesture\";\nimport useDim from \"./useDim\";\nimport useMousePosition from \"./useMousePosition\";\nimport usePositionNavigator from \"./usePositionNavigator\";\nimport useMainStore from \"./store/main\";\nimport { hasClass, insideClass } from \"@/utils\";\n\nconst PanZoom = ({ children, moveFirst = false }) => {\n const wrappedRef = React.useRef(null);\n const [\n itemExtentGlobal,\n getConfiguration,\n updateBoardState,\n getSelection,\n ] = useMainStore((state) => [\n state.config.itemExtent,\n state.getConfiguration,\n state.updateBoardState,\n state.getSelection,\n ]);\n const { zoomToCenter, zoomToExtent, moveBoard } = useDim();\n\n const [centered, setCentered] = React.useState(false);\n const timeoutRef = React.useRef({});\n\n // Get mouse position and hover status\n const getMouseInfo = useMousePosition(wrappedRef);\n\n // Hooks to save/restore position\n usePositionNavigator();\n\n /**\n * Center board on startup\n */\n const centerBoard = React.useCallback(() => {\n const { itemExtent } = getConfiguration();\n zoomToExtent(itemExtent);\n }, [getConfiguration, zoomToExtent]);\n\n React.useEffect(() => {\n if (!centered && itemExtentGlobal.radius) {\n // Center board on first valid extent\n centerBoard();\n setCentered(true);\n }\n }, [centerBoard, centered, itemExtentGlobal]);\n\n const onZoom = ({ clientX, clientY, scale }) => {\n zoomToCenter({ to: { x: clientX, y: clientY }, factor: 1 - scale / 500 });\n\n // Update the board zooming state\n clearTimeout(timeoutRef.current.zoom);\n timeoutRef.current.zoom = setTimeout(() => {\n updateBoardState({ zooming: false });\n }, 200);\n updateBoardState({ zooming: true });\n };\n\n const onPan = ({ deltaX, deltaY, target }) => {\n const item = insideClass(target, \"item\");\n if (item && hasClass(item, \"selected\")) {\n return;\n }\n\n moveBoard(({ translateX, translateY }) => ({\n translateX: translateX + deltaX,\n translateY: translateY + deltaY,\n }));\n\n // update the board panning state\n clearTimeout(timeoutRef.current.pan);\n timeoutRef.current.pan = setTimeout(() => {\n updateBoardState({ panning: false });\n }, 200);\n updateBoardState({ panning: true });\n };\n\n const onKeyDown = (e) => {\n // Block shortcut if we are typing in a textarea or input\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n let moveX = 0;\n let moveY = 0;\n let zoom = 1;\n switch (e.key) {\n case \"ArrowLeft\":\n moveX = -10;\n break;\n case \"ArrowRight\":\n moveX = 10;\n break;\n case \"ArrowUp\":\n moveY = -10;\n break;\n case \"ArrowDown\":\n moveY = 10;\n break;\n case \"PageUp\":\n zoom = 1.2;\n break;\n case \"PageDown\":\n zoom = 0.8;\n break;\n default:\n }\n if (moveX || moveY || zoom !== 1) {\n // Don't move board if moving item\n const selectedItems = getSelection();\n if (zoom === 1 && selectedItems.length) {\n return;\n }\n if (e.shiftKey) {\n moveX *= 5;\n moveY *= 5;\n }\n if (e.ctrlKey || e.altKey || e.metaKey) {\n moveX /= 5;\n moveY /= 5;\n }\n\n moveBoard(({ translateX, translateY }) => ({\n translateX: translateX + moveX,\n translateY: translateY + moveY,\n }));\n\n zoomToCenter({ factor: zoom });\n\n e.preventDefault();\n }\n // Temporary zoom\n if (e.key === \" \" && !e.repeat) {\n if (getMouseInfo().hover) {\n zoomToCenter({ factor: 3, to: getMouseInfo() });\n }\n }\n };\n\n const onKeyUp = (e) => {\n // Ignore text in Input or Textarea\n if ([\"INPUT\", \"TEXTAREA\"].includes(e.target.tagName)) return;\n\n // Zoom out on release\n if (e.key === \" \" && getMouseInfo().hover) {\n zoomToCenter({ factor: 1 / 3, to: getMouseInfo() });\n }\n };\n\n useEventListener(document, \"keydown\", onKeyDown);\n useEventListener(document, \"keyup\", onKeyUp);\n\n return (\n <Gesture\n fill\n onPan={onPan}\n onZoom={onZoom}\n mainAction={moveFirst ? \"pan\" : \"drag\"}\n >\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n }}\n className=\"board\"\n ref={wrappedRef}\n >\n {children}\n </div>\n </Gesture>\n );\n};\n\nexport default PanZoom;\n","import React from \"react\";\nimport { css } from \"goober\";\nimport { useDebouncedCallback } from \"@react-hookz/web\";\n\nimport { getItemsBoundingBox } from \"@/utils\";\nimport { useSyncedStore } from \"@/board/store/synced\";\nimport useMainStore from \"./store/main\";\n\nconst defaultZoneStyle = css({\n position: \"absolute\",\n top: 0,\n left: 0,\n zIndex: 210,\n backgroundColor: \"hsla(0, 40%, 50%, 0%)\",\n border: \"2px dashed hsl(20, 55%, 40%)\",\n pointerEvents: \"none\",\n});\n\n/**\n * Show a bounding box around all selected items.\n */\nconst BoundingBox = () => {\n const [\n selection,\n getSelection,\n selectionBox,\n setSelectionBox,\n getConfiguration,\n { translateX, translateY, scale },\n ] = useMainStore((state) => [\n state.selection,\n state.getSelection,\n state.selectionBox,\n state.setSelectionBox,\n state.getConfiguration,\n {\n translateX: state.boardState.translateX,\n translateY: state.boardState.translateY,\n scale: state.boardState.scale,\n },\n ]);\n\n const [items] = useSyncedStore((state) => [state.items]);\n\n // Update selection bounding box\n const updateBox = React.useCallback(() => {\n const currentSelectedItems = getSelection();\n const { boardWrapperRect, uid } = getConfiguration();\n\n if (currentSelectedItems.length === 0) {\n setSelectionBox(null);\n return;\n }\n\n const boundingBox = getItemsBoundingBox(currentSelectedItems, uid);\n\n if (!boundingBox) {\n setSelectionBox(null);\n return;\n }\n\n const { left, top, width, height } = boundingBox;\n\n const newBB = {\n left: left - boardWrapperRect.left,\n top: top - boardWrapperRect.top,\n height,\n width,\n };\n setSelectionBox(newBB);\n }, [getConfiguration, getSelection, setSelectionBox]);\n\n // Debounced version of update box\n const updateBoxDelay = useDebouncedCallback(updateBox, [updateBox], 300);\n\n React.useEffect(() => {\n // Update selected elements bounding box\n updateBox();\n updateBoxDelay(); // Delay to update after board item animation like tap/untap.\n }, [\n selection,\n items,\n translateX,\n translateY,\n scale,\n updateBox,\n updateBoxDelay,\n ]);\n\n if (!selectionBox || selection.length < 2) return null;\n\n return (\n <div\n style={{\n transform: `translate(${selectionBox.left}px, ${selectionBox.top}px)`,\n height: `${selectionBox.height}px`,\n width: `${selectionBox.width}px`,\n }}\n className={`selection ${defaultZoneStyle}`}\n />\n );\n};\n\nconst Selection = () => {\n const [movingItems] = useMainStore((state) => [state.boardState.movingItems]);\n\n if (movingItems) {\n return null;\n }\n\n return <BoundingBox />;\n};\n\nexport default Selection;\n","/**\n * Clamps a number between a lower and upper bound.\n *\n * ```js\n * guard(0, 1, 2); // 1\n * ```\n *\n * @param low The lower bound.\n * @param high The upper bound.\n * @param value The number to clamp.\n * @returns The clamped number.\n */\nfunction guard(low, high, value) {\n return Math.min(Math.max(low, value), high);\n}\n\n/**\n * Error thrown when color2k cannot parse an input color.\n *\n * ```js\n * new ColorError('nope').message; // 'Failed to parse color: \"nope\"'\n * ```\n *\n * @param color The color value that failed to parse.\n */\nclass ColorError extends Error {\n constructor(color) {\n super(`Failed to parse color: \"${color}\"`);\n }\n}\n\n/**\n * Parses a color into red, green, blue, and alpha channel values.\n *\n * Supports hex, RGB, RGBA, HSL, HSLA, CSS named colors, and `transparent`.\n *\n * ```js\n * parseToRgba('rgba(255, 0, 0, 0.5)'); // [255, 0, 0, 0.5]\n * ```\n *\n * @param color The input color.\n * @returns A tuple of red, green, blue, and alpha channel values.\n */\nfunction parseToRgba(color) {\n if (typeof color !== 'string') throw new ColorError(color);\n if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];\n let normalizedColor = color.trim();\n normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;\n const reducedHexMatch = reducedHexRegex.exec(normalizedColor);\n if (reducedHexMatch) {\n const arr = Array.from(reducedHexMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(r(x, 2), 16)), parseInt(r(arr[3] || 'f', 2), 16) / 255];\n }\n const hexMatch = hexRegex.exec(normalizedColor);\n if (hexMatch) {\n const arr = Array.from(hexMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(x, 16)), parseInt(arr[3] || 'ff', 16) / 255];\n }\n const rgbaMatch = rgbaRegex.exec(normalizedColor);\n if (rgbaMatch) {\n const arr = Array.from(rgbaMatch).slice(1);\n return [...arr.slice(0, 3).map(x => parseInt(x, 10)), parseFloat(arr[3] || '1')];\n }\n const hslaMatch = hslaRegex.exec(normalizedColor);\n if (hslaMatch) {\n const [h, s, l, a] = Array.from(hslaMatch).slice(1).map(parseFloat);\n if (guard(0, 100, s) !== s) throw new ColorError(color);\n if (guard(0, 100, l) !== l) throw new ColorError(color);\n return [...hslToRgb(h, s, l), Number.isNaN(a) ? 1 : a];\n }\n throw new ColorError(color);\n}\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n while (i) {\n hash = hash * 33 ^ str.charCodeAt(--i);\n }\n\n /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed\n * integers. Since we want the results to be always positive, convert the\n * signed int to an unsigned by doing an unsigned bitshift. */\n return (hash >>> 0) % 2341;\n}\nconst colorToInt = x => parseInt(x.replace(/_/g, ''), 36);\nconst compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce((acc, next) => {\n const key = colorToInt(next.substring(0, 3));\n const hex = colorToInt(next.substring(3)).toString(16);\n\n // NOTE: padStart could be used here but it breaks Node 6 compat\n // https://github.com/ricokahler/color2k/issues/351\n let prefix = '';\n for (let i = 0; i < 6 - hex.length; i++) {\n prefix += '0';\n }\n acc[key] = `${prefix}${hex}`;\n return acc;\n}, {});\n\n/**\n * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.\n */\nfunction nameToHex(color) {\n const normalizedColorName = color.toLowerCase().trim();\n const result = compressedColorMap[hash(normalizedColorName)];\n if (!result) throw new ColorError(color);\n return `#${result}`;\n}\nconst r = (str, amount) => Array.from(Array(amount)).map(() => str).join('');\nconst reducedHexRegex = new RegExp(`^#${r('([a-f0-9])', 3)}([a-f0-9])?$`, 'i');\nconst hexRegex = new RegExp(`^#${r('([a-f0-9]{2})', 3)}([a-f0-9]{2})?$`, 'i');\nconst rgbaRegex = new RegExp(`^rgba?\\\\(\\\\s*(\\\\d+)\\\\s*${r(',\\\\s*(\\\\d+)\\\\s*', 2)}(?:,\\\\s*([\\\\d.]+))?\\\\s*\\\\)$`, 'i');\nconst hslaRegex = /^hsla?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)%\\s*,\\s*([\\d.]+)%(?:\\s*,\\s*([\\d.]+))?\\s*\\)$/i;\nconst namedColorRegex = /^[a-z]+$/i;\nconst roundColor = color => {\n return Math.round(color * 255);\n};\nconst hslToRgb = (hue, saturation, lightness) => {\n let l = lightness / 100;\n if (saturation === 0) {\n // achromatic\n return [l, l, l].map(roundColor);\n }\n\n // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV\n const huePrime = (hue % 360 + 360) % 360 / 60;\n const chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);\n const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));\n let red = 0;\n let green = 0;\n let blue = 0;\n if (huePrime >= 0 && huePrime < 1) {\n red = chroma;\n green = secondComponent;\n } else if (huePrime >= 1 && huePrime < 2) {\n red = secondComponent;\n green = chroma;\n } else if (huePrime >= 2 && huePrime < 3) {\n green = chroma;\n blue = secondComponent;\n } else if (huePrime >= 3 && huePrime < 4) {\n green = secondComponent;\n blue = chroma;\n } else if (huePrime >= 4 && huePrime < 5) {\n red = secondComponent;\n blue = chroma;\n } else if (huePrime >= 5 && huePrime < 6) {\n red = chroma;\n blue = secondComponent;\n }\n const lightnessModification = l - chroma / 2;\n const finalRed = red + lightnessModification;\n const finalGreen = green + lightnessModification;\n const finalBlue = blue + lightnessModification;\n return [finalRed, finalGreen, finalBlue].map(roundColor);\n};\n\n// taken from:\n// https://github.com/styled-components/polished/blob/a23a6a2bb26802b3d922d9c3b67bac3f3a54a310/src/internalHelpers/_rgbToHsl.js\n\n/**\n * Parses a color into hue, saturation, lightness, and alpha channel values.\n *\n * Hue is a number between 0 and 360. Saturation, lightness, and alpha are\n * decimal percentages between 0 and 1.\n *\n * ```js\n * parseToHsla('red'); // [0, 1, 0.5, 1]\n * ```\n *\n * @param color The input color.\n * @returns A tuple of hue, saturation, lightness, and alpha values.\n */\nfunction parseToHsla(color) {\n const [red, green, blue, alpha] = parseToRgba(color).map((value, index) =>\n // 3rd index is alpha channel which is already normalized\n index === 3 ? value : value / 255);\n const max = Math.max(red, green, blue);\n const min = Math.min(red, green, blue);\n const lightness = (max + min) / 2;\n\n // achromatic\n if (max === min) return [0, 0, lightness, alpha];\n const delta = max - min;\n const saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);\n const hue = 60 * (red === max ? (green - blue) / delta + (green < blue ? 6 : 0) : green === max ? (blue - red) / delta + 2 : (red - green) / delta + 4);\n return [hue, saturation, lightness, alpha];\n}\n\n/**\n * Builds an `hsla` color string from hue, saturation, lightness, and alpha\n * channel values.\n *\n * ```js\n * hsla(0, 1, 0.5, 1); // 'hsla(0, 100%, 50%, 1)'\n * ```\n *\n * @param hue The color wheel angle from 0 to 360.\n * @param saturation The saturation as a decimal between 0 and 1.\n * @param lightness The lightness as a decimal between 0 and 1.\n * @param alpha The opacity as a decimal between 0 and 1.\n * @returns An `hsla` color string.\n */\nfunction hsla(hue, saturation, lightness, alpha) {\n return `hsla(${(hue % 360).toFixed()}, ${guard(0, 100, saturation * 100).toFixed()}%, ${guard(0, 100, lightness * 100).toFixed()}%, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;\n}\n\n/**\n * Rotates a color's hue by the given number of degrees and returns the result\n * as an `hsla` string. Hue values wrap around the 0 to 360 degree color wheel.\n *\n * ```js\n * adjustHue('red', 180); // 'hsla(180, 100%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param degrees The number of degrees to rotate the hue.\n * @returns The adjusted color as an `hsla` string.\n */\nfunction adjustHue(color, degrees) {\n const [h, s, l, a] = parseToHsla(color);\n return hsla(h + degrees, s, l, a);\n}\n\n/**\n * Darkens a color by subtracting from the lightness channel in HSL space.\n *\n * ```js\n * darken('white', 0.1); // 'hsla(0, 0%, 90%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to darken, given as a decimal between 0 and 1.\n * @returns The darkened color as an `hsla` string.\n */\nfunction darken(color, amount) {\n const [hue, saturation, lightness, alpha] = parseToHsla(color);\n return hsla(hue, saturation, lightness - amount, alpha);\n}\n\n/**\n * Desaturates a color by subtracting from the saturation channel in HSL space.\n *\n * ```js\n * desaturate('red', 0.5); // 'hsla(0, 50%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to desaturate, given as a decimal between 0 and 1.\n * @returns The desaturated color as an `hsla` string.\n */\nfunction desaturate(color, amount) {\n const [h, s, l, a] = parseToHsla(color);\n return hsla(h, s - amount, l, a);\n}\n\n// taken from:\n// https://github.com/styled-components/polished/blob/0764c982551b487469043acb56281b0358b3107b/src/color/getLuminance.js\n\n/**\n * Returns the relative luminance of a color using the WCAG formula.\n *\n * ```js\n * getLuminance('papayawhip'); // 0.877971001998354\n * ```\n *\n * @param color The input color.\n * @returns A number between 0 for darkest black and 1 for lightest white.\n */\nfunction getLuminance(color) {\n if (color === 'transparent') return 0;\n function f(x) {\n const channel = x / 255;\n return channel <= 0.04045 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);\n }\n const [r, g, b] = parseToRgba(color);\n return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);\n}\n\n// taken from:\n// https://github.com/styled-components/polished/blob/0764c982551b487469043acb56281b0358b3107b/src/color/getContrast.js\n\n/**\n * Returns the contrast ratio between two colors based on the WCAG contrast\n * ratio formula.\n *\n * ```js\n * getContrast('#444', '#fff'); // 9.739769120526205\n * ```\n *\n * @param color1 The first color.\n * @param color2 The second color.\n * @returns The contrast ratio between the two colors.\n */\nfunction getContrast(color1, color2) {\n const luminance1 = getLuminance(color1);\n const luminance2 = getLuminance(color2);\n return luminance1 > luminance2 ? (luminance1 + 0.05) / (luminance2 + 0.05) : (luminance2 + 0.05) / (luminance1 + 0.05);\n}\n\n/**\n * Builds an `rgba` color string from red, green, blue, and alpha channel\n * values.\n *\n * ```js\n * rgba(255, 0, 0, 1); // 'rgba(255, 0, 0, 1)'\n * ```\n *\n * @param red The red channel value from 0 to 255.\n * @param green The green channel value from 0 to 255.\n * @param blue The blue channel value from 0 to 255.\n * @param alpha The opacity as a decimal between 0 and 1.\n * @returns An `rgba` color string.\n */\nfunction rgba(red, green, blue, alpha) {\n return `rgba(${guard(0, 255, red).toFixed()}, ${guard(0, 255, green).toFixed()}, ${guard(0, 255, blue).toFixed()}, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;\n}\n\n/**\n * Mixes two colors together using the Sass mix algorithm and returns an `rgba`\n * color string.\n *\n * ```js\n * mix('red', 'blue', 0.5); // 'rgba(128, 0, 128, 1)'\n * ```\n *\n * @param color1 The first color.\n * @param color2 The second color.\n * @param weight The mix weight as a decimal between 0 and 1.\n * @returns The mixed color as an `rgba` string.\n */\nfunction mix(color1, color2, weight) {\n const normalize = (n, index) =>\n // 3rd index is alpha channel which is already normalized\n index === 3 ? n : n / 255;\n const [r1, g1, b1, a1] = parseToRgba(color1).map(normalize);\n const [r2, g2, b2, a2] = parseToRgba(color2).map(normalize);\n\n // The formula is copied from the original Sass implementation:\n // http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method\n const alphaDelta = a2 - a1;\n const normalizedWeight = weight * 2 - 1;\n const combinedWeight = normalizedWeight * alphaDelta === -1 ? normalizedWeight : normalizedWeight + alphaDelta / (1 + normalizedWeight * alphaDelta);\n const weight2 = (combinedWeight + 1) / 2;\n const weight1 = 1 - weight2;\n const r = (r1 * weight1 + r2 * weight2) * 255;\n const g = (g1 * weight1 + g2 * weight2) * 255;\n const b = (b1 * weight1 + b2 * weight2) * 255;\n const a = a2 * weight + a1 * (1 - weight);\n return rgba(r, g, b, a);\n}\n\n/**\n * Returns a scale function that interpolates through a list of colors.\n *\n * The returned function accepts a decimal between 0 and 1 and returns the color\n * at that percentage in the scale.\n *\n * ```js\n * const scale = getScale('red', 'yellow', 'green');\n * console.log(scale(0)); // rgba(255, 0, 0, 1)\n * console.log(scale(0.5)); // rgba(255, 255, 0, 1)\n * console.log(scale(1)); // rgba(0, 128, 0, 1)\n * ```\n *\n * If you'd like to limit the domain and range like chroma-js, we recommend\n * wrapping scale again.\n *\n * ```js\n * const _scale = getScale('red', 'yellow', 'green');\n * const scale = x => _scale(x / 100);\n *\n * console.log(scale(0)); // rgba(255, 0, 0, 1)\n * console.log(scale(50)); // rgba(255, 255, 0, 1)\n * console.log(scale(100)); // rgba(0, 128, 0, 1)\n * ```\n *\n * @param colors The colors to interpolate through.\n * @returns A function that maps a decimal percentage to an `rgba` color.\n */\nfunction getScale(...colors) {\n return n => {\n const lastIndex = colors.length - 1;\n const lowIndex = guard(0, lastIndex, Math.floor(n * lastIndex));\n const highIndex = guard(0, lastIndex, Math.ceil(n * lastIndex));\n const color1 = colors[lowIndex];\n const color2 = colors[highIndex];\n const unit = 1 / lastIndex;\n const weight = (n - unit * lowIndex) / unit;\n return mix(color1, color2, weight);\n };\n}\n\nconst guidelines = {\n decorative: 1.5,\n readable: 3,\n aa: 4.5,\n aaa: 7\n};\n\n/**\n * Returns whether a color fails a contrast threshold against a background.\n *\n * The supported standards are `decorative`, `readable`, `aa`, and `aaa`.\n *\n * ```js\n * hasBadContrast('red', 'aa'); // true\n * ```\n *\n * @param color The foreground color.\n * @param standard The contrast standard to test against.\n * @param background The background color.\n * @returns `true` when the contrast ratio is below the selected standard.\n */\nfunction hasBadContrast(color, standard = 'aa', background = '#fff') {\n return getContrast(color, background) < guidelines[standard];\n}\n\n/**\n * Lightens a color by adding to the lightness channel in HSL space.\n *\n * This is equivalent to `darken(color, -amount)`.\n *\n * ```js\n * lighten('black', 0.1); // 'hsla(0, 0%, 10%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to lighten, given as a decimal between 0 and 1.\n * @returns The lightened color as an `hsla` string.\n */\nfunction lighten(color, amount) {\n return darken(color, -amount);\n}\n\n/**\n * Makes a color more transparent by decreasing the alpha channel.\n *\n * ```js\n * transparentize('white', 0.1); // 'rgba(255, 255, 255, 0.9)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to increase transparency by, given as a decimal between 0 and 1.\n * @returns The more transparent color as an `rgba` string.\n */\nfunction transparentize(color, amount) {\n const [r, g, b, a] = parseToRgba(color);\n return rgba(r, g, b, a - amount);\n}\n\n/**\n * Makes a color more opaque by increasing the alpha channel.\n *\n * This is equivalent to `transparentize(color, -amount)`.\n *\n * ```js\n * opacify('rgba(255, 255, 255, 0.5)', 0.1); // 'rgba(255, 255, 255, 0.6)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to increase opacity by, given as a decimal between 0 and 1.\n * @returns The more opaque color as an `rgba` string.\n */\nfunction opacify(color, amount) {\n return transparentize(color, -amount);\n}\n\n/**\n * Returns whether black is the more readable color to place on top of the\n * input color.\n *\n * This is the boolean form of `readableColor`.\n *\n * ```js\n * readableColorIsBlack('white'); // true\n * ```\n *\n * @param color The background color.\n * @returns `true` when black is the more readable foreground color.\n */\nfunction readableColorIsBlack(color) {\n return getLuminance(color) > 0.179;\n}\n\n/**\n * Returns black or white, whichever has better contrast against the given\n * color.\n *\n * ```js\n * readableColor('white'); // '#000'\n * ```\n *\n * @param color The background color.\n * @returns `#000` or `#fff`.\n */\nfunction readableColor(color) {\n return readableColorIsBlack(color) ? '#000' : '#fff';\n}\n\n/**\n * Saturates a color by adding to the saturation channel in HSL space.\n *\n * This is equivalent to `desaturate(color, -amount)`.\n *\n * ```js\n * saturate('hsl(0, 50%, 50%)', 0.1); // 'hsla(0, 60%, 50%, 1)'\n * ```\n *\n * @param color The input color.\n * @param amount The amount to saturate, given as a decimal between 0 and 1.\n * @returns The saturated color as an `hsla` string.\n */\nfunction saturate(color, amount) {\n return desaturate(color, -amount);\n}\n\n/**\n * Converts a color to a hex color string.\n *\n * Includes an alpha channel when the input color is not fully opaque.\n *\n * ```js\n * toHex('palevioletred'); // '#db7093'\n * ```\n *\n * @param color The input color.\n * @returns A hex color string.\n */\nfunction toHex(color) {\n const [r, g, b, a] = parseToRgba(color);\n let hex = x => {\n const h = guard(0, 255, x).toString(16);\n // NOTE: padStart could be used here but it breaks Node 6 compat\n // https://github.com/ricokahler/color2k/issues/351\n return h.length === 1 ? `0${h}` : h;\n };\n return `#${hex(r)}${hex(g)}${hex(b)}${a < 1 ? hex(Math.round(a * 255)) : ''}`;\n}\n\n/**\n * Converts a color to an `rgba` color string.\n *\n * ```js\n * toRgba('midnightblue'); // 'rgba(25, 25, 112, 1)'\n * ```\n *\n * @param color The input color.\n * @returns An `rgba` color string.\n */\nfunction toRgba(color) {\n return rgba(...parseToRgba(color));\n}\n\n/**\n * Converts a color to an `hsla` color string.\n *\n * ```js\n * toHsla('peachpuff'); // 'hsla(28, 100%, 86%, 1)'\n * ```\n *\n * @param color The input color.\n * @returns An `hsla` color string.\n */\nfunction toHsla(color) {\n return hsla(...parseToHsla(color));\n}\n\nexport { ColorError, adjustHue, darken, desaturate, getContrast, getLuminance, getScale, guard, hasBadContrast, hsla, lighten, mix, opacify, parseToHsla, parseToRgba, readableColor, readableColorIsBlack, rgba, saturate, toHex, toHsla, toRgba, transparentize };\n//# sourceMappingURL=index.exports.import.es.mjs.map\n","import React from \"react\";\nimport { css } from \"goober\";\n\nimport { readableColorIsBlack } from \"color2k\";\n\nconst cursorClass = css({\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n zIndex: 210,\n pointerEvents: \"none\",\n});\n\nconst cursorLabelClass = css({\n fontWeight: \"bold\",\n padding: \"0 0.5em\",\n borderRadius: \"2px\",\n maxWidth: \"5em\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n marginLeft: \"-0.5em\",\n marginTop: \"1.7em\",\n whitespace: \"nowrap\",\n pointerEvents: \"none\",\n});\n\nconst Cursor = ({ color = \"#666\", size = 40, text }) => {\n const textColor = readableColorIsBlack(color) ? \"#222\" : \"#EEE\";\n return (\n <div className={cursorClass}>\n <svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"1064.7701 445.5539 419.8101 717.0565\"\n width={size}\n height={size}\n >\n <path\n d=\"m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z\"\n style={{\n fill: textColor,\n }}\n />\n <path\n d=\"m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z\"\n style={{\n fill: \"white\",\n stroke: \"#111\",\n strokeWidth: 20,\n }}\n />\n </svg>\n <div\n style={{\n color: textColor,\n backgroundColor: color,\n }}\n className={cursorLabelClass}\n >\n {text}\n </div>\n </div>\n );\n};\n\nconst MemoizedCursor = React.memo(Cursor);\n\nconst defaultPositionedCursorClass = css({\n top: 0,\n left: 0,\n zIndex: 210,\n position: \"fixed\",\n pointerEvents: \"none\",\n});\n\nconst PositionedCursor = ({ pos, ...rest }) => {\n return (\n <div\n className={defaultPositionedCursorClass}\n style={{\n transform: `translate(${pos.x - 6}px, ${pos.y - 15}px)`,\n }}\n >\n <MemoizedCursor {...rest} />\n </div>\n );\n};\n\nexport default PositionedCursor;\n","import React from \"react\";\nimport Cursor from \"./Cursor\";\nimport { useSyncedUsers } from \"@/users/store\";\nimport useDim from \"@/board/useDim\";\nimport { isPointInsideRect } from \"@/utils\";\nimport useMainStore from \"@/board/store/main\";\n\nconst CursorPane = ({ children }) => {\n const [getConfiguration] = useMainStore((state) => [\n state.getConfiguration,\n state.boardState.scale, // We want to update this component when the scale changes\n ]);\n const { fromWrapperToBoard, fromBoardToWrapper } = useDim();\n const [currentUser, localUsers, cursors, usersById] = useSyncedUsers(\n (state) => [\n state.getUser(),\n state.getLocalUsers(),\n state.cursors,\n state.users,\n ]\n );\n const [moveCursor, removeCursor] = useSyncedUsers((state) => [\n state.moveCursor,\n state.removeCursor,\n ]);\n\n const { boardWrapperRect } = getConfiguration();\n\n const onMouseMove = ({ clientX, clientY }) => {\n const [x, y] = fromWrapperToBoard(\n clientX - boardWrapperRect.left,\n clientY - boardWrapperRect.top\n );\n moveCursor(currentUser.id, { x, y });\n };\n\n const onLeave = () => {\n removeCursor(currentUser.id);\n };\n\n // Prevent race condition when removing user\n const currentCursors = localUsers.reduce((acc, user) => {\n if (user.id !== currentUser.id && cursors[user.id]) {\n acc[user.id] = cursors[user.id];\n }\n return acc;\n }, {});\n\n return (\n <div onPointerMove={onMouseMove} onPointerLeave={onLeave}>\n {children}\n {Object.entries(currentCursors).map(([userId, pos]) => {\n const [x, y] = fromBoardToWrapper(pos.x, pos.y);\n const coord = {\n x: x + boardWrapperRect.left,\n y: y + boardWrapperRect.top,\n };\n if (!isPointInsideRect(coord, boardWrapperRect)) {\n return null;\n }\n return (\n <Cursor\n key={userId}\n pos={coord}\n text={usersById[userId].name}\n color={usersById[userId].color}\n />\n );\n })}\n </div>\n );\n};\n\nexport default CursorPane;\n","import { transformFrom, transformTo } from \"@/utils\";\n\nconst CSS_LENGTH_RE = /[+-]?(?:\\d*\\.)?\\d+(?:e[+-]?\\d+)?(?:px|%)/gi;\n\n/**\n * Splits a CSS list while ignoring separators inside strings and parentheses.\n * This keeps gradients, URLs, and calc() expressions together.\n *\n * @param {string} value CSS list to split.\n * @param {string} [separator=\",\"] Character separating list items.\n * @returns {string[]} Trimmed, non-empty list items.\n */\nexport function splitCSS(value, separator = \",\") {\n let depth = 0;\n let quote = \"\";\n let partStart = 0;\n const parts = [];\n\n for (const [index, char] of value.split(\"\").entries()) {\n if (quote) {\n if (char === quote && value[index - 1] !== \"\\\\\") quote = \"\";\n } else if (char === '\"' || char === \"'\") quote = char;\n else if (char === \"(\") depth++;\n else if (char === \")\") depth--;\n else if (depth === 0 && char === separator) {\n const part = value.slice(partStart, index).trim();\n if (part) parts.push(part);\n partStart = index + 1;\n }\n }\n\n const finalPart = value.slice(partStart).trim();\n if (finalPart) parts.push(finalPart);\n return parts;\n}\n\n/**\n * Converts CSS pixel and percentage lengths into pixels.\n * Percentage values are resolved against the supplied reference dimension.\n *\n * @param {string} value CSS length or calc() expression.\n * @param {number} reference Dimension used to resolve percentages.\n * @returns {number} Resolved pixel value.\n */\nexport function cssLength(value, reference) {\n return [...value.replace(/\\s/g, \"\").matchAll(CSS_LENGTH_RE)].reduce(\n (sum, [term]) =>\n sum +\n Number.parseFloat(term) * (term.endsWith(\"%\") ? reference / 100 : 1),\n 0\n );\n}\n\n/**\n * Calculates the rendered width and height of a background tile.\n * Supports explicit lengths, auto dimensions, cover, and contain sizing.\n *\n * @param {string} size CSS background-size value.\n * @param {number} width Available width in pixels.\n * @param {number} height Available height in pixels.\n * @param {{ width?: number, height?: number }} [intrinsic] Source dimensions.\n * @returns {[number, number]} Tile width and height in pixels.\n */\nexport function tileSize(size, width, height, intrinsic) {\n const [x, y = \"auto\"] = splitCSS(size, \" \");\n const iw = intrinsic?.width;\n const ih = intrinsic?.height;\n if (x === \"cover\" || x === \"contain\") {\n if (!iw || !ih) return [width, height];\n const factor = Math[x === \"cover\" ? \"max\" : \"min\"](width / iw, height / ih);\n return [iw * factor, ih * factor];\n }\n let w = x === \"auto\" ? null : cssLength(x, width);\n let h = y === \"auto\" ? null : cssLength(y, height);\n if (w === null && h === null) return [iw || width, ih || height];\n if (w === null) w = iw && ih ? (h * iw) / ih : width;\n if (h === null) h = iw && ih ? (w * ih) / iw : height;\n return [w, h];\n}\n\n/**\n * Finds a world-space rectangle covering the transformed viewport.\n * The extra padding prevents visible gaps at the edges during transforms.\n *\n * @param {number} width Viewport width in pixels.\n * @param {number} height Viewport height in pixels.\n * @param {object} camera Current pan, scale, and rotation.\n * @returns {{ left: number, top: number, width: number, height: number, x: number, y: number }}\n * World bounds and their screen-space origin.\n */\nexport function backgroundWindow(width, height, camera) {\n const corners = [\n [0, 0],\n [width, 0],\n [0, height],\n [width, height],\n ].map((corner) => transformFrom(corner, camera));\n const xs = corners.map(([x]) => x);\n const ys = corners.map(([, y]) => y);\n const left = Math.floor(Math.min(...xs)) - 2;\n const top = Math.floor(Math.min(...ys)) - 2;\n const right = Math.ceil(Math.max(...xs)) + 2;\n const bottom = Math.ceil(Math.max(...ys)) + 2;\n const [x, y] = transformTo([left, top], camera);\n return { left, top, width: right - left, height: bottom - top, x, y };\n}\n\n/**\n * Returns a position wrapped into a repeating interval.\n * Unlike the remainder operator, this also works for negative coordinates.\n *\n * @param {number} position Position to wrap.\n * @param {number} start Start of the interval.\n * @param {number} size Interval length.\n * @returns {number} Wrapped position offset.\n */\nexport const repeatOffset = (position, start, size) =>\n (((position - start) % size) + size) % size;\n\n/**\n * Generates the world-space background tiles intersecting the viewport.\n * It adds a one-tile buffer around the visible bounds for smooth panning.\n *\n * @param {number} width Viewport width in pixels.\n * @param {number} height Viewport height in pixels.\n * @param {object} camera Current pan, scale, and rotation.\n * @param {number} [tileSizeOverride] Fixed tile size in world pixels.\n * @returns {{ tiles: Array<{ key: string, left: number, top: number }>, size: number, left: number, top: number, x: number, y: number }}\n * Tile descriptors and the transformed grid origin.\n */\nexport function visibleTiles(width, height, camera, tileSizeOverride) {\n const bounds = backgroundWindow(width, height, camera);\n // Coarser tiles when zoomed out keep the mounted count bounded.\n const size =\n Number.isFinite(tileSizeOverride) && tileSizeOverride > 0\n ? tileSizeOverride\n : 512 * 2 ** Math.max(0, Math.ceil(Math.log2(1 / camera.scale)));\n const firstColumn = Math.floor(bounds.left / size) - 1;\n const lastColumn = Math.floor((bounds.left + bounds.width) / size) + 1;\n const firstRow = Math.floor(bounds.top / size) - 1;\n const lastRow = Math.floor((bounds.top + bounds.height) / size) + 1;\n const left = firstColumn * size;\n const top = firstRow * size;\n const [x, y] = transformTo([left, top], camera);\n const tiles = Array.from(\n { length: lastRow - firstRow + 1 },\n (_, rowIndex) => {\n const row = firstRow + rowIndex;\n return Array.from(\n { length: lastColumn - firstColumn + 1 },\n (_, columnIndex) => {\n const column = firstColumn + columnIndex;\n return {\n key: `${size}:${column}:${row}`,\n left: column * size,\n top: row * size,\n };\n }\n );\n }\n ).flat();\n\n return { tiles, size, left, top, x, y };\n}\n","import React from \"react\";\nimport useMainStore from \"./store/main\";\nimport {\n visibleTiles,\n cssLength,\n repeatOffset,\n splitCSS,\n tileSize,\n} from \"./background\";\n\nconst fill = { position: \"absolute\", inset: 0, pointerEvents: \"none\" };\n\nexport default function WorldBackground({ style, tileSizeOverride }) {\n const [camera, rect] = useMainStore((state) => [\n state.boardState,\n state.config.boardWrapperRect,\n ]);\n const width = rect.width || 1;\n const height = rect.height || 1;\n const probe = React.useRef(null);\n const [background, setBackground] = React.useState({\n color: \"#333\",\n layers: [],\n });\n const [images, setImages] = React.useState({});\n\n React.useLayoutEffect(() => {\n const css = getComputedStyle(probe.current);\n const read = (key) => splitCSS(css[key]);\n const sizes = read(\"backgroundSize\");\n const xs = read(\"backgroundPositionX\");\n const ys = read(\"backgroundPositionY\");\n const repeats = read(\"backgroundRepeat\");\n const blends = read(\"backgroundBlendMode\");\n setBackground({\n color: css.backgroundColor,\n layers: read(\"backgroundImage\").map((image, i) => ({\n image,\n size: sizes[i % sizes.length],\n x: xs[i % xs.length],\n y: ys[i % ys.length],\n repeat: repeats[i % repeats.length],\n blend: blends[i % blends.length],\n })),\n });\n }, [style, width, height]);\n\n React.useEffect(() => {\n let active = true;\n background.layers.forEach(({ image }) => {\n if (!image.startsWith(\"url(\")) return;\n const img = new Image();\n img.onload = () => {\n if (active)\n setImages((prev) => ({\n ...prev,\n [image]: { width: img.naturalWidth, height: img.naturalHeight },\n }));\n };\n img.src = image.slice(4, -1).replace(/^[\"']|[\"']$/g, \"\");\n });\n return () => {\n active = false;\n };\n }, [background.layers]);\n\n const grid = visibleTiles(width, height, camera, tileSizeOverride);\n const layers = background.layers.map((layer) => {\n const [w, h] = tileSize(layer.size, width, height, images[layer.image]);\n const repeatX =\n [\"repeat\", \"repeat-x\"].includes(layer.repeat) ||\n layer.repeat.startsWith(\"repeat \");\n const repeatY =\n [\"repeat\", \"repeat-y\"].includes(layer.repeat) ||\n layer.repeat.endsWith(\" repeat\");\n const x = cssLength(layer.x, width - w);\n const y = cssLength(layer.y, height - h);\n return {\n ...layer,\n size: `${w}px ${h}px`,\n position: (left, top) =>\n `${repeatX && w ? repeatOffset(x, left, w) : x - left}px ${repeatY && h ? repeatOffset(y, top, h) : y - top}px`,\n };\n });\n\n return (\n <div\n className=\"world-background\"\n aria-hidden=\"true\"\n style={{ ...fill, overflow: \"hidden\", backgroundColor: background.color }}\n >\n <div\n ref={probe}\n style={{\n backgroundColor: \"#333\",\n ...style,\n position: \"absolute\",\n width,\n height,\n visibility: \"hidden\",\n pointerEvents: \"none\",\n }}\n />\n <div\n className=\"world-background-tiles\"\n style={{\n position: \"absolute\",\n transformOrigin: \"0 0\",\n transform: `translate(${grid.x}px, ${grid.y}px) rotate(${camera.rotate}deg) scale(${camera.scale})`,\n }}\n >\n {grid.tiles.map((tile) => (\n <div\n key={tile.key}\n className=\"world-background-tile\"\n data-tile={tile.key}\n style={{\n position: \"absolute\",\n left: tile.left - grid.left,\n top: tile.top - grid.top,\n width: grid.size,\n height: grid.size,\n backgroundImage: layers.map((l) => l.image).join(\", \"),\n backgroundSize: layers.map((l) => l.size).join(\", \"),\n backgroundPosition: layers\n .map((l) => l.position(tile.left, tile.top))\n .join(\", \"),\n backgroundRepeat: layers.map((l) => l.repeat).join(\", \"),\n backgroundBlendMode: layers.map((l) => l.blend).join(\", \"),\n }}\n />\n ))}\n </div>\n </div>\n );\n}\n","import React from \"react\";\nimport { nanoid } from \"nanoid\";\n\nimport { ItemList } from \"./Items\";\nimport Selector from \"./Selector\";\nimport ActionPane from \"./ActionPane\";\nimport PanZoom from \"./PanZoom\";\nimport Selection from \"./Selection\";\nimport { DEFAULT_BOARD_MAX_SIZE } from \"@/settings\";\nimport useDim from \"./useDim\";\nimport useMainStore from \"./store/main\";\n\nimport { useResizeObserver } from \"@react-hookz/web\";\nimport { css } from \"goober\";\nimport CursorPane from \"./Cursors/CursorPane\";\nimport WorldBackground from \"./WorldBackground\";\n\nconst NullWrapper = ({ children }) => children;\nconst emptyTemplates = {};\n\nconst defaultStyle = {\n overflow: \"hidden\",\n position: \"absolute\",\n inset: 0,\n};\n\nconst Board = ({\n moveFirst = true,\n style,\n wrapperStyle,\n itemTemplates = emptyTemplates,\n // Deprecated compatibility prop. The logical canvas is unbounded.\n boardSize = DEFAULT_BOARD_MAX_SIZE,\n backgroundTileSize,\n children,\n showResizeHandle = false,\n Wrapper = NullWrapper,\n}) => {\n const boardWrapperRef = React.useRef(null);\n const [uid, updateConfiguration] = useMainStore((state) => [\n state.config.uid,\n state.updateConfiguration,\n ]);\n const [translateX, translateY, scale, rotate] = useMainStore(\n (state) => [\n state.boardState.translateX,\n state.boardState.translateY,\n state.boardState.scale,\n state.boardState.rotate,\n ]\n );\n const { updateItemExtent } = useDim();\n\n const boardStyle = {\n userSelect: \"none\",\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n transformOrigin: \"0 0\",\n transform: `translate(${translateX}px, ${translateY}px) rotate(${rotate}deg) scale(${scale})`,\n pointerEvents: \"none\",\n };\n\n\n React.useEffect(() => {\n // Chrome-related issue.\n // Making the wheel event non-passive, which allows to use preventDefault() to prevent\n // the browser original zoom and therefore allowing our custom one.\n // More detail at https://github.com/facebook/react/issues/14856\n const cancelWheel = (event) => {\n if (boardWrapperRef.current?.contains(event.target)) event.preventDefault();\n };\n\n document.body.addEventListener(\"wheel\", cancelWheel, { passive: false });\n\n return () => {\n document.body.removeEventListener(\"wheel\", cancelWheel);\n };\n }, []);\n\n React.useEffect(() => {\n updateConfiguration({\n boardWrapper: boardWrapperRef.current,\n });\n }, [updateConfiguration]);\n\n React.useEffect(() => {\n if (!uid) {\n updateConfiguration({\n uid: nanoid(),\n });\n }\n }, [uid, updateConfiguration]);\n\n React.useEffect(() => {\n updateConfiguration({\n itemTemplates,\n boardSize,\n showResizeHandle,\n });\n }, [itemTemplates, boardSize, showResizeHandle, updateConfiguration]);\n\n React.useEffect(() => {\n updateConfiguration({\n boardWrapperRect: boardWrapperRef.current.getBoundingClientRect(),\n });\n updateItemExtent();\n // Hack to update item extent on load\n setTimeout(updateItemExtent, 2000);\n }, [updateConfiguration, updateItemExtent]);\n\n useResizeObserver(boardWrapperRef, () => {\n if (!boardWrapperRef.current) {\n return;\n }\n updateConfiguration({\n boardWrapperRect: boardWrapperRef.current.getBoundingClientRect(),\n });\n });\n\n const boardWrapperClass = css({ ...defaultStyle, ...wrapperStyle });\n\n return (\n <div\n ref={boardWrapperRef}\n id={uid}\n className={`sync-board ${boardWrapperClass}`}\n >\n <WorldBackground style={style} tileSizeOverride={backgroundTileSize} />\n <CursorPane>\n <Selector moveFirst={moveFirst}>\n <PanZoom moveFirst={moveFirst}>\n <ActionPane moveFirst={moveFirst}>\n <Wrapper>\n <div\n onContextMenu={(e) => {\n e.preventDefault();\n }}\n style={boardStyle}\n className={`board-pane${scale < 0.5 ? \" board-pane__far\" : \"\"}`}\n >\n <ItemList />\n <div style={{ pointerEvents: \"auto\" }}>{children}</div>\n </div>\n </Wrapper>\n </ActionPane>\n </PanZoom>\n </Selector>\n </CursorPane>\n <Selection />\n </div>\n );\n};\n\nexport default Board;\n","export { default as useWire } from \"@/hooks/useWire\";\n\nexport { default as useItems } from \"@/board/Items/useItems\";\nexport { default as useDebouncedItems } from \"@/board/Items/useDebouncedItems\";\nexport { default as useSelectedItems } from \"@/board/Items/useSelectedItems\";\nexport { default as useGetSelectedItems } from \"@/board/Items/useGetSelectedItems\";\nexport { default as useItemActions } from \"@/board/Items/useItemActions\";\nexport { default as useItemInteraction } from \"@/board/Items/useItemInteraction\";\nexport { default as useAvailableActions } from \"@/board/Items/useAvailableActions\";\n\nexport { default as useSelectionBox } from \"@/board/useSelectionBox\";\n\nexport { useUsers } from \"@/users\";\n\nexport { default as useBoardConfig } from \"@/board/useBoardConfig\";\nexport { default as useBoardState } from \"@/board/useBoardState\";\nexport { default as useBoardPosition } from \"@/board/useDim\";\nexport { default as useSessionInfo } from \"@/board/useSessionInfo\";\n\nexport { default as useMessage } from \"@/message/useMessage\";\n\nexport { default as BoardWrapper } from \"@/BoardWrapper\";\nexport { default as RoomWrapper } from \"@/RoomWrapper\";\nexport { default as Board } from \"@/board/Board\";\n\nimport React from \"react\";\nimport { setup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