From 803d3fded5068ed6debd9ff2281bfaec6b065263 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 17 Oct 2026 12:43:25 -0400 Subject: [PATCH] third commit --- CLAUDE.md | 75 +++++++------- dist/assets/index-BhQDCmrl.js | 41 -------- dist/assets/index-DDOav9ki.js | 41 ++++++++ dist/index.html | 4 +- index.html | 2 +- src/App.tsx | 165 +++++++++++++++++++++++------- src/components/CustomForm.tsx | 113 ++++++++++++++++++++ src/components/FurnitureShape.tsx | 10 +- src/components/Icons.tsx | 33 ++++++ src/components/ItemPanel.tsx | 120 ++++++++++++++++++++++ src/components/Palette.tsx | 91 ++++++++-------- src/components/Room.tsx | 99 +++++++++++------- src/components/TypeMenu.tsx | 28 ++--- src/components/Wheel.tsx | 124 +++++++++++++++------- src/components/panelStyles.ts | 24 +++++ src/geometry.ts | 114 +++++++++++---------- src/inventory.ts | 6 +- src/store.ts | 59 ++++++----- src/types.ts | 32 +++--- 19 files changed, 825 insertions(+), 356 deletions(-) delete mode 100644 dist/assets/index-BhQDCmrl.js create mode 100644 dist/assets/index-DDOav9ki.js create mode 100644 src/components/CustomForm.tsx create mode 100644 src/components/Icons.tsx create mode 100644 src/components/ItemPanel.tsx create mode 100644 src/components/panelStyles.ts diff --git a/CLAUDE.md b/CLAUDE.md index 8619559..142b34e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,26 +2,27 @@ A web tool for venues (events, banquets, conferences) to lay out furniture in a room and, eventually, auto-optimize the layout. -## Current scope: Phase 1 (UI only) +## Current scope: Phase 1 + Phase 2 (UI only) -The ONLY feature right now is drag-and-drop layout: +Layout and editing UI. No optimizer yet. -- Left sidebar (palette) with three source tiles: chair, table, screen. - - Resizable by dragging its right edge (default 264px, min 152px, max 600px). Tiles live in an auto-fill grid: they stretch in width only (fixed 84px height) until another column fits. -- Large rectangular room in the center (fixed 10m x 8m). It is scaled to fill the available space (`pxPerM` computed via `fitScale` and passed down; a ResizeObserver in `App.tsx` recomputes it). A "1 m" scale bar sits under the room. No grid lines. -- Click (no drag) a palette tile to open its settings menu. The menu takes over the sidebar (replaces the tiles); close with Escape or the "Back" button: - - Available: how many of that type the venue has. Min = number already placed. - - Tables only: Seats per table (min 1). - - Both are iOS-timer-style scroll wheels (`components/Wheel.tsx`): drag 1:1, momentum fling, press to stop mid-roll, spring settle for slow releases, mouse wheel / trackpad, tap a row, arrow keys. Max 999. - - Palette tiles show a badge with remaining count (available minus placed). Defaults: 20 chairs, 6 tables, 8 seats per table. -- Drag a tile into the room to create an item. The tile stays in the palette. If remaining is 0, the tile is greyed out and can't be dragged (click still opens the menu). -- Distinguish click from drag with a small movement threshold (5px). -- Screens (2 x 0.2 m default, 2 available by default) are the only resizable type: click a placed screen to select it, then drag its left/right end handles to change its length only (top-down view, so thickness stays 0.2 m; min length 0.5 m, stays inside the room; red + snap back to the old size if it would overlap). `RESIZABLE` and `resizeRect` live in `geometry.ts`. -- Drag existing items to move them. Items are clamped inside the room walls. -- No overlap allowed (touching edges is fine). Invalid position = red outline while dragging, green when valid; on drop, snap back to last valid position (or cancel the add if new). -- NO grid snapping: items land exactly where dropped (snapping was removed on request). +**Layout (Phase 1)** +- Left sidebar (palette): one tile per furniture type (built-in chair, table, screen + any custom) and a dashed "Custom" tile. Resizable by dragging its right edge (default 264px, min 152, max 600); tiles live in an auto-fill grid and stretch in width only (84px tall). The sidebar scrolls vertically. +- Room in the center (fixed 10m x 8m), scaled to fill the space (`pxPerM` from `fitScale`, recomputed by a ResizeObserver in `App.tsx`), with a "1 m" scale bar. No grid, NO snapping: items land exactly where dropped. +- Drag a tile into the room to create an item (tile stays). Click (<5px movement) a tile to open its type menu (takes over the sidebar; Escape / Back closes): "Available" wheel (min = placed) and, if the type has seats, a seats wheel. Badge = available - placed; at 0 the tile greys out and can't be dragged. +- Items are free-placed, clamped to the room, no overlap (touching is fine). Red outline while the position is invalid, green when valid; invalid drop snaps back (or cancels a new add). +- Wheels (`components/Wheel.tsx`) are iOS-timer style: 1:1 drag, momentum fling, press to stop, spring settle, mouse wheel/trackpad, tap a row, arrow keys. Props: `step`, `wrap`, `rows`, `disabled`, `format`. If the parent rejects a change the wheel glides back to the real value. -Do not build anything beyond this unless asked. Do not design in a way that blocks the roadmap below. +**Editing (Phase 2)** +- Click an item to select it (blue outline); click empty floor to deselect (Escape/Done too). Dragging still moves. Selecting opens the item panel in the sidebar (replaces tiles / type menu). +- Item panel: Rotate 90 button + free angle wheel (0-359, wraps); Lock/Unlock; Delete (also Delete/Backspace key, ignored while typing in an input); "Seats at this table" wheel for tables (per-item override, "Reset to default" link when overridden); Size wheels (0.3-6 m, 0.1 steps; screens show only Length). +- Rotation turns around the item's center and collision/wall clamping use the rotated bounding box (`boundsOf`). A rotate/size change is pushed back inside the walls, then rejected if it would overlap (`tryUpdate`). +- Locked items can't be dragged or rotated and show a padlock. (Size, seats and delete are still allowed on locked items.) +- Delete frees inventory automatically (remaining is derived from `items`). +- Screens: while selected, unlocked and unrotated, left/right end handles change their length (`resizeLength`, min 0.5 m). Thickness is only changed by size wheels, never handles (top-down view). +- Custom furniture: "Custom" tile opens a form (name, Seating/Table, width, length, seats, available). Saving adds a config + palette tile. Custom seating draws as a chair, custom tables as a table. + +Out of scope: room features (doors, room screen), room import, placement rules, optimization, scanning. Do not design in a way that blocks the roadmap below. ## Tech stack @@ -32,47 +33,49 @@ Do not build anything beyond this unless asked. Do not design in a way that bloc ## Data model ```ts -type FurnitureType = "chair" | "table" | "screen"; +type FurnitureType = string; // config id: "chair" | "table" | "screen" | "custom-1" ... +type Shape = "chair" | "table" | "screen"; // how a type is drawn interface FurnitureItem { id: string; - type: FurnitureType; - x: number; // meters, top-left, room coordinates + type: FurnitureType; // config id + x: number; // meters, top-left of the UNROTATED rect, room coordinates y: number; width: number; // meters height: number; - rotation: number; // degrees, always 0 for now - locked: boolean; // always false for now, reserved + rotation: number; // degrees, around the rect's center + locked: boolean; + seatsOverride?: number; // tables: overrides config.seatsPerUnit } interface Room { width: number; height: number; } // meters -// Per-type settings, edited via the palette menu interface FurnitureTypeConfig { - type: FurnitureType; - available: number; // inventory count - seatsPerUnit?: number; // tables only: people who can sit at one + id: FurnitureType; name: string; shape: Shape; + defaultWidth: number; defaultHeight: number; // meters + isTable: boolean; + available: number; // inventory count + seatsPerUnit?: number; // type-level seats } -// remaining = available - items.filter(i => i.type === type).length +// remaining = available - items.filter(i => i.type === type).length (derived, never stored) +// seats for an item = item.seatsOverride ?? config.seatsPerUnit (effectiveSeats) ``` -Seats per table is a type-level setting for now (applies to all tables). Per-table overrides come later. Chairs and table seats are independent for now. - -Default sizes: chair 0.5 x 0.5 m, table 1.8 x 0.8 m, screen 2 x 0.2 m. +Store (`store.ts`): `{ room, items, configs: Record, typeOrder: id[] }`. Defaults live in the configs (chair 0.5x0.5, table 1.8x0.8 w/ 8 seats, screen 2x0.2). Chairs and table seats are independent. ## Conventions -- Store everything in meters. Convert to pixels only at render time using the `pxPerM` scale (dynamic, computed by `fitScale` in `geometry.ts`; there is no fixed px-per-meter constant). -- Collision = axis-aligned bounding boxes. Keep collision and clamping logic in pure functions (no React or Konva imports) so the optimizer can reuse them. +- Store everything in meters. Convert to pixels only at render time using the dynamic `pxPerM` scale (`fitScale` in `geometry.ts`). +- Collision = axis-aligned bounding boxes of the rotated rect (`boundsOf`). Keep collision and clamping logic in pure functions (no React or Konva imports) so the optimizer can reuse them. - Keep geometry/rules logic separate from rendering components. - Small, typed, readable code. No new dependencies without a good reason. - Keep the UI minimal: light grey app background, room centered in the remaining space. ## File layout -- `src/types.ts`, `src/geometry.ts` (pure: clamp, overlap, validity, fitScale, default sizes), `src/inventory.ts` (pure: placedCount, remaining), `src/store.ts` (reducer: items, room, configs). -- `src/App.tsx`: owns the store, palette drag, room scale. -- `src/components/`: `Palette` (sidebar, tiles, resize), `TypeMenu`, `Wheel`, `Room` (Konva), `FurnitureShape`, `ScaleBar`. +- `src/types.ts`; `src/geometry.ts` (pure: `boundsOf`, `clampToRoom`, `overlaps`, `isValidPlacement`, `tryUpdate`, `resizeLength`, `fitScale`); `src/inventory.ts` (pure: `placedCount`, `remaining`, `effectiveSeats`); `src/store.ts` (reducer + built-in configs). +- `src/App.tsx`: owns the store, selection, sidebar mode, palette drag, room scale, Delete key. +- `src/components/`: `Palette`, `TypeMenu`, `ItemPanel`, `CustomForm`, `Wheel`, `Room` (Konva), `FurnitureShape`, `Icons`, `ScaleBar`, `panelStyles`. ## Roadmap (not built yet, don't block) @@ -99,6 +102,6 @@ npx tsc --noEmit # type check ## Working agreement -- Ask before expanding scope past Phase 1. +- Ask before expanding scope past Phase 2. - After changes, make sure the app builds and type checks. - Hackathon pace: prefer simple and working over clever. \ No newline at end of file diff --git a/dist/assets/index-BhQDCmrl.js b/dist/assets/index-BhQDCmrl.js deleted file mode 100644 index abeb26d..0000000 --- a/dist/assets/index-BhQDCmrl.js +++ /dev/null @@ -1,41 +0,0 @@ -var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-tet&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():S=!1}}}var re;if(typeof y==`function`)re=function(){y(w)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=w,re=function(){ae.postMessage(null)}}else re=function(){_(w,0)};function oe(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,re()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function ee(){}var te={H:null,A:null,T:null,S:null},ne=Object.prototype.hasOwnProperty;function w(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function re(e,t){return w(e.type,t,e.props)}function ie(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ae(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var oe=/\/+/g;function se(e,t){return typeof e==`object`&&e&&e.key!=null?ae(``+e.key):t.toString(36)}function T(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function E(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,E(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+se(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(oe,`$&/`)+`/`),E(o,r,i,``,function(e){return e})):o!=null&&(ie(o)&&(o=re(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(oe,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1Te||(e.current=we[Te],we[Te]=null,Te--)}function De(e,t){Te++,we[Te]=e.current,e.current=t}var Oe=Ee(null),ke=Ee(null),Ae=Ee(null),je=Ee(null);function Me(e,t){switch(De(Ae,t),De(ke,e),De(Oe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}A(Oe),De(Oe,e)}function Ne(){A(Oe),A(ke),A(Ae)}function Pe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,De(je,e)),t=Oe.current;var n=dp(t,e.type);t!==n&&(De(ke,e),De(Oe,n))}function Fe(e){ke.current===e&&(A(Oe),A(ke)),je.current===e&&(A(je),sh._currentValue=Ce)}var Ie,Le;function Re(e){if(Ie===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ie=t&&t[1]||``,Le=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ze=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Re(n):``}function Ve(e,t){switch(e.tag){case 26:case 27:case 5:return Re(e.type);case 16:return Re(`Lazy`);case 13:return e.child!==t&&t!==null?Re(`Suspense Fallback`):Re(`Suspense`);case 19:return Re(`SuspenseList`);case 0:case 15:return Be(e.type,!1);case 11:return Be(e.type.render,!1);case 1:return Be(e.type,!0);case 31:return Re(`Activity`);case 30:return Re(`ViewTransition`);default:return``}}function He(e){try{var t=``,n=null;do t+=Ve(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Ue=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,Ge=t.unstable_cancelCallback,Ke=t.unstable_shouldYield,qe=t.unstable_requestPaint,Je=t.unstable_now,Ye=t.unstable_getCurrentPriorityLevel,Xe=t.unstable_ImmediatePriority,Ze=t.unstable_UserBlockingPriority,Qe=t.unstable_NormalPriority,j=t.unstable_LowPriority,$e=t.unstable_IdlePriority,et=t.log,tt=t.unstable_setDisableYieldValue,nt=null,rt=null;function it(e){if(typeof et==`function`&&tt(e),rt&&typeof rt.setStrictMode==`function`)try{rt.setStrictMode(nt,e)}catch{}}var at=Math.clz32?Math.clz32:ct,ot=Math.log,st=Math.LN2;function ct(e){return e>>>=0,e===0?32:31-(ot(e)/st|0)|0}var lt=256,ut=262144,dt=4194304;function ft(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function pt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ft(n))):i=ft(o):i=ft(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ft(n))):i=ft(o)):i=ft(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function mt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ht(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function vt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function yt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=pr),gr=` `,_r=!1;function vr(e,t){switch(e){case`keyup`:return dr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function yr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var br=!1;function xr(e,t){switch(e){case`compositionend`:return yr(t);case`keypress`:return t.which===32?(_r=!0,gr):null;case`textInput`:return e=t.data,e===gr&&_r?null:e;default:return null}}function Sr(e,t){if(br)return e===`compositionend`||!fr&&vr(e,t)?(e=Fn(),Pn=Nn=Mn=null,br=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Gr(n)}}function qr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?qr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Jr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Wr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Wr(e.document)}return t}function Yr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Xr=kn&&`documentMode`in document&&11>=document.documentMode,Zr=null,Qr=null,$r=null,ei=!1;function ti(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ei||Zr==null||Zr!==Wr(r)||(r=Zr,`selectionStart`in r&&Yr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),$r&&Ur($r,r)||($r=r,r=qf(Qr,`onSelect`),0>=o,i-=o,Zi=1<<32-at(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),z&&$i(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),z&&$i(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return z&&$i(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),z&&$i(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===oe&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case ie:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===oe){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),so(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===fe&&eo(l)===r.type){n(e,r.sibling),c=a(r,o.props),so(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===oe?(c=Ri(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Li(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case ae:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Vi(o,e.mode,c),c.return=e,e=c}return s(e);case fe:return o=eo(o),_(e,r,o,c)}if(Se(o))return h(e,r,o,c);if(ye(o)){if(l=ye(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===ce)return _(e,r,Ea(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=zi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ya||t===Za)throw t;var a=Ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ed&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ai(e),ki(e,null,n),t}return Ei(e,r,t,n),Ai(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function H(){if(bo){var e=Ba;if(e!==null)throw e}}function xo(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===za&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function So(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Co(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=O.T,s={};s.types=o===null?null:o.types,O.T=s,lc(e,!1,t,n);try{var c=i(),l=O.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?cc(e,t,Ua(c,r),Md(e)):cc(e,t,r,Md(e))}catch(n){cc(e,t,{then:function(){},status:`rejected`,reason:n},Md())}finally{k.p=a,o!==null&&s.types!==null&&(o.types=s.types),O.T=o}}function Qs(){}function $s(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=ec(e).queue;Zs(e,a,t,Ce,n===null?Qs:function(){return tc(e),n(r)})}function ec(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Ce,baseState:Ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:Ce},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function tc(e){var t=ec(e);t.next===null&&(t=e.alternate.memoizedState),cc(e,t.next.queue,{},Md())}function nc(){return Ta(sh)}function rc(){return as().memoizedState}function ic(){return as().memoizedState}function ac(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Md();e=go(n);var r=_o(t,e,n);r!==null&&(Fd(r,t,n),vo(r,t,n)),t={cache:Ma()},e.payload=t;return}t=t.return}}function oc(e,t,n){var r=Md();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},uc(e)?dc(t,n):(n=Di(e,t,n,r),n!==null&&(Fd(n,e,r),fc(n,t,r)))}function sc(e,t,n){cc(e,t,n,Md())}function cc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(uc(e))dc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Hr(s,o))return Ei(e,t,i,0),td===null&&Ti(),!1}catch{}if(n=Di(e,t,i,r),n!==null)return Fd(n,e,r),fc(n,t,r),!0}return!1}function lc(e,t,n,r){if(r={lane:2,revertLane:Nf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},uc(e)){if(t)throw Error(i(479))}else t=Di(e,n,r,2),t!==null&&Fd(t,e,2)}function uc(e){var t=e.alternate;return e===U||t!==null&&t===U}function dc(e,t){Wo=Uo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}var pc={readContext:Ta,use:cs,useCallback:Yo,useContext:Yo,useEffect:Yo,useImperativeHandle:Yo,useLayoutEffect:Yo,useInsertionEffect:Yo,useMemo:Yo,useReducer:Yo,useRef:Yo,useState:Yo,useDebugValue:Yo,useDeferredValue:Yo,useTransition:Yo,useSyncExternalStore:Yo,useId:Yo,useHostTransitionStatus:Yo,useFormState:Yo,useActionState:Yo,useOptimistic:Yo,useMemoCache:Yo,useCacheRefresh:Yo,useEffectEvent:Yo},mc={readContext:Ta,use:cs,useCallback:function(e,t){return is().memoizedState=[e,t===void 0?null:t],e},useContext:Ta,useEffect:Rs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Is(4194308,4,Ws.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Is(4194308,4,e,t)},useInsertionEffect:function(e,t){Is(4,2,e,t)},useMemo:function(e,t){var n=is();t=t===void 0?null:t;var r=e();if(W){it(!0);try{e()}finally{it(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=is();if(n!==void 0){var i=n(t);if(W){it(!0);try{n(t)}finally{it(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=oc.bind(null,U,e),[r.memoizedState,e]},useRef:function(e){var t=is();return e={current:e},t.memoizedState=e},useState:function(e){e=bs(e);var t=e.queue,n=sc.bind(null,U,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ks,useDeferredValue:function(e,t){return Ys(is(),e,t)},useTransition:function(){var e=bs(!1);return e=Zs.bind(null,U,e.queue,!0,!1),is().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=U,a=is();if(z){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),td===null)throw Error(i(349));q&127||hs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Rs(_s.bind(null,r,o,e),[e]),r.flags|=2048,Ps(9,{destroy:void 0},gs.bind(null,r,o,n,t),null),n},useId:function(){var e=is(),t=td.identifierPrefix;if(z){var n=Qi,r=Zi;n=(r&~(1<<32-at(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Go++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Dt]=t,o[Ot]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&fl(t)}}return _l(t),t.subtreeFlags&=-33554433,pl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&fl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=Ae.current,da(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ia,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ca(t,!0)}else e=lp(e).createTextNode(r),e[Dt]=t,t.stateNode=e}return _l(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=da(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Dt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_l(t),e=!1}else n=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Fo(t),t):(Fo(t),null);if(t.flags&128)throw Error(i(558))}return _l(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=da(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Dt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_l(t),a=!1}else a=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Fo(t),t):(Fo(t),null)}return Fo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),hl(t,t.updateQueue),_l(t),null);case 4:return Ne(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,_l(t),null;case 10:return ya(t.type),_l(t),null;case 19:if(Ro(t),r=t.memoizedState,r===null)return _l(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)gl(r,!1);else{if(od!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=zo(e),o!==null){for(t.flags|=128,gl(r,!1),e=o.updateQueue,t.updateQueue=e,hl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ii(n,e),n=n.sibling;return Lo(t,Io.current&1|2),z&&$i(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Je()>_d&&(t.flags|=128,a=!0,gl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=zo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,hl(t,e),gl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!z)return _l(t),null}else 2*Je()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,a=!0,gl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Je(),e.sibling=null,o=Io.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||z?Lo(t,o):(n=o,De(ko,t),De(Io,n),Ao===null&&(Ao=t)),z&&$i(t,r.treeForkCount),e}return _l(t),null;case 22:case 23:return Fo(t),Oo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(_l(t),t.subtreeFlags&6&&(t.flags|=8192)):_l(t),n=t.updateQueue,n!==null&&hl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&A(Ga),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ya(ja),_l(t),null;case 25:return null;case 30:return t.flags|=33554432,_l(t),null}throw Error(i(156,t.tag))}function yl(e,t){switch(na(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ya(ja),Ne(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Fe(t),null;case 31:if(t.memoizedState!==null){if(Fo(t),t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Fo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ro(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Ne(),null;case 10:return ya(t.type),null;case 22:case 23:return Fo(t),Oo(),e!==null&&A(Ga),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ya(ja),null;case 25:return null;default:return null}}function bl(e,t){switch(na(t),t.tag){case 3:ya(ja),Ne();break;case 26:case 27:case 5:Fe(t);break;case 4:Ne();break;case 31:t.memoizedState!==null&&Fo(t);break;case 13:Fo(t);break;case 19:Ro(t);break;case 10:ya(t.type);break;case 22:case 23:Fo(t),Oo(),e!==null&&A(Ga);break;case 24:ya(ja)}}function xl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){ff(t,t.return,e)}}function Sl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){ff(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ff(t,t.return,e)}}function Cl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Co(t,n)}catch(t){ff(e,e.return,t)}}}function wl(e,t,n){n.props=xc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ff(e,t,n)}}function Tl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=vi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);m(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){ff(e,t,n)}}function El(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){ff(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){ff(e,t,n)}else n.current=null}}function Dl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[Dt]=e,Bt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Kr(s,h),v=Kr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,O.T=null,n=Td,Td=null;var o=xd,s=Cd;if(bd=0,Sd=xd=null,Cd=0,ed&6)throw Error(i(331));var c=ed;if(ed|=4,Yu(o.current),Vu(o,o.current,s,n),ed=c,Ef(0,!1),rt&&typeof rt.onPostCommitFiberRoot==`function`)try{rt.onPostCommitFiberRoot(nt,o)}catch{}return!0}finally{k.p=a,O.T=r,cf(e,t)}}function df(e,t,n){t=Ui(n,t),t=Dc(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(vt(e,2),Tf(e))}function ff(e,t,n){if(e.tag===3)df(e,e,n);else for(;t!==null;){if(t.tag===3){df(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=Ui(n,e),n=Oc(2),r=_o(t,n,2),r!==null&&(kc(n,r,t,e),vt(r,2),Tf(r));break}}t=t.return}}function pf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new $u;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(id=!0,i.add(n),e=mf.bind(null,e,t,n),t.then(e,e))}function mf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,td===e&&(q&n)===n&&(od===4||od===3&&(q&62914560)===q&&300>Je()-hd?ed&2?ld|=n:Hd(e,0):ld|=n,dd===q&&(dd=0)),Tf(e)}function hf(e,t){t===0&&(t=M()),e=Oi(e,t),e!==null&&(vt(e,t),Tf(e))}function gf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),hf(e,n)}function _f(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),hf(e,n)}function vf(e,t){return We(e,t)}var yf=null,bf=null,xf=!1,Sf=!1,Cf=!1,wf=0;function Tf(e){e!==bf&&e.next===null&&(bf===null?yf=bf=e:bf=bf.next=e),Sf=!0,xf||(xf=!0,Mf())}function Ef(e,t){if(!Cf&&Sf){Cf=!0;do for(var n=!1,r=yf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-at(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,jf(r,a))}else a=q,a=pt(r,r===td?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||mt(r,a)||(n=!0,jf(r,a))}r=r.next}while(n);Cf=!1}}function Df(){Of()}function Of(){Sf=xf=!1;var e=0;wf!==0&&hp()&&(e=wf);for(var t=Je(),n=null,r=yf;r!==null;){var i=r.next,a=kf(r,t);a===0?(r.next=null,n===null?yf=i:n.next=i,i===null&&(bf=n)):(n=r,(e!==0||a&3)&&(Sf=!0)),r=i}bd!==0&&bd!==5||Ef(e,!1),wf!==0&&(wf=0)}function kf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=an(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Bt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+an(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+an(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+an(n.imageSizes)+`"]`)):i+=`[href="`+an(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Ft]=!0,o.onload=o.onerror=function(){Vt(o)}),Bt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+an(r)+`"][href="`+an(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Bt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=zt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Bt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=zt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Bt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=zt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Bt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=Ae.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=zt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=zt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=zt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+an(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Ft]){r.loading=1;return}}else t=e.createElement(`link`),t[Ft]=!0,t.onload=t.onerror=Vt.bind(null,t),np(t,`link`,n),Bt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+an(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+an(n.href)+`"]`);if(r)return t.instance=r,Bt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Bt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Bt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Bt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Bt(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Bt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Bt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Bt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=l(p(),1),y=_(),b=(e,t,n)=>Math.max(1,Math.min(t/e.width,n/e.height)),x={chair:{width:.5,height:.5},table:{width:1.8,height:.8},screen:{width:2,height:.2}},S={chair:!1,table:!1,screen:!0},C={width:.5,height:.1};function ee(e,t,n,r,i,a){let o={...e};if(t===`right`)o.width=ne(n-e.x,a.width,i.width-e.x);else if(t===`left`){let t=e.x+e.width;o.x=ne(n,0,t-a.width),o.width=t-o.x}else if(t===`bottom`)o.height=ne(r-e.y,a.height,i.height-e.y);else{let t=e.y+e.height;o.y=ne(r,0,t-a.height),o.height=t-o.y}return o}var te={width:10,height:8},ne=(e,t,n)=>Math.min(Math.max(e,t),n);function w(e,t){return{...e,x:ne(e.x,0,t.width-e.width),y:ne(e.y,0,t.height-e.height)}}function re(e,t){let n=1e-9;return e.xt.x+n&&e.yt.y+n}function ie(e,t){let n=1e-9;return e.x>=-1e-9&&e.y>=-1e-9&&e.x+e.width<=t.width+n&&e.y+e.height<=t.height+n}function ae(e,t,n,r){return ie(e,n)&&!t.some(t=>t.id!==r&&re(e,t))}var oe={room:te,items:[],configs:{chair:{type:`chair`,available:20},table:{type:`table`,available:6,seatsPerUnit:8},screen:{type:`screen`,available:2}}};function se(e,t){switch(t.kind){case`add`:{let{width:n,height:r}=x[t.type],i={id:t.id,type:t.type,x:t.x,y:t.y,width:n,height:r,rotation:0,locked:!1};return{...e,items:[...e.items,i]}}case`move`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,x:t.x,y:t.y}:e)};case`resize`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,x:t.x,y:t.y,width:t.width,height:t.height}:e)};case`setAvailable`:return{...e,configs:{...e.configs,[t.type]:{...e.configs[t.type],available:t.value}}};case`setSeats`:return{...e,configs:{...e.configs,table:{...e.configs.table,seatsPerUnit:t.value}}}}}var T=[`chair`,`table`,`screen`],E={chair:`Chair`,table:`Table`,screen:`Screen`},ce=(e,t)=>e.filter(e=>e.type===t).length,le=(e,t,n)=>n-ce(e,t),ue=o((e=>{var t=Symbol.for(`react.transitional.element`);function n(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.jsx=n,e.jsxs=n})),D=o(((e,t)=>{t.exports=ue()}))(),de=5,fe={width:`100%`,height:84,boxSizing:`border-box`,background:`#fff`,border:`1px solid #cfcfcf`,borderRadius:8,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:6,cursor:`grab`,userSelect:`none`,touchAction:`none`,font:`12px system-ui, sans-serif`,color:`#444`};function pe({size:e=36}){return(0,D.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,D.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`28`,rx:`3`,fill:`#8fb4d9`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,D.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`8`,rx:`3`,fill:`#4a6f96`})]})}function me({size:e=36}){return(0,D.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:(0,D.jsx)(`rect`,{x:`2`,y:`9`,width:`32`,height:`18`,rx:`3`,fill:`#d9b382`,stroke:`#3b3b3b`,strokeWidth:`1.5`})})}var he=152,ge=600;function _e({type:e,remaining:t,onStartDrag:n,onOpenMenu:r}){let i=t<=0,a=t=>{t.preventDefault();let{clientX:a,clientY:o}=t,s=!1,c=t=>{s||i||Math.hypot(t.clientX-a,t.clientY-o)>=de&&(s=!0,u(),n(e,t.clientX,t.clientY))},l=t=>{u(),(Math.hypot(t.clientX-a,t.clientY-o){window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)};return(0,D.jsxs)(`div`,{role:`button`,"aria-label":`${e} (${t} remaining)`,style:{...fe,position:`relative`,opacity:i?.45:1,filter:i?`grayscale(1)`:void 0,cursor:i?`pointer`:`grab`},onPointerDown:a,children:[(0,D.jsx)(`span`,{style:{position:`absolute`,top:6,right:6,minWidth:20,height:20,padding:`0 6px`,boxSizing:`border-box`,borderRadius:10,background:i?`#888`:`#2b2b2b`,color:`#fff`,font:`600 11px/20px system-ui, sans-serif`,textAlign:`center`},children:t}),(()=>{let t=ye[e];return(0,D.jsx)(t,{})})(),E[e]]})}function ve({size:e=36}){return(0,D.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,D.jsx)(`rect`,{x:`2`,y:`14`,width:`32`,height:`8`,rx:`2`,fill:`#2d3748`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,D.jsx)(`rect`,{x:`4`,y:`16`,width:`28`,height:`4`,fill:`#63b3ed`})]})}var ye={chair:pe,table:me,screen:ve};function be({remaining:e,onStartDrag:t,onOpenMenu:n,panel:r}){let[i,a]=(0,v.useState)(264);return(0,D.jsxs)(`aside`,{style:{position:`relative`,width:i,boxSizing:`border-box`,flexShrink:0,padding:16,display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(84px, 1fr))`,alignContent:`start`,gap:12,borderRight:`1px solid #d4d4d4`,background:`#ececec`},children:[r??T.map(r=>(0,D.jsx)(_e,{type:r,remaining:e[r],onStartDrag:t,onOpenMenu:n},r)),(0,D.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e.clientX,n=i,r=e=>a(Math.min(ge,Math.max(he,n+e.clientX-t))),o=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,o)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,o)},style:{position:`absolute`,top:0,right:-3,width:6,height:`100%`,cursor:`col-resize`,touchAction:`none`}})]})}var xe=Math.PI/180;function Se(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var O=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},k={_global:O,version:`10.9.0`,isBrowser:Se(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return k.angleDeg?e*xe:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return k.DD.isDragging},isTransforming(){return k.Transformer?.isTransforming()??!1},isDragReady(){return!!k.DD.node},releaseCanvasOnDestroy:!0,document:O.document,_injectGlobal(e){O.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),O.Konva=e}},Ce=new Set,we=(e,t=!1)=>{k[e.prototype.getClassName()]=e,t&&Ce.add(e)};k._injectGlobal(k);var Te=`Konva.js unsupported environment. - -Looks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined. - -To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module. - -bash: npm install canvas -js: import "konva/canvas-backend"; - -or - -bash: npm install skia-canvas -js: import "konva/skia-backend"; -`,Ee=()=>{if(typeof document>`u`)throw Error(Te)},A=class e{constructor(e){this.dirty=!1,this.m=e?e.slice():[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=o&&(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=o&&(e*n+t*r)/o}return s.rotation=j._getRotation(s.rotation),s}},De=`[object Array]`,Oe=`[object Number]`,ke=`[object String]`,Ae=`[object Boolean]`,je=Math.PI/180,Me=180/Math.PI,Ne=`#`,Pe=``,Fe=`0`,Ie=`Konva warning: `,Le=`Konva error: `,Re={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[0,0,0,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ze=null,Be=typeof window<`u`?window:{},Ve=new WeakMap,He=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},Ue=new Map,We=Object.getPrototypeOf(Int8Array),Ge=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},Ke=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,qe=RegExp(`^(${Ke})(%?)$`,`i`),Je=(e,t)=>{let n=qe.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},Ye=/^#[0-9a-f]+$/i,Xe=RegExp(`^(${Ke})(deg|grad|rad|turn)?$`,`i`),Ze={deg:1,grad:.9,rad:Me,turn:360};function Qe(e,t){return Math.min(Math.max(e||0,0),t)}var j={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===De},_isNumber(e){return Object.prototype.toString.call(e)===Oe&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===ke},_isBoolean(e){return Object.prototype.toString.call(e)===Ae},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e,t){let n=t&&!t.closed&&t||Be,r=Ve.get(n);r||(r=[],Ve.set(n,r),He(n,function(){Ve.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){Ee();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return Ee(),document.createElement(`img`)},_urlToImage(e,t,n){let r=j.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(Ne,Pe);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215|0).toString(16);for(;e.length<6;)e=Fe+e;return Ne+e},isCanvasFarblingActive(){if(ze!==null)return ze;if(typeof document>`u`)return ze=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return ze=r,this.releaseCanvas(e),ze},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return Ne+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=j.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=j._namedColorToRBA(e)||j._hex3ColorToRGBA(e)||j._hex4ColorToRGBA(e)||j._hex6ColorToRGBA(e)||j._hex8ColorToRGBA(e)||j._rgbColorToRGBA(e)||j._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(j._isNumber))return t},_namedColorToRBA(e){let t=Re[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:t.length>3?t[3]:1}:null},_rgbColorToRGBA(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Ge(t[1]);if(!(n.length<3||n.length>4))return{r:Je(n[0],255),g:Je(n[1],255),b:Je(n[2],255),a:n.length>3?Je(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&Ye.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e.length===7&&Ye.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e.length===5&&Ye.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e.length===4&&Ye.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){let t=/^hsla?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Ge(t[1]);if(n.length<3||n.length>4)return;let r=Xe.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?Ze[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=Je(n[1],100)/100,c=Je(n[2],100)/100,l=n.length>3?Je(n[3],1):1,u=c<.5?c*(1+s):c+s-c*s,d=2*c-u,f=[0,0,0];for(let e=0;e<3;e++){let t=o+1/3*-(e-1);t<0&&t++,t>1&&t--;let n;n=6*t<1?d+(u-d)*6*t:2*t<1?u:3*t<2?d+(u-d)*(2/3-t)*6:d,f[e]=n*255}return{r:Math.round(f[0]),g:Math.round(f[1]),b:Math.round(f[2]),a:l}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;ae.x+e.width||t.x+t.widthe.y+e.height||t.y+t.heighttypeof e==`object`)?e.map(j._cloneValue):e.slice():j._isPlainObject(e)?j.cloneObject(e):e instanceof We?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*je},radToDeg(e){return e*Me},_getRotation(e){return k.angleDeg?j.radToDeg(e):e},_capitalize(e){let t=Ue.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return Ue.set(e,n),n},throw(e){throw Error(Le+e)},error(e){console.error(Le+e)},warn(e){k.showWarnings&&console.warn(Ie+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{n||!r?j.warn(`eventBatchFunc must call its argument exactly once, synchronously.`):(n=!0,t())})}finally{r=!1,n||j.warn(`eventBatchFunc must call its argument synchronously.`)}},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=j.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=j._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];dt.length){let n=t;t=e,e=n}for(let t=0;t=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){k.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=Qe(e,r);return[t,t,t,t]}return[Qe(e[0],r),Qe(e[1],r),Qe(e[2],r),Qe(e[3],r)]},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let[o,s,c,l]=j._cornerRadii(r,t,n);e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;atypeof e==`number`?Math.floor(e):e)),i+=tt+c.join(et)+nt)):(i+=o.property,e||(i+=at+o.val)),i+=rt;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ct&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash(e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=ot.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=$e(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.widthMath.min(r,Math.ceil((n4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),j.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new ft(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},gt=class extends mt{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new pt(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},M={get isDragging(){let e=!1;return M._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of M._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>M._endDragBefore(t,e),n=t=>M._batchEvents(()=>M._drag(t,e),e),r=e=>M._batchEvents(()=>M._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!M._dragElements.size)return;let n=new Set;for(let{node:e}of M._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>j._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;M._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=j._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y)){t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;M._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===j._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)M._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){M._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&M._dragElements.delete(r))})}},_t=new Map,vt=k._global.PointerEvent!==void 0;function yt(e,t){let n=_t.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function bt(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function xt(e,t){return _t.get(e)?.shape===t}function St(e,t){var n;wt(e);let r=t.getStage();if(r&&(_t.set(e,{shape:t,stage:r}),vt)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}bt(t,`gotpointercapture`,e)}}function Ct(e){_t.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&wt(r)})}function wt(e,t){var n;let r=_t.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(_t.delete(e),vt){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}bt(i,`lostpointercapture`,e)}}function Tt(e){return j._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||j._isBoolean(e)?e:Object.prototype.toString.call(e)}function Et(e){return e>255?255:e<0?0:Math.round(e)}function N(){if(k.isUnminified)return function(e,t){return j._isNumber(e)||j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function Dt(e){if(k.isUnminified)return function(t,n){let r=j._isNumber(t),i=j._isArray(t)&&t.length==e;return!r&&!i&&j.warn(Tt(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array(`+e+`)`),t}}function Ot(){if(k.isUnminified)return function(e,t){return j._isNumber(e)||e===`auto`||j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function kt(){if(k.isUnminified)return function(e,t){return j._isString(e)||j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function At(){if(k.isUnminified)return function(e,t){let n=j._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function jt(){if(k.isUnminified)return function(e,t){return e instanceof We||(j._isArray(e)?e.forEach(function(e){j._isNumber(e)||j.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function Mt(){if(k.isUnminified)return function(e,t){return e!==!0&&e!==!1&&j.warn(Tt(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function Nt(e){if(k.isUnminified)return function(t,n){return t==null||j.isObject(t)||j.warn(Tt(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var Pt=`get`,Ft=`set`,P={addGetterSetter(e,t,n,r,i){P.addGetter(e,t,n),P.addSetter(e,t,r,i),P.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=Pt+j._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=Ft+j._capitalize(t);e.prototype[i]||P.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=Ft+j._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=j._capitalize,s=Pt+o(t),c=Ft+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>Pt+o(e));e.prototype[s]=function(){let e={};for(let t=0;t{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},P.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=j._capitalize(t),r=Ft+n,i=Pt+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){j.each(t,function(t,n){let r=e.prototype[n],i=Pt+j._capitalize(t),a=Ft+j._capitalize(t);function o(){return j.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function It(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){j.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e0?e._pendingUpdates.add(t):t()}static _flushUpdateBatch(){if(e._updateBatchDepth>0)return;let t=e._pendingUpdates;t.size&&(e._pendingUpdates=new Set,t.forEach(e=>e()))}static _updateBatch(t){e._updateBatchDepth++;try{return t()}finally{e._updateBatchDepth--,e._flushUpdateBatch()}}static _beginUpdateBatch(){e._updateBatchDepth++;let t=!1;return()=>{t||(t=!0,e._updateBatchDepth--,e._flushUpdateBatch())}}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return j.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new ht({pixelRatio:s,width:a,height:o}),f=new ht({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Lt);try{this.drawScene(d,this)}catch(e){throw j.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(Lt),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new gt(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;tt===void 0?e:`${Number(t)*u}${n}`);return i.clear(),i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s{this.isAncestorOf(e.node)&&M._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Rt),this._clearSelfAndDescendantCache(Lt),this._clearSelfAndDescendantCache(qt),this._clearSelfAndDescendantCache(F),this._clearSelfAndDescendantCache(Ht)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),Ct(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+j._capitalize(e);return j._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==Bt&&(n=Wt+j._capitalize(t),j._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Ht,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(F,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==Yt&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(t){this._batchingTransformChange?t():e._updateBatch(()=>{this._batchingTransformChange=!0;try{t()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(Jt),this._clearSelfAndDescendantCache(Rt))}})}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=this.getAbsoluteTransform(e).getMatrix(),n=new A,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(Jt);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):j.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(Jt),this._clearSelfAndDescendantCache(Rt),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return j.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return j.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return j.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&j.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Lt,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i={attrs:{},className:this.getClassName()};for(t in e)n=e[t],n instanceof We&&(n=Array.from(n)),r=j.isObject(n)&&!j._isPlainObject(n)&&!j._isArray(n),!r&&(this[`get`+j._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&j._isArray(n)?n.filter(e=>typeof e==`string`):j.isObject(n)?j._prepareToStringify(n):n);return i}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r{try{let{callback:r,...i}=e||{};j._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;r?(t(r),(i=e?.callback)==null||i.call(e,r)):n(Error(`Konva: toBlob() failed, the canvas was not encoded`))},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():k.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i=0)||M._dragElements.has(this._id))return;let t=!1;M._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=M._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&M._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return j.haveIntersection(n,this.getClientRect())}static create(e,t){return j._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;if(n&&(t.attrs.container=n),!k[r]){let e=i?`Group`:`Shape`;j.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=k[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s0}removeChildren(){return this._clearChildren(`remove`)}destroyChildren(){return this._clearChildren(`destroy`)}_clearChildren(e){return I._updateBatch(()=>(this.children.forEach(t=>{t.parent=null,t.index=0,t[e]()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this))}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=I.prototype.toObject.call(this);return e.children=[],this.children.forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=I.prototype.clone.call(this,e);return this.children.forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;let n=e===void 0||e===`absoluteTransform`;n&&I._updateBatchDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{n&&--I._updateBatchDepth===0&&I._flushUpdateBatch()}}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._notifySubtreeChange(),this._requestDraw()}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCachedHitCanvas(t);if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};P.addComponentsGetterSetter(Qt,`clip`,[`x`,`y`,`width`,`height`]),P.addGetterSetter(Qt,`clipX`,void 0,N()),P.addGetterSetter(Qt,`clipY`,void 0,N()),P.addGetterSetter(Qt,`clipWidth`,void 0,N()),P.addGetterSetter(Qt,`clipHeight`,void 0,N()),P.addGetterSetter(Qt,`clipFunc`);var $t=`Stage`,en=`string`,tn=`px`,nn=`mouseout`,rn=`mouseleave`,an=`mouseover`,on=`mouseenter`,sn=`mousemove`,cn=`mousedown`,ln=`mouseup`,un=`pointermove`,dn=`pointerdown`,fn=`pointerup`,pn=`pointercancel`,mn=`lostpointercapture`,hn=`pointerout`,gn=`pointerleave`,_n=`pointerover`,vn=`pointerenter`,yn=`contextmenu`,bn=`touchstart`,xn=`touchend`,Sn=`touchmove`,Cn=`touchcancel`,wn=`wheel`,Tn=5,En=[[on,`_pointerenter`],[cn,`_pointerdown`],[sn,`_pointermove`],[ln,`_pointerup`],[rn,`_pointerleave`],[bn,`_pointerdown`],[Sn,`_pointermove`],[xn,`_pointerup`],[Cn,`_pointercancel`],[an,`_pointerover`],[wn,`_wheel`],[yn,`_contextmenu`],[dn,`_pointerdown`],[un,`_pointermove`],[fn,`_pointerup`],[pn,`_pointercancel`],[gn,`_pointerleave`],[mn,`_lostpointercapture`]],Dn={mouse:{[hn]:nn,[gn]:rn,[_n]:an,[vn]:on,[un]:sn,[dn]:cn,[fn]:ln,[pn]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[hn]:`touchout`,[gn]:`touchleave`,[_n]:`touchover`,[vn]:`touchenter`,[un]:Sn,[dn]:bn,[fn]:xn,[pn]:Cn,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[hn]:hn,[gn]:gn,[_n]:_n,[vn]:vn,[un]:un,[dn]:dn,[fn]:fn,[pn]:pn,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},On=e=>{let t=j._getEventType(e);if(t===`pointer`)return k.pointerEventsEnabled&&Dn.pointer;if(t===`touch`)return Dn.touch;if(t===`mouse`)return Dn.mouse};function kn(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&j.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var An=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,jn=[],Mn=new WeakSet,Nn=e=>{e&&!Mn.has(e)&&(Mn.add(e),M._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{jn.forEach(e=>{e.batchDraw()})}))},Pn=class extends Qt{constructor(e){super(kn(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),jn.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{kn(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||j.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(k.isBrowser?window:null)}setContainer(e){if(typeof e===en){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content),Nn(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n-1&&jn.splice(n,1),j.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(j.warn(An),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new ht({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio()),j.releaseCanvas(r._canvas)}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+tn,this.content.style.height=t+tn),this.children.forEach(n=>{n._setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;eTn&&j.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e._setSize({width:this.width(),height:this.height()}),e.draw(),k.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return xt(e,this)}setPointerCapture(e){St(e,this)}releaseCapture(e){wt(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){k.isBrowser&&En.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){j._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=On(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=On(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(k.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of M._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>k.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=On(e.type),n=j._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=On(e.type),n=j._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of M._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;k.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=On(e.type),n=j._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of M._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=yt(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=On(e.type),n=j._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=yt(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time{let r=j._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=yt(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(fn,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),wt(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){yt(e.pointerId,this)&&wt(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:j._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:j._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){j.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferHitCanvas=new gt({pixelRatio:1,width:0,height:0}),!k.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),Nn(this._getOwnerWindow()),this._resizeDOM()}cache(){return j.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};Pn.prototype.nodeType=$t,we(Pn),P.addGetterSetter(Pn,`container`),P.addGetterSetter(Pn,`eventBatchFunc`);var Fn=`hasShadow`,In=`hasFill`,Ln=`hasStroke`,Rn=`shadowRGBA`,zn=`patternImage`,Bn=`linearGradient`,Vn=`radialGradient`,Hn;function Un(){return Hn||(Hn=j.createCanvasElement().getContext(`2d`),Hn)}var Wn={};function Gn(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function Kn(e){e.stroke()}function qn(){this._clearCache(Fn)}function Jn(){this._clearCache(In)}function Yn(){this._clearCache(Ln)}function Xn(){this._clearCache(Rn)}function Zn(){this._clearCache(zn)}function Qn(){this._clearCache(Bn)}function $n(){this._clearCache(Vn)}var R=class e extends I{constructor(e){super(e);let t,n=0;for(;t=j.getHitColor(),!t||t in Wn;)if(n++,n>=1e4){j.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=j.getRandomColor();break}this.colorKey=t,Wn[t]=this}getContext(){return j.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return j.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Fn,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(zn,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=Un().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new A;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(k.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Bn,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Un(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t0}destroy(){return I.prototype.destroy.call(this),delete Wn[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){j.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this._getSelfRectForDrawing():this.getSelfRect();i&&!this.strokeScaleEnabled()?a=this._transformedRect(a,r):(a.width<0||a.height<0)&&(a=new A()._getTransformedRect(a));let o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new A,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new A}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&Ce.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||j.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=j._hexToRgb(this.colorKey);for(let t=0;te?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;r.putImageData(t,0,0)}catch(e){j.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return xt(e,this)}setPointerCapture(e){St(e,this)}releaseCapture(e){wt(e,this)}};R.prototype._fillFunc=Gn,R.prototype._strokeFunc=Kn,R.prototype._fillFuncHit=Gn,R.prototype._strokeFuncHit=Kn,R.prototype._centroid=!1,R.prototype.nodeType=`Shape`,we(R),R.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,qn),R.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Xn),R.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,Jn),R.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,Yn),R.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,Zn),R.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,Qn),R.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,$n),P.addGetterSetter(R,`stroke`,void 0,At()),P.addGetterSetter(R,`strokeWidth`,2,N()),P.addGetterSetter(R,`fillAfterStrokeEnabled`,!1),P.addGetterSetter(R,`hitStrokeWidth`,`auto`,Ot()),P.addGetterSetter(R,`strokeHitEnabled`,!0,Mt()),P.addGetterSetter(R,`perfectDrawEnabled`,!0,Mt()),P.addGetterSetter(R,`shadowForStrokeEnabled`,!0,Mt()),P.addGetterSetter(R,`lineJoin`),P.addGetterSetter(R,`lineCap`),P.addGetterSetter(R,`miterLimit`),P.addGetterSetter(R,`sceneFunc`),P.addGetterSetter(R,`hitFunc`),P.addGetterSetter(R,`selfRectFunc`),P.addGetterSetter(R,`dash`),P.addGetterSetter(R,`dashOffset`,0,N()),P.addGetterSetter(R,`shadowColor`,void 0,kt()),P.addGetterSetter(R,`shadowBlur`,0,N()),P.addGetterSetter(R,`shadowOpacity`,1,N()),P.addComponentsGetterSetter(R,`shadowOffset`,[`x`,`y`]),P.addGetterSetter(R,`shadowOffsetX`,0,N()),P.addGetterSetter(R,`shadowOffsetY`,0,N()),P.addGetterSetter(R,`fillPatternImage`),P.addGetterSetter(R,`fill`,void 0,At()),P.addGetterSetter(R,`fillPatternX`,0,N()),P.addGetterSetter(R,`fillPatternY`,0,N()),P.addGetterSetter(R,`fillLinearGradientColorStops`),P.addGetterSetter(R,`strokeLinearGradientColorStops`),P.addGetterSetter(R,`fillRadialGradientStartRadius`,0),P.addGetterSetter(R,`fillRadialGradientEndRadius`,0),P.addGetterSetter(R,`fillRadialGradientColorStops`),P.addGetterSetter(R,`fillPatternRepeat`,`repeat`),P.addGetterSetter(R,`fillEnabled`,!0),P.addGetterSetter(R,`strokeEnabled`,!0),P.addGetterSetter(R,`shadowEnabled`,!0),P.addGetterSetter(R,`dashEnabled`,!0),P.addGetterSetter(R,`strokeScaleEnabled`,!0),P.addGetterSetter(R,`fillPriority`,`color`),P.addComponentsGetterSetter(R,`fillPatternOffset`,[`x`,`y`]),P.addGetterSetter(R,`fillPatternOffsetX`,0,N()),P.addGetterSetter(R,`fillPatternOffsetY`,0,N()),P.addComponentsGetterSetter(R,`fillPatternScale`,[`x`,`y`]),P.addGetterSetter(R,`fillPatternScaleX`,1,N()),P.addGetterSetter(R,`fillPatternScaleY`,1,N()),P.addComponentsGetterSetter(R,`fillLinearGradientStartPoint`,[`x`,`y`]),P.addComponentsGetterSetter(R,`strokeLinearGradientStartPoint`,[`x`,`y`]),P.addGetterSetter(R,`fillLinearGradientStartPointX`,0),P.addGetterSetter(R,`strokeLinearGradientStartPointX`,0),P.addGetterSetter(R,`fillLinearGradientStartPointY`,0),P.addGetterSetter(R,`strokeLinearGradientStartPointY`,0),P.addComponentsGetterSetter(R,`fillLinearGradientEndPoint`,[`x`,`y`]),P.addComponentsGetterSetter(R,`strokeLinearGradientEndPoint`,[`x`,`y`]),P.addGetterSetter(R,`fillLinearGradientEndPointX`,0),P.addGetterSetter(R,`strokeLinearGradientEndPointX`,0),P.addGetterSetter(R,`fillLinearGradientEndPointY`,0),P.addGetterSetter(R,`strokeLinearGradientEndPointY`,0),P.addComponentsGetterSetter(R,`fillRadialGradientStartPoint`,[`x`,`y`]),P.addGetterSetter(R,`fillRadialGradientStartPointX`,0),P.addGetterSetter(R,`fillRadialGradientStartPointY`,0),P.addComponentsGetterSetter(R,`fillRadialGradientEndPoint`,[`x`,`y`]),P.addGetterSetter(R,`fillRadialGradientEndPointX`,0),P.addGetterSetter(R,`fillRadialGradientEndPointY`,0),P.addGetterSetter(R,`fillPatternRotation`,0),P.addGetterSetter(R,`fillRule`,void 0,kt()),P.backCompat(R,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var er=`beforeDraw`,tr=`draw`,nr=10,rr=256;function ir(e,t){return e[t+3]>=128?Wn[j.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var ar=class extends Qt{constructor(e){super(e),this.canvas=new ht,this.hitCanvas=new gt({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=nr,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=rr;e++){e>o&&(o=Math.min(rr,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=ir(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=ir(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(er,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Qt.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire(tr,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||k.hitOnDragEnabled)return!0;let t=!1;return M._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!k.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),Qt.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){j.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return j.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return this.getCanvas()._releaseIsolationCanvas(),j.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};ar.prototype.nodeType=`Layer`,we(ar),P.addGetterSetter(ar,`imageSmoothingEnabled`,!0),P.addGetterSetter(ar,`clearBeforeDraw`,!0),P.addOverloadedGetterSetter(ar,`hitGraphEnabled`);var or=class extends ar{constructor(e){super(e),this.listening(!1),j.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};or.prototype.nodeType=`FastLayer`,we(or);var sr=class extends Qt{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&j.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};P.addGetterSetter(sr,`isolated`,!1,Mt()),sr.prototype.nodeType=`Group`,we(sr);var cr=O.performance?.now?()=>O.performance.now():Date.now,lr=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:cr(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r{Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(cr()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))})}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),j.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,j.requestAnimFrame(this._animationLoop))}};lr.animations=new Set,lr.animIdCounter=0,lr.animRunning=!1;var ur={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},dr=1,fr=2,pr=3,mr=[`fill`,`stroke`,`shadowColor`],hr=0;function gr(e){return j.colorToRGBA(e)||j.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function _r(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function vr(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var yr=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=fr,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=pr,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===fr?this.setTime(e):this.state===pr&&this.setTime(this.duration-e)}pause(){this.state=dr,this.fire(`onPause`)}getTimer(){return Date.now()}},br=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||xr.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=hr++;let l=r.getLayer()||(r instanceof k.Stage?r.getLayers():null);for(c in l||j.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new lr(function(){n.tween.onEnterFrame()},l),this.tween=new yr(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)ur[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){if(j._isPlainObject(n)){for(let e in n)this._addAttr(t+j._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(j._isArray(n)||j._isArray(u)){if(a=[],c=u,s=n,u=j._isArray(u)?u.slice():Array(n.length).fill(u||0),j._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=j._prepareArrayForTween(u,n,r.closed()):n=j._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;ethis.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,this.onReset),this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};br.attrs={},br.tweens={},I.prototype.to=function(e){let t=e.onFinish,n=new br({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var xr={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};Cr.prototype._centroid=!0,Cr.prototype.className=`Arc`,Cr.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],we(Cr,!0),P.addGetterSetter(Cr,`innerRadius`,0,N()),P.addGetterSetter(Cr,`outerRadius`,0,N()),P.addGetterSetter(Cr,`angle`,0,N()),P.addGetterSetter(Cr,`clockwise`,!1,Mt());var wr=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],Tr=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],Er=(e,t,n)=>{let r=n/2,i=0;for(let n=0;nEr([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function Or(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var kr=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c500)break}return i},Ar=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},jr=(e,t,n,r,i,a)=>{let o=[];for(let s of[[e,n,i],[t,r,a]]){let c=(s[0]-s[1])/(s[0]-2*s[1]+s[2]);c>0&&c<1&&o.push(Ar(e,n,i,c),Ar(t,r,a,c))}return o},Mr=(e,t,n,r,i)=>{let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r},Nr=(e,t,n,r,i,a,o,s)=>{let c=[];for(let l of[[e,n,i,o],[t,r,a,s]]){let u=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],f=-3*l[0]+3*l[1],p=d*d-4*u*f;if(p<0)continue;let m=-(d+(d<0?-1:1)*Math.sqrt(p))/2;for(let l of[m/u,f/m])l>0&&l<1&&c.push(Mr(e,n,i,o,l),Mr(t,r,a,s,l))}return c};function Pr(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=s+c;if(l===0)return[n,r,n,r];let u=o*s/l,d=o*c/l;return[n-u*(i-e),r-u*(a-t),n+d*(i-e),r+d*(a-t)]}function Fr(e,t){let n=e.length,r=[];for(let i=2;i4}_eachTensionSegment(e,t){let n=this.points(),r=n.length,i=this.closed(),a=this.getTensionPoints(),o=a.length,s=n[0],c=n[1],l=i?0:4;for(i||(e(s,c,a[0],a[1],a[2],a[3]),s=a[2],c=a[3]);le.quadraticCurveTo(r,i,a,o),(t,n,r,i,a,o,s,c)=>e.bezierCurveTo(r,i,a,o,s,c));else if(i)for(a=2;at.push(a,o,...jr(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...Nr(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...Ir(e)]);return j._getPointsRect(e)}};Lr.prototype.className=`Line`,Lr.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],we(Lr,!0),P.addGetterSetter(Lr,`closed`,!1),P.addGetterSetter(Lr,`bezier`,!1),P.addGetterSetter(Lr,`tension`,0,N()),P.addGetterSetter(Lr,`points`,[],jt());var Rr={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},zr=Math.PI*2,Br=class e extends R{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r{if(((n-s)*Math.sign(c)%zr+zr)%zr0&&t<=o;)o-=n[--a].pathLength;for(t-=o;an[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&aEr([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(kr(t,c.pathLength,e=>Dr([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return Er([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return Dr([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]=1&&(ee=0),a===0&&ee>0&&(ee-=2*Math.PI),a===1&&ee<0&&(ee+=2*Math.PI),[g,_,o,s,x,ee,l,a]}};Br.prototype.className=`Path`,Br.prototype._attrsAffectingSize=[`data`],we(Br,!0),P.addGetterSetter(Br,`data`);var Vr=class extends Lr{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=Br.calcLength(e,t,`Q`,[n,r,a,o]),u=Br.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?j.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?j.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=j.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};Wr.prototype.className=`Image`,Wr.prototype._attrsAffectingSize=[`image`],we(Wr,!0),P.addGetterSetter(Wr,`cornerRadius`,0,Dt(4)),P.addGetterSetter(Wr,`image`),P.addComponentsGetterSetter(Wr,`crop`,[`x`,`y`,`width`,`height`]),P.addGetterSetter(Wr,`cropX`,0,N()),P.addGetterSetter(Wr,`cropY`,0,N()),P.addGetterSetter(Wr,`cropWidth`,0,N()),P.addGetterSetter(Wr,`cropHeight`,0,N());var Gr=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function Kr(e){return e/15}function qr(e){return Gr?Array.from(Gr.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var Jr=`auto`,Yr=`center`,Xr=`inherit`,Zr=`justify`,Qr=`Change.konva`,$r=`2d`,ei=`-`,ti=`left`,ni=`text`,ri=`Text`,ii=`top`,ai=`bottom`,oi=`middle`,si=`normal`,ci=`px `,li=` `,ui=`right`,di=`rtl`,fi=`word`,pi=`char`,mi=`none`,hi=`…`,gi=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],_i=null;function vi(){if(_i!==null)return _i;_i=!1;let e;try{e=j.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext($r);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t0){_i=!0;break}}}catch{}finally{e&&j.releaseCanvas(e)}return _i}function yi(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var bi;function xi(){return bi||(bi=j.createCanvasElement().getContext($r),bi)}function Si(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Ci(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function wi(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var Ti=class extends R{constructor(e){super(wi(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=oi;if(!k.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Xr?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,ti),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===oi?e+t/2:n===ai?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(k.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return k.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+Kr(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===ui?i-t:a===Yr?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=j._isString(e)?e:e==null?``:e+``;return this._setAttr(ni,t),this}getWidth(){return this.attrs.width===Jr||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Jr||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return j.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=xi(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+li+this.fontVariant()+li+(this.fontSize()+ci)+yi(this.fontFamily())}_addTextLine(e){this.align()===Zr&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??qr(e).length):0;return xi().measureText(e).width+r}_setTextData(){let e=this.text().split(` -`),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Jr&&r!==void 0,o=i!==Jr&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==pi&&d!==mi,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=xi();h.font=this._getContextFont(),h.fontKerning=this.direction()!==di&&(this.letterSpacing()!==0||this.align()===Zr||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(hi):0;for(let t=0,r=e.length;tc){let e=qr(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===li||e===ei,_=Math.max(1,Math.ceil(a*c/s));for(;dl?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;dl&&tl)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Jr&&r!==void 0,a=r-this.padding()*2;return this.wrap()===mi||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Jr&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+hi;if(t){let e=qr(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+hi;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&vi()?!0:super._useBufferCanvas(e,t)}};Ti.prototype._fillFunc=Si,Ti.prototype._strokeFunc=Ci,Ti.prototype.className=ri,Ti.prototype._attrsAffectingSize=gi.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),we(Ti,!0),Ti.prototype.on(gi.map(e=>e+Qr).join(` `),function(){this._setTextData()}),P.overWriteSetter(Ti,`width`,Ot()),P.overWriteSetter(Ti,`height`,Ot()),P.addGetterSetter(Ti,`direction`,Xr),P.addGetterSetter(Ti,`fontFamily`,`Arial`),P.addGetterSetter(Ti,`fontSize`,12,N()),P.addGetterSetter(Ti,`fontStyle`,si),P.addGetterSetter(Ti,`fontVariant`,si),P.addGetterSetter(Ti,`padding`,0,N()),P.addGetterSetter(Ti,`align`,ti),P.addGetterSetter(Ti,`verticalAlign`,ii),P.addGetterSetter(Ti,`lineHeight`,1,N()),P.addGetterSetter(Ti,`wrap`,fi),P.addGetterSetter(Ti,`ellipsis`,!1,Mt()),P.addGetterSetter(Ti,`letterSpacing`,0,N()),P.addGetterSetter(Ti,`text`,``,kt()),P.addGetterSetter(Ti,`textDecoration`,``),P.addGetterSetter(Ti,`underlineOffset`,void 0,N()),P.addGetterSetter(Ti,`charRenderFunc`,void 0);var Ei=[...Ti.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Di=`none`,Oi=`up`,ki=`right`,Ai=`down`,ji=`left`,Mi=class extends sr{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(Ei,this._sync).on(Ei,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case Oi:o=n/2,s=-1*c;break;case ki:o=n+a,s=r/2;break;case Ai:o=n/2,s=r+c;break;case ji:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};Mi.prototype.className=`Label`,we(Mi);var Ni=class extends R{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=j._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===Oi&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===ki&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===Ai&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===ji&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===Oi||n===Ai?{x:Math.min(0,(r-e)/2),y:n===Oi?-t:0,width:Math.max(r,e),height:i+t}:n===ji||n===ki?{x:n===ji?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};Ni.prototype.className=`Tag`,we(Ni,!0),P.addGetterSetter(Ni,`pointerDirection`,Di),P.addGetterSetter(Ni,`pointerWidth`,0,N()),P.addGetterSetter(Ni,`pointerHeight`,0,N()),P.addGetterSetter(Ni,`cornerRadius`,0,Dt(4));var Pi=class extends R{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?j.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Pi.prototype.className=`Rect`,we(Pi,!0),P.addGetterSetter(Pi,`cornerRadius`,0,Dt(4));var Fi=class extends R{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)j.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Fi.prototype.className=`RegularPolygon`,Fi.prototype._centroid=!0,Fi.prototype._attrsAffectingSize=[`radius`,`sides`],we(Fi,!0),P.addGetterSetter(Fi,`radius`,0,N()),P.addGetterSetter(Fi,`sides`,0,N()),P.addGetterSetter(Fi,`cornerRadius`,0,Dt(4));var Ii=Math.PI*2,Li=class extends R{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Ii,!1),e.moveTo(n,0),e.arc(0,0,n,Ii,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Li.prototype.className=`Ring`,Li.prototype._centroid=!0,Li.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],we(Li,!0),P.addGetterSetter(Li,`innerRadius`,0,N()),P.addGetterSetter(Li,`outerRadius`,0,N());var Ri=class extends R{constructor(e){super(e),this._updated=!0,this.anim=new lr(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(ethis.pathLength?null:Br.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Br.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;tthis.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Br.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=j._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};Wi.prototype._fillFunc=Hi,Wi.prototype._strokeFunc=Ui,Wi.prototype._fillFuncHit=Hi,Wi.prototype._strokeFuncHit=Ui,Wi.prototype.className=`TextPath`,Wi.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],we(Wi,!0),Wi.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),Wi.prototype.on(Wi.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),P.addGetterSetter(Wi,`data`),P.addGetterSetter(Wi,`fontFamily`,`Arial`),P.addGetterSetter(Wi,`fontSize`,12,N()),P.addGetterSetter(Wi,`fontStyle`,Vi),P.addGetterSetter(Wi,`align`,`left`),P.addGetterSetter(Wi,`letterSpacing`,0,N()),P.addGetterSetter(Wi,`textBaseline`,`middle`),P.addGetterSetter(Wi,`fontVariant`,Vi),P.addGetterSetter(Wi,`text`,Bi),P.addGetterSetter(Wi,`textDecoration`,``),P.addGetterSetter(Wi,`kerningFunc`,void 0),P.addGetterSetter(Wi,`direction`,`inherit`);var Gi=`tr-konva`,Ki=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`rotateModeChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${Gi}`).join(` `),qi=`nodesRect`,Ji=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],Yi={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Xi=`ontouchstart`in k._global,Zi=[`rotater-top-left`,`rotater-top-right`,`rotater-bottom-left`,`rotater-bottom-right`];function Qi(e){return e.startsWith(`rotater`)}var $i=Math.PI/12;function ea(e,t){let n=``;return`url("data:image/svg+xml,${encodeURIComponent(n)}") 12 12, ${t}`}function ta(e,t,n){if(e===`rotater`)return n;if(Qi(e)){let r=e.slice(8);return ea(Math.round(j.radToDeg(t)+Yi[r]-45),n)}t+=j.degToRad(Yi[e]||0);let r=(j.radToDeg(t)%360+360)%360;return j._inRange(r,337.5,360)||j._inRange(r,0,22.5)?`ns-resize`:j._inRange(r,22.5,67.5)?`nesw-resize`:j._inRange(r,67.5,112.5)?`ew-resize`:j._inRange(r,112.5,157.5)?`nwse-resize`:j._inRange(r,157.5,202.5)?`ns-resize`:j._inRange(r,202.5,247.5)?`nesw-resize`:j._inRange(r,247.5,292.5)?`ew-resize`:j._inRange(r,292.5,337.5)?`nwse-resize`:(j.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var na=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function ra(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function ia(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function aa(e,t){return ia(e,t,ra(e))}function z(e,t,n){let r=t,i=n;for(let n=0;n0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var sa=new Set,B=class extends sr{static _isLayerTransforming(e){for(let t of sa)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updatePending=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this._syncUpdate=this._syncUpdate.bind(this),this.on(Ki,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${Gi}`,()=>this._clearCache(qi)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return j.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Gi+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(j.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,this._resetRotation(),this._nodes.forEach(e=>{let t=()=>{var t;this._fitting?(t=this._nodeRectCache)==null||t.delete(e):(this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),this.isDragging()||this._scheduleUpdate())};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(Ji.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof Qt&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this._removeNode(e)}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._back&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}_detachNode(e){e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}_resetRotation(){let e=this._nodes.length===1&&this.useSingleNodeRotation();this.rotation(e?this._nodes[0].getAbsoluteRotation():0)}_removeNode(e){this._detachNode(e),this._nodes=this._nodes.filter(t=>t!==e),this._resetRotation(),this._resetTransformCache(e),this._scheduleUpdate()}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){var e,t;(e=this._nodes)==null||e.forEach(e=>this._detachNode(e)),this._nodes=[],this._updatePending=!1,this._resetTransformCache(),(t=this.getLayer())==null||t.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(qi),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||((!this._updatePending||this._cache[qi])&&this._resetTransformCache(e),I._updateBatchDepth>0?this._scheduleUpdate():this._updatePending||(this._updatePending=!0,j.requestAnimFrame(this._syncUpdate,this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncUpdate(){this._updatePending&&!this._fitting&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncUpdate(),super.drawScene(e,t)}drawHit(e,t){return this._syncUpdate(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(qi,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=k.getAngle(this.rotation()),t=this.ignoreStroke(),n=new A;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof R&&c.getSelfRect===R.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new A),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:k.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Zi.forEach(e=>{this._createAnchor(e,`_rotate-zone`).setAttrs({fill:`transparent`,strokeEnabled:!1,visible:!1})}),na.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e,t=`_anchor`){let n=new Pi({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` `+t,dragDistance:0,draggable:!0,hitStrokeWidth:Xi?10:`auto`});this._anchors[e]=n;let r=this;return n.on(`mousedown touchstart`,function(e){r._handleMouseDown(e)}),n.on(`dragstart`,e=>{n.stopDrag(),e.cancelBubble=!0}),n.on(`dragend`,e=>{e.cancelBubble=!0}),n.on(`mouseenter`,()=>{this.isTransforming()||(this._setAnchorCursor(e),this._cursorChange=!0)}),n.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&n.getStage().content&&(n.getStage().content.style.cursor=``)}),this.add(n),n}_setAnchorCursor(e,t=k.getAngle(this.rotation())){let n=this.getStage()?.content;n&&(n.style.cursor=ta(e,t,this.rotateAnchorCursor()))}_createBack(){let e=new R({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()&&n.rotateMode()!==`corners`){let t=oa(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this._back=e,this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(e.evt.button!==void 0&&!k.dragButtons.includes(e.evt.button)||this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??j._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);if(this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},Qi(this._movingAnchorName)){let e=ra(t);this._rotateStart={pointerAngle:Math.atan2(s.y-e.y,s.x-e.x),rotation:t.rotation}}sa.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncUpdate();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(Qi(this._movingAnchorName)){let t=this._getNodeRect(),n=ra(t),r=this._rotateStart,i={x:l.x+this._anchorDragOffset.x,y:l.y+this._anchorDragOffset.y},a=Math.atan2(i.y-n.y,i.x-n.x),o=r.rotation+a-r.pointerAngle,s;if(e.shiftKey&&this.shiftBehavior()!==`none`)s=Math.round(o/$i)*$i;else{let e=k.getAngle(this.rotationSnapTolerance());s=z(this.rotationSnaps(),o,e)}this._movingAnchorName!==`rotater`&&this._setAnchorCursor(this._movingAnchorName,s);let c=aa(t,s-t.rotation);this._fitNodesInto(c,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`top-right`].y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.xe.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();sa.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||j._inRange(e.width,-this.padding()*2-1,1)||j._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new A;i.rotate(k.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:j.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new A;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new A,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new A;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(j._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updatePending=!0,I._runAfterUpdateBatch(this._syncUpdate)}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._updatePending=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>e.hasName(`_anchor`)&&r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).filter(e=>e.hasName(`_anchor`)).forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=this.rotateMode(),l=oa(this,n,r);this._anchors.rotater.setAttrs({x:l.endX,y:l.endY,visible:this.rotateEnabled()&&c!==`corners`});let u=s*2,d=this.rotateEnabled()&&c!==`handle`,f=-o-u;Zi.forEach(e=>{this._anchors[e].setAttrs({x:e.includes(`left`)?f:n+o,y:e.includes(`top`)?f:r+o,width:u,height:u,visible:d})}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),sr.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(j.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return I.prototype.toObject.call(this)}clone(e){return I.prototype.clone.call(this,e)}getClientRect(e){return this._syncUpdate(),this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};B.isTransforming=()=>sa.size>0;function ca(e){return e instanceof Array||j.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){na.indexOf(e)===-1&&j.warn(`Unknown anchor name: `+e+`. Available names are: `+na.join(`, `))}),e||[]}B.prototype.className=`Transformer`,we(B),P.addGetterSetter(B,`enabledAnchors`,na,ca),P.addGetterSetter(B,`flipEnabled`,!0,Mt()),P.addGetterSetter(B,`resizeEnabled`,!0),P.addGetterSetter(B,`anchorSize`,10,N()),P.addGetterSetter(B,`rotateEnabled`,!0),P.addGetterSetter(B,`rotateLineVisible`,!0),P.addGetterSetter(B,`rotationSnaps`,[]),P.addGetterSetter(B,`rotateAnchorOffset`,50,N()),P.addGetterSetter(B,`rotateAnchorAngle`,0,N()),P.addGetterSetter(B,`rotateAnchorCursor`,`crosshair`),P.addGetterSetter(B,`rotateMode`,`handle`),P.addGetterSetter(B,`rotationSnapTolerance`,5,N()),P.addGetterSetter(B,`borderEnabled`,!0),P.addGetterSetter(B,`anchorStroke`,`rgb(0, 161, 255)`),P.addGetterSetter(B,`anchorStrokeWidth`,1,N()),P.addGetterSetter(B,`anchorFill`,`white`),P.addGetterSetter(B,`anchorCornerRadius`,0,N()),P.addGetterSetter(B,`borderStroke`,`rgb(0, 161, 255)`),P.addGetterSetter(B,`borderStrokeWidth`,1,N()),P.addGetterSetter(B,`borderDash`),P.addGetterSetter(B,`keepRatio`,!0),P.addGetterSetter(B,`shiftBehavior`,`default`),P.addGetterSetter(B,`centeredScaling`,!1),P.addGetterSetter(B,`ignoreStroke`,!1),P.addGetterSetter(B,`padding`,0,N()),P.addGetterSetter(B,`nodes`),P.addGetterSetter(B,`node`),P.addGetterSetter(B,`boundBoxFunc`),P.addGetterSetter(B,`anchorDragBoundFunc`),P.addGetterSetter(B,`anchorStyleFunc`),P.addGetterSetter(B,`shouldOverdrawWholeArea`,!1),P.addGetterSetter(B,`useSingleNodeRotation`,!0),P.backCompat(B,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var la=class extends R{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,k.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};la.prototype.className=`Wedge`,la.prototype._centroid=!0,la.prototype._attrsAffectingSize=[`radius`],we(la,!0),P.addGetterSetter(la,`radius`,0,N()),P.addGetterSetter(la,`angle`,0,N()),P.addGetterSetter(la,`clockwise`,!1),P.backCompat(la,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function ua(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var da=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],fa=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function pa(e,t){return t===255?e:e*t/255}var ma=180;function ha(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,ee,te=t+t+1,ne=r-1,w=i-1,re=t+1,ie=re*(re+1)/2,ae=new ua,oe=t<=ma?da[t]/2**fa[t]:1/(re*re),se=null,T=ae,E=null,ce=null;for(let e=1;e0?(C=255/C,n[a]=Math.floor(c*oe)*C,n[a+1]=Math.floor(l*oe)*C,n[a+2]=Math.floor(u*oe)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=E.r,p-=E.g,m-=E.b,h-=E.a,a=e+((a=t+re)0&&ha(e,n)};P.addGetterSetter(I,`blurRadius`,0,N(),P.afterSetFilter);var _a=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};P.addGetterSetter(I,`contrast`,0,N(),P.afterSetFilter);var ba=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Float32Array(n*r);for(let e=0,n=0;ne<0?0:e>255?255:e;for(let e=0;ei&&(i=a),c=t[e+1],cs&&(s=c),d=t[e+2],du&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;el?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;el?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;ut&&(y=v,b=0,x=-1),i=0;i=0&&d=0&&f=0&&d=0&&f=1020?255:0}return o}function La(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s=0&&d=0&&fMath.min(1,Math.max(0,e)),P.afterSetFilter),P.addGetterSetter(I,`threshold`,.5,N(),P.afterSetFilter),Sr.Util._assign(Sr,{Arc:Cr,Arrow:Vr,Circle:Hr,Ellipse:Ur,Image:Wr,Label:Mi,Tag:Ni,Line:Lr,Path:Br,Rect:Pi,RegularPolygon:Fi,Ring:Li,Sprite:Ri,Star:zi,Text:Ti,TextPath:Wi,Transformer:B,Wedge:la,Filters:{Blur:ga,Brightness:va,Brighten:_a,Contrast:ya,Emboss:ba,Enhance:Sa,Grayscale:Ca,HSL:wa,HSV:Ta,Invert:Ea,Kaleidoscope:ka,Mask:function(e){let t=Na(e,this.attrs.threshold??10);return t&&(t=Fa(t,e.width,e.height),t=Ia(t,e.width,e.height),t=La(t,e.width,e.height),Pa(e,t)),e},Noise:function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Threshold:function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{t.exports=function(e){function t(e,t,n,r){return new io(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1Ol||(e.current=Dl[Ol],Dl[Ol]=null,Ol--)}function h(e,t){Ol++,Dl[Ol]=e.current,e.current=t}function g(e){return e>>>=0,e===0?32:31-(jl(e)/Ml|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function ee(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function te(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{tu=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function D(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 15:return ue(e.type,!1);case 11:return ue(e.type.render,!1);case 1:return ue(e.type,!0);case 31:return le(`Activity`);case 30:return le(`ViewTransition`);default:return``}}function de(e){try{var t=``,n=null;do t+=D(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}function fe(e,t){if(typeof e==`object`&&e){var n=nu.get(e);return n===void 0?(t={value:e,source:t,stack:de(t)},nu.set(e,t),t):n}return{value:e,source:t,stack:de(t)}}function pe(e,t){ru[iu++]=ou,ru[iu++]=au,au=e,ou=t}function me(e,t,n){su[cu++]=uu,su[cu++]=du,su[cu++]=lu,lu=e;var r=uu;e=du;var i=32-Al(r)-1;r&=~(1<>=o,i-=o,uu=1<<32-Al(t)+i|n<f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),G&&pe(t,f),l;if(d===null){for(;fp?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),G&&pe(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return G&&pe(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&f.delete(_.key===null?p:_.key)),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),G&&pe(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===Do&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case To:a:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===Do){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),ct(s,a),s.return=e,e=s;break a}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===Io&&it(u)===t.type){i(e,t.sibling),s=o(t,a.props),ct(s,a),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}a.type===Do?(s=lo(a.props.children,e.mode,s,a.key),ct(s,a),s.return=e,e=s):(s=co(a.type,a.key,a.props,null,e.mode,s),ct(s,a),s.return=e,e=s)}return c(e);case Eo:a:{for(u=a.key;t!==null;){if(t.key===u){if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}s=po(a,e.mode,s),s.return=e,e=s}return c(e);case Io:return a=it(a),y(e,t,a,s)}if(Wo(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,st(a),s);if(a.$$typeof===jo)return y(e,t,Pe(e,a),s);lt(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=uo(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{qu=0;var a=y(e,n,r,i);return Ku=null,a}catch(n){if(n===Vu||n===Uu)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function dt(){for(var e=Zu,t=Qu=Zu=0;ta?a:8);var o=W.T,s={};s.types=o===null?null:o.types,W.T=s,Wn(e,!1,t,n);try{var c=i(),l=W.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Un(e,t,Qe(c,r),ga(e)):Un(e,t,r,ga(e))}catch(n){Un(e,t,{then:function(){},status:`rejected`,reason:n},ga())}finally{ps(a),o!==null&&s.types!==null&&(o.types=s.types),W.T=o}}function In(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Es,baseState:Es,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:F,lastRenderedState:Es},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:F,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ln(){return Ne(Ds)}function Rn(){return Gt().memoizedState}function zn(){return Gt().memoizedState}function Bn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=ga();e=vt(n);var r=yt(t,e,n);r!==null&&(ya(r,t,n),bt(r,t,n)),t={cache:Ie()},e.payload=t;return}t=t.return}}function Vn(e,t,n){var r=ga();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Gn(e)?Kn(t,n):(n=pt(e,t,n,r),n!==null&&(ya(n,e,r),qn(n,t,r)))}function Hn(e,t,n){Un(e,t,n,ga())}function Un(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Gn(e))Kn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Xl(s,o))return ft(e,t,i,0),Jd===null&&dt(),!1}catch{}if(n=pt(e,t,i,r),n!==null)return ya(n,e,r),qn(n,t,r),!0}return!1}function Wn(e,t,n,i){if(i={lane:2,revertLane:Ye(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Gn(e)){if(t)throw Error(r(479))}else t=pt(e,n,i,2),t!==null&&ya(t,e,2)}function Gn(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function Kn(e,t){sd=od=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,w(e,n)}}function Jn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Co({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function Yn(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!tt(n,r)||!tt(i,a):!0}function Xn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&_d.enqueueReplaceState(t,t.state,null)}function Zn(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=Co({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Qn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function $n(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function R(e,t,n){return n=vt(n),n.tag=3,n.payload={element:null},n.callback=function(){Qn(e,t)},n}function er(e){return e=vt(e),e.tag=3,e}function tr(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){$n(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){$n(t,n,r),typeof i!=`function`&&(hf===null?hf=new Set([this]):hf.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function nr(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&Ae(t,n,a,!0),n=q.current,n!==null){switch(n.tag){case 31:case 13:case 19:return J===null?ja():n.alternate===null&&tf===0&&(tf=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===Wu?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),Qa(e,i,a)),!1;case 22:return n.flags|=65536,i===Wu?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),Qa(e,i,a)),!1}throw Error(r(435,n.tag))}return Qa(e,i,a),ja(),!1}if(G)return t=q.current,t===null?(i!==bu&&(t=Error(r(423),{cause:i}),Ee(fe(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=fe(i,n),a=R(e.stateNode,i,a),xt(e,a),tf!==4&&(tf=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==bu&&(e=Error(r(422),{cause:i}),Ee(fe(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=fe(o,n),cf===null?cf=[o]:cf.push(o),tf!==4&&(tf=2),t===null)return!0;i=fe(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=R(n.stateNode,i,e),xt(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(hf===null||!hf.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=er(a),tr(a,e,n,i),xt(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}function rr(e,t,n,r){t.child=e===null?Yu(t,null,n,r):Ju(t,e.child,n,r)}function ir(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Me(t),r=Lt(e,t,n,o,a,i),s=Vt(),e!==null&&!yd?(Ht(e,t,i),jr(e,t,i)):(G&&s&&he(t),t.flags|=1,rr(e,t,r,i),t.child)}function ar(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ao(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,or(e,t,a,r,i)):(e=co(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Mr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?tt:n,n(o,r)&&e.ref===t.ref)return jr(e,t,i)}return t.flags|=1,e=oo(a,r),e.ref=t.ref,e.return=t,t.child=e}function or(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(tt(a,r)&&e.ref===t.ref){if(yd=!1,t.pendingProps=r=a,Mr(e,i))e.flags&131072&&(yd=!0);else return t.lanes=e.lanes,jr(e,t,i)}}return mr(e,t,n,r,i)}function sr(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return lr(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&$e(t,a===null?null:a.cachePool),a===null?N():Et(t,a),At(t);else return r=t.lanes=536870912,lr(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&$e(t,null),N(),jt()):($e(t,a.cachePool),Et(t,a),jt(),t.memoizedState=null);return rr(e,t,i,n),t.child}function cr(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lr(e,t,n,r,i){var a=j();return a=a===null?null:{parent:ss?Du._currentValue:Du._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&$e(t,null),N(),At(t),e!==null&&Ae(e,t,r,!0),t.childLanes=i,null}function ur(e,t){return t=Sr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function dr(e,t,n){return Ju(t,e.child,null,n),e=ur(t,t.pendingProps),e.flags|=2,Mt(t),t.memoizedState=null,e}function fr(e,t,n){var i=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(G){if(i.mode===`hidden`)return e=ur(t,i),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},cr(null,e);if(kt(t),(e=_u)?(e=Bc(e,yu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:lu===null?null:{id:uu,overflow:du},retryLane:536870912,hydrationErrors:null},n=fo(e),n.return=t,t.child=n,gu=t,_u=null)):e=null,e===null)throw Se(t);return t.lanes=536870912,null}return ur(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(kt(t),a){if(t.flags&256)t.flags&=-257,t=dr(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558))}else if(yd||Ae(e,t,n,!1),a=(n&e.childLanes)!==0,yd||a){if(td.current===null){if(i=Jd,i!==null&&(s=re(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,mt(e,s),ya(i,e,s),vd;ja()}t=dr(e,t,n)}else e=o.treeContext,us&&(_u=Fc(s),gu=t,G=!0,vu=null,yu=!1,e!==null&&_e(t,e)),t=ur(t,i),t.flags|=134221824;return t}return e=oo(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pr(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function mr(e,t,n,r,i){return Me(t),n=Lt(e,t,n,r,void 0,i),r=Vt(),e!==null&&!yd?(Ht(e,t,i),jr(e,t,i)):(G&&r&&he(t),t.flags|=1,rr(e,t,n,i),t.child)}function hr(e,t,n,r,i,a){return Me(t),t.updateQueue=null,n=zt(t,r,n,i),Rt(e),r=Vt(),e!==null&&!yd?(Ht(e,t,a),jr(e,t,a)):(G&&r&&he(t),t.flags|=1,rr(e,t,n,a),t.child)}function gr(e,t,n,r,i){if(Me(t),t.stateNode===null){var a=kl,o=n.contextType;typeof o==`object`&&o&&(a=Ne(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=_d,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},M(t),o=n.contextType,a.context=typeof o==`object`&&o?Ne(o):kl,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Jn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&_d.enqueueReplaceState(a,a.state,null),Ct(t,r,a,i),St(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Zn(n,s);a.props=c;var l=a.context,u=n.contextType;o=kl,typeof u==`object`&&u&&(o=Ne(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Xn(t,a,r,o),$u=!1;var f=t.memoizedState;a.state=f,Ct(t,r,a,i),St(),l=t.memoizedState,s||f!==l||$u?(typeof d==`function`&&(Jn(t,n,d,r),l=t.memoizedState),(c=$u||Yn(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,_t(e,t),o=t.memoizedProps,u=Zn(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=kl,typeof l==`object`&&l&&(c=Ne(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Xn(t,a,r,c),$u=!1,f=t.memoizedState,a.state=f,Ct(t,r,a,i),St();var p=t.memoizedState;o!==d||f!==p||$u||e!==null&&e.dependencies!==null&&je(e.dependencies)?(typeof s==`function`&&(Jn(t,n,s,r),p=t.memoizedState),(u=$u||Yn(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&je(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,pr(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ju(t,e.child,null,i),t.child=Ju(t,null,n,i)):rr(e,t,n,i),t.memoizedState=a.state,e=t.child):e=jr(e,t,i),e}function _r(e,t,n,r){return we(),t.flags|=256,rr(e,t,n,r),t.child}function vr(e){return{baseLanes:e,cachePool:et()}}function yr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=of),e}function br(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(nd.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(G){if(i?Ot(t):jt(),(e=_u)?(e=Vc(e,yu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:lu===null?null:{id:uu,overflow:du},retryLane:536870912,hydrationErrors:null},n=fo(e),n.return=t,t.child=n,gu=t,_u=null)):e=null,e===null)throw Se(t);return t.lanes=Ec(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(jt(),i=t.mode,a=Sr({mode:`hidden`,children:a},i),r=lo(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=vr(n),r.childLanes=yr(e,o,n),t.memoizedState=bd,cr(null,r)):(Ot(t),xr(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return wr(e,t,a,o,r,c,s,n)}return i?(jt(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=oo(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=lo(i,a,n,null),i.flags|=2):i=oo(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,cr(null,r),r=t.child,i=e.child.memoizedState,i===null?i=vr(n):(a=i.cachePool,a===null?a=et():(s=ss?Du._currentValue:Du._currentValue2,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=yr(e,o,n),t.memoizedState=bd,cr(e.child,r)):(Ot(t),n=e.child,e=n.sibling,n=oo(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function xr(e,t){return t=Sr({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Sr(e,n){return e=t(22,e,null,n),e.lanes=0,e}function Cr(e,t,n){return Ju(t,e.child,null,n),e=xr(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wr(e,t,n,i,a,o,s,c){if(n)return t.flags&256?(Ot(t),t.flags&=-257,Cr(e,t,c)):t.memoizedState===null?(jt(),o=a.fallback,s=t.mode,a=Sr({mode:`visible`,children:a.children},s),o=lo(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,Ju(t,e.child,null,c),a=t.child,a.memoizedState=vr(c),a.childLanes=yr(e,i,c),t.memoizedState=bd,cr(null,a)):(jt(),t.child=e.child,t.flags|=128,null);if(Ot(t),Ec(o))return i=Dc(o).digest,i!==``&&(a=Error(r(419)),a.stack=``,a.digest=i,Ee({value:a,source:null,stack:null})),Cr(e,t,c);if(yd||Ae(e,t,c,!1),i=(c&e.childLanes)!==0,yd||i){if(td.current!==null)return Cr(e,t,c);if(i=Jd,i!==null&&(a=re(i,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,mt(e,a),ya(i,e,a),vd;return Tc(o)||ja(),Cr(e,t,c)}return Tc(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,us&&(_u=Ic(o),gu=t,G=!0,vu=null,yu=!1,e!==null&&_e(t,e)),t=xr(t,a.children),t.flags|=134221824,t)}function Tr(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Oe(e.return,t,n)}function Er(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Ft(n)===null&&(t=e),e=e.sibling}return t}function Dr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Or(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function kr(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=nd.current;if(t.flags&128)return Nt(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Nt(t,o),i===`backwards`&&e!==null?(Or(e),rr(e,t,r,n),Or(e)):rr(e,t,r,n),r=G?ou:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Tr(e,n,t);else if(e.tag===19)Tr(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Er(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,Or(t)),Dr(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Ft(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Dr(t,!0,n,null,a,r);break;case`together`:Dr(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Er(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Dr(t,!1,i,n,a,r)}return t.child}function Ar(e,t,n){var r=t.pendingProps;return A(t,t.type,r.value),rr(e,t,r.children,n),t.child}function jr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),nf|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ae(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=oo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=oo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Mr(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&je(e)))}function Nr(e,t,n){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),A(t,Du,e.memoizedState.cache),we();break;case 27:case 5:be(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:A(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,kt(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Ot(t),t.flags|=128,null;r=Ae(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?br(e,t,n):(Ot(t),e=jr(e,t,n),e===null?null:e.sibling)}Ot(t);break;case 19:if(t.flags&128)return kr(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ae(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return kr(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Nt(t,nd.current),r)break;return null;case 22:return t.lanes=0,sr(e,t,n,t.pendingProps);case 24:A(t,Du,e.memoizedState.cache)}return jr(e,t,n)}function Pr(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)yd=!0;else{if(!Mr(e,n)&&!(t.flags&128))return yd=!1,Nr(e,t,n);yd=!!(e.flags&131072)}}else yd=!1,G&&t.flags&1048576&&me(t,ou,t.index);switch(t.lanes=0,t.tag){case 16:a:{var i=t.pendingProps;if(e=it(t.elementType),t.type=e,typeof e==`function`)ao(e)?(i=Zn(e,i),t.tag=1,t=gr(null,t,e,i,n)):(t.tag=0,t=mr(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Mo){t.tag=11,t=ir(null,t,e,i,n);break a}if(a===Fo){t.tag=14,t=ar(null,t,e,i,n);break a}if(a===jo){t.tag=10,t.type=e,t=Ar(null,t,n);break a}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return mr(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=Zn(i,t.pendingProps),gr(e,t,i,a,n);case 3:a:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,_t(e,t),Ct(t,o,null,n);var s=t.memoizedState;if(o=s.cache,A(t,Du,o),o!==a.cache&&ke(t,[Du],n,!0),St(),o=s.element,us&&a.isDehydrated){if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=_r(e,t,o,n);break a}if(o!==i){i=fe(Error(r(424)),t),Ee(i),t=_r(e,t,o,n);break a}for(us&&(_u=Pc(t.stateNode.containerInfo),gu=t,G=!0,vu=null,yu=!0),n=Yu(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(we(),o===i){t=jr(e,t,n);break a}rr(e,t,o,n)}t=t.child}return t;case 26:if(sl)return pr(e,t),e===null?(n=ul(t.type,null,t.pendingProps,null))?t.memoizedState=n:G||(t.stateNode=gl(t.type,t.pendingProps,mu.current,t)):t.memoizedState=ul(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(xl)return be(t),e===null&&xl&&G&&(i=t.stateNode=Sl(t.type,t.pendingProps,mu.current,fu.current,!1),gu=t,yu=!0,_u=Lc(t.type,i,_u)),rr(e,t,t.pendingProps.children,n),pr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&G&&(al(t.type,t.pendingProps,fu.current),(a=i=_u)&&(i=Rc(i,t.type,t.pendingProps,yu),i===null?a=!1:(t.stateNode=i,gu=t,_u=Nc(i),yu=!1,a=!0)),a||Se(t)),be(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,ns(a,o)?i=null:s!==null&&ns(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Lt(e,t,Bt,null,null,n),ss?Ds._currentValue=a:Ds._currentValue2=a),pr(e,t),rr(e,t,i,n),t.child;case 6:return e===null&&G&&(ol(t.pendingProps,fu.current),(e=n=_u)&&(n=zc(n,t.pendingProps,yu),n===null?e=!1:(t.stateNode=n,gu=t,_u=null,e=!0)),e||Se(t)),null;case 13:return br(e,t,n);case 4:return ve(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ju(t,null,i,n):rr(e,t,i,n),t.child;case 11:return ir(e,t,t.type,t.pendingProps,n);case 7:return i=t.pendingProps,pr(e,t),rr(e,t,i,n),t.child;case 8:return rr(e,t,t.pendingProps.children,n),t.child;case 12:return rr(e,t,t.pendingProps.children,n),t.child;case 10:return Ar(e,t,n);case 9:return a=t.type._context,i=t.pendingProps.children,Me(t),a=Ne(a),i=i(a),t.flags|=1,rr(e,t,i,n),t.child;case 14:return ar(e,t,t.type,t.pendingProps,n);case 15:return or(e,t,t.type,t.pendingProps,n);case 19:return kr(e,t,n);case 31:return fr(e,t,n);case 22:return sr(e,t,n,t.pendingProps);case 24:return Me(t),i=Ne(Du),e===null?(a=j(),a===null&&(a=Jd,o=Ie(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},M(t),A(t,Du,a)):((e.lanes&n)!==0&&(_t(e,t),Ct(t,null,null,n),St()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,A(t,Du,i),i!==a.cache&&ke(t,[Du],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),A(t,Du,i))),rr(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),i=t.pendingProps,i.name!=null&&i.name!==`auto`?t.flags|=e===null?18882560:18874368:G&&he(t),e!==null&&e.memoizedProps.name!==i.name?t.flags|=4194816:pr(e,t),rr(e,t,i.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function Fr(e){e.flags|=4}function Ir(e){ls&&(e.flags|=8)}function Lr(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function Rr(e,t,n,r){if(cs)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)es(e,n.stateNode);else if(!(n.tag===4||xl&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(ls)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=Cc(a,i.type,i.memoizedProps)),es(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=wc(a,i.memoizedProps)),es(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),Rr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function zr(e,t,n,r){var i=!1;if(ls)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=Cc(o,a.type,a.memoizedProps)),bc(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=wc(o,a.memoizedProps)),bc(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),zr(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function Br(e,t){if(ls&&Lr(e,t)){e=t.stateNode;var n=e.containerInfo,r=yc();zr(r,t,!1,!1),e.pendingChildren=r,Fr(t),xc(n,r)}}function Vr(e,t,n,r){if(cs)e.memoizedProps!==r&&Fr(t);else if(ls){var i=e.stateNode,a=e.memoizedProps;if((e=Lr(e,t))||a!==r){var o=fu.current;a=vc(i,n,a,r,!e,null),a===i?t.stateNode=i:(Ir(t),ts(a,n,r,o)&&Fr(t),t.stateNode=a,e&&Rr(a,t,!1,!1))}else t.stateNode=i}}function Hr(e,t,n,r,i){if(e.mode&32&&(n===null?vs(t,r):ys(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||bs(t,r)){if(xs(e.stateNode,t,r))e.flags|=8192;else if(Oa())e.flags|=8192;else throw Gu=Wu,Hu}}else e.flags&=-16777217}function Ur(e,t){if(vl(t)){if(e.flags|=16777216,!yl(t)){if(Oa())e.flags|=8192;else throw Gu=Wu,Hu}}else e.flags&=-16777217}function Wr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:S(),e.lanes|=t,sf|=t)}function Gr(e,t){if(!G)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function Kr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function qr(e,t,n){var i=t.pendingProps;switch(ge(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kr(t),null;case 1:return Kr(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),De(Du),ye(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ce(t)?Fr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Te())),Br(e,t),Kr(t),null;case 26:if(sl){var a=t.type,o=t.memoizedState;return e===null?(Fr(t),o===null?(Kr(t),Hr(t,a,null,i,n)):(Kr(t),Ur(t,o))):o?o===e.memoizedState?(Kr(t),t.flags&=-16777217):(Fr(t),Kr(t),Ur(t,o)):(o=e.memoizedProps,cs?o!==i&&Fr(t):Vr(e,t,a,i),Kr(t),Hr(t,a,o,i,n)),null}case 27:if(xl){if(xe(t),n=mu.current,a=t.type,e!==null&&t.stateNode!=null)cs?e.memoizedProps!==i&&Fr(t):Vr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Kr(t),t.subtreeFlags&=-33554433,null}e=fu.current,Ce(t)?O(t,e):(e=Sl(a,i,n,e,!0),t.stateNode=e,Fr(t))}return Kr(t),t.subtreeFlags&=-33554433,null}case 5:if(xe(t),a=t.type,e!==null&&t.stateNode!=null)Vr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Kr(t),t.subtreeFlags&=-33554433,null}if(o=fu.current,Ce(t))O(t,o),Qc(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=$o(a,i,mu.current,o,t);Ir(t),Rr(s,t,!1,!1),t.stateNode=s,ts(s,a,i,o)&&Fr(t)}}return Kr(t),t.subtreeFlags&=-33554433,Hr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,cs?n!==i&&Fr(t):ls&&(n===i?t.stateNode=e.stateNode:(e=mu.current,n=fu.current,Ir(t),t.stateNode=rs(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=mu.current,n=fu.current,Ce(t)){if(!us)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=gu,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Uc(e,n,t,i)||Se(t,!0)}else Ir(t),t.stateNode=rs(i,e,n,t)}return Kr(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=Ce(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!us)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Wc(e,t)}else we(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Kr(t),e=!1}else n=Te(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Mt(t),t):(Mt(t),null);if(t.flags&128)throw Error(r(558))}return Kr(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ce(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!us)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));Gc(a,t)}else we(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Kr(t),a=!1}else a=Te(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Mt(t),t):(Mt(t),null)}return Mt(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Wr(t,t.updateQueue),Kr(t),null);case 4:return ye(),Br(e,t),e===null&&fs(t.stateNode.containerInfo),t.flags|=67108864,Kr(t),null;case 10:return De(t.type),Kr(t),null;case 19:if(Pt(t),i=t.memoizedState,i===null)return Kr(t),null;if(a=!!(t.flags&128),o=i.rendering,o===null){if(a)Gr(i,!1);else{if(tf!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Ft(e),o!==null){for(t.flags|=128,Gr(i,!1),e=o.updateQueue,t.updateQueue=e,Wr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)so(n,e),n=n.sibling;return Nt(t,nd.current&1|2),G&&pe(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Bl()>pf&&(t.flags|=128,a=!0,Gr(i,!1),t.lanes=4194304)}}else{if(!a){if(e=Ft(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Wr(t,e),Gr(i,!0),i.tail===null&&i.tailMode!==`collapsed`&&i.tailMode!==`visible`&&!o.alternate&&!G)return Kr(t),null}else 2*Bl()-i.renderingStartTime>pf&&n!==536870912&&(t.flags|=128,a=!0,Gr(i,!1),t.lanes=4194304)}i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}if(i.tail!==null){e=i.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Bl(),e.sibling=null,o=nd.current,o=a?o&1|2:o&1,i.tailMode===`visible`||i.tailMode===`collapsed`||!n||G?Nt(t,o):(n=o,h(q,t),h(nd,n),J===null&&(J=t)),G&&pe(t,i.treeForkCount),e}return Kr(t),null;case 22:case 23:return Mt(t),Dt(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Kr(t),t.subtreeFlags&6&&(t.flags|=8192)):Kr(t),n=t.updateQueue,n!==null&&Wr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&m(Bu),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),De(Du),Kr(t),null;case 25:return null;case 30:return t.flags|=33554432,Kr(t),null}throw Error(r(156,t.tag))}function Jr(e,t){switch(ge(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return De(Du),ye(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return xe(t),null;case 31:if(t.memoizedState!==null){if(Mt(t),t.alternate===null)throw Error(r(340));we()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Mt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));we()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Pt(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ye(),null;case 10:return De(t.type),null;case 22:case 23:return Mt(t),Dt(),e!==null&&m(Bu),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return De(Du),null;case 25:return null;default:return null}}function Yr(e,t){switch(ge(t),t.tag){case 3:De(Du),ye();break;case 26:case 27:case 5:xe(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&Mt(t);break;case 13:Mt(t);break;case 19:Pt(t);break;case 10:De(t.type);break;case 22:case 23:Mt(t),Dt(),e!==null&&m(Bu);break;case 24:De(Du)}}function Xr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){V(t,t.return,e)}}function Zr(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){V(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){V(t,t.return,e)}}function Qr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Tt(t,n)}catch(t){V(e,e.return,t)}}}function $r(e,t,n){n.props=Zn(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){V(e,t,n)}}function ei(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=Jo(e.stateNode);break;case 30:var i=e.stateNode,a=se(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=fc(a)),r=i.ref;break;case 7:e.stateNode===null&&(e.stateNode=mc(e)),r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){V(e,t,n)}}function ti(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){V(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){V(e,t,n)}else n.current=null}}function ni(){var e=xd;return xd=!1,e}function ri(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n`;case Hd:return`:has(`+(pa(e)||``)+`)`;case Ud:return`[role="`+e.value+`"]`;case Gd:return`"`+e.value+`"`;case Wd:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function ma(e,t){var n=[];e=[e,0];for(var r=0;rn?32:n;n=W.T;var a=ms();try{ps(i),W.T=null,i=xf,xf=null;var o=_f,s=yf;if(gf=0,vf=_f=null,yf=0,X&6)throw Error(r(331));var c=X;if(X|=4,ca(o.current),ra(o,o.current,s,i),X=c,He(0,!1),Jl&&typeof Jl.onPostCommitFiberRoot==`function`)try{Jl.onPostCommitFiberRoot(ql,o)}catch{}return!0}finally{ps(a),W.T=n,Ja(e,t)}}function Za(e,t,n){t=fe(n,t),t=R(e.stateNode,t,2),e=yt(e,t,2),e!==null&&(ee(e,2),Ve(e))}function V(e,t,n){if(e.tag===3)Za(e,e,n);else for(;t!==null;){if(t.tag===3){Za(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(hf===null||!hf.has(r))){e=fe(n,e),n=er(2),r=yt(t,n,2),r!==null&&(tr(n,r,t,e),ee(r,2),Ve(r));break}}t=t.return}}function Qa(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||($d=!0,i.add(n),e=$a.bind(null,e,t,n),t.then(e,e))}function $a(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Jd===e&&(Q&n)===n&&(tf===4||tf===3&&(Q&62914560)===Q&&300>Bl()-df?X&2?af|=n:Ea(e,0):af|=n,sf===Q&&(sf=0)),Ve(e)}function eo(e,t){t===0&&(t=S()),e=mt(e,t),e!==null&&(ee(e,t),Ve(e))}function to(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),eo(e,n)}function no(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),eo(e,n)}function ro(e,t){return Il(e,t)}function io(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ao(e){return e=e.prototype,!(!e||!e.isReactComponent)}function oo(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&1206910976,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function so(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function co(e,n,i,a,o,s){var c=0;if(a=e,typeof a==`function`)ao(a)&&(c=1);else if(typeof a==`string`)c=sl&&xl?cl(e,i,fu.current)?26:Tl(e)?27:5:sl?cl(e,i,fu.current)?26:5:xl&&Tl(e)?27:5;else a:switch(a){case Lo:return e=t(31,i,n,o),e.elementType=Lo,e.lanes=s,e;case Do:return lo(i.children,o,s,n);case Oo:c=8,o|=24;break;case ko:return e=t(12,i,n,o|2),e.elementType=ko,e.lanes=s,e;case No:return e=t(13,i,n,o),e.elementType=No,e.lanes=s,e;case Po:return e=t(19,i,n,o),e.elementType=Po,e.lanes=s,e;case Ro:case Bo:return e=o|32,e=t(30,i,n,e),e.elementType=Bo,e.lanes=s,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof a==`object`&&a)switch(a.$$typeof){case jo:c=10;break a;case Ao:c=9;break a;case Mo:c=11;break a;case Fo:c=14;break a;case Io:c=16,a=null;break a}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function lo(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function uo(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function fo(e){var n=t(18,null,null,0);return n.stateNode=e,n}function po(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function mo(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=os,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=C(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=C(0),this.hiddenUpdates=C(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function ho(e,n,r,i,a,o,s,c,l,u,d,f){return e=new mo(e,n,r,s,l,u,d,f,c),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=Ie(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},M(o),e}function go(e){return e?(e=kl,e):kl}function _o(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:Jo(e.stateNode)}function vo(e,t,n,r,i,a){i=go(i),r.context===null?r.context=i:r.pendingContext=i,r=vt(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=yt(e,r,t),n!==null&&(ya(n,e,t),bt(n,e,t))}function yo(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}if(!(i!==u||n.width!==l.width||ps)){f>o&&(l.height+=f-o,l.y=o),pa)){u>i&&(l.width+=u-i,l.x=i),dn&&(n=c)),c `)+` - -No matching component was found for: - `)+e.join(` > `)}return null},H.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return Jo(e.child.stateNode);default:return e.child.stateNode}},H.injectIntoDevTools=function(){var e={bundleType:0,version:Go,rendererPackageName:Ko,currentDispatcherRef:W,reconcilerVersion:`19.3.0`};if(qo!==null&&(e.rendererConfig=qo),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{ql=t.inject(e),Jl=t}catch{}e=!!t.checkDCE}}return e},H.isAlreadyRendering=function(){return!!(X&6)},H.observeVisibleRects=function(e,t,n,i){if(!js)throw Error(r(363));e=ha(e,t);var a=Rs(e,n,i).disconnect;return{disconnect:function(){a()}}},H.shouldError=function(){return null},H.shouldSuspend=function(){return!1},H.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=In(e).queue;Fn(e,o,t,Es,i===null?n:function(){var t=In(e);return t.next===null&&(t=e.alternate.memoizedState),Un(e,t.next.queue,{},ga()),i(a)})},H.updateContainer=function(e,t,n,r){var i=t.current,a=ga();return vo(i,a,e,t,n,r),a},H.updateContainerSync=function(e,t,n,r){return vo(t.current,2,e,t,n,r),2},H},t.exports.default=t.exports,Object.defineProperty(t.exports,"__esModule",{value:!0})})),Va=o(((e,t)=>{t.exports=Ba()})),Ha=o((e=>{e.ConcurrentRoot=1,e.DefaultEventPriority=32,e.DiscreteEventPriority=2})),Ua=o(((e,t)=>{t.exports=Ha()})),Wa=l(Va()),Ga=Ua(),Ka={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,eventBatchFunc:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},qa=!1,Ja=!1,Ya=`.react-konva-event`,Xa=!1,Za=`ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled. -Position of a node will be changed during drag&drop, so you should update state of the react app as well. -Consider to add onDragMove or onDragEnd events. -For more info see: https://github.com/konvajs/react-konva/issues/256 -`,V=`ReactKonva: You are using "zIndex" attribute for a Konva node. -react-konva may get confused with ordering. Just define correct order of elements in your render function of a component. -For more info see: https://github.com/konvajs/react-konva/issues/194 -`,Qa={};function $a(e,t,n=Qa){if(!qa&&`zIndex`in t&&(console.warn(V),qa=!0),!Ja&&t.draggable){var r=t.x!==void 0||t.y!==void 0,i=t.onDragEnd||t.onDragMove;r&&!i&&(console.warn(Za),Ja=!0)}var a={},o=!1;for(var s in n)if(!Ka[s]){var c=s.slice(0,2)===`on`,l=n[s]!==t[s];if(c&&l){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),e.off(u+Ya)}var d=!t.hasOwnProperty(s);!c&&d&&(a[s]=void 0,o=!0)}var f=Xa||t._useStrictMode;let p={};for(var s in t)if(!Ka[s]){var c=s.slice(0,2)===`on`,m=n[s]!==t[s];if(c&&m){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),t[s]&&(p[u]=t[s])}!c&&(t[s]!==n[s]||f&&t[s]!==e.getAttr(s))&&(o=!0,a[s]=t[s])}for(var u in o&&(e.setAttrs(a),eo(e)),p)e.off(u+Ya),e.on(u+Ya,p[u])}function eo(e){if(!k.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}var to=d(),no=new Set,ro=new Set,io=typeof queueMicrotask==`function`?queueMicrotask:e=>Promise.resolve().then(e),ao=0,oo=new WeakMap;function so(e){return ro.add(e),()=>{ro.delete(e)}}function co(){for(let e of ro)e()}function lo(e){if(!e)return fo;let t=oo.get(e);return t||(t=t=>fo(()=>e(t)),oo.set(e,t)),t}function uo(e){let t=()=>{no.delete(t)&&(co(),e())};no.add(t),io(t)}function fo(e){if(ao)return e();ao++;try{(0,Ra.flushSync)(e)}finally{try{for(;no.size;)(0,Ra.flushSync)(()=>{for(let e of no)e()})}finally{ao--}}}var po=s({HostTransitionContext:()=>ys,NotPendingTransition:()=>vs,afterActiveInstanceBlur:()=>Xo,appendChild:()=>Po,appendChildToContainer:()=>Fo,appendInitialChild:()=>go,beforeActiveInstanceBlur:()=>Yo,bindToConsole:()=>Jo,cancelTimeout:()=>Mo,clearContainer:()=>Go,commitMount:()=>U,commitNewChildToFragmentInstance:()=>So,commitTextUpdate:()=>Bo,commitUpdate:()=>Vo,createFragmentInstance:()=>H,createInstance:()=>_o,createTextInstance:()=>vo,createViewTransitionInstance:()=>cs,deleteChildFromFragmentInstance:()=>Co,detachDeletedInstance:()=>Ko,finalizeInitialChildren:()=>yo,getChildHostContext:()=>Ao,getCurrentUpdatePriority:()=>es,getInstanceFromNode:()=>qo,getInstanceFromScope:()=>Qo,getPublicInstance:()=>bo,getRootHostContext:()=>ko,getSuspendedCommitReason:()=>_s,hideInstance:()=>Ho,hideTextInstance:()=>Uo,idlePriority:()=>to.unstable_IdlePriority,insertBefore:()=>Io,insertInContainerBefore:()=>Lo,isPrimaryRenderer:()=>!1,maySuspendCommit:()=>ss,maySuspendCommitInSyncRender:()=>us,maySuspendCommitOnUpdate:()=>ls,noTimeout:()=>-1,now:()=>to.unstable_now,preloadInstance:()=>fs,prepareForCommit:()=>To,preparePortalMount:()=>Eo,prepareScopeUpdate:()=>Zo,removeChild:()=>Ro,removeChildFromContainer:()=>zo,requestPostPaintCallback:()=>os,resetAfterCommit:()=>Do,resetFormInstance:()=>bs,resetTextContent:()=>Oo,resolveEventTimeStamp:()=>as,resolveEventType:()=>is,resolveUpdatePriority:()=>ts,run:()=>to.unstable_runWithPriority,scheduleMicrotask:()=>uo,scheduleTimeout:()=>jo,setCurrentUpdatePriority:()=>$o,shouldAttemptEagerTransition:()=>ns,shouldSetTextContent:()=>No,startSuspendingCommit:()=>ps,startViewTransition:()=>ds,supportsHydration:()=>!1,supportsMicrotasks:()=>!0,supportsMutation:()=>!0,supportsPersistence:()=>!1,suspendInstance:()=>ms,suspendOnActiveViewTransition:()=>hs,trackSchedulerEvent:()=>rs,unhideInstance:()=>Wo,unhideTextInstance:()=>W,updateFragmentInstanceFiber:()=>xo,waitForCommitToBeReady:()=>gs,warnsIfNotActing:()=>!1}),mo={};za.Node.prototype._applyProps=$a;var ho=Ga.DefaultEventPriority;function go(e,t){typeof t==`string`?console.error(`Do not use plain text as child of Konva.Node. You are using text: ${t}`):(e.add(t),eo(e))}function _o(e,t,n){let r=za[e];r||=(console.error(`Konva has no node with the type ${e}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${e}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),za.Group);let i={},a={};for(var o in t)o!==`ref`&&(o.slice(0,2)===`on`?a[o]=t[o]:i[o]=t[o]);let s=new r(i);return $a(s,a),s}function vo(e,t,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function yo(e,t,n){return!1}function bo(e){return e}function H(){return null}function xo(){}function So(){}function Co(){}var wo;function To(){return wo=za.beginUpdateBatch?.(),null}function Eo(){return null}function Do(){let e=wo;wo=void 0,e?.()}function Oo(e){}function ko(){return mo}function Ao(){return mo}var jo=setTimeout,Mo=clearTimeout;function No(e,t){return!1}function Po(e,t){t.parent===e?t.moveToTop():e.add(t),eo(e)}var Fo=Po;function Io(e,t,n){t._remove(),e.add(t),t.setZIndex(n.getZIndex()),eo(e)}var Lo=Io;function Ro(e,t){t.destroy(),t.off(Ya),eo(e)}var zo=Ro;function Bo(e,t,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function U(e,t,n){}function Vo(e,t,n,r){$a(e,r,n)}function Ho(e){e.hide(),eo(e)}function Uo(e){}function Wo(e,t){(t.visible==null||t.visible)&&(e.show(),eo(e))}function W(e,t){}function Go(e){}function Ko(e){e.off(Ya)}function qo(){return null}function Jo(e,t){return console[e].bind(console,...t)}function Yo(){}function Xo(){}function Zo(){}function Qo(){return null}function $o(e){ho=e}function es(){return ho}function ts(){return Ga.DiscreteEventPriority}function ns(){return!1}function rs(){}function is(){return null}function as(){return-1.1}function os(){}function ss(){throw Error(`ViewTransition is not supported inside a Stage. Place ViewTransition around Stage to animate its DOM container.`)}var cs=ss,ls=ss,us=ss;function ds(e,t,n,r,i,a,o,s,c,l,u){return r(),i(),u?.(),o(),null}function fs(){return!0}function ps(){}function ms(){}function hs(){}function gs(){return null}function _s(){return null}var vs=Object.freeze({pending:!1,data:null,method:null,action:null}),ys=v.createContext(vs);function bs(){}typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?v.useLayoutEffect:v.useEffect;function xs(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=xs(r,t,n);if(e)return e;r=t?null:r.sibling}}function Ss(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var Cs=Ss(v.createContext(null)),ws=class extends v.Component{render(){return v.createElement(Cs.Provider,{value:this._reactInternals},this.props.children)}};function Ts(){let e=v.useContext(Cs);if(e===null)throw Error(`its-fine: useFiber must be called within a !`);let t=v.useId();return v.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=xs(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var Es=Symbol.for(`react.context`),Ds=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Es;function Os(){let e=Ts(),[t]=v.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;Ds(e)&&e!==Cs&&!t.has(e)&&t.set(e,v.use(Ss(e))),n=n.return}return t}function ks(){let e=Os();return v.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>v.createElement(t,null,v.createElement(n.Provider,{...r,value:e.get(n)})),e=>v.createElement(ws,{...e})),[e])}var[As,js]=`19.3.1`.split(`.`).map(Number);if(As!==19||js<3)throw Error(`react-konva requires React 19.3 or later within React 19. Install matching versions of react and react-dom. For React 19.2, use react-konva 19.2. For React 18, use react-konva 18.`);function Ms({promise:e}){throw e}var Ns=e=>{let t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),i=v.useRef(null),a=v.useRef(null),o=v.useId(),s=(0,Ra.useFormStatus)(),c=v.useRef({}),l=c.current,u=ks(),d=!!xs(Ts(),!0,e=>e.type===v.StrictMode),f=v.useRef(!1),p=v.useRef(!1),m=v.useRef(null);v.useInsertionEffect(()=>(p.current=!1,()=>{p.current=!0,f.current&&n.current&&h()}),[]);let h=()=>{m.current?.(),m.current=null,co(),zs.flushSyncFromReconciler(()=>{zs.updateContainer(null,r.current,null)}),n.current?.destroy(),n.current?.off(Ya),n.current=null,a.current?.resolve(),a.current=null},g=e=>{if(e===`suspended`){if(!a.current){let e,t=new Promise(t=>{e=t});a.current={promise:t,resolve:e}}}else a.current?.resolve(),a.current=null;zs.updateContainer(v.createElement(v.Activity,{mode:e===`hidden`?`hidden`:`visible`,children:v.createElement(v.Suspense,{fallback:null},i.current,a.current&&v.createElement(Ms,{promise:a.current.promise}))}),r.current,null),co(),zs.flushSyncWork()};return v.useLayoutEffect(()=>(m.current?.(),m.current=null,n.current||(n.current=new za.Stage({width:e.width,height:e.height,container:t.current}),r.current=zs.createContainer(n.current,Ga.ConcurrentRoot,null,d,null,o,console.error,console.error,console.error,null,null)),()=>{p.current?h():(m.current=so(()=>{p.current&&(m.current?.(),m.current=null,zs.updateContainer(null,r.current,null))}),g(`suspended`))}),[]),v.useEffect(()=>(f.current=!1,()=>{f.current=!0,n.current&&(p.current?h():g(`hidden`))}),[]),v.useLayoutEffect(()=>{typeof n.current.eventBatchFunc==`function`&&n.current.eventBatchFunc(lo(e.eventBatchFunc))},[e.eventBatchFunc]),v.useImperativeHandle(e.forwardedRef,()=>n.current,[]),v.useLayoutEffect(()=>{c.current=e,$a(n.current,e,l),i.current=v.createElement(ys.Provider,{value:s},v.createElement(u,{},e.children)),g(`visible`)}),v.createElement(`div`,{ref:t,id:e.id,accessKey:e.accessKey,className:e.className,role:e.role,style:e.style,tabIndex:e.tabIndex,title:e.title})},Ps=`Layer`,Fs=`Group`,Is=`Rect`,Ls=`19.3.2`,Rs={...po,HostTransitionContext:ys,rendererVersion:Ls,rendererPackageName:`react-konva`,extraDevToolsConfig:null},zs=(0,Wa.default)(Rs);zs.injectIntoDevTools();var Bs=v.forwardRef((e,t)=>v.createElement(ws,{},v.createElement(Ns,{...e,forwardedRef:t}))),Vs={normal:`#3b3b3b`,selected:`#1c7ed6`,valid:`#2f9e44`,invalid:`#e03131`};function Hs({type:e,width:t,height:n,pxPerM:r,outline:i,opacity:a=1}){let o=t*r,s=n*r,c=Vs[i],l=i===`normal`?1.5:3;if(e===`screen`){let e=Math.min(3,s/4);return(0,D.jsxs)(Fs,{opacity:a,children:[(0,D.jsx)(Is,{width:o,height:s,fill:`#2d3748`,stroke:c,strokeWidth:l,cornerRadius:2}),(0,D.jsx)(Is,{x:e,y:e,width:Math.max(0,o-e*2),height:Math.max(0,s-e*2),fill:`#63b3ed`,listening:!1})]})}if(e===`table`)return(0,D.jsx)(Fs,{opacity:a,children:(0,D.jsx)(Is,{width:o,height:s,fill:`#d9b382`,stroke:c,strokeWidth:l,cornerRadius:3})});let u=Math.max(4,s*.2);return(0,D.jsxs)(Fs,{opacity:a,children:[(0,D.jsx)(Is,{width:o,height:s,fill:`#8fb4d9`,stroke:c,strokeWidth:l,cornerRadius:3}),(0,D.jsx)(Is,{width:o,height:u,fill:`#4a6f96`,cornerRadius:[3,3,0,0],listening:!1})]})}var Us=10,Ws=[`left`,`right`];function Gs({room:e,items:t,preview:n,pxPerM:r,floorRef:i,onMove:a,onResize:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(null),m=e.width*r,h=e.height*r,g=(t,n)=>w({x:n.x()/r,y:n.y()/r,width:t.width,height:t.height},e);return(0,D.jsx)(`div`,{ref:i,style:{width:m,height:h,border:`6px solid #2b2b2b`,boxSizing:`content-box`,background:`#fff`,boxShadow:`0 4px 18px rgba(0,0,0,0.12)`,touchAction:`none`},children:(0,D.jsx)(Bs,{width:m,height:h,onMouseDown:e=>e.target===e.target.getStage()&&u(null),onTouchStart:e=>e.target===e.target.getStage()&&u(null),children:(0,D.jsxs)(Ps,{children:[t.map(n=>{let i=d?.id===n.id,o=i?d.rect:n,f=i?d.valid?`valid`:`invalid`:s?.id===n.id?s.valid?`valid`:`invalid`:l===n.id?`selected`:`normal`;return(0,D.jsx)(Fs,{x:o.x*r,y:o.y*r,onMouseDown:()=>u(S[n.type]?n.id:null),onTouchStart:()=>u(S[n.type]?n.id:null),draggable:!n.locked,dragBoundFunc:e=>({x:Math.min(Math.max(e.x,0),m-n.width*r),y:Math.min(Math.max(e.y,0),h-n.height*r)}),onDragStart:e=>{e.target.moveToTop()},onDragMove:r=>{let i=g(n,r.target);c({id:n.id,valid:ae(i,t,e,n.id)})},onDragEnd:i=>{let o=i.target,s=g(n,o),l=ae(s,t,e,n.id),u=l?s:n;o.position({x:u.x*r,y:u.y*r}),l&&a(n.id,s.x,s.y),c(null)},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`grab`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)},children:(0,D.jsx)(Hs,{type:n.type,width:o.width,height:o.height,pxPerM:r,outline:f})},n.id)}),t.map(n=>{if(n.id!==l||!S[n.type]||s?.id===n.id)return null;let i=d?.id===n.id?d.rect:n,a={left:[i.x,i.y+i.height/2],right:[i.x+i.width,i.y+i.height/2]};return Ws.map(i=>(0,D.jsx)(Is,{x:a[i][0]*r,y:a[i][1]*r,offsetX:Us/2,offsetY:Us/2,width:Us,height:Us,fill:`#fff`,stroke:`#1c7ed6`,strokeWidth:2,cornerRadius:2,hitStrokeWidth:12,draggable:!0,dragBoundFunc:function(){return this.absolutePosition()},onDragStart:e=>{e.cancelBubble=!0,p.current={x:n.x,y:n.y,width:n.width,height:n.height}},onDragMove:a=>{let o=a.target.getStage()?.getPointerPosition(),s=p.current;if(!o||!s)return;let c=ee(s,i,o.x/r,o.y/r,e,C);f({id:n.id,rect:c,valid:ae(c,t,e,n.id)})},onDragEnd:()=>{d?.valid&&o(n.id,d.rect),f(null),p.current=null},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`ew-resize`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)}},`${n.id}-${i}`))}),n&&(0,D.jsx)(`Group`,{x:n.x*r,y:n.y*r,listening:!1,children:(0,D.jsx)(Hs,{type:n.type,width:n.width,height:n.height,pxPerM:r,outline:n.valid?`valid`:`invalid`,opacity:.85})})]})})})}function Ks({pxPerM:e,roomWidthPx:t}){return(0,D.jsx)(`div`,{style:{width:t,height:40,display:`flex`,alignItems:`flex-end`,paddingBottom:4,boxSizing:`border-box`},children:(0,D.jsxs)(`div`,{style:{font:`12px system-ui, sans-serif`,color:`#555`},children:[(0,D.jsx)(`div`,{style:{width:e,height:6,borderBottom:`2px solid #555`,borderLeft:`2px solid #555`,borderRight:`2px solid #555`,boxSizing:`border-box`,marginBottom:2}}),`1 m`]})})}var qs=34,Js=3,Ys=4,Xs=7,Zs=12,Qs=4,$s=40,ec=40;function tc({value:e,min:t,max:n=999,onChange:r}){let[i,a]=(0,v.useState)(e),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(e),l=(0,v.useRef)(e),u=(0,v.useRef)(0),d=(0,v.useRef)(0),f=(0,v.useRef)(e),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)([]),g=(0,v.useRef)({min:t,max:n,onChange:r});g.current={min:t,max:n,onChange:r};let _=e=>Math.min(g.current.max,Math.max(g.current.min,e)),y=e=>{let t=_(e);c.current=t,a(t);let n=Math.round(t);return n!==l.current&&(l.current=n,g.current.onChange(n)),t},b=()=>{cancelAnimationFrame(u.current),u.current=0,window.clearTimeout(d.current),d.current=0},x=e=>{b();let t=_(Math.round(e));f.current=t;let n=performance.now(),r=e=>{let i=Math.min(.05,(e-n)/1e3);n=e;let a=c.current+(t-c.current)*(1-Math.exp(-7*i));Math.abs(t-a)<.003?(y(t),u.current=0):(y(a),u.current=requestAnimationFrame(r))};u.current=requestAnimationFrame(r)},S=(e,t)=>{b();let n=_(Math.round(e));f.current=n;let r=c.current-n,i=Math.abs(r),a=i>0&&Math.sign(t)===-Math.sign(r)?Math.max(Zs,Math.abs(t)/i):Zs,o=t+a*r,s=performance.now(),l=e=>{let t=(e-s)/1e3,i=Math.exp(-a*t),c=n+(r+o*t)*i,d=(o-a*(r+o*t))*i;Math.abs(c-n)<.003&&Math.abs(d)<.05||t>1.5?(y(n),u.current=0):(y(c),u.current=requestAnimationFrame(l))};u.current=requestAnimationFrame(l)};(0,v.useEffect)(()=>{m.current||u.current||(c.current=e,l.current=e,a(e))},[e]),(0,v.useEffect)(()=>b,[]);let C=e=>{e.currentTarget.setPointerCapture(e.pointerId);let t=u.current!==0||d.current!==0;b(),m.current={y0:e.clientY,pos0:c.current,moved:!1,wasMoving:t},h.current=[{t:performance.now(),pos:c.current}],s(!0)},ee=e=>{let t=m.current;if(!t)return;let n=e.clientY-t.y0;Math.abs(n)>Ys&&(t.moved=!0);let r=y(t.pos0-n/qs),i=performance.now();h.current.push({t:i,pos:r}),h.current=h.current.filter(e=>i-e.t<100)},te=e=>{let t=m.current;if(m.current=null,s(!1),!t)return;if(!t.moved){if(t.wasMoving)S(c.current,0);else{let n=p.current.getBoundingClientRect(),r=Math.round((e.clientY-n.top-85)/qs);c.current=t.pos0,x(Math.round(t.pos0)+r)}return}let n=performance.now(),r=h.current,i=0;if(r.length>1&&n-r[r.length-1].t<80){let e=r[0],t=(r[r.length-1].t-e.t)/1e3;t>.005&&(i=(r[r.length-1].pos-e.pos)/t)}i=Math.max(-40,Math.min($s,i)),Math.abs(i){if(Math.abs(e.deltaY)>=ec){let t=u.current?f.current:Math.round(c.current);x(t+Math.sign(e.deltaY))}else b(),y(c.current+e.deltaY/(qs*1.5)),d.current=window.setTimeout(()=>{d.current=0,S(c.current,0)},120)},w=e=>{if(e.key===`ArrowUp`)x(Math.round(c.current)+1);else if(e.key===`ArrowDown`)x(Math.round(c.current)-1);else return;e.preventDefault()},re=Math.round(i),ie=[];for(let e=Math.max(t,re-Js);e<=Math.min(n,re+Js);e++){let t=e-i;ie.push((0,D.jsx)(`div`,{style:{position:`absolute`,left:0,right:0,height:qs,display:`flex`,alignItems:`center`,justifyContent:`center`,font:`600 20px system-ui, sans-serif`,color:`#222`,opacity:Math.max(0,1-Math.abs(t)*.38),transform:`translateY(${(2+t)*qs}px) scale(${1-Math.min(1,Math.abs(t))*.12})`,pointerEvents:`none`},children:e},e))}return(0,D.jsxs)(`div`,{ref:p,tabIndex:0,role:`spinbutton`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,onPointerDown:C,onPointerMove:ee,onPointerUp:te,onPointerCancel:te,onWheel:ne,onKeyDown:w,style:{position:`relative`,width:`100%`,height:170,overflow:`hidden`,background:`#f4f4f4`,borderRadius:10,cursor:o?`grabbing`:`ns-resize`,userSelect:`none`,touchAction:`none`,outline:`none`},children:[(0,D.jsx)(`div`,{style:{position:`absolute`,left:6,right:6,top:68,height:qs,background:`rgba(0,0,0,0.08)`,borderRadius:8,pointerEvents:`none`}}),ie]})}var nc={font:`600 12px system-ui, sans-serif`,color:`#555`,marginBottom:4},rc={font:`12px system-ui, sans-serif`,color:`#888`,marginTop:4};function ic({type:e,config:t,placed:n,onSetAvailable:r,onSetSeats:i,onClose:a}){return(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,D.jsxs)(`div`,{style:{gridColumn:`1 / -1`,display:`flex`,flexDirection:`column`,gap:14},children:[(0,D.jsx)(`button`,{onClick:a,style:{alignSelf:`flex-start`,border:`none`,background:`none`,padding:0,cursor:`pointer`,font:`13px system-ui, sans-serif`,color:`#555`},children:`← Back`}),(0,D.jsx)(`div`,{style:{font:`600 15px system-ui, sans-serif`,color:`#222`},children:E[e]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{style:nc,children:`Available`}),(0,D.jsx)(tc,{value:t.available,min:n,onChange:r}),(0,D.jsxs)(`div`,{style:rc,children:[n,` placed`]})]}),e===`screen`&&(0,D.jsx)(`div`,{style:rc,children:`Click a placed screen, then drag an end handle to change its length.`}),e===`table`&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{style:nc,children:`Seats per table`}),(0,D.jsx)(tc,{value:t.seatsPerUnit??8,min:1,onChange:i})]})]})}var ac=40;function oc(){let[e,t]=(0,v.useReducer)(se,oe),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useCallback)(()=>a(null),[]),s=(0,v.useRef)(null),c=(0,v.useRef)(null),[l,u]=(0,v.useState)(60);(0,v.useEffect)(()=>{let t=c.current;if(!t)return;let n=new ResizeObserver(([t])=>{let{width:n,height:r}=t.contentRect;u(b(e.room,n-12,r-12-ac))});return n.observe(t),()=>n.disconnect()},[e.room]);let d=(0,v.useRef)(1),f=t=>{let n=s.current?.getBoundingClientRect();if(!n)return null;let r=(n.width-e.room.width*l)/2,i=t.clientX-n.left-r,a=t.clientY-n.top-r;if(i<0||a<0||i>e.room.width*l||a>e.room.height*l)return null;let{width:o,height:c}=x[t.type];return w({x:i/l-o/2,y:a/l-c/2,width:o,height:c},e.room)};(0,v.useEffect)(()=>{if(!n)return;let i=n.type,a=e=>r({type:i,clientX:e.clientX,clientY:e.clientY}),o=n=>{let a=f({type:i,clientX:n.clientX,clientY:n.clientY});a&&le(e.items,i,e.configs[i].available)>0&&ae(a,e.items,e.room)&&t({kind:`add`,id:`item-${d.current++}`,type:i,x:a.x,y:a.y}),r(null)},s=()=>r(null);return window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s)}},[n?.type,e.items,e.room,e.configs,l]);let p=(0,v.useMemo)(()=>{if(!n)return null;let t=f(n);return t?{type:n.type,...t,valid:ae(t,e.items,e.room)}:null},[n,e.items,e.room,l]),m=(e,t,n)=>{a(null),r({type:e,clientX:t,clientY:n})},h=Object.fromEntries(T.map(t=>[t,le(e.items,t,e.configs[t].available)]));return(0,D.jsxs)(`div`,{style:{display:`flex`,height:`100vh`,background:`#e9e9e9`,cursor:n?`grabbing`:void 0},children:[(0,D.jsx)(be,{remaining:h,onStartDrag:m,onOpenMenu:a,panel:i&&(0,D.jsx)(ic,{type:i,config:e.configs[i],placed:ce(e.items,i),onSetAvailable:e=>t({kind:`setAvailable`,type:i,value:e}),onSetSeats:e=>t({kind:`setSeats`,value:e}),onClose:o})}),(0,D.jsxs)(`main`,{ref:c,style:{flex:1,minWidth:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,padding:24},children:[(0,D.jsx)(Gs,{pxPerM:l,room:e.room,items:e.items,preview:p,floorRef:s,onMove:(e,n,r)=>t({kind:`move`,id:e,x:n,y:r}),onResize:(e,n)=>t({kind:`resize`,id:e,...n})}),(0,D.jsx)(Ks,{pxPerM:l,roomWidthPx:e.room.width*l+12})]}),n&&!p&&(0,D.jsx)(`div`,{style:{position:`fixed`,left:n.clientX,top:n.clientY,transform:`translate(-50%, -50%)`,pointerEvents:`none`,opacity:.8},children:(()=>{let e=ye[n.type];return(0,D.jsx)(e,{})})()})]})}document.body.style.margin=`0`,(0,y.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(oc,{})); \ No newline at end of file diff --git a/dist/assets/index-DDOav9ki.js b/dist/assets/index-DDOav9ki.js new file mode 100644 index 0000000..b0cff8d --- /dev/null +++ b/dist/assets/index-DDOav9ki.js @@ -0,0 +1,41 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ne());else{var t=n(l);t!==null&&E(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,w=-1;function te(){return g?!0:!(e.unstable_now()-wt&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&E(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function E(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,E(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function ee(){}var w={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function T(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ne(e,t){return T(e.type,t,e.props)}function re(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ie(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var E=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?ie(``+e.key):t.toString(36)}function D(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function O(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,O(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(E,`$&/`)+`/`),O(o,r,i,``,function(e){return e})):o!=null&&(re(o)&&(o=ne(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(E,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1Se||(e.current=xe[Se],xe[Se]=null,Se--)}function N(e,t){Se++,xe[Se]=e.current,e.current=t}var Te=Ce(null),Ee=Ce(null),De=Ce(null),Oe=Ce(null);function ke(e,t){switch(N(De,t),N(Ee,e),N(Te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}we(Te),N(Te,e)}function Ae(){we(Te),we(Ee),we(De)}function je(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,N(Oe,e)),t=Te.current;var n=dp(t,e.type);t!==n&&(N(Ee,e),N(Te,n))}function Me(e){Ee.current===e&&(we(Te),we(Ee)),Oe.current===e&&(we(Oe),sh._currentValue=M)}var Ne,Pe;function Fe(e){if(Ne===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ne=t&&t[1]||``,Pe=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ie=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Fe(n):``}function Re(e,t){switch(e.tag){case 26:case 27:case 5:return Fe(e.type);case 16:return Fe(`Lazy`);case 13:return e.child!==t&&t!==null?Fe(`Suspense Fallback`):Fe(`Suspense`);case 19:return Fe(`SuspenseList`);case 0:case 15:return Le(e.type,!1);case 11:return Le(e.type.render,!1);case 1:return Le(e.type,!0);case 31:return Fe(`Activity`);case 30:return Fe(`ViewTransition`);default:return``}}function ze(e){try{var t=``,n=null;do t+=Re(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var Be=Object.prototype.hasOwnProperty,Ve=t.unstable_scheduleCallback,He=t.unstable_cancelCallback,Ue=t.unstable_shouldYield,We=t.unstable_requestPaint,Ge=t.unstable_now,Ke=t.unstable_getCurrentPriorityLevel,qe=t.unstable_ImmediatePriority,Je=t.unstable_UserBlockingPriority,Ye=t.unstable_NormalPriority,Xe=t.unstable_LowPriority,P=t.unstable_IdlePriority,Ze=t.log,Qe=t.unstable_setDisableYieldValue,$e=null,et=null;function tt(e){if(typeof Ze==`function`&&Qe(e),et&&typeof et.setStrictMode==`function`)try{et.setStrictMode($e,e)}catch{}}var nt=Math.clz32?Math.clz32:at,rt=Math.log,it=Math.LN2;function at(e){return e>>>=0,e===0?32:31-(rt(e)/it|0)|0}var ot=256,st=262144,ct=4194304;function lt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ut(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=lt(n))):i=lt(o):i=lt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=lt(n))):i=lt(o)):i=lt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function dt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ft(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function ht(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function gt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return cr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var _r=!1;function vr(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function yr(e,t){if(_r)return e===`compositionend`||!lr&&hr(e,t)?(e=Mn(),jn=An=kn=null,_r=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Hr(n)}}function Wr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vr(e.document)}return t}function Kr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var qr=En&&`documentMode`in document&&11>=document.documentMode,Jr=null,Yr=null,Xr=null,Zr=!1;function Qr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zr||Jr==null||Jr!==Vr(r)||(r=Jr,`selectionStart`in r&&Kr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Xr&&Br(Xr,r)||(Xr=r,r=qf(Yr,`onSelect`),0>=o,i-=o,qi=1<<32-nt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),U&&Yi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),U&&Yi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return U&&Yi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),U&&Yi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===E&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case re:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===E){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),io(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ue&&Za(l)===r.type){n(e,r.sibling),c=a(r,o.props),io(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===E?(c=Fi(o.props.children,e.mode,c,o.key),io(c,o),c.return=e,e=c):(c=Pi(o.type,o.key,o.props,null,e.mode,c),io(c,o),c.return=e,e=c)}return s(e);case ie:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ri(o,e.mode,c),c.return=e,e=c}return s(e);case ue:return o=Za(o),_(e,r,o,c)}if(be(o))return h(e,r,o,c);if(_e(o)){if(l=_e(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,ro(o),c);if(o.$$typeof===oe)return _(e,r,Sa(e,o),c);ao(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ii(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{no=0;var i=_(e,t,n,r);return to=null,i}catch(t){if(t===Ga||t===qa)throw t;var a=Ai(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var so=oo(!0),co=oo(!1),lo=!1;function uo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function po(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function mo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Zu&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Di(e),Ei(e,null,n),t}return Ci(e,r,t,n),Di(e)}function ho(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,vt(e,n)}}function go(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var _o=!1;function G(){if(_o){var e=Ia;if(e!==null)throw e}}function vo(e,t,n,r){_o=!1;var i=e.updateQueue;lo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(X&f)===f:(r&f)===f){f!==0&&f===Fa&&(_o=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=T({},d,f);break a;case 2:lo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),id|=o,e.lanes=o,e.memoizedState=d}}function yo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function bo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=A.T,s={};s.types=o===null?null:o.types,A.T=s,oc(e,!1,t,n);try{var c=i(),l=A.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ac(e,t,za(c,r),kd(e)):ac(e,t,r,kd(e))}catch(n){ac(e,t,{then:function(){},status:`rejected`,reason:n},kd())}finally{j.p=a,o!==null&&s.types!==null&&(o.types=s.types),A.T=o}}function Ys(){}function Xs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Zs(e).queue;Js(e,a,t,M,n===null?Ys:function(){return Qs(e),n(r)})}function Zs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:M,baseState:M,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:M},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Qs(e){var t=Zs(e);t.next===null&&(t=e.alternate.memoizedState),ac(e,t.next.queue,{},kd())}function $s(){return xa(sh)}function ec(){return ns().memoizedState}function tc(){return ns().memoizedState}function nc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=kd();e=po(n);var r=mo(t,e,n);r!==null&&(Md(r,t,n),ho(r,t,n)),t={cache:Oa()},e.payload=t;return}t=t.return}}function rc(e,t,n){var r=kd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},sc(e)?cc(t,n):(n=wi(e,t,n,r),n!==null&&(Md(n,e,r),lc(n,t,r)))}function ic(e,t,n){ac(e,t,n,kd())}function ac(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(sc(e))cc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,zr(s,o))return Ci(e,t,i,0),Qu===null&&Si(),!1}catch{}if(n=wi(e,t,i,r),n!==null)return Md(n,e,r),lc(n,t,r),!0}return!1}function oc(e,t,n,r){if(r={lane:2,revertLane:Mf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},sc(e)){if(t)throw Error(i(479))}else t=wi(e,n,r,2),t!==null&&Md(t,e,2)}function sc(e){var t=e.alternate;return e===K||t!==null&&t===K}function cc(e,t){Vo=Bo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function lc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,vt(e,n)}}var uc={readContext:xa,use:as,useCallback:Ko,useContext:Ko,useEffect:Ko,useImperativeHandle:Ko,useLayoutEffect:Ko,useInsertionEffect:Ko,useMemo:Ko,useReducer:Ko,useRef:Ko,useState:Ko,useDebugValue:Ko,useDeferredValue:Ko,useTransition:Ko,useSyncExternalStore:Ko,useId:Ko,useHostTransitionStatus:Ko,useFormState:Ko,useActionState:Ko,useOptimistic:Ko,useMemoCache:Ko,useCacheRefresh:Ko,useEffectEvent:Ko},dc={readContext:xa,use:as,useCallback:function(e,t){return ts().memoizedState=[e,t===void 0?null:t],e},useContext:xa,useEffect:Fs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ns(4194308,4,Vs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ns(4194308,4,e,t)},useInsertionEffect:function(e,t){Ns(4,2,e,t)},useMemo:function(e,t){var n=ts();t=t===void 0?null:t;var r=e();if(q){tt(!0);try{e()}finally{tt(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ts();if(n!==void 0){var i=n(t);if(q){tt(!0);try{n(t)}finally{tt(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=rc.bind(null,K,e),[r.memoizedState,e]},useRef:function(e){var t=ts();return e={current:e},t.memoizedState=e},useState:function(e){e=_s(e);var t=e.queue,n=ic.bind(null,K,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Us,useDeferredValue:function(e,t){return Ks(ts(),e,t)},useTransition:function(){var e=_s(!1);return e=Js.bind(null,K,e.queue,!0,!1),ts().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=K,a=ts();if(U){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Qu===null)throw Error(i(349));X&127||fs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Fs(ms.bind(null,r,o,e),[e]),r.flags|=2048,js(9,{destroy:void 0},ps.bind(null,r,o,n,t),null),n},useId:function(){var e=ts(),t=Qu.identifierPrefix;if(U){var n=Ji,r=qi;n=(r&~(1<<32-nt(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ho++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[I]=t,o[Tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ll(t)}}return ml(t),t.subtreeFlags&=-33554433,ul(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ll(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=De.current,sa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ea,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[I]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||W(t,!0)}else e=lp(e).createTextNode(r),e[I]=t,t.stateNode=e}return ml(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=sa(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[I]=t}else ca(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ml(t),e=!1}else n=la(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Mo(t),t):(Mo(t),null);if(t.flags&128)throw Error(i(558))}return ml(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=sa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[I]=t}else ca(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ml(t),a=!1}else a=la(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Mo(t),t):(Mo(t),null)}return Mo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),fl(t,t.updateQueue),ml(t),null);case 4:return Ae(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,ml(t),null;case 10:return ha(t.type),ml(t),null;case 19:if(Fo(t),r=t.memoizedState,r===null)return ml(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)pl(r,!1);else{if(rd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Io(e),o!==null){for(t.flags|=128,pl(r,!1),e=o.updateQueue,t.updateQueue=e,fl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ni(n,e),n=n.sibling;return Po(t,No.current&1|2),U&&Yi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ge()>md&&(t.flags|=128,a=!0,pl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Io(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,fl(t,e),pl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!U)return ml(t),null}else 2*Ge()-r.renderingStartTime>md&&n!==536870912&&(t.flags|=128,a=!0,pl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ge(),e.sibling=null,o=No.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||U?Po(t,o):(n=o,N(Eo,t),N(No,n),Do===null&&(Do=t)),U&&Yi(t,r.treeForkCount),e}return ml(t),null;case 22:case 23:return Mo(t),To(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(ml(t),t.subtreeFlags&6&&(t.flags|=8192)):ml(t),n=t.updateQueue,n!==null&&fl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&we(Va),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ha(Da),ml(t),null;case 25:return null;case 30:return t.flags|=33554432,ml(t),null}throw Error(i(156,t.tag))}function gl(e,t){switch(Qi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ha(Da),Ae(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Me(t),null;case 31:if(t.memoizedState!==null){if(Mo(t),t.alternate===null)throw Error(i(340));ca()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Mo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ca()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Fo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Ae(),null;case 10:return ha(t.type),null;case 22:case 23:return Mo(t),To(),e!==null&&we(Va),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ha(Da),null;case 25:return null;default:return null}}function _l(e,t){switch(Qi(t),t.tag){case 3:ha(Da),Ae();break;case 26:case 27:case 5:Me(t);break;case 4:Ae();break;case 31:t.memoizedState!==null&&Mo(t);break;case 13:Mo(t);break;case 19:Fo(t);break;case 10:ha(t.type);break;case 22:case 23:Mo(t),To(),e!==null&&we(Va);break;case 24:ha(Da)}}function vl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){df(t,t.return,e)}}function yl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){df(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){df(t,t.return,e)}}function bl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{bo(t,n)}catch(t){df(e,e.return,t)}}}function xl(e,t,n){n.props=vc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){df(e,t,n)}}function Sl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=hi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);m(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){df(e,t,n)}}function Cl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){df(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){df(e,t,n)}else n.current=null}}function wl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[I]=e,Lt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Ur(s,h),v=Ur(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,A.T=null,n=Sd,Sd=null;var o=vd,s=bd;if(_d=0,yd=vd=null,bd=0,Zu&6)throw Error(i(331));var c=Zu;if(Zu|=4,Ku(o.current),Ru(o,o.current,s,n),Zu=c,Tf(0,!1),et&&typeof et.onPostCommitFiberRoot==`function`)try{et.onPostCommitFiberRoot($e,o)}catch{}return!0}finally{j.p=a,A.T=r,sf(e,t)}}function uf(e,t,n){t=Bi(n,t),t=wc(e.stateNode,t,2),e=mo(e,t,2),e!==null&&(ht(e,2),wf(e))}function df(e,t,n){if(e.tag===3)uf(e,e,n);else for(;t!==null;){if(t.tag===3){uf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(gd===null||!gd.has(r))){e=Bi(n,e),n=Tc(2),r=mo(t,n,2),r!==null&&(Ec(n,r,t,e),ht(r,2),wf(r));break}}t=t.return}}function ff(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Xu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(td=!0,i.add(n),e=pf.bind(null,e,t,n),t.then(e,e))}function pf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Qu===e&&(X&n)===n&&(rd===4||rd===3&&(X&62914560)===X&&300>Ge()-fd?Zu&2?od|=n:zd(e,0):od|=n,cd===X&&(cd=0)),wf(e)}function mf(e,t){t===0&&(t=mt()),e=Ti(e,t),e!==null&&(ht(e,t),wf(e))}function hf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),mf(e,n)}function gf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),mf(e,n)}function _f(e,t){return Ve(e,t)}var vf=null,yf=null,bf=!1,xf=!1,Sf=!1,Cf=0;function wf(e){e!==yf&&e.next===null&&(yf===null?vf=yf=e:yf=yf.next=e),xf=!0,bf||(bf=!0,jf())}function Tf(e,t){if(!Sf&&xf){Sf=!0;do for(var n=!1,r=vf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-nt(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Af(r,a))}else a=X,a=ut(r,r===Qu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||dt(r,a)||(n=!0,Af(r,a))}r=r.next}while(n);Sf=!1}}function Ef(){Df()}function Df(){xf=bf=!1;var e=0;Cf!==0&&hp()&&(e=Cf);for(var t=Ge(),n=null,r=vf;r!==null;){var i=r.next,a=Of(r,t);a===0?(r.next=null,n===null?vf=i:n.next=i,i===null&&(yf=n)):(n=r,(e!==0||a&3)&&(xf=!0)),r=i}_d!==0&&_d!==5||Tf(e,!1),Cf!==0&&(Cf=0)}function Of(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=tn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Lt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+tn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+tn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+tn(n.imageSizes)+`"]`)):i+=`[href="`+tn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=T({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){Rt(o)}),Lt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+tn(r)+`"][href="`+tn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=T({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Lt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=It(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=T({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Lt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=It(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Lt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=It(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Lt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=De.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=It(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=It(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=It(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+tn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return T({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=Rt.bind(null,t),np(t,`link`,n),Lt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+tn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+tn(n.href)+`"]`);if(r)return t.instance=r,Lt(r),r;var a=T({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Lt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Lt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Lt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Lt(a),a):(r=n,(a=vm.get(o))&&(r=T({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Lt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Lt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=l(p(),1),y=_(),b=(e,t,n)=>Math.max(1,Math.min(t/e.width,n/e.height)),x={width:10,height:8},S=(e,t,n)=>Math.min(Math.max(e,t),n);function C(e){let t=(e.rotation??0)*Math.PI/180,n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=e.width*n+e.height*r,a=e.width*r+e.height*n,o=e.x+e.width/2,s=e.y+e.height/2;return{x:o-i/2,y:s-a/2,width:i,height:a}}function ee(e,t){let n=C(e),r=S(n.x,0,t.width-n.width)-n.x,i=S(n.y,0,t.height-n.height)-n.y;return{...e,x:e.x+r,y:e.y+i}}function w(e,t){let n=1e-9;return e.xt.x+n&&e.yt.y+n}function te(e,t){let n=1e-9;return e.x>=-1e-9&&e.y>=-1e-9&&e.x+e.width<=t.width+n&&e.y+e.height<=t.height+n}function T(e,t,n,r){let i=C(e);return te(i,n)&&!t.some(e=>e.id!==r&&w(i,C(e)))}function ne(e,t,n,r){let i={...e,...t};return t.x===void 0&&t.y===void 0&&(i.x=e.x+e.width/2-i.width/2,i.y=e.y+e.height/2-i.height/2),i=ee(i,r),T(i,n,r,e.id)?i:null}var re=.5;function ie(e,t,n,r){if(t===`right`)return{...e,width:S(n-e.x,re,r.width-e.x)};let i=e.x+e.width,a=S(n,0,i-re);return{...e,x:a,width:i-a}}var E=[{id:`chair`,name:`Chair`,shape:`chair`,defaultWidth:.5,defaultHeight:.5,isTable:!1,available:20},{id:`table`,name:`Table`,shape:`table`,defaultWidth:1.8,defaultHeight:.8,isTable:!0,available:6,seatsPerUnit:8},{id:`screen`,name:`Screen`,shape:`screen`,defaultWidth:2,defaultHeight:.2,isTable:!1,available:2}],ae={room:x,items:[],configs:Object.fromEntries(E.map(e=>[e.id,e])),typeOrder:E.map(e=>e.id)};function D(e,t){switch(t.kind){case`add`:{let n=e.configs[t.type],r={id:t.id,type:t.type,x:t.x,y:t.y,width:n.defaultWidth,height:n.defaultHeight,rotation:0,locked:!1};return{...e,items:[...e.items,r]}}case`move`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,x:t.x,y:t.y}:e)};case`update`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,...t.patch}:e)};case`remove`:return{...e,items:e.items.filter(e=>e.id!==t.id)};case`setAvailable`:return{...e,configs:{...e.configs,[t.type]:{...e.configs[t.type],available:t.value}}};case`setSeats`:return{...e,configs:{...e.configs,[t.type]:{...e.configs[t.type],seatsPerUnit:t.value}}};case`addConfig`:return{...e,configs:{...e.configs,[t.config.id]:t.config},typeOrder:[...e.typeOrder,t.config.id]}}}var O=(e,t)=>e.filter(e=>e.type===t).length,oe=(e,t,n)=>n-O(e,t),se=(e,t)=>e.seatsOverride??t.seatsPerUnit,ce=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),k=o(((e,t)=>{t.exports=ce()}))();function le({size:e=36}){return(0,k.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,k.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`28`,rx:`3`,fill:`#8fb4d9`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,k.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`8`,rx:`3`,fill:`#4a6f96`})]})}function ue({size:e=36}){return(0,k.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:(0,k.jsx)(`rect`,{x:`2`,y:`9`,width:`32`,height:`18`,rx:`3`,fill:`#d9b382`,stroke:`#3b3b3b`,strokeWidth:`1.5`})})}function de({size:e=36}){return(0,k.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,k.jsx)(`rect`,{x:`2`,y:`14`,width:`32`,height:`8`,rx:`2`,fill:`#2d3748`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,k.jsx)(`rect`,{x:`4`,y:`16`,width:`28`,height:`4`,fill:`#63b3ed`})]})}function fe({shape:e,size:t}){return e===`table`?(0,k.jsx)(ue,{size:t}):e===`screen`?(0,k.jsx)(de,{size:t}):(0,k.jsx)(le,{size:t})}var pe=5,me={width:`100%`,height:84,boxSizing:`border-box`,background:`#fff`,border:`1px solid #cfcfcf`,borderRadius:8,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:6,cursor:`grab`,userSelect:`none`,touchAction:`none`,font:`12px system-ui, sans-serif`,color:`#444`},he=152,ge=600;function _e({config:e,remaining:t,onStartDrag:n,onOpenMenu:r}){let i=e.id,a=t<=0,o=e=>{e.preventDefault();let{clientX:t,clientY:o}=e,s=!1,c=e=>{s||a||Math.hypot(e.clientX-t,e.clientY-o)>=pe&&(s=!0,u(),n(i,e.clientX,e.clientY))},l=e=>{u(),(Math.hypot(e.clientX-t,e.clientY-o){window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)};return(0,k.jsxs)(`div`,{role:`button`,"aria-label":`${e.name} (${t} remaining)`,style:{...me,position:`relative`,opacity:a?.45:1,filter:a?`grayscale(1)`:void 0,cursor:a?`pointer`:`grab`},onPointerDown:o,children:[(0,k.jsx)(`span`,{style:{position:`absolute`,top:6,right:6,minWidth:20,height:20,padding:`0 6px`,boxSizing:`border-box`,borderRadius:10,background:a?`#888`:`#2b2b2b`,color:`#fff`,font:`600 11px/20px system-ui, sans-serif`,textAlign:`center`},children:t}),(0,k.jsx)(fe,{shape:e.shape}),e.name]})}function ve({onClick:e}){return(0,k.jsxs)(`div`,{role:`button`,"aria-label":`New custom furniture`,onClick:e,style:{...me,border:`1.5px dashed #9a9a9a`,background:`transparent`,cursor:`pointer`},children:[(0,k.jsx)(`span`,{style:{font:`300 30px/30px system-ui, sans-serif`,color:`#666`},children:`+`}),`Custom`]})}function ye({types:e,remaining:t,onStartDrag:n,onOpenMenu:r,onNewCustom:i,panel:a}){let[o,s]=(0,v.useState)(264);return(0,k.jsxs)(`aside`,{style:{position:`relative`,width:o,flexShrink:0,borderRight:`1px solid #d4d4d4`,background:`#ececec`},children:[(0,k.jsx)(`div`,{style:{height:`100%`,boxSizing:`border-box`,overflowY:`auto`,padding:16,display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(84px, 1fr))`,alignContent:`start`,gap:12},children:a??(0,k.jsxs)(k.Fragment,{children:[e.map(e=>(0,k.jsx)(_e,{config:e,remaining:t[e.id],onStartDrag:n,onOpenMenu:r},e.id)),(0,k.jsx)(ve,{onClick:i})]})}),(0,k.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e.clientX,n=o,r=e=>s(Math.min(ge,Math.max(he,n+e.clientX-t))),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},style:{position:`absolute`,top:0,right:-3,width:6,height:`100%`,cursor:`col-resize`,touchAction:`none`}})]})}var be=Math.PI/180;function A(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var j=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},M={_global:j,version:`10.9.0`,isBrowser:A(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return M.angleDeg?e*be:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return M.DD.isDragging},isTransforming(){return M.Transformer?.isTransforming()??!1},isDragReady(){return!!M.DD.node},releaseCanvasOnDestroy:!0,document:j.document,_injectGlobal(e){j.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),j.Konva=e}},xe=new Set,Se=(e,t=!1)=>{M[e.prototype.getClassName()]=e,t&&xe.add(e)};M._injectGlobal(M);var Ce=`Konva.js unsupported environment. + +Looks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined. + +To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module. + +bash: npm install canvas +js: import "konva/canvas-backend"; + +or + +bash: npm install skia-canvas +js: import "konva/skia-backend"; +`,we=()=>{if(typeof document>`u`)throw Error(Ce)},N=class e{constructor(e){this.dirty=!1,this.m=e?e.slice():[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=o&&(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=o&&(e*n+t*r)/o}return s.rotation=P._getRotation(s.rotation),s}},Te=`[object Array]`,Ee=`[object Number]`,De=`[object String]`,Oe=`[object Boolean]`,ke=Math.PI/180,Ae=180/Math.PI,je=`#`,Me=``,Ne=`0`,Pe=`Konva warning: `,Fe=`Konva error: `,Ie={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[0,0,0,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Le=null,Re=typeof window<`u`?window:{},ze=new WeakMap,Be=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},Ve=new Map,He=Object.getPrototypeOf(Int8Array),Ue=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},We=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,Ge=RegExp(`^(${We})(%?)$`,`i`),Ke=(e,t)=>{let n=Ge.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},qe=/^#[0-9a-f]+$/i,Je=RegExp(`^(${We})(deg|grad|rad|turn)?$`,`i`),Ye={deg:1,grad:.9,rad:Ae,turn:360};function Xe(e,t){return Math.min(Math.max(e||0,0),t)}var P={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===Te},_isNumber(e){return Object.prototype.toString.call(e)===Ee&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===De},_isBoolean(e){return Object.prototype.toString.call(e)===Oe},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e,t){let n=t&&!t.closed&&t||Re,r=ze.get(n);r||(r=[],ze.set(n,r),Be(n,function(){ze.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){we();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return we(),document.createElement(`img`)},_urlToImage(e,t,n){let r=P.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(je,Me);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215|0).toString(16);for(;e.length<6;)e=Ne+e;return je+e},isCanvasFarblingActive(){if(Le!==null)return Le;if(typeof document>`u`)return Le=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return Le=r,this.releaseCanvas(e),Le},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return je+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=P.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=P._namedColorToRBA(e)||P._hex3ColorToRGBA(e)||P._hex4ColorToRGBA(e)||P._hex6ColorToRGBA(e)||P._hex8ColorToRGBA(e)||P._rgbColorToRGBA(e)||P._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(P._isNumber))return t},_namedColorToRBA(e){let t=Ie[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:t.length>3?t[3]:1}:null},_rgbColorToRGBA(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Ue(t[1]);if(!(n.length<3||n.length>4))return{r:Ke(n[0],255),g:Ke(n[1],255),b:Ke(n[2],255),a:n.length>3?Ke(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&qe.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e.length===7&&qe.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e.length===5&&qe.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e.length===4&&qe.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){let t=/^hsla?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Ue(t[1]);if(n.length<3||n.length>4)return;let r=Je.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?Ye[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=Ke(n[1],100)/100,c=Ke(n[2],100)/100,l=n.length>3?Ke(n[3],1):1,u=c<.5?c*(1+s):c+s-c*s,d=2*c-u,f=[0,0,0];for(let e=0;e<3;e++){let t=o+1/3*-(e-1);t<0&&t++,t>1&&t--;let n;n=6*t<1?d+(u-d)*6*t:2*t<1?u:3*t<2?d+(u-d)*(2/3-t)*6:d,f[e]=n*255}return{r:Math.round(f[0]),g:Math.round(f[1]),b:Math.round(f[2]),a:l}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;ae.x+e.width||t.x+t.widthe.y+e.height||t.y+t.heighttypeof e==`object`)?e.map(P._cloneValue):e.slice():P._isPlainObject(e)?P.cloneObject(e):e instanceof He?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*ke},radToDeg(e){return e*Ae},_getRotation(e){return M.angleDeg?P.radToDeg(e):e},_capitalize(e){let t=Ve.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return Ve.set(e,n),n},throw(e){throw Error(Fe+e)},error(e){console.error(Fe+e)},warn(e){M.showWarnings&&console.warn(Pe+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{n||!r?P.warn(`eventBatchFunc must call its argument exactly once, synchronously.`):(n=!0,t())})}finally{r=!1,n||P.warn(`eventBatchFunc must call its argument synchronously.`)}},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=P.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=P._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];dt.length){let n=t;t=e,e=n}for(let t=0;t=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){M.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=Xe(e,r);return[t,t,t,t]}return[Xe(e[0],r),Xe(e[1],r),Xe(e[2],r),Xe(e[3],r)]},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let[o,s,c,l]=P._cornerRadii(r,t,n);e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;atypeof e==`number`?Math.floor(e):e)),i+=$e+c.join(Qe)+et)):(i+=o.property,e||(i+=rt+o.val)),i+=tt;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ot&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash(e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=it.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Ze(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.widthMath.min(r,Math.ceil((n4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),P.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new ut(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},mt=class extends ft{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new dt(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},F={get isDragging(){let e=!1;return F._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of F._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>F._endDragBefore(t,e),n=t=>F._batchEvents(()=>F._drag(t,e),e),r=e=>F._batchEvents(()=>F._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!F._dragElements.size)return;let n=new Set;for(let{node:e}of F._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>P._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;F._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=P._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y)){t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;F._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===P._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)F._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){F._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&F._dragElements.delete(r))})}},ht=new Map,gt=M._global.PointerEvent!==void 0;function _t(e,t){let n=ht.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function vt(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function yt(e,t){return ht.get(e)?.shape===t}function bt(e,t){var n;St(e);let r=t.getStage();if(r&&(ht.set(e,{shape:t,stage:r}),gt)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}vt(t,`gotpointercapture`,e)}}function xt(e){ht.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&St(r)})}function St(e,t){var n;let r=ht.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(ht.delete(e),gt){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}vt(i,`lostpointercapture`,e)}}function Ct(e){return P._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||P._isBoolean(e)?e:Object.prototype.toString.call(e)}function wt(e){return e>255?255:e<0?0:Math.round(e)}function I(){if(M.isUnminified)return function(e,t){return P._isNumber(e)||P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function Tt(e){if(M.isUnminified)return function(t,n){let r=P._isNumber(t),i=P._isArray(t)&&t.length==e;return!r&&!i&&P.warn(Ct(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array(`+e+`)`),t}}function Et(){if(M.isUnminified)return function(e,t){return P._isNumber(e)||e===`auto`||P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function Dt(){if(M.isUnminified)return function(e,t){return P._isString(e)||P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function Ot(){if(M.isUnminified)return function(e,t){let n=P._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function kt(){if(M.isUnminified)return function(e,t){return e instanceof He||(P._isArray(e)?e.forEach(function(e){P._isNumber(e)||P.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function At(){if(M.isUnminified)return function(e,t){return e!==!0&&e!==!1&&P.warn(Ct(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function jt(e){if(M.isUnminified)return function(t,n){return t==null||P.isObject(t)||P.warn(Ct(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var Mt=`get`,Nt=`set`,L={addGetterSetter(e,t,n,r,i){L.addGetter(e,t,n),L.addSetter(e,t,r,i),L.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=Mt+P._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=Nt+P._capitalize(t);e.prototype[i]||L.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=Nt+P._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=P._capitalize,s=Mt+o(t),c=Nt+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>Mt+o(e));e.prototype[s]=function(){let e={};for(let t=0;t{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},L.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=P._capitalize(t),r=Nt+n,i=Mt+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){P.each(t,function(t,n){let r=e.prototype[n],i=Mt+P._capitalize(t),a=Nt+P._capitalize(t);function o(){return P.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function Pt(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){P.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e0?e._pendingUpdates.add(t):t()}static _flushUpdateBatch(){if(e._updateBatchDepth>0)return;let t=e._pendingUpdates;t.size&&(e._pendingUpdates=new Set,t.forEach(e=>e()))}static _updateBatch(t){e._updateBatchDepth++;try{return t()}finally{e._updateBatchDepth--,e._flushUpdateBatch()}}static _beginUpdateBatch(){e._updateBatchDepth++;let t=!1;return()=>{t||(t=!0,e._updateBatchDepth--,e._flushUpdateBatch())}}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return P.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new pt({pixelRatio:s,width:a,height:o}),f=new pt({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Ft);try{this.drawScene(d,this)}catch(e){throw P.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(Ft),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new mt(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;tt===void 0?e:`${Number(t)*u}${n}`);return i.clear(),i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s{this.isAncestorOf(e.node)&&F._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(It),this._clearSelfAndDescendantCache(Ft),this._clearSelfAndDescendantCache(Gt),this._clearSelfAndDescendantCache(qt),this._clearSelfAndDescendantCache(Bt)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),xt(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+P._capitalize(e);return P._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==Rt&&(n=Ht+P._capitalize(t),P._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Bt,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(qt,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==R&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(t){this._batchingTransformChange?t():e._updateBatch(()=>{this._batchingTransformChange=!0;try{t()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(Kt),this._clearSelfAndDescendantCache(It))}})}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=this.getAbsoluteTransform(e).getMatrix(),n=new N,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(Kt);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):P.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(Kt),this._clearSelfAndDescendantCache(It),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return P.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return P.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return P.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&P.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Ft,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i={attrs:{},className:this.getClassName()};for(t in e)n=e[t],n instanceof He&&(n=Array.from(n)),r=P.isObject(n)&&!P._isPlainObject(n)&&!P._isArray(n),!r&&(this[`get`+P._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&P._isArray(n)?n.filter(e=>typeof e==`string`):P.isObject(n)?P._prepareToStringify(n):n);return i}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r{try{let{callback:r,...i}=e||{};P._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;r?(t(r),(i=e?.callback)==null||i.call(e,r)):n(Error(`Konva: toBlob() failed, the canvas was not encoded`))},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():M.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i=0)||F._dragElements.has(this._id))return;let t=!1;F._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=F._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&F._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return P.haveIntersection(n,this.getClientRect())}static create(e,t){return P._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;if(n&&(t.attrs.container=n),!M[r]){let e=i?`Group`:`Shape`;P.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=M[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s0}removeChildren(){return this._clearChildren(`remove`)}destroyChildren(){return this._clearChildren(`destroy`)}_clearChildren(e){return z._updateBatch(()=>(this.children.forEach(t=>{t.parent=null,t.index=0,t[e]()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this))}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=z.prototype.toObject.call(this);return e.children=[],this.children.forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=z.prototype.clone.call(this,e);return this.children.forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;let n=e===void 0||e===`absoluteTransform`;n&&z._updateBatchDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{n&&--z._updateBatchDepth===0&&z._flushUpdateBatch()}}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._notifySubtreeChange(),this._requestDraw()}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCachedHitCanvas(t);if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};L.addComponentsGetterSetter(Xt,`clip`,[`x`,`y`,`width`,`height`]),L.addGetterSetter(Xt,`clipX`,void 0,I()),L.addGetterSetter(Xt,`clipY`,void 0,I()),L.addGetterSetter(Xt,`clipWidth`,void 0,I()),L.addGetterSetter(Xt,`clipHeight`,void 0,I()),L.addGetterSetter(Xt,`clipFunc`);var Zt=`Stage`,Qt=`string`,$t=`px`,en=`mouseout`,tn=`mouseleave`,nn=`mouseover`,rn=`mouseenter`,an=`mousemove`,on=`mousedown`,sn=`mouseup`,cn=`pointermove`,ln=`pointerdown`,un=`pointerup`,dn=`pointercancel`,fn=`lostpointercapture`,pn=`pointerout`,mn=`pointerleave`,hn=`pointerover`,gn=`pointerenter`,_n=`contextmenu`,vn=`touchstart`,yn=`touchend`,bn=`touchmove`,xn=`touchcancel`,Sn=`wheel`,Cn=5,wn=[[rn,`_pointerenter`],[on,`_pointerdown`],[an,`_pointermove`],[sn,`_pointerup`],[tn,`_pointerleave`],[vn,`_pointerdown`],[bn,`_pointermove`],[yn,`_pointerup`],[xn,`_pointercancel`],[nn,`_pointerover`],[Sn,`_wheel`],[_n,`_contextmenu`],[ln,`_pointerdown`],[cn,`_pointermove`],[un,`_pointerup`],[dn,`_pointercancel`],[mn,`_pointerleave`],[fn,`_lostpointercapture`]],Tn={mouse:{[pn]:en,[mn]:tn,[hn]:nn,[gn]:rn,[cn]:an,[ln]:on,[un]:sn,[dn]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[pn]:`touchout`,[mn]:`touchleave`,[hn]:`touchover`,[gn]:`touchenter`,[cn]:bn,[ln]:vn,[un]:yn,[dn]:xn,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[pn]:pn,[mn]:mn,[hn]:hn,[gn]:gn,[cn]:cn,[ln]:ln,[un]:un,[dn]:dn,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},En=e=>{let t=P._getEventType(e);if(t===`pointer`)return M.pointerEventsEnabled&&Tn.pointer;if(t===`touch`)return Tn.touch;if(t===`mouse`)return Tn.mouse};function Dn(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&P.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var On=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,kn=[],An=new WeakSet,jn=e=>{e&&!An.has(e)&&(An.add(e),F._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{kn.forEach(e=>{e.batchDraw()})}))},Mn=class extends Xt{constructor(e){super(Dn(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),kn.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{Dn(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||P.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(M.isBrowser?window:null)}setContainer(e){if(typeof e===Qt){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content),jn(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n-1&&kn.splice(n,1),P.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(P.warn(On),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new pt({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio()),P.releaseCanvas(r._canvas)}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+$t,this.content.style.height=t+$t),this.children.forEach(n=>{n._setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;eCn&&P.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e._setSize({width:this.width(),height:this.height()}),e.draw(),M.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return yt(e,this)}setPointerCapture(e){bt(e,this)}releaseCapture(e){St(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){M.isBrowser&&wn.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){P._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=En(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=En(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(M.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of F._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>M.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=En(e.type),n=P._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=En(e.type),n=P._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of F._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;M.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=En(e.type),n=P._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of F._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=_t(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=En(e.type),n=P._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=_t(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time{let r=P._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=_t(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(un,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),St(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){_t(e.pointerId,this)&&St(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:P._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:P._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){P.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferHitCanvas=new mt({pixelRatio:1,width:0,height:0}),!M.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),jn(this._getOwnerWindow()),this._resizeDOM()}cache(){return P.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};Mn.prototype.nodeType=Zt,Se(Mn),L.addGetterSetter(Mn,`container`),L.addGetterSetter(Mn,`eventBatchFunc`);var Nn=`hasShadow`,Pn=`hasFill`,Fn=`hasStroke`,In=`shadowRGBA`,Ln=`patternImage`,Rn=`linearGradient`,zn=`radialGradient`,Bn;function Vn(){return Bn||(Bn=P.createCanvasElement().getContext(`2d`),Bn)}var Hn={};function Un(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function Wn(e){e.stroke()}function Gn(){this._clearCache(Nn)}function Kn(){this._clearCache(Pn)}function qn(){this._clearCache(Fn)}function Jn(){this._clearCache(In)}function Yn(){this._clearCache(Ln)}function Xn(){this._clearCache(Rn)}function Zn(){this._clearCache(zn)}var V=class e extends z{constructor(e){super(e);let t,n=0;for(;t=P.getHitColor(),!t||t in Hn;)if(n++,n>=1e4){P.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=P.getRandomColor();break}this.colorKey=t,Hn[t]=this}getContext(){return P.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return P.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Nn,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Ln,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=Vn().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new N;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(M.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Rn,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Vn(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t0}destroy(){return z.prototype.destroy.call(this),delete Hn[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){P.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this._getSelfRectForDrawing():this.getSelfRect();i&&!this.strokeScaleEnabled()?a=this._transformedRect(a,r):(a.width<0||a.height<0)&&(a=new N()._getTransformedRect(a));let o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new N,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new N}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&xe.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||P.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=P._hexToRgb(this.colorKey);for(let t=0;te?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;r.putImageData(t,0,0)}catch(e){P.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return yt(e,this)}setPointerCapture(e){bt(e,this)}releaseCapture(e){St(e,this)}};V.prototype._fillFunc=Un,V.prototype._strokeFunc=Wn,V.prototype._fillFuncHit=Un,V.prototype._strokeFuncHit=Wn,V.prototype._centroid=!1,V.prototype.nodeType=`Shape`,Se(V),V.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Gn),V.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Jn),V.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,Kn),V.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,qn),V.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,Yn),V.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,Xn),V.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,Zn),L.addGetterSetter(V,`stroke`,void 0,Ot()),L.addGetterSetter(V,`strokeWidth`,2,I()),L.addGetterSetter(V,`fillAfterStrokeEnabled`,!1),L.addGetterSetter(V,`hitStrokeWidth`,`auto`,Et()),L.addGetterSetter(V,`strokeHitEnabled`,!0,At()),L.addGetterSetter(V,`perfectDrawEnabled`,!0,At()),L.addGetterSetter(V,`shadowForStrokeEnabled`,!0,At()),L.addGetterSetter(V,`lineJoin`),L.addGetterSetter(V,`lineCap`),L.addGetterSetter(V,`miterLimit`),L.addGetterSetter(V,`sceneFunc`),L.addGetterSetter(V,`hitFunc`),L.addGetterSetter(V,`selfRectFunc`),L.addGetterSetter(V,`dash`),L.addGetterSetter(V,`dashOffset`,0,I()),L.addGetterSetter(V,`shadowColor`,void 0,Dt()),L.addGetterSetter(V,`shadowBlur`,0,I()),L.addGetterSetter(V,`shadowOpacity`,1,I()),L.addComponentsGetterSetter(V,`shadowOffset`,[`x`,`y`]),L.addGetterSetter(V,`shadowOffsetX`,0,I()),L.addGetterSetter(V,`shadowOffsetY`,0,I()),L.addGetterSetter(V,`fillPatternImage`),L.addGetterSetter(V,`fill`,void 0,Ot()),L.addGetterSetter(V,`fillPatternX`,0,I()),L.addGetterSetter(V,`fillPatternY`,0,I()),L.addGetterSetter(V,`fillLinearGradientColorStops`),L.addGetterSetter(V,`strokeLinearGradientColorStops`),L.addGetterSetter(V,`fillRadialGradientStartRadius`,0),L.addGetterSetter(V,`fillRadialGradientEndRadius`,0),L.addGetterSetter(V,`fillRadialGradientColorStops`),L.addGetterSetter(V,`fillPatternRepeat`,`repeat`),L.addGetterSetter(V,`fillEnabled`,!0),L.addGetterSetter(V,`strokeEnabled`,!0),L.addGetterSetter(V,`shadowEnabled`,!0),L.addGetterSetter(V,`dashEnabled`,!0),L.addGetterSetter(V,`strokeScaleEnabled`,!0),L.addGetterSetter(V,`fillPriority`,`color`),L.addComponentsGetterSetter(V,`fillPatternOffset`,[`x`,`y`]),L.addGetterSetter(V,`fillPatternOffsetX`,0,I()),L.addGetterSetter(V,`fillPatternOffsetY`,0,I()),L.addComponentsGetterSetter(V,`fillPatternScale`,[`x`,`y`]),L.addGetterSetter(V,`fillPatternScaleX`,1,I()),L.addGetterSetter(V,`fillPatternScaleY`,1,I()),L.addComponentsGetterSetter(V,`fillLinearGradientStartPoint`,[`x`,`y`]),L.addComponentsGetterSetter(V,`strokeLinearGradientStartPoint`,[`x`,`y`]),L.addGetterSetter(V,`fillLinearGradientStartPointX`,0),L.addGetterSetter(V,`strokeLinearGradientStartPointX`,0),L.addGetterSetter(V,`fillLinearGradientStartPointY`,0),L.addGetterSetter(V,`strokeLinearGradientStartPointY`,0),L.addComponentsGetterSetter(V,`fillLinearGradientEndPoint`,[`x`,`y`]),L.addComponentsGetterSetter(V,`strokeLinearGradientEndPoint`,[`x`,`y`]),L.addGetterSetter(V,`fillLinearGradientEndPointX`,0),L.addGetterSetter(V,`strokeLinearGradientEndPointX`,0),L.addGetterSetter(V,`fillLinearGradientEndPointY`,0),L.addGetterSetter(V,`strokeLinearGradientEndPointY`,0),L.addComponentsGetterSetter(V,`fillRadialGradientStartPoint`,[`x`,`y`]),L.addGetterSetter(V,`fillRadialGradientStartPointX`,0),L.addGetterSetter(V,`fillRadialGradientStartPointY`,0),L.addComponentsGetterSetter(V,`fillRadialGradientEndPoint`,[`x`,`y`]),L.addGetterSetter(V,`fillRadialGradientEndPointX`,0),L.addGetterSetter(V,`fillRadialGradientEndPointY`,0),L.addGetterSetter(V,`fillPatternRotation`,0),L.addGetterSetter(V,`fillRule`,void 0,Dt()),L.backCompat(V,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var Qn=`beforeDraw`,$n=`draw`,er=10,tr=256;function nr(e,t){return e[t+3]>=128?Hn[P.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var rr=class extends Xt{constructor(e){super(e),this.canvas=new pt,this.hitCanvas=new mt({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=er,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=tr;e++){e>o&&(o=Math.min(tr,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=nr(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=nr(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(Qn,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Xt.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire($n,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||M.hitOnDragEnabled)return!0;let t=!1;return F._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!M.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),Xt.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){P.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return P.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return this.getCanvas()._releaseIsolationCanvas(),P.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};rr.prototype.nodeType=`Layer`,Se(rr),L.addGetterSetter(rr,`imageSmoothingEnabled`,!0),L.addGetterSetter(rr,`clearBeforeDraw`,!0),L.addOverloadedGetterSetter(rr,`hitGraphEnabled`);var ir=class extends rr{constructor(e){super(e),this.listening(!1),P.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};ir.prototype.nodeType=`FastLayer`,Se(ir);var ar=class extends Xt{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&P.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};L.addGetterSetter(ar,`isolated`,!1,At()),ar.prototype.nodeType=`Group`,Se(ar);var or=j.performance?.now?()=>j.performance.now():Date.now,sr=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:or(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r{Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(or()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))})}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),P.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,P.requestAnimFrame(this._animationLoop))}};sr.animations=new Set,sr.animIdCounter=0,sr.animRunning=!1;var cr={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},lr=1,ur=2,dr=3,fr=[`fill`,`stroke`,`shadowColor`],pr=0;function mr(e){return P.colorToRGBA(e)||P.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function hr(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function gr(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var _r=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=ur,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=dr,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===ur?this.setTime(e):this.state===dr&&this.setTime(this.duration-e)}pause(){this.state=lr,this.fire(`onPause`)}getTimer(){return Date.now()}},vr=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||yr.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=pr++;let l=r.getLayer()||(r instanceof M.Stage?r.getLayers():null);for(c in l||P.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new sr(function(){n.tween.onEnterFrame()},l),this.tween=new _r(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)cr[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){if(P._isPlainObject(n)){for(let e in n)this._addAttr(t+P._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(P._isArray(n)||P._isArray(u)){if(a=[],c=u,s=n,u=P._isArray(u)?u.slice():Array(n.length).fill(u||0),P._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=P._prepareArrayForTween(u,n,r.closed()):n=P._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;ethis.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,this.onReset),this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};vr.attrs={},vr.tweens={},z.prototype.to=function(e){let t=e.onFinish,n=new vr({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var yr={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};xr.prototype._centroid=!0,xr.prototype.className=`Arc`,xr.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Se(xr,!0),L.addGetterSetter(xr,`innerRadius`,0,I()),L.addGetterSetter(xr,`outerRadius`,0,I()),L.addGetterSetter(xr,`angle`,0,I()),L.addGetterSetter(xr,`clockwise`,!1,At());var Sr=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],Cr=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],wr=(e,t,n)=>{let r=n/2,i=0;for(let n=0;nwr([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function Er(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var Dr=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c500)break}return i},Or=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},kr=(e,t,n,r,i,a)=>{let o=[];for(let s of[[e,n,i],[t,r,a]]){let c=(s[0]-s[1])/(s[0]-2*s[1]+s[2]);c>0&&c<1&&o.push(Or(e,n,i,c),Or(t,r,a,c))}return o},Ar=(e,t,n,r,i)=>{let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r},jr=(e,t,n,r,i,a,o,s)=>{let c=[];for(let l of[[e,n,i,o],[t,r,a,s]]){let u=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],f=-3*l[0]+3*l[1],p=d*d-4*u*f;if(p<0)continue;let m=-(d+(d<0?-1:1)*Math.sqrt(p))/2;for(let l of[m/u,f/m])l>0&&l<1&&c.push(Ar(e,n,i,o,l),Ar(t,r,a,s,l))}return c};function Mr(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=s+c;if(l===0)return[n,r,n,r];let u=o*s/l,d=o*c/l;return[n-u*(i-e),r-u*(a-t),n+d*(i-e),r+d*(a-t)]}function Nr(e,t){let n=e.length,r=[];for(let i=2;i4}_eachTensionSegment(e,t){let n=this.points(),r=n.length,i=this.closed(),a=this.getTensionPoints(),o=a.length,s=n[0],c=n[1],l=i?0:4;for(i||(e(s,c,a[0],a[1],a[2],a[3]),s=a[2],c=a[3]);le.quadraticCurveTo(r,i,a,o),(t,n,r,i,a,o,s,c)=>e.bezierCurveTo(r,i,a,o,s,c));else if(i)for(a=2;at.push(a,o,...kr(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...jr(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...Pr(e)]);return P._getPointsRect(e)}};Fr.prototype.className=`Line`,Fr.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],Se(Fr,!0),L.addGetterSetter(Fr,`closed`,!1),L.addGetterSetter(Fr,`bezier`,!1),L.addGetterSetter(Fr,`tension`,0,I()),L.addGetterSetter(Fr,`points`,[],kt());var Ir={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},Lr=Math.PI*2,Rr=class e extends V{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r{if(((n-s)*Math.sign(c)%Lr+Lr)%Lr0&&t<=o;)o-=n[--a].pathLength;for(t-=o;an[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&awr([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(Dr(t,c.pathLength,e=>Tr([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return wr([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return Tr([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]=1&&(ee=0),a===0&&ee>0&&(ee-=2*Math.PI),a===1&&ee<0&&(ee+=2*Math.PI),[g,_,o,s,x,ee,l,a]}};Rr.prototype.className=`Path`,Rr.prototype._attrsAffectingSize=[`data`],Se(Rr,!0),L.addGetterSetter(Rr,`data`);var zr=class extends Fr{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=Rr.calcLength(e,t,`Q`,[n,r,a,o]),u=Rr.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?P.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?P.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=P.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};Hr.prototype.className=`Image`,Hr.prototype._attrsAffectingSize=[`image`],Se(Hr,!0),L.addGetterSetter(Hr,`cornerRadius`,0,Tt(4)),L.addGetterSetter(Hr,`image`),L.addComponentsGetterSetter(Hr,`crop`,[`x`,`y`,`width`,`height`]),L.addGetterSetter(Hr,`cropX`,0,I()),L.addGetterSetter(Hr,`cropY`,0,I()),L.addGetterSetter(Hr,`cropWidth`,0,I()),L.addGetterSetter(Hr,`cropHeight`,0,I());var Ur=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function Wr(e){return e/15}function Gr(e){return Ur?Array.from(Ur.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var Kr=`auto`,qr=`center`,Jr=`inherit`,Yr=`justify`,Xr=`Change.konva`,Zr=`2d`,Qr=`-`,$r=`left`,ei=`text`,ti=`Text`,ni=`top`,ri=`bottom`,ii=`middle`,ai=`normal`,oi=`px `,si=` `,ci=`right`,li=`rtl`,ui=`word`,di=`char`,fi=`none`,pi=`…`,mi=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],hi=null;function gi(){if(hi!==null)return hi;hi=!1;let e;try{e=P.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext(Zr);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t0){hi=!0;break}}}catch{}finally{e&&P.releaseCanvas(e)}return hi}function _i(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var vi;function yi(){return vi||(vi=P.createCanvasElement().getContext(Zr),vi)}function bi(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function xi(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Si(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var Ci=class extends V{constructor(e){super(Si(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=ii;if(!M.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Jr?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,$r),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===ii?e+t/2:n===ri?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(M.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return M.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+Wr(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===ci?i-t:a===qr?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=P._isString(e)?e:e==null?``:e+``;return this._setAttr(ei,t),this}getWidth(){return this.attrs.width===Kr||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Kr||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return P.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=yi(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+si+this.fontVariant()+si+(this.fontSize()+oi)+_i(this.fontFamily())}_addTextLine(e){this.align()===Yr&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??Gr(e).length):0;return yi().measureText(e).width+r}_setTextData(){let e=this.text().split(` +`),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Kr&&r!==void 0,o=i!==Kr&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==di&&d!==fi,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=yi();h.font=this._getContextFont(),h.fontKerning=this.direction()!==li&&(this.letterSpacing()!==0||this.align()===Yr||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(pi):0;for(let t=0,r=e.length;tc){let e=Gr(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===si||e===Qr,_=Math.max(1,Math.ceil(a*c/s));for(;dl?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;dl&&tl)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Kr&&r!==void 0,a=r-this.padding()*2;return this.wrap()===fi||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Kr&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+pi;if(t){let e=Gr(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+pi;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&gi()?!0:super._useBufferCanvas(e,t)}};Ci.prototype._fillFunc=bi,Ci.prototype._strokeFunc=xi,Ci.prototype.className=ti,Ci.prototype._attrsAffectingSize=mi.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Se(Ci,!0),Ci.prototype.on(mi.map(e=>e+Xr).join(` `),function(){this._setTextData()}),L.overWriteSetter(Ci,`width`,Et()),L.overWriteSetter(Ci,`height`,Et()),L.addGetterSetter(Ci,`direction`,Jr),L.addGetterSetter(Ci,`fontFamily`,`Arial`),L.addGetterSetter(Ci,`fontSize`,12,I()),L.addGetterSetter(Ci,`fontStyle`,ai),L.addGetterSetter(Ci,`fontVariant`,ai),L.addGetterSetter(Ci,`padding`,0,I()),L.addGetterSetter(Ci,`align`,$r),L.addGetterSetter(Ci,`verticalAlign`,ni),L.addGetterSetter(Ci,`lineHeight`,1,I()),L.addGetterSetter(Ci,`wrap`,ui),L.addGetterSetter(Ci,`ellipsis`,!1,At()),L.addGetterSetter(Ci,`letterSpacing`,0,I()),L.addGetterSetter(Ci,`text`,``,Dt()),L.addGetterSetter(Ci,`textDecoration`,``),L.addGetterSetter(Ci,`underlineOffset`,void 0,I()),L.addGetterSetter(Ci,`charRenderFunc`,void 0);var wi=[...Ci.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Ti=`none`,Ei=`up`,Di=`right`,Oi=`down`,ki=`left`,Ai=class extends ar{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(wi,this._sync).on(wi,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case Ei:o=n/2,s=-1*c;break;case Di:o=n+a,s=r/2;break;case Oi:o=n/2,s=r+c;break;case ki:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};Ai.prototype.className=`Label`,Se(Ai);var ji=class extends V{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=P._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===Ei&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===Di&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===Oi&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===ki&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===Ei||n===Oi?{x:Math.min(0,(r-e)/2),y:n===Ei?-t:0,width:Math.max(r,e),height:i+t}:n===ki||n===Di?{x:n===ki?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};ji.prototype.className=`Tag`,Se(ji,!0),L.addGetterSetter(ji,`pointerDirection`,Ti),L.addGetterSetter(ji,`pointerWidth`,0,I()),L.addGetterSetter(ji,`pointerHeight`,0,I()),L.addGetterSetter(ji,`cornerRadius`,0,Tt(4));var Mi=class extends V{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?P.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Mi.prototype.className=`Rect`,Se(Mi,!0),L.addGetterSetter(Mi,`cornerRadius`,0,Tt(4));var Ni=class extends V{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)P.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ni.prototype.className=`RegularPolygon`,Ni.prototype._centroid=!0,Ni.prototype._attrsAffectingSize=[`radius`,`sides`],Se(Ni,!0),L.addGetterSetter(Ni,`radius`,0,I()),L.addGetterSetter(Ni,`sides`,0,I()),L.addGetterSetter(Ni,`cornerRadius`,0,Tt(4));var Pi=Math.PI*2,Fi=class extends V{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Pi,!1),e.moveTo(n,0),e.arc(0,0,n,Pi,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Fi.prototype.className=`Ring`,Fi.prototype._centroid=!0,Fi.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Se(Fi,!0),L.addGetterSetter(Fi,`innerRadius`,0,I()),L.addGetterSetter(Fi,`outerRadius`,0,I());var Ii=class extends V{constructor(e){super(e),this._updated=!0,this.anim=new sr(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(ethis.pathLength?null:Rr.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Rr.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;tthis.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Rr.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=P._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};H.prototype._fillFunc=Bi,H.prototype._strokeFunc=Vi,H.prototype._fillFuncHit=Bi,H.prototype._strokeFuncHit=Vi,H.prototype.className=`TextPath`,H.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Se(H,!0),H.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),H.prototype.on(H.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),L.addGetterSetter(H,`data`),L.addGetterSetter(H,`fontFamily`,`Arial`),L.addGetterSetter(H,`fontSize`,12,I()),L.addGetterSetter(H,`fontStyle`,zi),L.addGetterSetter(H,`align`,`left`),L.addGetterSetter(H,`letterSpacing`,0,I()),L.addGetterSetter(H,`textBaseline`,`middle`),L.addGetterSetter(H,`fontVariant`,zi),L.addGetterSetter(H,`text`,Ri),L.addGetterSetter(H,`textDecoration`,``),L.addGetterSetter(H,`kerningFunc`,void 0),L.addGetterSetter(H,`direction`,`inherit`);var Hi=`tr-konva`,Ui=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`rotateModeChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${Hi}`).join(` `),Wi=`nodesRect`,Gi=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],Ki={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},qi=`ontouchstart`in M._global,Ji=[`rotater-top-left`,`rotater-top-right`,`rotater-bottom-left`,`rotater-bottom-right`];function Yi(e){return e.startsWith(`rotater`)}var Xi=Math.PI/12;function Zi(e,t){let n=``;return`url("data:image/svg+xml,${encodeURIComponent(n)}") 12 12, ${t}`}function Qi(e,t,n){if(e===`rotater`)return n;if(Yi(e)){let r=e.slice(8);return Zi(Math.round(P.radToDeg(t)+Ki[r]-45),n)}t+=P.degToRad(Ki[e]||0);let r=(P.radToDeg(t)%360+360)%360;return P._inRange(r,337.5,360)||P._inRange(r,0,22.5)?`ns-resize`:P._inRange(r,22.5,67.5)?`nesw-resize`:P._inRange(r,67.5,112.5)?`ew-resize`:P._inRange(r,112.5,157.5)?`nwse-resize`:P._inRange(r,157.5,202.5)?`ns-resize`:P._inRange(r,202.5,247.5)?`nesw-resize`:P._inRange(r,247.5,292.5)?`ew-resize`:P._inRange(r,292.5,337.5)?`nwse-resize`:(P.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var $i=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function ea(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function ta(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function U(e,t){return ta(e,t,ea(e))}function na(e,t,n){let r=t,i=n;for(let n=0;n0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var ia=new Set,W=class extends ar{static _isLayerTransforming(e){for(let t of ia)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updatePending=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this._syncUpdate=this._syncUpdate.bind(this),this.on(Ui,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${Hi}`,()=>this._clearCache(Wi)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return P.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Hi+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(P.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,this._resetRotation(),this._nodes.forEach(e=>{let t=()=>{var t;this._fitting?(t=this._nodeRectCache)==null||t.delete(e):(this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),this.isDragging()||this._scheduleUpdate())};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(Gi.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof Xt&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this._removeNode(e)}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._back&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}_detachNode(e){e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}_resetRotation(){let e=this._nodes.length===1&&this.useSingleNodeRotation();this.rotation(e?this._nodes[0].getAbsoluteRotation():0)}_removeNode(e){this._detachNode(e),this._nodes=this._nodes.filter(t=>t!==e),this._resetRotation(),this._resetTransformCache(e),this._scheduleUpdate()}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){var e,t;(e=this._nodes)==null||e.forEach(e=>this._detachNode(e)),this._nodes=[],this._updatePending=!1,this._resetTransformCache(),(t=this.getLayer())==null||t.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(Wi),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||((!this._updatePending||this._cache[Wi])&&this._resetTransformCache(e),z._updateBatchDepth>0?this._scheduleUpdate():this._updatePending||(this._updatePending=!0,P.requestAnimFrame(this._syncUpdate,this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncUpdate(){this._updatePending&&!this._fitting&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncUpdate(),super.drawScene(e,t)}drawHit(e,t){return this._syncUpdate(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(Wi,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=M.getAngle(this.rotation()),t=this.ignoreStroke(),n=new N;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof V&&c.getSelfRect===V.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new N),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:M.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ji.forEach(e=>{this._createAnchor(e,`_rotate-zone`).setAttrs({fill:`transparent`,strokeEnabled:!1,visible:!1})}),$i.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e,t=`_anchor`){let n=new Mi({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` `+t,dragDistance:0,draggable:!0,hitStrokeWidth:qi?10:`auto`});this._anchors[e]=n;let r=this;return n.on(`mousedown touchstart`,function(e){r._handleMouseDown(e)}),n.on(`dragstart`,e=>{n.stopDrag(),e.cancelBubble=!0}),n.on(`dragend`,e=>{e.cancelBubble=!0}),n.on(`mouseenter`,()=>{this.isTransforming()||(this._setAnchorCursor(e),this._cursorChange=!0)}),n.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&n.getStage().content&&(n.getStage().content.style.cursor=``)}),this.add(n),n}_setAnchorCursor(e,t=M.getAngle(this.rotation())){let n=this.getStage()?.content;n&&(n.style.cursor=Qi(e,t,this.rotateAnchorCursor()))}_createBack(){let e=new V({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()&&n.rotateMode()!==`corners`){let t=ra(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this._back=e,this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(e.evt.button!==void 0&&!M.dragButtons.includes(e.evt.button)||this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??P._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);if(this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},Yi(this._movingAnchorName)){let e=ea(t);this._rotateStart={pointerAngle:Math.atan2(s.y-e.y,s.x-e.x),rotation:t.rotation}}ia.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncUpdate();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(Yi(this._movingAnchorName)){let t=this._getNodeRect(),n=ea(t),r=this._rotateStart,i={x:l.x+this._anchorDragOffset.x,y:l.y+this._anchorDragOffset.y},a=Math.atan2(i.y-n.y,i.x-n.x),o=r.rotation+a-r.pointerAngle,s;if(e.shiftKey&&this.shiftBehavior()!==`none`)s=Math.round(o/Xi)*Xi;else{let e=M.getAngle(this.rotationSnapTolerance());s=na(this.rotationSnaps(),o,e)}this._movingAnchorName!==`rotater`&&this._setAnchorCursor(this._movingAnchorName,s);let c=U(t,s-t.rotation);this._fitNodesInto(c,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`top-right`].y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.xe.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();ia.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||P._inRange(e.width,-this.padding()*2-1,1)||P._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new N;i.rotate(M.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:P.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new N;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new N,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new N;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(P._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updatePending=!0,z._runAfterUpdateBatch(this._syncUpdate)}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._updatePending=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>e.hasName(`_anchor`)&&r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).filter(e=>e.hasName(`_anchor`)).forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=this.rotateMode(),l=ra(this,n,r);this._anchors.rotater.setAttrs({x:l.endX,y:l.endY,visible:this.rotateEnabled()&&c!==`corners`});let u=s*2,d=this.rotateEnabled()&&c!==`handle`,f=-o-u;Ji.forEach(e=>{this._anchors[e].setAttrs({x:e.includes(`left`)?f:n+o,y:e.includes(`top`)?f:r+o,width:u,height:u,visible:d})}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),ar.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(P.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return z.prototype.toObject.call(this)}clone(e){return z.prototype.clone.call(this,e)}getClientRect(e){return this._syncUpdate(),this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};W.isTransforming=()=>ia.size>0;function aa(e){return e instanceof Array||P.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){$i.indexOf(e)===-1&&P.warn(`Unknown anchor name: `+e+`. Available names are: `+$i.join(`, `))}),e||[]}W.prototype.className=`Transformer`,Se(W),L.addGetterSetter(W,`enabledAnchors`,$i,aa),L.addGetterSetter(W,`flipEnabled`,!0,At()),L.addGetterSetter(W,`resizeEnabled`,!0),L.addGetterSetter(W,`anchorSize`,10,I()),L.addGetterSetter(W,`rotateEnabled`,!0),L.addGetterSetter(W,`rotateLineVisible`,!0),L.addGetterSetter(W,`rotationSnaps`,[]),L.addGetterSetter(W,`rotateAnchorOffset`,50,I()),L.addGetterSetter(W,`rotateAnchorAngle`,0,I()),L.addGetterSetter(W,`rotateAnchorCursor`,`crosshair`),L.addGetterSetter(W,`rotateMode`,`handle`),L.addGetterSetter(W,`rotationSnapTolerance`,5,I()),L.addGetterSetter(W,`borderEnabled`,!0),L.addGetterSetter(W,`anchorStroke`,`rgb(0, 161, 255)`),L.addGetterSetter(W,`anchorStrokeWidth`,1,I()),L.addGetterSetter(W,`anchorFill`,`white`),L.addGetterSetter(W,`anchorCornerRadius`,0,I()),L.addGetterSetter(W,`borderStroke`,`rgb(0, 161, 255)`),L.addGetterSetter(W,`borderStrokeWidth`,1,I()),L.addGetterSetter(W,`borderDash`),L.addGetterSetter(W,`keepRatio`,!0),L.addGetterSetter(W,`shiftBehavior`,`default`),L.addGetterSetter(W,`centeredScaling`,!1),L.addGetterSetter(W,`ignoreStroke`,!1),L.addGetterSetter(W,`padding`,0,I()),L.addGetterSetter(W,`nodes`),L.addGetterSetter(W,`node`),L.addGetterSetter(W,`boundBoxFunc`),L.addGetterSetter(W,`anchorDragBoundFunc`),L.addGetterSetter(W,`anchorStyleFunc`),L.addGetterSetter(W,`shouldOverdrawWholeArea`,!1),L.addGetterSetter(W,`useSingleNodeRotation`,!0),L.backCompat(W,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var oa=class extends V{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,M.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};oa.prototype.className=`Wedge`,oa.prototype._centroid=!0,oa.prototype._attrsAffectingSize=[`radius`],Se(oa,!0),L.addGetterSetter(oa,`radius`,0,I()),L.addGetterSetter(oa,`angle`,0,I()),L.addGetterSetter(oa,`clockwise`,!1),L.backCompat(oa,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function sa(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var ca=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],la=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function ua(e,t){return t===255?e:e*t/255}var da=180;function fa(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,ee,w=t+t+1,te=r-1,T=i-1,ne=t+1,re=ne*(ne+1)/2,ie=new sa,E=t<=da?ca[t]/2**la[t]:1/(ne*ne),ae=null,D=ie,O=null,oe=null;for(let e=1;e0?(C=255/C,n[a]=Math.floor(c*E)*C,n[a+1]=Math.floor(l*E)*C,n[a+2]=Math.floor(u*E)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=O.r,p-=O.g,m-=O.b,h-=O.a,a=e+((a=t+ne)0&&fa(e,n)};L.addGetterSetter(z,`blurRadius`,0,I(),L.afterSetFilter);var ma=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};L.addGetterSetter(z,`contrast`,0,I(),L.afterSetFilter);var _a=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Float32Array(n*r);for(let e=0,n=0;ne<0?0:e>255?255:e;for(let e=0;ei&&(i=a),c=t[e+1],cs&&(s=c),d=t[e+2],du&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;el?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;el?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;ut&&(y=v,b=0,x=-1),i=0;i=0&&d=0&&f=0&&d=0&&f=1020?255:0}return o}function Pa(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s=0&&d=0&&fMath.min(1,Math.max(0,e)),L.afterSetFilter),L.addGetterSetter(z,`threshold`,.5,I(),L.afterSetFilter),br.Util._assign(br,{Arc:xr,Arrow:zr,Circle:Br,Ellipse:Vr,Image:Hr,Label:Ai,Tag:ji,Line:Fr,Path:Rr,Rect:Mi,RegularPolygon:Ni,Ring:Fi,Sprite:Ii,Star:Li,Text:Ci,TextPath:H,Transformer:W,Wedge:oa,Filters:{Blur:pa,Brightness:ha,Brighten:ma,Contrast:ga,Emboss:_a,Enhance:ya,Grayscale:ba,HSL:xa,HSV:Sa,Invert:Ca,Kaleidoscope:Ea,Mask:function(e){let t=Aa(e,this.attrs.threshold??10);return t&&(t=Ma(t,e.width,e.height),t=Na(t,e.width,e.height),t=Pa(t,e.width,e.height),ja(e,t)),e},Noise:function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Threshold:function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{t.exports=function(e){function t(e,t,n,r){return new to(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1Tl||(e.current=wl[Tl],wl[Tl]=null,Tl--)}function h(e,t){Tl++,wl[Tl]=e.current,e.current=t}function g(e){return e>>>=0,e===0?32:31-(Ol(e)/kl|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function ee(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function w(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ql=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?se(n):``}function k(e,t){switch(e.tag){case 26:case 27:case 5:return se(e.type);case 16:return se(`Lazy`);case 13:return e.child!==t&&t!==null?se(`Suspense Fallback`):se(`Suspense`);case 19:return se(`SuspenseList`);case 0:case 15:return ce(e.type,!1);case 11:return ce(e.type.render,!1);case 1:return ce(e.type,!0);case 31:return se(`Activity`);case 30:return se(`ViewTransition`);default:return``}}function le(e){try{var t=``,n=null;do t+=k(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}function ue(e,t){if(typeof e==`object`&&e){var n=$l.get(e);return n===void 0?(t={value:e,source:t,stack:le(t)},$l.set(e,t),t):n}return{value:e,source:t,stack:le(t)}}function de(e,t){eu[tu++]=ru,eu[tu++]=nu,nu=e,ru=t}function fe(e,t,n){iu[au++]=su,iu[au++]=cu,iu[au++]=ou,ou=e;var r=su;e=cu;var i=32-Dl(r)-1;r&=~(1<>=o,i-=o,su=1<<32-Dl(t)+i|n<f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),J&&de(t,f),l;if(d===null){for(;fp?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),J&&de(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return J&&de(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&f.delete(_.key===null?p:_.key)),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),J&&de(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===wo&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case So:a:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===wo){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),at(s,a),s.return=e,e=s;break a}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===No&&tt(u)===t.type){i(e,t.sibling),s=o(t,a.props),at(s,a),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}a.type===wo?(s=oo(a.props.children,e.mode,s,a.key),at(s,a),s.return=e,e=s):(s=ao(a.type,a.key,a.props,null,e.mode,s),at(s,a),s.return=e,e=s)}return c(e);case Co:a:{for(u=a.key;t!==null;){if(t.key===u){if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}s=lo(a,e.mode,s),s.return=e,e=s}return c(e);case No:return a=tt(a),y(e,t,a,s)}if(Vo(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,it(a),s);if(a.$$typeof===Oo)return y(e,t,je(e,a),s);ot(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=so(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{Wu=0;var a=y(e,n,r,i);return Uu=null,a}catch(n){if(n===Ru||n===Bu)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function ct(){for(var e=Ju,t=Yu=Ju=0;ta?a:8);var o=q.T,s={};s.types=o===null?null:o.types,q.T=s,Vn(e,!1,t,n);try{var c=i(),l=q.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Bn(e,t,Ye(c,r),fa(e)):Bn(e,t,r,fa(e))}catch(n){Bn(e,t,{then:function(){},status:`rejected`,reason:n},fa())}finally{us(a),o!==null&&s.types!==null&&(o.types=s.types),q.T=o}}function Nn(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Cs,baseState:Cs,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:R,lastRenderedState:Cs},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:R,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Pn(){return Ae(ws)}function Fn(){return Ht().memoizedState}function In(){return Ht().memoizedState}function Ln(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fa();e=ht(n);var r=gt(t,e,n);r!==null&&(ha(r,t,n),_t(r,t,n)),t={cache:Ne()},e.payload=t;return}t=t.return}}function Rn(e,t,n){var r=fa();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Hn(e)?Un(t,n):(n=ut(e,t,n,r),n!==null&&(ha(n,e,r),Wn(n,t,r)))}function zn(e,t,n){Bn(e,t,n,fa())}function Bn(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Hn(e))Un(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,ql(s,o))return lt(e,t,i,0),Gd===null&&ct(),!1}catch{}if(n=ut(e,t,i,r),n!==null)return ha(n,e,r),Wn(n,t,r),!0}return!1}function Vn(e,t,n,i){if(i={lane:2,revertLane:Ke(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Hn(e)){if(t)throw Error(r(479))}else t=ut(e,n,i,2),t!==null&&ha(t,e,2)}function Hn(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Un(e,t){id=rd=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Wn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,T(e,n)}}function Gn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:bo({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function Kn(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Qe(n,r)||!Qe(i,a):!0}function qn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&md.enqueueReplaceState(t,t.state,null)}function Jn(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=bo({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Yn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Xn(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Zn(e,t,n){return n=ht(n),n.tag=3,n.payload={element:null},n.callback=function(){Yn(e,t)},n}function V(e){return e=ht(e),e.tag=3,e}function Qn(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Xn(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Xn(t,n,r),typeof i!=`function`&&(mf===null?mf=new Set([this]):mf.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function $n(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&De(t,n,a,!0),n=X.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Z===null?Da():n.alternate===null&&ef===0&&(ef=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===Vu?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),Ya(e,i,a)),!1;case 22:return n.flags|=65536,i===Vu?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),Ya(e,i,a)),!1}throw Error(r(435,n.tag))}return Ya(e,i,a),Da(),!1}if(J)return t=X.current,t===null?(i!==_u&&(t=Error(r(423),{cause:i}),Ce(ue(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=ue(i,n),a=Zn(e.stateNode,i,a),vt(e,a),ef!==4&&(ef=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==_u&&(e=Error(r(422),{cause:i}),Ce(ue(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=ue(o,n),sf===null?sf=[o]:sf.push(o),ef!==4&&(ef=2),t===null)return!0;i=ue(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Zn(n.stateNode,i,e),vt(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(mf===null||!mf.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=V(a),Qn(a,e,n,i),vt(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}function er(e,t,n,r){t.child=e===null?Ku(t,null,n,r):Gu(t,e.child,n,r)}function tr(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ke(t),r=Pt(e,t,n,o,a,i),s=Rt(),e!==null&&!gd?(zt(e,t,i),Or(e,t,i)):(J&&s&&pe(t),t.flags|=1,er(e,t,r,i),t.child)}function nr(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!no(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,rr(e,t,a,r,i)):(e=ao(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!kr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Qe:n,n(o,r)&&e.ref===t.ref)return Or(e,t,i)}return t.flags|=1,e=ro(a,r),e.ref=t.ref,e.return=t,t.child=e}function rr(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Qe(a,r)&&e.ref===t.ref){if(gd=!1,t.pendingProps=r=a,kr(e,i))e.flags&131072&&(gd=!0);else return t.lanes=e.lanes,Or(e,t,i)}}return dr(e,t,n,r,i)}function ir(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return or(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&P(t,a===null?null:a.cachePool),a===null?wt():Ct(t,a),Dt(t);else return r=t.lanes=536870912,or(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&P(t,null),wt(),Ot()):(P(t,a.cachePool),Ct(t,a),Ot(),t.memoizedState=null);return er(e,t,i,n),t.child}function ar(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function or(e,t,n,r,i){var a=Xe();return a=a===null?null:{parent:is?wu._currentValue:wu._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&P(t,null),wt(),Dt(t),e!==null&&De(e,t,r,!0),t.childLanes=i,null}function sr(e,t){return t=yr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function cr(e,t,n){return Gu(t,e.child,null,n),e=sr(t,t.pendingProps),e.flags|=2,kt(t),t.memoizedState=null,e}function lr(e,t,n){var i=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(J){if(i.mode===`hidden`)return e=sr(t,i),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},ar(null,e);if(Et(t),(e=mu)?(e=Lc(e,gu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:ou===null?null:{id:su,overflow:cu},retryLane:536870912,hydrationErrors:null},n=co(e),n.return=t,t.child=n,pu=t,mu=null)):e=null,e===null)throw be(t);return t.lanes=536870912,null}return sr(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Et(t),a){if(t.flags&256)t.flags&=-257,t=cr(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558))}else if(gd||De(e,t,n,!1),a=(n&e.childLanes)!==0,gd||a){if(Qu.current===null){if(i=Gd,i!==null&&(s=ne(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,dt(e,s),ha(i,e,s),hd;Da()}t=cr(e,t,n)}else e=o.treeContext,ss&&(mu=Mc(s),pu=t,J=!0,hu=null,gu=!1,e!==null&&he(t,e)),t=sr(t,i),t.flags|=134221824;return t}return e=ro(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ur(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function dr(e,t,n,r,i){return ke(t),n=Pt(e,t,n,r,void 0,i),r=Rt(),e!==null&&!gd?(zt(e,t,i),Or(e,t,i)):(J&&r&&pe(t),t.flags|=1,er(e,t,n,i),t.child)}function fr(e,t,n,r,i,a){return ke(t),t.updateQueue=null,n=It(t,r,n,i),Ft(e),r=Rt(),e!==null&&!gd?(zt(e,t,a),Or(e,t,a)):(J&&r&&pe(t),t.flags|=1,er(e,t,n,a),t.child)}function pr(e,t,n,r,i){if(ke(t),t.stateNode===null){var a=El,o=n.contextType;typeof o==`object`&&o&&(a=Ae(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=md,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},mt(t),o=n.contextType,a.context=typeof o==`object`&&o?Ae(o):El,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Gn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&md.enqueueReplaceState(a,a.state,null),bt(t,r,a,i),yt(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Jn(n,s);a.props=c;var l=a.context,u=n.contextType;o=El,typeof u==`object`&&u&&(o=Ae(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&qn(t,a,r,o),Xu=!1;var f=t.memoizedState;a.state=f,bt(t,r,a,i),yt(),l=t.memoizedState,s||f!==l||Xu?(typeof d==`function`&&(Gn(t,n,d,r),l=t.memoizedState),(c=Xu||Kn(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,F(e,t),o=t.memoizedProps,u=Jn(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=El,typeof l==`object`&&l&&(c=Ae(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&qn(t,a,r,c),Xu=!1,f=t.memoizedState,a.state=f,bt(t,r,a,i),yt();var p=t.memoizedState;o!==d||f!==p||Xu||e!==null&&e.dependencies!==null&&Oe(e.dependencies)?(typeof s==`function`&&(Gn(t,n,s,r),p=t.memoizedState),(u=Xu||Kn(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Oe(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,ur(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Gu(t,e.child,null,i),t.child=Gu(t,null,n,i)):er(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Or(e,t,i),e}function mr(e,t,n,r){return xe(),t.flags|=256,er(e,t,n,r),t.child}function hr(e){return{baseLanes:e,cachePool:Ze()}}function gr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=af),e}function _r(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!($u.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(J){if(i?Tt(t):Ot(),(e=mu)?(e=Rc(e,gu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:ou===null?null:{id:su,overflow:cu},retryLane:536870912,hydrationErrors:null},n=co(e),n.return=t,t.child=n,pu=t,mu=null)):e=null,e===null)throw be(t);return t.lanes=Cc(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Ot(),i=t.mode,a=yr({mode:`hidden`,children:a},i),r=oo(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=hr(n),r.childLanes=gr(e,o,n),t.memoizedState=_d,ar(null,r)):(Tt(t),vr(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return xr(e,t,a,o,r,c,s,n)}return i?(Ot(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=ro(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=oo(i,a,n,null),i.flags|=2):i=ro(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,ar(null,r),r=t.child,i=e.child.memoizedState,i===null?i=hr(n):(a=i.cachePool,a===null?a=Ze():(s=is?wu._currentValue:wu._currentValue2,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=gr(e,o,n),t.memoizedState=_d,ar(e.child,r)):(Tt(t),n=e.child,e=n.sibling,n=ro(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function vr(e,t){return t=yr({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function yr(e,n){return e=t(22,e,null,n),e.lanes=0,e}function br(e,t,n){return Gu(t,e.child,null,n),e=vr(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xr(e,t,n,i,a,o,s,c){if(n)return t.flags&256?(Tt(t),t.flags&=-257,br(e,t,c)):t.memoizedState===null?(Ot(),o=a.fallback,s=t.mode,a=yr({mode:`visible`,children:a.children},s),o=oo(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,Gu(t,e.child,null,c),a=t.child,a.memoizedState=hr(c),a.childLanes=gr(e,i,c),t.memoizedState=_d,ar(null,a)):(Ot(),t.child=e.child,t.flags|=128,null);if(Tt(t),Cc(o))return i=wc(o).digest,i!==``&&(a=Error(r(419)),a.stack=``,a.digest=i,Ce({value:a,source:null,stack:null})),br(e,t,c);if(gd||De(e,t,c,!1),i=(c&e.childLanes)!==0,gd||i){if(Qu.current!==null)return br(e,t,c);if(i=Gd,i!==null&&(a=ne(i,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,dt(e,a),ha(i,e,a),hd;return Sc(o)||Da(),br(e,t,c)}return Sc(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ss&&(mu=Nc(o),pu=t,J=!0,hu=null,gu=!1,e!==null&&he(t,e)),t=vr(t,a.children),t.flags|=134221824,t)}function Sr(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Te(e.return,t,n)}function Cr(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Mt(n)===null&&(t=e),e=e.sibling}return t}function wr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Tr(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function Er(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=$u.current;if(t.flags&128)return At(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,At(t,o),i===`backwards`&&e!==null?(Tr(e),er(e,t,r,n),Tr(e)):er(e,t,r,n),r=J?ru:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Sr(e,n,t);else if(e.tag===19)Sr(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Cr(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,Tr(t)),wr(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Mt(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}wr(t,!0,n,null,a,r);break;case`together`:wr(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Cr(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),wr(t,!1,i,n,a,r)}return t.child}function Dr(e,t,n){var r=t.pendingProps;return we(t,t.type,r.value),er(e,t,r.children,n),t.child}function Or(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),tf|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(De(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=ro(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ro(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kr(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Oe(e)))}function Ar(e,t,n){switch(t.tag){case 3:ge(t,t.stateNode.containerInfo),we(t,wu,e.memoizedState.cache),xe();break;case 27:case 5:ve(t);break;case 4:ge(t,t.stateNode.containerInfo);break;case 10:we(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Et(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Tt(t),t.flags|=128,null;r=De(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?_r(e,t,n):(Tt(t),e=Or(e,t,n),e===null?null:e.sibling)}Tt(t);break;case 19:if(t.flags&128)return Er(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(De(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Er(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),At(t,$u.current),r)break;return null;case 22:return t.lanes=0,ir(e,t,n,t.pendingProps);case 24:we(t,wu,e.memoizedState.cache)}return Or(e,t,n)}function jr(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)gd=!0;else{if(!kr(e,n)&&!(t.flags&128))return gd=!1,Ar(e,t,n);gd=!!(e.flags&131072)}}else gd=!1,J&&t.flags&1048576&&fe(t,ru,t.index);switch(t.lanes=0,t.tag){case 16:a:{var i=t.pendingProps;if(e=tt(t.elementType),t.type=e,typeof e==`function`)no(e)?(i=Jn(e,i),t.tag=1,t=pr(null,t,e,i,n)):(t.tag=0,t=dr(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===ko){t.tag=11,t=tr(null,t,e,i,n);break a}if(a===Mo){t.tag=14,t=nr(null,t,e,i,n);break a}if(a===Oo){t.tag=10,t.type=e,t=Dr(null,t,n);break a}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return dr(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=Jn(i,t.pendingProps),pr(e,t,i,a,n);case 3:a:{if(ge(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,F(e,t),bt(t,o,null,n);var s=t.memoizedState;if(o=s.cache,we(t,wu,o),o!==a.cache&&Ee(t,[wu],n,!0),yt(),o=s.element,ss&&a.isDehydrated){if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=mr(e,t,o,n);break a}if(o!==i){i=ue(Error(r(424)),t),Ce(i),t=mr(e,t,o,n);break a}for(ss&&(mu=jc(t.stateNode.containerInfo),pu=t,J=!0,hu=null,gu=!0),n=Ku(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(xe(),o===i){t=Or(e,t,n);break a}er(e,t,o,n)}t=t.child}return t;case 26:if(il)return ur(e,t),e===null?(n=sl(t.type,null,t.pendingProps,null))?t.memoizedState=n:J||(t.stateNode=pl(t.type,t.pendingProps,du.current,t)):t.memoizedState=sl(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(vl)return ve(t),e===null&&vl&&J&&(i=t.stateNode=yl(t.type,t.pendingProps,du.current,lu.current,!1),pu=t,gu=!0,mu=Pc(t.type,i,mu)),er(e,t,t.pendingProps.children,n),ur(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&J&&(nl(t.type,t.pendingProps,lu.current),(a=i=mu)&&(i=Fc(i,t.type,t.pendingProps,gu),i===null?a=!1:(t.stateNode=i,pu=t,mu=Ac(i),gu=!1,a=!0)),a||be(t)),ve(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,$o(a,o)?i=null:s!==null&&$o(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Pt(e,t,Lt,null,null,n),is?ws._currentValue=a:ws._currentValue2=a),ur(e,t),er(e,t,i,n),t.child;case 6:return e===null&&J&&(rl(t.pendingProps,lu.current),(e=n=mu)&&(n=Ic(n,t.pendingProps,gu),n===null?e=!1:(t.stateNode=n,pu=t,mu=null,e=!0)),e||be(t)),null;case 13:return _r(e,t,n);case 4:return ge(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Gu(t,null,i,n):er(e,t,i,n),t.child;case 11:return tr(e,t,t.type,t.pendingProps,n);case 7:return i=t.pendingProps,ur(e,t),er(e,t,i,n),t.child;case 8:return er(e,t,t.pendingProps.children,n),t.child;case 12:return er(e,t,t.pendingProps.children,n),t.child;case 10:return Dr(e,t,n);case 9:return a=t.type._context,i=t.pendingProps.children,ke(t),a=Ae(a),i=i(a),t.flags|=1,er(e,t,i,n),t.child;case 14:return nr(e,t,t.type,t.pendingProps,n);case 15:return rr(e,t,t.type,t.pendingProps,n);case 19:return Er(e,t,n);case 31:return lr(e,t,n);case 22:return ir(e,t,n,t.pendingProps);case 24:return ke(t),i=Ae(wu),e===null?(a=Xe(),a===null&&(a=Gd,o=Ne(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},mt(t),we(t,wu,a)):((e.lanes&n)!==0&&(F(e,t),bt(t,null,null,n),yt()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,we(t,wu,i),i!==a.cache&&Ee(t,[wu],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),we(t,wu,i))),er(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),i=t.pendingProps,i.name!=null&&i.name!==`auto`?t.flags|=e===null?18882560:18874368:J&&pe(t),e!==null&&e.memoizedProps.name!==i.name?t.flags|=4194816:ur(e,t),er(e,t,i.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function Mr(e){e.flags|=4}function Nr(e){os&&(e.flags|=8)}function Pr(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function Fr(e,t,n,r){if(as)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)Zo(e,n.stateNode);else if(!(n.tag===4||vl&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(os)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=bc(a,i.type,i.memoizedProps)),Zo(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=xc(a,i.memoizedProps)),Zo(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),Fr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function Ir(e,t,n,r){var i=!1;if(os)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=bc(o,a.type,a.memoizedProps)),_c(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=xc(o,a.memoizedProps)),_c(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),Ir(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function Lr(e,t){if(os&&Pr(e,t)){e=t.stateNode;var n=e.containerInfo,r=gc();Ir(r,t,!1,!1),e.pendingChildren=r,Mr(t),vc(n,r)}}function Rr(e,t,n,r){if(as)e.memoizedProps!==r&&Mr(t);else if(os){var i=e.stateNode,a=e.memoizedProps;if((e=Pr(e,t))||a!==r){var o=lu.current;a=hc(i,n,a,r,!e,null),a===i?t.stateNode=i:(Nr(t),Qo(a,n,r,o)&&Mr(t),t.stateNode=a,e&&Fr(a,t,!1,!1))}else t.stateNode=i}}function zr(e,t,n,r,i){if(e.mode&32&&(n===null?hs(t,r):gs(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||_s(t,r)){if(vs(e.stateNode,t,r))e.flags|=8192;else if(wa())e.flags|=8192;else throw Hu=Vu,zu}}else e.flags&=-16777217}function Br(e,t){if(hl(t)){if(e.flags|=16777216,!gl(t)){if(wa())e.flags|=8192;else throw Hu=Vu,zu}}else e.flags&=-16777217}function Vr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:S(),e.lanes|=t,of|=t)}function Hr(e,t){if(!J)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function Ur(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Wr(e,t,n){var i=t.pendingProps;switch(me(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ur(t),null;case 1:return Ur(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),N(wu),_e(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(M(t)?Mr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Se())),Lr(e,t),Ur(t),null;case 26:if(il){var a=t.type,o=t.memoizedState;return e===null?(Mr(t),o===null?(Ur(t),zr(t,a,null,i,n)):(Ur(t),Br(t,o))):o?o===e.memoizedState?(Ur(t),t.flags&=-16777217):(Mr(t),Ur(t),Br(t,o)):(o=e.memoizedProps,as?o!==i&&Mr(t):Rr(e,t,a,i),Ur(t),zr(t,a,o,i,n)),null}case 27:if(vl){if(ye(t),n=du.current,a=t.type,e!==null&&t.stateNode!=null)as?e.memoizedProps!==i&&Mr(t):Rr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Ur(t),t.subtreeFlags&=-33554433,null}e=lu.current,M(t)?A(t,e):(e=yl(a,i,n,e,!0),t.stateNode=e,Mr(t))}return Ur(t),t.subtreeFlags&=-33554433,null}case 5:if(ye(t),a=t.type,e!==null&&t.stateNode!=null)Rr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Ur(t),t.subtreeFlags&=-33554433,null}if(o=lu.current,M(t))A(t,o),Yc(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=Xo(a,i,du.current,o,t);Nr(t),Fr(s,t,!1,!1),t.stateNode=s,Qo(s,a,i,o)&&Mr(t)}}return Ur(t),t.subtreeFlags&=-33554433,zr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,as?n!==i&&Mr(t):os&&(n===i?t.stateNode=e.stateNode:(e=du.current,n=lu.current,Nr(t),t.stateNode=es(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=du.current,n=lu.current,M(t)){if(!ss)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=pu,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Bc(e,n,t,i)||be(t,!0)}else Nr(t),t.stateNode=es(i,e,n,t)}return Ur(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=M(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!ss)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Vc(e,t)}else xe(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ur(t),e=!1}else n=Se(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(kt(t),t):(kt(t),null);if(t.flags&128)throw Error(r(558))}return Ur(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=M(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!ss)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));Hc(a,t)}else xe(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ur(t),a=!1}else a=Se(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(kt(t),t):(kt(t),null)}return kt(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Vr(t,t.updateQueue),Ur(t),null);case 4:return _e(),Lr(e,t),e===null&&ls(t.stateNode.containerInfo),t.flags|=67108864,Ur(t),null;case 10:return N(t.type),Ur(t),null;case 19:if(jt(t),i=t.memoizedState,i===null)return Ur(t),null;if(a=!!(t.flags&128),o=i.rendering,o===null){if(a)Hr(i,!1);else{if(ef!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Mt(e),o!==null){for(t.flags|=128,Hr(i,!1),e=o.updateQueue,t.updateQueue=e,Vr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)io(n,e),n=n.sibling;return At(t,$u.current&1|2),J&&de(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Ll()>ff&&(t.flags|=128,a=!0,Hr(i,!1),t.lanes=4194304)}}else{if(!a){if(e=Mt(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Vr(t,e),Hr(i,!0),i.tail===null&&i.tailMode!==`collapsed`&&i.tailMode!==`visible`&&!o.alternate&&!J)return Ur(t),null}else 2*Ll()-i.renderingStartTime>ff&&n!==536870912&&(t.flags|=128,a=!0,Hr(i,!1),t.lanes=4194304)}i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}if(i.tail!==null){e=i.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Ll(),e.sibling=null,o=$u.current,o=a?o&1|2:o&1,i.tailMode===`visible`||i.tailMode===`collapsed`||!n||J?At(t,o):(n=o,h(X,t),h($u,n),Z===null&&(Z=t)),J&&de(t,i.treeForkCount),e}return Ur(t),null;case 22:case 23:return kt(t),I(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Ur(t),t.subtreeFlags&6&&(t.flags|=8192)):Ur(t),n=t.updateQueue,n!==null&&Vr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&m(Lu),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),N(wu),Ur(t),null;case 25:return null;case 30:return t.flags|=33554432,Ur(t),null}throw Error(r(156,t.tag))}function Gr(e,t){switch(me(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return N(wu),_e(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ye(t),null;case 31:if(t.memoizedState!==null){if(kt(t),t.alternate===null)throw Error(r(340));xe()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(kt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));xe()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return jt(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return _e(),null;case 10:return N(t.type),null;case 22:case 23:return kt(t),I(),e!==null&&m(Lu),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return N(wu),null;case 25:return null;default:return null}}function Kr(e,t){switch(me(t),t.tag){case 3:N(wu),_e();break;case 26:case 27:case 5:ye(t);break;case 4:_e();break;case 31:t.memoizedState!==null&&kt(t);break;case 13:kt(t);break;case 19:jt(t);break;case 10:N(t.type);break;case 22:case 23:kt(t),I(),e!==null&&m(Lu);break;case 24:N(wu)}}function qr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ja(t,t.return,e)}}function Jr(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ja(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ja(t,t.return,e)}}function Yr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{St(t,n)}catch(t){Ja(e,e.return,t)}}}function Xr(e,t,n){n.props=Jn(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ja(e,t,n)}}function Zr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=Go(e.stateNode);break;case 30:var i=e.stateNode,a=ae(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=lc(a)),r=i.ref;break;case 7:e.stateNode===null&&(e.stateNode=dc(e)),r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ja(e,t,n)}}function Qr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Ja(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ja(e,t,n)}else n.current=null}}function $r(){var e=vd;return vd=!1,e}function ei(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n`;case zd:return`:has(`+(la(e)||``)+`)`;case Bd:return`[role="`+e.value+`"]`;case Hd:return`"`+e.value+`"`;case Vd:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function ua(e,t){var n=[];e=[e,0];for(var r=0;rn?32:n;n=q.T;var a=ds();try{us(i),q.T=null,i=bf,bf=null;var o=gf,s=vf;if(hf=0,_f=gf=null,vf=0,$&6)throw Error(r(331));var c=$;if($|=4,W(o.current),$i(o,o.current,s,i),$=c,ze(0,!1),Gl&&typeof Gl.onPostCommitFiberRoot==`function`)try{Gl.onPostCommitFiberRoot(Wl,o)}catch{}return!0}finally{us(a),q.T=n,Wa(e,t)}}function qa(e,t,n){t=ue(n,t),t=Zn(e.stateNode,t,2),e=gt(e,t,2),e!==null&&(ee(e,2),Re(e))}function Ja(e,t,n){if(e.tag===3)qa(e,e,n);else for(;t!==null;){if(t.tag===3){qa(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(mf===null||!mf.has(r))){e=ue(n,e),n=V(2),r=gt(t,n,2),r!==null&&(Qn(n,r,t,e),ee(r,2),Re(r));break}}t=t.return}}function Ya(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Wd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Qd=!0,i.add(n),e=Xa.bind(null,e,t,n),t.then(e,e))}function Xa(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Gd===e&&(qd&n)===n&&(ef===4||ef===3&&(qd&62914560)===qd&&300>Ll()-uf?$&2?rf|=n:Sa(e,0):rf|=n,of===qd&&(of=0)),Re(e)}function Za(e,t){t===0&&(t=S()),e=dt(e,t),e!==null&&(ee(e,t),Re(e))}function Qa(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Za(e,n)}function $a(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),Za(e,n)}function eo(e,t){return Nl(e,t)}function to(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function no(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ro(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&1206910976,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function io(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ao(e,n,i,a,o,s){var c=0;if(a=e,typeof a==`function`)no(a)&&(c=1);else if(typeof a==`string`)c=il&&vl?al(e,i,lu.current)?26:Sl(e)?27:5:il?al(e,i,lu.current)?26:5:vl&&Sl(e)?27:5;else a:switch(a){case Po:return e=t(31,i,n,o),e.elementType=Po,e.lanes=s,e;case wo:return oo(i.children,o,s,n);case To:c=8,o|=24;break;case Eo:return e=t(12,i,n,o|2),e.elementType=Eo,e.lanes=s,e;case Ao:return e=t(13,i,n,o),e.elementType=Ao,e.lanes=s,e;case jo:return e=t(19,i,n,o),e.elementType=jo,e.lanes=s,e;case Fo:case Lo:return e=o|32,e=t(30,i,n,e),e.elementType=Lo,e.lanes=s,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof a==`object`&&a)switch(a.$$typeof){case Oo:c=10;break a;case Do:c=9;break a;case ko:c=11;break a;case Mo:c=14;break a;case No:c=16,a=null;break a}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function oo(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function so(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function co(e){var n=t(18,null,null,0);return n.stateNode=e,n}function lo(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function uo(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=rs,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=C(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=C(0),this.hiddenUpdates=C(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function fo(e,n,r,i,a,o,s,c,l,u,d,f){return e=new uo(e,n,r,s,l,u,d,f,c),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=Ne(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},mt(o),e}function po(e){return e?(e=El,e):El}function mo(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:Go(e.stateNode)}function ho(e,t,n,r,i,a){i=po(i),r.context===null?r.context=i:r.pendingContext=i,r=ht(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=gt(e,r,t),n!==null&&(ha(n,e,t),_t(n,e,t))}function go(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}if(!(i!==u||n.width!==l.width||ps)){f>o&&(l.height+=f-o,l.y=o),pa)){u>i&&(l.width+=u-i,l.x=i),dn&&(n=c)),c `)+` + +No matching component was found for: + `)+e.join(` > `)}return null},G.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return Go(e.child.stateNode);default:return e.child.stateNode}},G.injectIntoDevTools=function(){var e={bundleType:0,version:Ho,rendererPackageName:Uo,currentDispatcherRef:q,reconcilerVersion:`19.3.0`};if(Wo!==null&&(e.rendererConfig=Wo),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Wl=t.inject(e),Gl=t}catch{}e=!!t.checkDCE}}return e},G.isAlreadyRendering=function(){return!!($&6)},G.observeVisibleRects=function(e,t,n,i){if(!Os)throw Error(r(363));e=da(e,t);var a=Fs(e,n,i).disconnect;return{disconnect:function(){a()}}},G.shouldError=function(){return null},G.shouldSuspend=function(){return!1},G.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=Nn(e).queue;Mn(e,o,t,Cs,i===null?n:function(){var t=Nn(e);return t.next===null&&(t=e.alternate.memoizedState),Bn(e,t.next.queue,{},fa()),i(a)})},G.updateContainer=function(e,t,n,r){var i=t.current,a=fa();return ho(i,a,e,t,n,r),a},G.updateContainerSync=function(e,t,n,r){return ho(t.current,2,e,t,n,r),2},G},t.exports.default=t.exports,Object.defineProperty(t.exports,"__esModule",{value:!0})})),Ra=o(((e,t)=>{t.exports=La()})),za=o((e=>{e.ConcurrentRoot=1,e.DefaultEventPriority=32,e.DiscreteEventPriority=2})),Ba=o(((e,t)=>{t.exports=za()})),Va=l(Ra()),Ha=Ba(),Ua={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,eventBatchFunc:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},Wa=!1,Ga=!1,Ka=`.react-konva-event`,qa=!1,Ja=`ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled. +Position of a node will be changed during drag&drop, so you should update state of the react app as well. +Consider to add onDragMove or onDragEnd events. +For more info see: https://github.com/konvajs/react-konva/issues/256 +`,Ya=`ReactKonva: You are using "zIndex" attribute for a Konva node. +react-konva may get confused with ordering. Just define correct order of elements in your render function of a component. +For more info see: https://github.com/konvajs/react-konva/issues/194 +`,Xa={};function Za(e,t,n=Xa){if(!Wa&&`zIndex`in t&&(console.warn(Ya),Wa=!0),!Ga&&t.draggable){var r=t.x!==void 0||t.y!==void 0,i=t.onDragEnd||t.onDragMove;r&&!i&&(console.warn(Ja),Ga=!0)}var a={},o=!1;for(var s in n)if(!Ua[s]){var c=s.slice(0,2)===`on`,l=n[s]!==t[s];if(c&&l){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),e.off(u+Ka)}var d=!t.hasOwnProperty(s);!c&&d&&(a[s]=void 0,o=!0)}var f=qa||t._useStrictMode;let p={};for(var s in t)if(!Ua[s]){var c=s.slice(0,2)===`on`,m=n[s]!==t[s];if(c&&m){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),t[s]&&(p[u]=t[s])}!c&&(t[s]!==n[s]||f&&t[s]!==e.getAttr(s))&&(o=!0,a[s]=t[s])}for(var u in o&&(e.setAttrs(a),Qa(e)),p)e.off(u+Ka),e.on(u+Ka,p[u])}function Qa(e){if(!M.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}var $a=d(),eo=new Set,to=new Set,no=typeof queueMicrotask==`function`?queueMicrotask:e=>Promise.resolve().then(e),ro=0,io=new WeakMap;function ao(e){return to.add(e),()=>{to.delete(e)}}function oo(){for(let e of to)e()}function so(e){if(!e)return lo;let t=io.get(e);return t||(t=t=>lo(()=>e(t)),io.set(e,t)),t}function co(e){let t=()=>{eo.delete(t)&&(oo(),e())};eo.add(t),no(t)}function lo(e){if(ro)return e();ro++;try{(0,Fa.flushSync)(e)}finally{try{for(;eo.size;)(0,Fa.flushSync)(()=>{for(let e of eo)e()})}finally{ro--}}}var uo=s({HostTransitionContext:()=>_s,NotPendingTransition:()=>gs,afterActiveInstanceBlur:()=>Jo,appendChild:()=>Mo,appendChildToContainer:()=>No,appendInitialChild:()=>mo,beforeActiveInstanceBlur:()=>qo,bindToConsole:()=>Ko,cancelTimeout:()=>Ao,clearContainer:()=>Uo,commitMount:()=>Ro,commitNewChildToFragmentInstance:()=>bo,commitTextUpdate:()=>K,commitUpdate:()=>zo,createFragmentInstance:()=>vo,createInstance:()=>ho,createTextInstance:()=>go,createViewTransitionInstance:()=>os,deleteChildFromFragmentInstance:()=>xo,detachDeletedInstance:()=>Wo,finalizeInitialChildren:()=>_o,getChildHostContext:()=>Oo,getCurrentUpdatePriority:()=>Qo,getInstanceFromNode:()=>Go,getInstanceFromScope:()=>Xo,getPublicInstance:()=>G,getRootHostContext:()=>Do,getSuspendedCommitReason:()=>hs,hideInstance:()=>Bo,hideTextInstance:()=>Vo,idlePriority:()=>$a.unstable_IdlePriority,insertBefore:()=>Po,insertInContainerBefore:()=>Fo,isPrimaryRenderer:()=>!1,maySuspendCommit:()=>as,maySuspendCommitInSyncRender:()=>cs,maySuspendCommitOnUpdate:()=>ss,noTimeout:()=>-1,now:()=>$a.unstable_now,preloadInstance:()=>us,prepareForCommit:()=>Co,preparePortalMount:()=>wo,prepareScopeUpdate:()=>Yo,removeChild:()=>Io,removeChildFromContainer:()=>Lo,requestPostPaintCallback:()=>is,resetAfterCommit:()=>To,resetFormInstance:()=>vs,resetTextContent:()=>Eo,resolveEventTimeStamp:()=>rs,resolveEventType:()=>ns,resolveUpdatePriority:()=>$o,run:()=>$a.unstable_runWithPriority,scheduleMicrotask:()=>co,scheduleTimeout:()=>ko,setCurrentUpdatePriority:()=>Zo,shouldAttemptEagerTransition:()=>es,shouldSetTextContent:()=>jo,startSuspendingCommit:()=>ds,startViewTransition:()=>ls,supportsHydration:()=>!1,supportsMicrotasks:()=>!0,supportsMutation:()=>!0,supportsPersistence:()=>!1,suspendInstance:()=>fs,suspendOnActiveViewTransition:()=>ps,trackSchedulerEvent:()=>ts,unhideInstance:()=>q,unhideTextInstance:()=>Ho,updateFragmentInstanceFiber:()=>yo,waitForCommitToBeReady:()=>ms,warnsIfNotActing:()=>!1}),fo={};Ia.Node.prototype._applyProps=Za;var po=Ha.DefaultEventPriority;function mo(e,t){typeof t==`string`?console.error(`Do not use plain text as child of Konva.Node. You are using text: ${t}`):(e.add(t),Qa(e))}function ho(e,t,n){let r=Ia[e];r||=(console.error(`Konva has no node with the type ${e}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${e}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),Ia.Group);let i={},a={};for(var o in t)o!==`ref`&&(o.slice(0,2)===`on`?a[o]=t[o]:i[o]=t[o]);let s=new r(i);return Za(s,a),s}function go(e,t,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function _o(e,t,n){return!1}function G(e){return e}function vo(){return null}function yo(){}function bo(){}function xo(){}var So;function Co(){return So=Ia.beginUpdateBatch?.(),null}function wo(){return null}function To(){let e=So;So=void 0,e?.()}function Eo(e){}function Do(){return fo}function Oo(){return fo}var ko=setTimeout,Ao=clearTimeout;function jo(e,t){return!1}function Mo(e,t){t.parent===e?t.moveToTop():e.add(t),Qa(e)}var No=Mo;function Po(e,t,n){t._remove(),e.add(t),t.setZIndex(n.getZIndex()),Qa(e)}var Fo=Po;function Io(e,t){t.destroy(),t.off(Ka),Qa(e)}var Lo=Io;function K(e,t,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function Ro(e,t,n){}function zo(e,t,n,r){Za(e,r,n)}function Bo(e){e.hide(),Qa(e)}function Vo(e){}function q(e,t){(t.visible==null||t.visible)&&(e.show(),Qa(e))}function Ho(e,t){}function Uo(e){}function Wo(e){e.off(Ka)}function Go(){return null}function Ko(e,t){return console[e].bind(console,...t)}function qo(){}function Jo(){}function Yo(){}function Xo(){return null}function Zo(e){po=e}function Qo(){return po}function $o(){return Ha.DiscreteEventPriority}function es(){return!1}function ts(){}function ns(){return null}function rs(){return-1.1}function is(){}function as(){throw Error(`ViewTransition is not supported inside a Stage. Place ViewTransition around Stage to animate its DOM container.`)}var os=as,ss=as,cs=as;function ls(e,t,n,r,i,a,o,s,c,l,u){return r(),i(),u?.(),o(),null}function us(){return!0}function ds(){}function fs(){}function ps(){}function ms(){return null}function hs(){return null}var gs=Object.freeze({pending:!1,data:null,method:null,action:null}),_s=v.createContext(gs);function vs(){}typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?v.useLayoutEffect:v.useEffect;function ys(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=ys(r,t,n);if(e)return e;r=t?null:r.sibling}}function bs(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var xs=bs(v.createContext(null)),Ss=class extends v.Component{render(){return v.createElement(xs.Provider,{value:this._reactInternals},this.props.children)}};function Cs(){let e=v.useContext(xs);if(e===null)throw Error(`its-fine: useFiber must be called within a !`);let t=v.useId();return v.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=ys(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var ws=Symbol.for(`react.context`),Ts=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===ws;function Es(){let e=Cs(),[t]=v.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;Ts(e)&&e!==xs&&!t.has(e)&&t.set(e,v.use(bs(e))),n=n.return}return t}function Ds(){let e=Es();return v.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>v.createElement(t,null,v.createElement(n.Provider,{...r,value:e.get(n)})),e=>v.createElement(Ss,{...e})),[e])}var[Os,ks]=`19.3.1`.split(`.`).map(Number);if(Os!==19||ks<3)throw Error(`react-konva requires React 19.3 or later within React 19. Install matching versions of react and react-dom. For React 19.2, use react-konva 19.2. For React 18, use react-konva 18.`);function As({promise:e}){throw e}var js=e=>{let t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),i=v.useRef(null),a=v.useRef(null),o=v.useId(),s=(0,Fa.useFormStatus)(),c=v.useRef({}),l=c.current,u=Ds(),d=!!ys(Cs(),!0,e=>e.type===v.StrictMode),f=v.useRef(!1),p=v.useRef(!1),m=v.useRef(null);v.useInsertionEffect(()=>(p.current=!1,()=>{p.current=!0,f.current&&n.current&&h()}),[]);let h=()=>{m.current?.(),m.current=null,oo(),Rs.flushSyncFromReconciler(()=>{Rs.updateContainer(null,r.current,null)}),n.current?.destroy(),n.current?.off(Ka),n.current=null,a.current?.resolve(),a.current=null},g=e=>{if(e===`suspended`){if(!a.current){let e,t=new Promise(t=>{e=t});a.current={promise:t,resolve:e}}}else a.current?.resolve(),a.current=null;Rs.updateContainer(v.createElement(v.Activity,{mode:e===`hidden`?`hidden`:`visible`,children:v.createElement(v.Suspense,{fallback:null},i.current,a.current&&v.createElement(As,{promise:a.current.promise}))}),r.current,null),oo(),Rs.flushSyncWork()};return v.useLayoutEffect(()=>(m.current?.(),m.current=null,n.current||(n.current=new Ia.Stage({width:e.width,height:e.height,container:t.current}),r.current=Rs.createContainer(n.current,Ha.ConcurrentRoot,null,d,null,o,console.error,console.error,console.error,null,null)),()=>{p.current?h():(m.current=ao(()=>{p.current&&(m.current?.(),m.current=null,Rs.updateContainer(null,r.current,null))}),g(`suspended`))}),[]),v.useEffect(()=>(f.current=!1,()=>{f.current=!0,n.current&&(p.current?h():g(`hidden`))}),[]),v.useLayoutEffect(()=>{typeof n.current.eventBatchFunc==`function`&&n.current.eventBatchFunc(so(e.eventBatchFunc))},[e.eventBatchFunc]),v.useImperativeHandle(e.forwardedRef,()=>n.current,[]),v.useLayoutEffect(()=>{c.current=e,Za(n.current,e,l),i.current=v.createElement(_s.Provider,{value:s},v.createElement(u,{},e.children)),g(`visible`)}),v.createElement(`div`,{ref:t,id:e.id,accessKey:e.accessKey,className:e.className,role:e.role,style:e.style,tabIndex:e.tabIndex,title:e.title})},Ms=`Layer`,Ns=`Group`,Ps=`Rect`,Fs=`Path`,Is=`19.3.2`,Ls={...uo,HostTransitionContext:_s,rendererVersion:Is,rendererPackageName:`react-konva`,extraDevToolsConfig:null},Rs=(0,Va.default)(Ls);Rs.injectIntoDevTools();var zs=v.forwardRef((e,t)=>v.createElement(Ss,{},v.createElement(js,{...e,forwardedRef:t}))),Bs={normal:`#3b3b3b`,selected:`#1c7ed6`,valid:`#2f9e44`,invalid:`#e03131`};function Vs({shape:e,width:t,height:n,pxPerM:r,outline:i,opacity:a=1}){let o=t*r,s=n*r,c=Bs[i],l=i===`normal`?1.5:3;if(e===`screen`){let e=Math.min(3,s/4);return(0,k.jsxs)(Ns,{opacity:a,children:[(0,k.jsx)(Ps,{width:o,height:s,fill:`#2d3748`,stroke:c,strokeWidth:l,cornerRadius:2}),(0,k.jsx)(Ps,{x:e,y:e,width:Math.max(0,o-e*2),height:Math.max(0,s-e*2),fill:`#63b3ed`,listening:!1})]})}if(e===`table`)return(0,k.jsx)(Ns,{opacity:a,children:(0,k.jsx)(Ps,{width:o,height:s,fill:`#d9b382`,stroke:c,strokeWidth:l,cornerRadius:3})});let u=Math.max(4,s*.2);return(0,k.jsxs)(Ns,{opacity:a,children:[(0,k.jsx)(Ps,{width:o,height:s,fill:`#8fb4d9`,stroke:c,strokeWidth:l,cornerRadius:3}),(0,k.jsx)(Ps,{width:o,height:u,fill:`#4a6f96`,cornerRadius:[3,3,0,0],listening:!1})]})}var Hs=10,Us=[`left`,`right`];function Ws({w:e,h:t,rotation:n}){let r=Math.min(1,Math.max(.35,Math.min(e,t)*.7/24));return(0,k.jsxs)(Ns,{x:e/2,y:t/2,offsetX:12,offsetY:12,scaleX:r,scaleY:r,rotation:-n,listening:!1,children:[(0,k.jsx)(Fs,{data:`M8 11V8a4 4 0 0 1 8 0v3`,stroke:`#1a1a1a`,strokeWidth:2.5}),(0,k.jsx)(Ps,{x:5,y:11,width:14,height:10,cornerRadius:2,fill:`#fff`,stroke:`#1a1a1a`,strokeWidth:2})]})}function Gs({room:e,items:t,configs:n,preview:r,pxPerM:i,floorRef:a,selectedId:o,onSelect:s,onMove:c,onResize:l}){let[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),m=(0,v.useRef)(null),h=e.width*i,g=e.height*i,_=(t,n)=>ee({...t,x:n.x()/i-t.width/2,y:n.y()/i-t.height/2},e);return(0,k.jsx)(`div`,{ref:a,style:{width:h,height:g,border:`6px solid #2b2b2b`,boxSizing:`content-box`,background:`#fff`,boxShadow:`0 4px 18px rgba(0,0,0,0.12)`,touchAction:`none`},children:(0,k.jsx)(zs,{width:h,height:g,onMouseDown:e=>e.target===e.target.getStage()&&s(null),onTouchStart:e=>e.target===e.target.getStage()&&s(null),children:(0,k.jsxs)(Ms,{children:[t.map(r=>{let a=n[r.type]?.shape??`chair`,l=f?.id===r.id,p=l?f.rect:r,m=l?f.valid?`valid`:`invalid`:u?.id===r.id?u.valid?`valid`:`invalid`:o===r.id?`selected`:`normal`,v=C({...p,rotation:r.rotation}),y=p.width*i,b=p.height*i;return(0,k.jsxs)(Ns,{x:(p.x+p.width/2)*i,y:(p.y+p.height/2)*i,offsetX:y/2,offsetY:b/2,rotation:r.rotation,draggable:!r.locked,onMouseDown:()=>s(r.id),onTouchStart:()=>s(r.id),dragBoundFunc:e=>{let t=v.width/2*i,n=v.height/2*i;return{x:Math.min(Math.max(e.x,t),h-t),y:Math.min(Math.max(e.y,n),g-n)}},onDragStart:e=>{e.target.moveToTop()},onDragMove:n=>{let i=_(r,n.target);d({id:r.id,valid:T(i,t,e,r.id)})},onDragEnd:n=>{let a=n.target,o=_(r,a),s=T(o,t,e,r.id),l=s?o:r;a.position({x:(l.x+r.width/2)*i,y:(l.y+r.height/2)*i}),s&&c(r.id,o.x,o.y),d(null)},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=r.locked?`not-allowed`:`grab`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)},children:[(0,k.jsx)(Vs,{shape:a,width:p.width,height:p.height,pxPerM:i,outline:m}),r.locked&&(0,k.jsx)(Ws,{w:y,h:b,rotation:r.rotation})]},r.id)}),t.map(r=>{let a=n[r.type]?.shape===`screen`;if(r.id!==o||!a||r.locked||r.rotation!==0||u?.id===r.id)return null;let s=f?.id===r.id?f.rect:r,c={left:[s.x,s.y+s.height/2],right:[s.x+s.width,s.y+s.height/2]};return Us.map(n=>(0,k.jsx)(Ps,{x:c[n][0]*i,y:c[n][1]*i,offsetX:Hs/2,offsetY:Hs/2,width:Hs,height:Hs,fill:`#fff`,stroke:`#1c7ed6`,strokeWidth:2,cornerRadius:2,hitStrokeWidth:12,draggable:!0,dragBoundFunc:function(){return this.absolutePosition()},onDragStart:e=>{e.cancelBubble=!0,m.current={x:r.x,y:r.y,width:r.width,height:r.height}},onDragMove:a=>{let o=a.target.getStage()?.getPointerPosition(),s=m.current;if(!o||!s)return;let c=ie(s,n,o.x/i,e);p({id:r.id,rect:c,valid:T({...r,...c},t,e,r.id)})},onDragEnd:()=>{f?.valid&&l(r.id,f.rect),p(null),m.current=null},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`ew-resize`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)}},`${r.id}-${n}`))}),r&&(0,k.jsx)(`Group`,{x:r.x*i,y:r.y*i,listening:!1,children:(0,k.jsx)(Vs,{shape:r.shape,width:r.width,height:r.height,pxPerM:i,outline:r.valid?`valid`:`invalid`,opacity:.85})})]})})})}function Ks({pxPerM:e,roomWidthPx:t}){return(0,k.jsx)(`div`,{style:{width:t,height:40,display:`flex`,alignItems:`flex-end`,paddingBottom:4,boxSizing:`border-box`},children:(0,k.jsxs)(`div`,{style:{font:`12px system-ui, sans-serif`,color:`#555`},children:[(0,k.jsx)(`div`,{style:{width:e,height:6,borderBottom:`2px solid #555`,borderLeft:`2px solid #555`,borderRight:`2px solid #555`,boxSizing:`border-box`,marginBottom:2}}),`1 m`]})})}var qs=34,Js=4,Ys=7,Xs=12,Zs=4,Qs=40,$s=40;function ec({value:e,min:t,max:n=999,step:r=1,wrap:i=!1,rows:a=5,disabled:o=!1,format:s,onChange:c}){let l=e=>Math.round(e/r),u=(String(r).split(`.`)[1]??``).length,[d,f]=(0,v.useState)(l(e)),[p,m]=(0,v.useState)(!1),h=(0,v.useRef)(l(e)),g=(0,v.useRef)(l(e)),_=(0,v.useRef)(0),y=(0,v.useRef)(0),b=(0,v.useRef)(l(e)),x=(0,v.useRef)(null),S=(0,v.useRef)(null),C=(0,v.useRef)([]),ee=l(t),w=l(n),te=w-ee+1,T=(0,v.useRef)({imin:ee,imax:w,n:te,wrap:i,step:r,onChange:c,valueIdx:l(e)});T.current={imin:ee,imax:w,n:te,wrap:i,step:r,onChange:c,valueIdx:l(e)};let ne=e=>T.current.imin+((e-T.current.imin)%T.current.n+T.current.n)%T.current.n,re=e=>T.current.wrap?ne(e):e,ie=e=>T.current.wrap?e:Math.min(T.current.imax,Math.max(T.current.imin,e)),E=e=>{let t=ie(e);h.current=t,f(t);let n=re(Math.round(t));return n!==g.current&&(g.current=n,T.current.onChange(Math.round(n*T.current.step*1e3)/1e3)),t},ae=()=>{cancelAnimationFrame(_.current),_.current=0,window.clearTimeout(y.current),y.current=0},D=()=>{let e=Math.round(h.current);if(!T.current.wrap)return T.current.valueIdx;let t=ne(T.current.valueIdx-e+T.current.imin)-T.current.imin;return e+(t>T.current.n/2?t-T.current.n:t)},O=()=>{_.current=requestAnimationFrame(()=>{_.current=0,!S.current&&re(Math.round(h.current))!==T.current.valueIdx&&(g.current=T.current.valueIdx,se(D(),0))})},oe=e=>{ae();let t=ie(Math.round(e));b.current=t;let n=performance.now(),r=e=>{let i=Math.min(.05,(e-n)/1e3);n=e;let a=h.current+(t-h.current)*(1-Math.exp(-7*i));Math.abs(t-a)<.003?(E(t),_.current=0,O()):(E(a),_.current=requestAnimationFrame(r))};_.current=requestAnimationFrame(r)};function se(e,t){ae();let n=ie(Math.round(e));b.current=n;let r=h.current-n,i=Math.abs(r),a=i>0&&Math.sign(t)===-Math.sign(r)?Math.max(Xs,Math.abs(t)/i):Xs,o=t+a*r,s=performance.now(),c=e=>{let t=(e-s)/1e3,i=Math.exp(-a*t),l=n+(r+o*t)*i,u=(o-a*(r+o*t))*i;Math.abs(l-n)<.003&&Math.abs(u)<.05||t>1.5?(E(n),_.current=0,O()):(E(l),_.current=requestAnimationFrame(c))};_.current=requestAnimationFrame(c)}(0,v.useEffect)(()=>{if(S.current||_.current)return;let e=D();h.current=e,g.current=re(Math.round(e)),f(e)},[e]),(0,v.useEffect)(()=>ae,[]);let ce=e=>{if(o)return;e.currentTarget.setPointerCapture(e.pointerId);let t=_.current!==0||y.current!==0;ae(),S.current={y0:e.clientY,pos0:h.current,moved:!1,wasMoving:t},C.current=[{t:performance.now(),pos:h.current}],m(!0)},le=e=>{let t=S.current;if(!t)return;let n=e.clientY-t.y0;Math.abs(n)>Js&&(t.moved=!0);let r=E(t.pos0-n/qs),i=performance.now();C.current.push({t:i,pos:r}),C.current=C.current.filter(e=>i-e.t<100)},ue=e=>{let t=S.current;if(S.current=null,m(!1),!t)return;if(!t.moved){if(t.wasMoving)se(h.current,0);else{let n=x.current.getBoundingClientRect(),r=Math.round((e.clientY-n.top-a*qs/2)/qs);h.current=t.pos0,oe(Math.round(t.pos0)+r)}return}let n=performance.now(),r=C.current,i=0;if(r.length>1&&n-r[r.length-1].t<80){let e=r[0],t=(r[r.length-1].t-e.t)/1e3;t>.005&&(i=(r[r.length-1].pos-e.pos)/t)}i=Math.max(-40,Math.min(Qs,i)),Math.abs(i){if(!o){if(Math.abs(e.deltaY)>=$s){let t=_.current?b.current:Math.round(h.current);oe(t+Math.sign(e.deltaY))}else ae(),E(h.current+e.deltaY/(qs*1.5)),y.current=window.setTimeout(()=>{y.current=0,se(h.current,0)},120)}},fe=e=>{if(!o){if(e.key===`ArrowUp`)oe(Math.round(h.current)+1);else if(e.key===`ArrowDown`)oe(Math.round(h.current)-1);else return;e.preventDefault()}},pe=Math.floor(a/2)+1,me=Math.round(d),he=i?me-pe:Math.max(ee,me-pe),ge=i?me+pe:Math.min(w,me+pe),_e=[];for(let e=he;e<=ge;e++){let t=e-d,n=(i?ne(e):e)*r;_e.push((0,k.jsx)(`div`,{style:{position:`absolute`,left:0,right:0,height:qs,display:`flex`,alignItems:`center`,justifyContent:`center`,font:`600 20px system-ui, sans-serif`,color:`#222`,opacity:Math.max(0,1-Math.abs(t)*(a<=3?.55:.38)),transform:`translateY(${((a-1)/2+t)*qs}px) scale(${1-Math.min(1,Math.abs(t))*.12})`,pointerEvents:`none`},children:s?s(n):n.toFixed(u)},e))}return(0,k.jsxs)(`div`,{ref:x,tabIndex:o?-1:0,role:`spinbutton`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,"aria-disabled":o,onPointerDown:ce,onPointerMove:le,onPointerUp:ue,onPointerCancel:ue,onWheel:de,onKeyDown:fe,style:{position:`relative`,width:`100%`,height:a*qs,overflow:`hidden`,background:`#f4f4f4`,borderRadius:10,cursor:o?`not-allowed`:p?`grabbing`:`ns-resize`,opacity:o?.45:1,userSelect:`none`,touchAction:`none`,outline:`none`},children:[(0,k.jsx)(`div`,{style:{position:`absolute`,left:6,right:6,top:(a-1)/2*qs,height:qs,background:`rgba(0,0,0,0.08)`,borderRadius:8,pointerEvents:`none`}}),_e]})}var tc={gridColumn:`1 / -1`,display:`flex`,flexDirection:`column`,gap:14},nc={font:`600 12px system-ui, sans-serif`,color:`#555`,marginBottom:4},rc={font:`12px system-ui, sans-serif`,color:`#888`,marginTop:4},ic={font:`600 15px system-ui, sans-serif`,color:`#222`},ac={alignSelf:`flex-start`,border:`none`,background:`none`,padding:0,cursor:`pointer`,font:`13px system-ui, sans-serif`,color:`#555`},oc={height:32,padding:`0 12px`,border:`1px solid #c4c4c4`,background:`#fff`,borderRadius:8,cursor:`pointer`,font:`13px system-ui, sans-serif`,color:`#222`},sc={display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(96px, 1fr))`,gap:12};function cc({config:e,placed:t,onSetAvailable:n,onSetSeats:r,onClose:i}){return(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&i();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,k.jsxs)(`div`,{style:tc,children:[(0,k.jsx)(`button`,{onClick:i,style:ac,children:`← Back`}),(0,k.jsx)(`div`,{style:ic,children:e.name}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Available`}),(0,k.jsx)(ec,{value:e.available,min:t,onChange:n}),(0,k.jsxs)(`div`,{style:rc,children:[t,` placed`]})]}),e.shape===`screen`&&(0,k.jsx)(`div`,{style:rc,children:`Click a placed screen, then drag an end handle (or use the Length wheel) to change its length.`}),e.seatsPerUnit!==void 0&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:e.isTable?`Seats per table`:`Seats each`}),(0,k.jsx)(ec,{value:e.seatsPerUnit,min:1,onChange:r})]})]})}var lc=.3,uc=6,dc=e=>e.toFixed(1);function fc({item:e,config:t,onPatch:n,onDelete:r,onClose:i}){let[a,o]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&i();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let s=e=>{let t=n(e);o(t?``:`No room for that change.`)},c=t.shape===`screen`,l=se(e,t)??1,u=e.seatsOverride!==void 0,d=(e,t)=>Math.min(t,e);return(0,k.jsxs)(`div`,{style:tc,children:[(0,k.jsx)(`button`,{onClick:i,style:ac,children:`← Done`}),(0,k.jsxs)(`div`,{style:ic,children:[t.name,e.locked?` 🔒`:``]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Rotation`}),(0,k.jsx)(ec,{value:e.rotation,min:0,max:359,wrap:!0,rows:3,disabled:e.locked,format:e=>`${e}°`,onChange:e=>s({rotation:e})}),(0,k.jsx)(`button`,{style:{...oc,marginTop:8,width:`100%`,opacity:e.locked?.45:1},disabled:e.locked,onClick:()=>s({rotation:(e.rotation+90)%360}),children:`Rotate 90°`})]}),t.isTable&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Seats at this table`}),(0,k.jsx)(ec,{value:l,min:1,max:99,rows:3,format:e=>String(e),onChange:e=>s({seatsOverride:e})}),u&&(0,k.jsxs)(`button`,{onClick:()=>s({seatsOverride:void 0}),style:{...rc,border:`none`,background:`none`,padding:0,cursor:`pointer`,color:`#1c7ed6`,textDecoration:`underline`},children:[`Reset to default (`,t.seatsPerUnit??1,`)`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Size (m)`}),(0,k.jsx)(`div`,{style:sc,children:c?(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:rc,children:`Length`}),(0,k.jsx)(ec,{value:e.width,min:.5,max:uc,step:.1,rows:3,format:dc,onChange:e=>s({width:e})})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:rc,children:`Width`}),(0,k.jsx)(ec,{value:e.width,min:d(e.width,lc),max:uc,step:.1,rows:3,format:dc,onChange:e=>s({width:e})})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:rc,children:`Length`}),(0,k.jsx)(ec,{value:e.height,min:d(e.height,lc),max:uc,step:.1,rows:3,format:dc,onChange:e=>s({height:e})})]})]})})]}),a&&(0,k.jsx)(`div`,{style:{...rc,color:`#e03131`,marginTop:0},children:a}),(0,k.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,k.jsx)(`button`,{style:{...oc,flex:1},onClick:()=>s({locked:!e.locked}),children:e.locked?`Unlock`:`Lock`}),(0,k.jsx)(`button`,{style:{...oc,flex:1,color:`#e03131`,borderColor:`#e8a8a8`},onClick:r,children:`Delete`})]})]})}var pc=e=>e.toFixed(1),mc={width:.5,height:.5,seats:1},hc={width:1.8,height:.8,seats:8};function gc({onSave:e,onCancel:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(mc.width),[c,l]=(0,v.useState)(mc.height),[u,d]=(0,v.useState)(mc.seats),[f,p]=(0,v.useState)(10);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&t();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let m=e=>{a(e);let t=e?hc:mc;s(t.width),l(t.height),d(t.seats)},h=n.trim().length>0,g=e=>({...oc,flex:1,background:e?`#2b2b2b`:`#fff`,color:e?`#fff`:`#222`});return(0,k.jsxs)(`div`,{style:tc,children:[(0,k.jsx)(`button`,{onClick:t,style:ac,children:`← Cancel`}),(0,k.jsx)(`div`,{style:ic,children:`New furniture`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Name`}),(0,k.jsx)(`input`,{value:n,autoFocus:!0,maxLength:24,placeholder:`e.g. Couch`,onChange:e=>r(e.target.value),style:{width:`100%`,boxSizing:`border-box`,height:32,padding:`0 10px`,border:`1px solid #c4c4c4`,borderRadius:8,font:`14px system-ui, sans-serif`}})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Type`}),(0,k.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,k.jsx)(`button`,{style:g(!i),onClick:()=>m(!1),children:`Seating`}),(0,k.jsx)(`button`,{style:g(i),onClick:()=>m(!0),children:`Table`})]})]}),(0,k.jsxs)(`div`,{style:sc,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Width (m)`}),(0,k.jsx)(ec,{value:o,min:.3,max:6,step:.1,rows:3,format:pc,onChange:s})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Length (m)`}),(0,k.jsx)(ec,{value:c,min:.3,max:6,step:.1,rows:3,format:pc,onChange:l})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Seats`}),(0,k.jsx)(ec,{value:u,min:1,max:99,rows:3,onChange:d})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:nc,children:`Available`}),(0,k.jsx)(ec,{value:f,min:1,max:999,rows:3,onChange:p})]})]}),!h&&(0,k.jsx)(`div`,{style:rc,children:`Enter a name to save.`}),(0,k.jsx)(`button`,{style:{...oc,background:h?`#2b2b2b`:`#ddd`,color:h?`#fff`:`#999`,cursor:h?`pointer`:`not-allowed`},disabled:!h,onClick:()=>e({name:n.trim(),isTable:i,width:o,height:c,seats:u,available:f}),children:`Save`})]})}var _c=40;function vc(){let[e,t]=(0,v.useReducer)(D,ae),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)({kind:`tiles`}),[o,s]=(0,v.useState)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(60),f=(0,v.useRef)(1),p=(0,v.useRef)(1),m=e.items.find(e=>e.id===o)??null,h=(0,v.useCallback)(e=>{s(e),e&&a({kind:`tiles`})},[]),g=e=>{s(null),a(e)},_=(0,v.useCallback)(()=>a({kind:`tiles`}),[]),y=(0,v.useCallback)(()=>s(null),[]),x=(0,v.useCallback)(()=>{o&&(t({kind:`remove`,id:o}),s(null))},[o]);(0,v.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&o&&(e.preventDefault(),x())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,x]),(0,v.useEffect)(()=>{let t=l.current;if(!t)return;let n=new ResizeObserver(([t])=>{let{width:n,height:r}=t.contentRect;d(b(e.room,n-12,r-12-_c))});return n.observe(t),()=>n.disconnect()},[e.room]);let S=t=>{let n=c.current?.getBoundingClientRect();if(!n)return null;let r=(n.width-e.room.width*u)/2,i=t.clientX-n.left-r,a=t.clientY-n.top-r;if(i<0||a<0||i>e.room.width*u||a>e.room.height*u)return null;let{defaultWidth:o,defaultHeight:s}=e.configs[t.type];return ee({x:i/u-o/2,y:a/u-s/2,width:o,height:s},e.room)};(0,v.useEffect)(()=>{if(!n)return;let i=n.type,a=e=>r({type:i,clientX:e.clientX,clientY:e.clientY}),o=n=>{let a=S({type:i,clientX:n.clientX,clientY:n.clientY});a&&oe(e.items,i,e.configs[i].available)>0&&T(a,e.items,e.room)&&t({kind:`add`,id:`item-${f.current++}`,type:i,x:a.x,y:a.y}),r(null)},s=()=>r(null);return window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s)}},[n?.type,e.items,e.room,e.configs,u]);let C=(0,v.useMemo)(()=>{if(!n)return null;let t=S(n);return t?{shape:e.configs[n.type].shape,...t,valid:T(t,e.items,e.room)}:null},[n,e.items,e.room,u]),w=(e,t,n)=>{a({kind:`tiles`}),r({type:e,clientX:t,clientY:n})},te=(n,r)=>{if(!(`rotation`in r||`width`in r||`height`in r))return t({kind:`update`,id:n.id,patch:r}),!0;let i=ne(n,r,e.items,e.room);return i?(t({kind:`update`,id:n.id,patch:{...r,x:i.x,y:i.y}}),!0):!1},re=e=>{let n=`custom-${p.current++}`;t({kind:`addConfig`,config:{id:n,name:e.name,shape:e.isTable?`table`:`chair`,defaultWidth:e.width,defaultHeight:e.height,isTable:e.isTable,available:e.available,seatsPerUnit:e.seats}}),a({kind:`tiles`})},ie=Object.fromEntries(e.typeOrder.map(t=>[t,oe(e.items,t,e.configs[t].available)])),E=null;if(m)E=(0,k.jsx)(fc,{item:m,config:e.configs[m.type],onPatch:e=>te(m,e),onDelete:x,onClose:y},m.id);else if(i.kind===`type`){let n=i.id;E=(0,k.jsx)(cc,{config:e.configs[n],placed:O(e.items,n),onSetAvailable:e=>t({kind:`setAvailable`,type:n,value:e}),onSetSeats:e=>t({kind:`setSeats`,type:n,value:e}),onClose:_})}else i.kind===`custom`&&(E=(0,k.jsx)(gc,{onSave:re,onCancel:_}));return(0,k.jsxs)(`div`,{style:{display:`flex`,height:`100vh`,background:`#e9e9e9`,cursor:n?`grabbing`:void 0},children:[(0,k.jsx)(ye,{types:e.typeOrder.map(t=>e.configs[t]),remaining:ie,onStartDrag:w,onOpenMenu:e=>g({kind:`type`,id:e}),onNewCustom:()=>g({kind:`custom`}),panel:E}),(0,k.jsxs)(`main`,{ref:l,style:{flex:1,minWidth:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,padding:24},children:[(0,k.jsx)(Gs,{pxPerM:u,room:e.room,items:e.items,configs:e.configs,preview:C,floorRef:c,selectedId:o,onSelect:h,onMove:(e,n,r)=>t({kind:`move`,id:e,x:n,y:r}),onResize:(e,n)=>t({kind:`update`,id:e,patch:{...n}})}),(0,k.jsx)(Ks,{pxPerM:u,roomWidthPx:e.room.width*u+12})]}),n&&!C&&(0,k.jsx)(`div`,{style:{position:`fixed`,left:n.clientX,top:n.clientY,transform:`translate(-50%, -50%)`,pointerEvents:`none`,opacity:.8},children:(0,k.jsx)(fe,{shape:e.configs[n.type].shape})})]})}document.body.style.margin=`0`,(0,y.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(vc,{})); \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index df5f30c..78cb441 100644 --- a/dist/index.html +++ b/dist/index.html @@ -3,8 +3,8 @@ - Furniture Optimizer - + FurnOp +
diff --git a/index.html b/index.html index b7a66b7..6e0ce70 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - Furniture Optimizer + FurnOp
diff --git a/src/App.tsx b/src/App.tsx index 367d0b2..6cf3f7c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,12 +1,15 @@ import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react"; -import { DEFAULT_SIZES, fitScale, isValidPlacement, clampToRoom } from "./geometry"; +import { clampToRoom, fitScale, isValidPlacement, tryUpdate } from "./geometry"; import { initialState, reducer } from "./store"; -import { FURNITURE_TYPES, type FurnitureType } from "./types"; -import { remaining, placedCount } from "./inventory"; -import { Palette, TYPE_ICON } from "./components/Palette"; +import type { FurnitureItem, FurnitureType, Rect } from "./types"; +import { placedCount, remaining } from "./inventory"; +import { Palette } from "./components/Palette"; import { Room, type Preview } from "./components/Room"; import { ScaleBar } from "./components/ScaleBar"; import { TypeMenu } from "./components/TypeMenu"; +import { ItemPanel } from "./components/ItemPanel"; +import { CustomForm, type CustomDraft } from "./components/CustomForm"; +import { ShapeIcon } from "./components/Icons"; const WALL_PX = 6; // room wall border, must match Room.tsx const SCALE_BAR_PX = 40; @@ -17,14 +20,53 @@ interface PaletteDrag { clientY: number; } +// What the sidebar shows besides the tiles. An item panel appears whenever an item is selected. +type Sidebar = { kind: "tiles" } | { kind: "type"; id: FurnitureType } | { kind: "custom" }; + export default function App() { const [state, dispatch] = useReducer(reducer, initialState); const [paletteDrag, setPaletteDrag] = useState(null); - const [menu, setMenu] = useState(null); - const closeMenu = useCallback(() => setMenu(null), []); + const [sidebar, setSidebar] = useState({ kind: "tiles" }); + const [selectedId, setSelectedId] = useState(null); const floorRef = useRef(null); const mainRef = useRef(null); const [pxPerM, setPxPerM] = useState(60); + const nextItemId = useRef(1); + const nextCustomId = useRef(1); + + const selectedItem = state.items.find((i) => i.id === selectedId) ?? null; + + // Selecting an item, opening a menu and dragging from the palette each replace the others. + const select = useCallback((id: string | null) => { + setSelectedId(id); + if (id) setSidebar({ kind: "tiles" }); + }, []); + const openSidebar = (s: Sidebar) => { + setSelectedId(null); + setSidebar(s); + }; + const closeSidebar = useCallback(() => setSidebar({ kind: "tiles" }), []); + const deselect = useCallback(() => setSelectedId(null), []); + + const deleteSelected = useCallback(() => { + if (!selectedId) return; + dispatch({ kind: "remove", id: selectedId }); + setSelectedId(null); + }, [selectedId]); + + // Delete / Backspace (Mac "delete") removes the selected item, unless the user is typing. + useEffect(() => { + const key = (e: KeyboardEvent) => { + if (e.key !== "Delete" && e.key !== "Backspace") return; + const t = e.target as HTMLElement | null; + if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable)) return; + if (!selectedId) return; + e.preventDefault(); + deleteSelected(); + }; + window.addEventListener("keydown", key); + return () => window.removeEventListener("keydown", key); + }, [selectedId, deleteSelected]); // Maximise the room inside the center area (minus wall border and the scale bar). useEffect(() => { @@ -37,10 +79,9 @@ export default function App() { ro.observe(el); return () => ro.disconnect(); }, [state.room]); - const nextId = useRef(1); - // Cursor position -> room meters (item centered on cursor), or null if outside the floor. - const toRoomRect = (d: PaletteDrag) => { + // Cursor position -> a new item's box (centered on cursor, clamped), or null if outside the floor. + const toRoomRect = (d: PaletteDrag): Rect | null => { const box = floorRef.current?.getBoundingClientRect(); if (!box) return null; // Floor excludes the CSS border: the Stage sits inside it. @@ -48,11 +89,8 @@ export default function App() { const px = d.clientX - box.left - border; const py = d.clientY - box.top - border; if (px < 0 || py < 0 || px > state.room.width * pxPerM || py > state.room.height * pxPerM) return null; - const { width, height } = DEFAULT_SIZES[d.type]; - return clampToRoom( - { x: px / pxPerM - width / 2, y: py / pxPerM - height / 2, width, height }, - state.room, - ); + const { defaultWidth: width, defaultHeight: height } = state.configs[d.type]; + return clampToRoom({ x: px / pxPerM - width / 2, y: py / pxPerM - height / 2, width, height }, state.room); }; useEffect(() => { @@ -67,7 +105,7 @@ export default function App() { remaining(state.items, type, state.configs[type].available) > 0 && isValidPlacement(r, state.items, state.room) ) { - dispatch({ kind: "add", id: `item-${nextId.current++}`, type, x: r.x, y: r.y }); + dispatch({ kind: "add", id: `item-${nextItemId.current++}`, type, x: r.x, y: r.y }); } // outside the room or invalid: cancel setPaletteDrag(null); }; @@ -87,37 +125,90 @@ export default function App() { if (!paletteDrag) return null; const r = toRoomRect(paletteDrag); if (!r) return null; - return { type: paletteDrag.type, ...r, valid: isValidPlacement(r, state.items, state.room) }; + return { + shape: state.configs[paletteDrag.type].shape, + ...r, + valid: isValidPlacement(r, state.items, state.room), + }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [paletteDrag, state.items, state.room, pxPerM]); const startDrag = (type: FurnitureType, clientX: number, clientY: number) => { - setMenu(null); + setSidebar({ kind: "tiles" }); setPaletteDrag({ type, clientX, clientY }); }; + /** Rotate / resize / lock / seats on one item. Geometry changes are checked; returns false if rejected. */ + const patchItem = (item: FurnitureItem, patch: Partial): boolean => { + const geometric = "rotation" in patch || "width" in patch || "height" in patch; + if (!geometric) { + dispatch({ kind: "update", id: item.id, patch }); + return true; + } + const next = tryUpdate(item, patch, state.items, state.room); + if (!next) return false; + dispatch({ kind: "update", id: item.id, patch: { ...patch, x: next.x, y: next.y } }); + return true; + }; + + const saveCustom = (d: CustomDraft) => { + const id = `custom-${nextCustomId.current++}`; + dispatch({ + kind: "addConfig", + config: { + id, + name: d.name, + shape: d.isTable ? "table" : "chair", + defaultWidth: d.width, + defaultHeight: d.height, + isTable: d.isTable, + available: d.available, + seatsPerUnit: d.seats, + }, + }); + setSidebar({ kind: "tiles" }); + }; + const remainingByType = Object.fromEntries( - FURNITURE_TYPES.map((t) => [t, remaining(state.items, t, state.configs[t].available)]), - ) as Record; + state.typeOrder.map((t) => [t, remaining(state.items, t, state.configs[t].available)]), + ); + + let panel = null; + if (selectedItem) { + panel = ( + patchItem(selectedItem, p)} + onDelete={deleteSelected} + onClose={deselect} + /> + ); + } else if (sidebar.kind === "type") { + const id = sidebar.id; + panel = ( + dispatch({ kind: "setAvailable", type: id, value })} + onSetSeats={(value) => dispatch({ kind: "setSeats", type: id, value })} + onClose={closeSidebar} + /> + ); + } else if (sidebar.kind === "custom") { + panel = ; + } return (
state.configs[t])} remaining={remainingByType} onStartDrag={startDrag} - onOpenMenu={setMenu} - panel={ - menu && ( - dispatch({ kind: "setAvailable", type: menu, value })} - onSetSeats={(value) => dispatch({ kind: "setSeats", value })} - onClose={closeMenu} - /> - ) - } + onOpenMenu={(id) => openSidebar({ kind: "type", id })} + onNewCustom={() => openSidebar({ kind: "custom" })} + panel={panel} />
dispatch({ kind: "move", id, x, y })} - onResize={(id, r) => dispatch({ kind: "resize", id, ...r })} + onResize={(id, r) => dispatch({ kind: "update", id, patch: { ...r } })} />
@@ -145,10 +239,7 @@ export default function App() { opacity: 0.8, }} > - {(() => { - const Icon = TYPE_ICON[paletteDrag.type]; - return ; - })()} +
)} diff --git a/src/components/CustomForm.tsx b/src/components/CustomForm.tsx new file mode 100644 index 0000000..d9c17c1 --- /dev/null +++ b/src/components/CustomForm.tsx @@ -0,0 +1,113 @@ +import { useEffect, useState } from "react"; +import { Wheel } from "./Wheel"; +import { backBtn, btn, hint, label, panelRoot, title, twoCol } from "./panelStyles"; + +export interface CustomDraft { + name: string; + isTable: boolean; + width: number; + height: number; + seats: number; + available: number; +} + +interface Props { + onSave: (draft: CustomDraft) => void; + onCancel: () => void; +} + +const fmt = (v: number) => v.toFixed(1); +const SEATING = { width: 0.5, height: 0.5, seats: 1 }; +const TABLE = { width: 1.8, height: 0.8, seats: 8 }; + +export function CustomForm({ onSave, onCancel }: Props) { + const [name, setName] = useState(""); + const [isTable, setIsTable] = useState(false); + const [width, setWidth] = useState(SEATING.width); + const [height, setHeight] = useState(SEATING.height); + const [seats, setSeats] = useState(SEATING.seats); + const [available, setAvailable] = useState(10); + + useEffect(() => { + const key = (e: KeyboardEvent) => e.key === "Escape" && onCancel(); + window.addEventListener("keydown", key); + return () => window.removeEventListener("keydown", key); + }, [onCancel]); + + const pickKind = (table: boolean) => { + setIsTable(table); + const d = table ? TABLE : SEATING; + setWidth(d.width); + setHeight(d.height); + setSeats(d.seats); + }; + + const canSave = name.trim().length > 0; + const seg = (active: boolean): React.CSSProperties => ({ + ...btn, + flex: 1, + background: active ? "#2b2b2b" : "#fff", + color: active ? "#fff" : "#222", + }); + + return ( +
+ +
New furniture
+ +
+
Name
+ setName(e.target.value)} + style={{ width: "100%", boxSizing: "border-box", height: 32, padding: "0 10px", border: "1px solid #c4c4c4", borderRadius: 8, font: "14px system-ui, sans-serif" }} + /> +
+ +
+
Type
+
+ + +
+
+ +
+
+
Width (m)
+ +
+
+
Length (m)
+ +
+
+
Seats
+ +
+
+
Available
+ +
+
+ {!canSave &&
Enter a name to save.
} + + +
+ ); +} diff --git a/src/components/FurnitureShape.tsx b/src/components/FurnitureShape.tsx index a6e8838..1a330ce 100644 --- a/src/components/FurnitureShape.tsx +++ b/src/components/FurnitureShape.tsx @@ -1,5 +1,5 @@ import { Group, Rect } from "react-konva"; -import type { FurnitureType } from "../types"; +import type { Shape } from "../types"; export type Outline = "normal" | "selected" | "valid" | "invalid"; @@ -11,7 +11,7 @@ const STROKE: Record = { }; interface Props { - type: FurnitureType; + shape: Shape; width: number; // meters height: number; pxPerM: number; @@ -20,13 +20,13 @@ interface Props { } /** Top-down shape drawn at local (0,0). Position is set by the parent Group. */ -export function FurnitureShape({ type, width, height, pxPerM, outline, opacity = 1 }: Props) { +export function FurnitureShape({ shape, width, height, pxPerM, outline, opacity = 1 }: Props) { const w = width * pxPerM; const h = height * pxPerM; const stroke = STROKE[outline]; const strokeWidth = outline === "normal" ? 1.5 : 3; - if (type === "screen") { + if (shape === "screen") { const inset = Math.min(3, h / 4); return ( @@ -35,7 +35,7 @@ export function FurnitureShape({ type, width, height, pxPerM, outline, opacity = ); } - if (type === "table") { + if (shape === "table") { return ( diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx new file mode 100644 index 0000000..b0c3468 --- /dev/null +++ b/src/components/Icons.tsx @@ -0,0 +1,33 @@ +import type { Shape } from "../types"; + +export function ChairIcon({ size = 36 }: { size?: number }) { + return ( + + + + + ); +} + +export function TableIcon({ size = 36 }: { size?: number }) { + return ( + + + + ); +} + +export function ScreenIcon({ size = 36 }: { size?: number }) { + return ( + + + + + ); +} + +export function ShapeIcon({ shape, size }: { shape: Shape; size?: number }) { + if (shape === "table") return ; + if (shape === "screen") return ; + return ; +} diff --git a/src/components/ItemPanel.tsx b/src/components/ItemPanel.tsx new file mode 100644 index 0000000..76133ed --- /dev/null +++ b/src/components/ItemPanel.tsx @@ -0,0 +1,120 @@ +import { useEffect, useState } from "react"; +import type { FurnitureItem, FurnitureTypeConfig } from "../types"; +import { effectiveSeats } from "../inventory"; +import { Wheel } from "./Wheel"; +import { backBtn, btn, hint, label, panelRoot, title, twoCol } from "./panelStyles"; + +interface Props { + item: FurnitureItem; + config: FurnitureTypeConfig; + /** Try to apply a change. Returns false if it was rejected (overlap / no room). */ + onPatch: (patch: Partial) => boolean; + onDelete: () => void; + onClose: () => void; +} + +const MIN_SIZE = 0.3; +const MAX_SIZE = 6; +const fmt = (v: number) => v.toFixed(1); + +export function ItemPanel({ item, config, onPatch, onDelete, onClose }: Props) { + const [notice, setNotice] = useState(""); + useEffect(() => { + const key = (e: KeyboardEvent) => e.key === "Escape" && onClose(); + window.addEventListener("keydown", key); + return () => window.removeEventListener("keydown", key); + }, [onClose]); + + const patch = (p: Partial) => { + const ok = onPatch(p); + setNotice(ok ? "" : "No room for that change."); + }; + + const isScreen = config.shape === "screen"; + const seats = effectiveSeats(item, config) ?? 1; + const overridden = item.seatsOverride !== undefined; + // Never let the wheel's range exclude the current value (e.g. a 0.2 m default). + const minOf = (v: number, floor: number) => Math.min(floor, v); + + return ( +
+ +
+ {config.name} + {item.locked ? " 🔒" : ""} +
+ +
+
Rotation
+ `${v}°`} + onChange={(v) => patch({ rotation: v })} + /> + +
+ + {config.isTable && ( +
+
Seats at this table
+ String(v)} onChange={(v) => patch({ seatsOverride: v })} /> + {overridden && ( + + )} +
+ )} + +
+
Size (m)
+
+ {isScreen ? ( +
+
Length
+ patch({ width: v })} /> +
+ ) : ( + <> +
+
Width
+ patch({ width: v })} /> +
+
+
Length
+ patch({ height: v })} /> +
+ + )} +
+
+ + {notice &&
{notice}
} + +
+ + +
+
+ ); +} diff --git a/src/components/Palette.tsx b/src/components/Palette.tsx index 67ea50e..8c3881e 100644 --- a/src/components/Palette.tsx +++ b/src/components/Palette.tsx @@ -1,13 +1,16 @@ import { useState, type PointerEvent, type ReactNode } from "react"; -import { FURNITURE_TYPES, TYPE_LABEL, type FurnitureType } from "../types"; +import type { FurnitureType, FurnitureTypeConfig } from "../types"; +import { ShapeIcon } from "./Icons"; const CLICK_THRESHOLD_PX = 5; interface Props { + types: FurnitureTypeConfig[]; // in palette order remaining: Record; onStartDrag: (type: FurnitureType, clientX: number, clientY: number) => void; onOpenMenu: (type: FurnitureType) => void; - panel: ReactNode; // when set, replaces the tiles (type settings menu) + onNewCustom: () => void; + panel: ReactNode; // when set, replaces the tiles (type menu, item panel, custom form) } const tile: React.CSSProperties = { @@ -29,35 +32,19 @@ const tile: React.CSSProperties = { color: "#444", }; -export function ChairIcon({ size = 36 }: { size?: number }) { - return ( - - - - - ); -} - -export function TableIcon({ size = 36 }: { size?: number }) { - return ( - - - - ); -} - const MIN_W = 152; const MAX_W = 600; interface TileProps { - type: FurnitureType; + config: FurnitureTypeConfig; remaining: number; onStartDrag: Props["onStartDrag"]; onOpenMenu: Props["onOpenMenu"]; } /** Press + move > threshold = drag a new item out. Press + release without moving = open menu. */ -function Tile({ type, remaining, onStartDrag, onOpenMenu }: TileProps) { +function Tile({ config, remaining, onStartDrag, onOpenMenu }: TileProps) { + const type = config.id; const empty = remaining <= 0; const onPointerDown = (e: PointerEvent) => { @@ -90,7 +77,7 @@ function Tile({ type, remaining, onStartDrag, onOpenMenu }: TileProps) { return (
@@ -112,31 +99,27 @@ function Tile({ type, remaining, onStartDrag, onOpenMenu }: TileProps) { > {remaining} - {(() => { - const Icon = TYPE_ICON[type]; - return ; - })()} - {TYPE_LABEL[type]} + + {config.name}
); } -export function ScreenIcon({ size = 36 }: { size?: number }) { +function NewCustomTile({ onClick }: { onClick: () => void }) { return ( - - - - +
+ + + Custom +
); } -export const TYPE_ICON: Record React.JSX.Element> = { - chair: ChairIcon, - table: TableIcon, - screen: ScreenIcon, -}; - -export function Palette({ remaining, onStartDrag, onOpenMenu, panel }: Props) { +export function Palette({ types, remaining, onStartDrag, onOpenMenu, onNewCustom, panel }: Props) { const [width, setWidth] = useState(264); const startResize = (e: PointerEvent) => { @@ -158,20 +141,32 @@ export function Palette({ remaining, onStartDrag, onOpenMenu, panel }: Props) { style={{ position: "relative", width, - boxSizing: "border-box", flexShrink: 0, - padding: 16, - display: "grid", - gridTemplateColumns: "repeat(auto-fill, minmax(84px, 1fr))", - alignContent: "start", - gap: 12, borderRight: "1px solid #d4d4d4", background: "#ececec", }} > - {panel ?? FURNITURE_TYPES.map((type) => ( - - ))} +
+ {panel ?? ( + <> + {types.map((cfg) => ( + + ))} + + + )} +
; preview: Preview | null; // new item being dragged in from the palette pxPerM: number; floorRef: RefObject; + selectedId: string | null; + onSelect: (id: string | null) => void; onMove: (id: string, x: number, y: number) => void; onResize: (id: string, rect: RectM) => void; } @@ -36,21 +39,34 @@ interface ResizeInfo { } const HANDLE_PX = 10; -// Top-down view: a screen only changes in length, its thickness is fixed. -const EDGES: ("left" | "right")[] = ["left", "right"]; +const ENDS: ("left" | "right")[] = ["left", "right"]; -export function Room({ room, items, preview, pxPerM, floorRef, onMove, onResize }: Props) { +function LockIcon({ w, h, rotation }: { w: number; h: number; rotation: number }) { + // 24x24 padlock centered in the item, counter-rotated so it stays upright. + const s = Math.min(1, Math.max(0.35, (Math.min(w, h) * 0.7) / 24)); + return ( + + + + + ); +} + +export function Room({ room, items, configs, preview, pxPerM, floorRef, selectedId, onSelect, onMove, onResize }: Props) { const [drag, setDrag] = useState(null); - const [selectedId, setSelectedId] = useState(null); const [resize, setResize] = useState(null); const resizeStart = useRef(null); const w = room.width * pxPerM; const h = room.height * pxPerM; - // Where the item would land if dropped now: clamped to walls. - const candidate = (item: FurnitureItem, node: Konva.Node) => + // The group's origin is the item's CENTER (offset puts the rect's center there), so rotation pivots on it. + const candidate = (item: FurnitureItem, node: Konva.Node): FurnitureItem => clampToRoom( - { x: node.x() / pxPerM, y: node.y() / pxPerM, width: item.width, height: item.height }, + { + ...item, + x: node.x() / pxPerM - item.width / 2, + y: node.y() / pxPerM - item.height / 2, + }, room, ); @@ -70,31 +86,42 @@ export function Room({ room, items, preview, pxPerM, floorRef, onMove, onResize e.target === e.target.getStage() && setSelectedId(null)} - onTouchStart={(e) => e.target === e.target.getStage() && setSelectedId(null)} + onMouseDown={(e) => e.target === e.target.getStage() && onSelect(null)} + onTouchStart={(e) => e.target === e.target.getStage() && onSelect(null)} > {items.map((item) => { + const shape = configs[item.type]?.shape ?? "chair"; const isResizing = resize?.id === item.id; const r: RectM = isResizing ? resize.rect : item; - const outline = isResizing + const outline: Outline = isResizing ? resize.valid ? "valid" : "invalid" : drag?.id === item.id ? drag.valid ? "valid" : "invalid" : selectedId === item.id ? "selected" : "normal"; + const half = boundsOf({ ...r, rotation: item.rotation }); + const wpx = r.width * pxPerM; + const hpx = r.height * pxPerM; return ( setSelectedId(RESIZABLE[item.type] ? item.id : null)} - onTouchStart={() => setSelectedId(RESIZABLE[item.type] ? item.id : null)} + x={(r.x + r.width / 2) * pxPerM} + y={(r.y + r.height / 2) * pxPerM} + offsetX={wpx / 2} + offsetY={hpx / 2} + rotation={item.rotation} draggable={!item.locked} - // Hard-clamp to the walls while dragging (stage is unscaled, so absolute = local). - dragBoundFunc={(pos) => ({ - x: Math.min(Math.max(pos.x, 0), w - item.width * pxPerM), - y: Math.min(Math.max(pos.y, 0), h - item.height * pxPerM), - })} + onMouseDown={() => onSelect(item.id)} + onTouchStart={() => onSelect(item.id)} + // Keep the rotated bounds inside the walls (stage is unscaled, so absolute = local). + dragBoundFunc={(pos) => { + const hx = (half.width / 2) * pxPerM; + const hy = (half.height / 2) * pxPerM; + return { + x: Math.min(Math.max(pos.x, hx), w - hx), + y: Math.min(Math.max(pos.y, hy), h - hy), + }; + }} onDragStart={(e) => { e.target.moveToTop(); }} @@ -107,31 +134,34 @@ export function Room({ room, items, preview, pxPerM, floorRef, onMove, onResize const c = candidate(item, node); const ok = isValidPlacement(c, items, room, item.id); const final = ok ? c : item; // snap back to last valid position - node.position({ x: final.x * pxPerM, y: final.y * pxPerM }); + node.position({ x: (final.x + item.width / 2) * pxPerM, y: (final.y + item.height / 2) * pxPerM }); if (ok) onMove(item.id, c.x, c.y); setDrag(null); }} onMouseEnter={(e) => { const c = e.target.getStage()?.container(); - if (c) c.style.cursor = "grab"; + if (c) c.style.cursor = item.locked ? "not-allowed" : "grab"; }} onMouseLeave={(e) => { const c = e.target.getStage()?.container(); if (c) c.style.cursor = ""; }} > - + + {item.locked && } ); })} {items.map((item) => { - if (item.id !== selectedId || !RESIZABLE[item.type] || drag?.id === item.id) return null; + // Screens get length handles on their ends while selected, unlocked and unrotated. + const isScreen = configs[item.type]?.shape === "screen"; + if (item.id !== selectedId || !isScreen || item.locked || item.rotation !== 0 || drag?.id === item.id) return null; const r: RectM = resize?.id === item.id ? resize.rect : item; - const mid: Record<"left" | "right", readonly [number, number]> = { + const mid = { left: [r.x, r.y + r.height / 2], right: [r.x + r.width, r.y + r.height / 2], - }; - return EDGES.map((edge) => ( + } as const; + return ENDS.map((edge) => ( { if (resize?.valid) onResize(item.id, resize.rect); // else snap back to the old size @@ -180,7 +210,7 @@ export function Room({ room, items, preview, pxPerM, floorRef, onMove, onResize {preview && ( ); } - diff --git a/src/components/TypeMenu.tsx b/src/components/TypeMenu.tsx index 1194f66..e7e09de 100644 --- a/src/components/TypeMenu.tsx +++ b/src/components/TypeMenu.tsx @@ -1,9 +1,9 @@ import { useEffect } from "react"; -import { TYPE_LABEL, type FurnitureType, type FurnitureTypeConfig } from "../types"; +import type { FurnitureTypeConfig } from "../types"; import { Wheel } from "./Wheel"; +import { backBtn, hint, label, panelRoot, title } from "./panelStyles"; interface Props { - type: FurnitureType; config: FurnitureTypeConfig; placed: number; onSetAvailable: (v: number) => void; @@ -11,10 +11,7 @@ interface Props { onClose: () => void; } -const label: React.CSSProperties = { font: "600 12px system-ui, sans-serif", color: "#555", marginBottom: 4 }; -const hint: React.CSSProperties = { font: "12px system-ui, sans-serif", color: "#888", marginTop: 4 }; - -export function TypeMenu({ type, config, placed, onSetAvailable, onSetSeats, onClose }: Props) { +export function TypeMenu({ config, placed, onSetAvailable, onSetSeats, onClose }: Props) { useEffect(() => { const key = (e: KeyboardEvent) => e.key === "Escape" && onClose(); window.addEventListener("keydown", key); @@ -22,26 +19,23 @@ export function TypeMenu({ type, config, placed, onSetAvailable, onSetSeats, onC }, [onClose]); return ( -
- -
{TYPE_LABEL[type]}
+
{config.name}
Available
{placed} placed
- {type === "screen" && ( -
Click a placed screen, then drag an end handle to change its length.
+ {config.shape === "screen" && ( +
Click a placed screen, then drag an end handle (or use the Length wheel) to change its length.
)} - {type === "table" && ( + {config.seatsPerUnit !== undefined && (
-
Seats per table
- +
{config.isTable ? "Seats per table" : "Seats each"}
+
)}
diff --git a/src/components/Wheel.tsx b/src/components/Wheel.tsx index f7519ed..7202a76 100644 --- a/src/components/Wheel.tsx +++ b/src/components/Wheel.tsx @@ -4,12 +4,15 @@ interface Props { value: number; min: number; max?: number; + step?: number; // value units per wheel notch (default 1) + wrap?: boolean; // loop from max back to min (angles) + rows?: number; // visible rows, odd (default 5) + disabled?: boolean; + format?: (v: number) => string; onChange: (v: number) => void; } const ROW_H = 34; -const VISIBLE = 5; // odd, so one row sits in the middle -const REACH = Math.floor(VISIBLE / 2) + 1; const CLICK_PX = 4; // total movement under this = a tap const SETTLE_K = 7; // 1/s; higher = snappier settle (fling distance = velocity / k) const SPRING_W = 12; // 1/s; stiffness of the critically damped settle spring @@ -21,34 +24,44 @@ const NOTCH_DELTA = 40; // wheel deltas this big are mouse notches (one step), s * Scroll-wheel number picker (like the iOS timer). * Drag follows the pointer 1:1, release flings with momentum and settles on a value, * touching it mid-roll stops it instantly. Also: mouse wheel, tap a row, arrow keys. + * Internally works in integer "notch" space; `step` maps notches to real values. + * If the parent doesn't accept a change (value prop stays put) the wheel settles back to the real value. */ -export function Wheel({ value, min, max = 999, onChange }: Props) { - const [pos, setPos] = useState(value); +export function Wheel({ value, min, max = 999, step = 1, wrap = false, rows: visible = 5, disabled = false, format, onChange }: Props) { + const idx = (v: number) => Math.round(v / step); + const decimals = (String(step).split(".")[1] ?? "").length; + + const [pos, setPos] = useState(idx(value)); const [dragging, setDragging] = useState(false); - const posRef = useRef(value); // fractional position in "value" units - const lastEmitted = useRef(value); + const posRef = useRef(idx(value)); // fractional position in notches + const lastEmitted = useRef(idx(value)); const raf = useRef(0); const settleTimer = useRef(0); - const targetRef = useRef(value); // where the running animation is heading + const targetRef = useRef(idx(value)); // where the running animation is heading const box = useRef(null); const drag = useRef<{ y0: number; pos0: number; moved: boolean; wasMoving: boolean } | null>(null); const samples = useRef<{ t: number; pos: number }[]>([]); // Keep latest props visible to the animation loop. - const cfg = useRef({ min, max, onChange }); - cfg.current = { min, max, onChange }; + const imin = idx(min); + const imax = idx(max); + const n = imax - imin + 1; + const cfg = useRef({ imin, imax, n, wrap, step, onChange, valueIdx: idx(value) }); + cfg.current = { imin, imax, n, wrap, step, onChange, valueIdx: idx(value) }; - const clamp = (v: number) => Math.min(cfg.current.max, Math.max(cfg.current.min, v)); + const wrapIdx = (i: number) => cfg.current.imin + ((((i - cfg.current.imin) % cfg.current.n) + cfg.current.n) % cfg.current.n); + const keyOf = (i: number) => (cfg.current.wrap ? wrapIdx(i) : i); + const clamp = (v: number) => (cfg.current.wrap ? v : Math.min(cfg.current.imax, Math.max(cfg.current.imin, v))); const setPosition = (p: number) => { const c = clamp(p); posRef.current = c; setPos(c); - const v = Math.round(c); - if (v !== lastEmitted.current) { - lastEmitted.current = v; - cfg.current.onChange(v); + const k = keyOf(Math.round(c)); + if (k !== lastEmitted.current) { + lastEmitted.current = k; + cfg.current.onChange(Math.round(k * cfg.current.step * 1000) / 1000); } return c; }; @@ -60,32 +73,53 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { settleTimer.current = 0; }; + /** Where the real value sits relative to the current position (shortest way round when wrapping). */ + const valueTarget = () => { + const have = Math.round(posRef.current); + if (!cfg.current.wrap) return cfg.current.valueIdx; + const d = wrapIdx(cfg.current.valueIdx - have + cfg.current.imin) - cfg.current.imin; // 0..n-1 + return have + (d > cfg.current.n / 2 ? d - cfg.current.n : d); + }; + + /** One frame after a settle ends, check the parent actually took our value; if not, glide back. */ + const reconcileSoon = () => { + raf.current = requestAnimationFrame(() => { + raf.current = 0; + if (drag.current) return; + if (keyOf(Math.round(posRef.current)) !== cfg.current.valueIdx) { + lastEmitted.current = cfg.current.valueIdx; + settleTo(valueTarget(), 0); + } + }); + }; + /** Ease from the current position to `target` with exponential decay (iOS-style deceleration). */ const animateTo = (rawTarget: number) => { stop(); const target = clamp(Math.round(rawTarget)); targetRef.current = target; let last = performance.now(); - const step = (now: number) => { + const frame = (now: number) => { const dt = Math.min(0.05, (now - last) / 1000); last = now; const next = posRef.current + (target - posRef.current) * (1 - Math.exp(-SETTLE_K * dt)); if (Math.abs(target - next) < 0.003) { setPosition(target); raf.current = 0; + reconcileSoon(); return; } setPosition(next); - raf.current = requestAnimationFrame(step); + raf.current = requestAnimationFrame(frame); }; - raf.current = requestAnimationFrame(step); + raf.current = requestAnimationFrame(frame); }; /** * Settle onto `rawTarget` with a critically damped spring that starts at the current release * velocity `v0` (rows/s). Smooth start (no velocity jump) and no overshoot, so slow releases glide in. */ - const settleTo = (rawTarget: number, v0: number) => { + function settleTo(rawTarget: number, v0: number) { stop(); const target = clamp(Math.round(rawTarget)); targetRef.current = target; @@ -97,7 +131,7 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { const w = toward ? Math.max(SPRING_W, Math.abs(v0) / dist) : SPRING_W; const b = v0 + w * a; const t0 = performance.now(); - const step = (now: number) => { + const frame = (now: number) => { const t = (now - t0) / 1000; const decay = Math.exp(-w * t); const x = target + (a + b * t) * decay; @@ -105,25 +139,29 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { if ((Math.abs(x - target) < 0.003 && Math.abs(vel) < 0.05) || t > 1.5) { setPosition(target); raf.current = 0; + reconcileSoon(); return; } setPosition(x); - raf.current = requestAnimationFrame(step); + raf.current = requestAnimationFrame(frame); }; - raf.current = requestAnimationFrame(step); - }; + raf.current = requestAnimationFrame(frame); + } - // Follow outside changes (e.g. min rising) when idle. + // Follow outside changes (rotate button, min rising, selection change) when idle. useEffect(() => { if (drag.current || raf.current) return; - posRef.current = value; - lastEmitted.current = value; - setPos(value); + const p = valueTarget(); + posRef.current = p; + lastEmitted.current = keyOf(Math.round(p)); + setPos(p); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [value]); useEffect(() => stop, []); const onPointerDown = (e: React.PointerEvent) => { + if (disabled) return; e.currentTarget.setPointerCapture(e.pointerId); const wasMoving = raf.current !== 0 || settleTimer.current !== 0; stop(); // stopping power: touching freezes the wheel exactly where it is @@ -155,9 +193,9 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { } else { // plain tap: jump to the tapped row const rect = box.current!.getBoundingClientRect(); - const rows = Math.round((e.clientY - rect.top - (VISIBLE * ROW_H) / 2) / ROW_H); + const r = Math.round((e.clientY - rect.top - (visible * ROW_H) / 2) / ROW_H); posRef.current = d.pos0; - animateTo(Math.round(d.pos0) + rows); + animateTo(Math.round(d.pos0) + r); } return; } @@ -177,6 +215,7 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { }; const onWheel = (e: React.WheelEvent) => { + if (disabled) return; if (Math.abs(e.deltaY) >= NOTCH_DELTA) { // mouse notch: one value per notch, repeated notches build on the pending target const base = raf.current ? targetRef.current : Math.round(posRef.current); @@ -193,17 +232,22 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { }; const onKeyDown = (e: React.KeyboardEvent) => { + if (disabled) return; if (e.key === "ArrowUp") animateTo(Math.round(posRef.current) + 1); else if (e.key === "ArrowDown") animateTo(Math.round(posRef.current) - 1); else return; e.preventDefault(); }; + const reach = Math.floor(visible / 2) + 1; const centre = Math.round(pos); - const rows = []; - for (let v = Math.max(min, centre - REACH); v <= Math.min(max, centre + REACH); v++) { + const lo = wrap ? centre - reach : Math.max(imin, centre - reach); + const hi = wrap ? centre + reach : Math.min(imax, centre + reach); + const items = []; + for (let v = lo; v <= hi; v++) { const off = v - pos; - rows.push( + const real = (wrap ? wrapIdx(v) : v) * step; + items.push(
- {v} + {format ? format(real) : real.toFixed(decimals)}
, ); } @@ -229,11 +273,12 @@ export function Wheel({ value, min, max = 999, onChange }: Props) { return (
- {rows} + {items}
); } diff --git a/src/components/panelStyles.ts b/src/components/panelStyles.ts new file mode 100644 index 0000000..e292c5d --- /dev/null +++ b/src/components/panelStyles.ts @@ -0,0 +1,24 @@ +export const panelRoot: React.CSSProperties = { gridColumn: "1 / -1", display: "flex", flexDirection: "column", gap: 14 }; +export const label: React.CSSProperties = { font: "600 12px system-ui, sans-serif", color: "#555", marginBottom: 4 }; +export const hint: React.CSSProperties = { font: "12px system-ui, sans-serif", color: "#888", marginTop: 4 }; +export const title: React.CSSProperties = { font: "600 15px system-ui, sans-serif", color: "#222" }; +export const backBtn: React.CSSProperties = { + alignSelf: "flex-start", + border: "none", + background: "none", + padding: 0, + cursor: "pointer", + font: "13px system-ui, sans-serif", + color: "#555", +}; +export const btn: React.CSSProperties = { + height: 32, + padding: "0 12px", + border: "1px solid #c4c4c4", + background: "#fff", + borderRadius: 8, + cursor: "pointer", + font: "13px system-ui, sans-serif", + color: "#222", +}; +export const twoCol: React.CSSProperties = { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(96px, 1fr))", gap: 12 }; diff --git a/src/geometry.ts b/src/geometry.ts index 2067e1d..e7b7e93 100644 --- a/src/geometry.ts +++ b/src/geometry.ts @@ -1,63 +1,37 @@ // Pure geometry/rules. No React or Konva imports so an optimizer can reuse this. -import type { FurnitureItem, FurnitureType, Rect, Room } from "./types"; +import type { FurnitureItem, Rect, Room } from "./types"; /** Largest px-per-meter that fits the room inside the given pixel box. */ export const fitScale = (room: Room, availW: number, availH: number): number => Math.max(1, Math.min(availW / room.width, availH / room.height)); -export const DEFAULT_SIZES: Record = { - chair: { width: 0.5, height: 0.5 }, - table: { width: 1.8, height: 0.8 }, - screen: { width: 2, height: 0.2 }, -}; - -/** Types the user can resize after placing. */ -export const RESIZABLE: Record = { chair: false, table: false, screen: true }; - -export const MIN_SCREEN_SIZE = { width: 0.5, height: 0.1 }; - -export type Edge = "left" | "right" | "top" | "bottom"; - -/** - * New rect when dragging one edge of `start` to the pointer (meters). The opposite edge stays fixed; - * the result never shrinks below `min` and never leaves the room. - */ -export function resizeRect( - start: Rect, - edge: Edge, - px: number, - py: number, - room: Room, - min: { width: number; height: number }, -): Rect { - const r = { ...start }; - if (edge === "right") { - r.width = clamp(px - start.x, min.width, room.width - start.x); - } else if (edge === "left") { - const right = start.x + start.width; - r.x = clamp(px, 0, right - min.width); - r.width = right - r.x; - } else if (edge === "bottom") { - r.height = clamp(py - start.y, min.height, room.height - start.y); - } else { - const bottom = start.y + start.height; - r.y = clamp(py, 0, bottom - min.height); - r.height = bottom - r.y; - } - return r; -} - export const DEFAULT_ROOM: Room = { width: 10, height: 8 }; +/** A rect with an optional rotation (degrees) around its center. */ +export type Box = Rect & { rotation?: number }; + const clamp = (v: number, min: number, max: number): number => Math.min(Math.max(v, min), max); -/** Keep a rect fully inside the room walls. */ -export function clampToRoom(r: Rect, room: Room): Rect { - return { - ...r, - x: clamp(r.x, 0, room.width - r.width), - y: clamp(r.y, 0, room.height - r.height), - }; +export const normalizeAngle = (deg: number): number => ((Math.round(deg) % 360) + 360) % 360; + +/** Axis-aligned bounding box of the rotated rect. All collision and wall checks use this. */ +export function boundsOf(b: Box): Rect { + const t = ((b.rotation ?? 0) * Math.PI) / 180; + const c = Math.abs(Math.cos(t)); + const s = Math.abs(Math.sin(t)); + const width = b.width * c + b.height * s; + const height = b.width * s + b.height * c; + const cx = b.x + b.width / 2; + const cy = b.y + b.height / 2; + return { x: cx - width / 2, y: cy - height / 2, width, height }; +} + +/** Shift a box so its (rotated) bounds sit fully inside the room walls. */ +export function clampToRoom(b: T, room: Room): T { + const r = boundsOf(b); + const dx = clamp(r.x, 0, room.width - r.width) - r.x; + const dy = clamp(r.y, 0, room.height - r.height) - r.y; + return { ...b, x: b.x + dx, y: b.y + dy }; } /** Axis-aligned overlap. Touching edges do not count as overlap. */ @@ -81,12 +55,46 @@ export function isInsideRoom(r: Rect, room: Room): boolean { ); } -/** Valid = inside the room and not overlapping any other item (ignoring `ignoreId`). */ +/** Valid = bounds inside the room and not overlapping any other item (ignoring `ignoreId`). */ export function isValidPlacement( - r: Rect, + c: Box, items: FurnitureItem[], room: Room, ignoreId?: string, ): boolean { - return isInsideRoom(r, room) && !items.some((o) => o.id !== ignoreId && overlaps(r, o)); + const cb = boundsOf(c); + return isInsideRoom(cb, room) && !items.some((o) => o.id !== ignoreId && overlaps(cb, boundsOf(o))); +} + +/** + * Apply a patch (rotation, size, ...) to an item. A size change keeps the center fixed; the result is + * pushed back inside the walls, then rejected (null) if it would overlap anything. + */ +export function tryUpdate( + item: FurnitureItem, + patch: Partial, + items: FurnitureItem[], + room: Room, +): FurnitureItem | null { + let next = { ...item, ...patch }; + if (patch.x === undefined && patch.y === undefined) { + next.x = item.x + item.width / 2 - next.width / 2; + next.y = item.y + item.height / 2 - next.height / 2; + } + next = clampToRoom(next, room); + return isValidPlacement(next, items, room, item.id) ? next : null; +} + +// ---- Screens: drag an end handle to change length (only while unrotated) ---- + +export const MIN_SCREEN_LENGTH = 0.5; + +/** New rect when dragging the left/right edge of `start` to pointer x (meters). Opposite edge stays fixed. */ +export function resizeLength(start: Rect, edge: "left" | "right", px: number, room: Room): Rect { + if (edge === "right") { + return { ...start, width: clamp(px - start.x, MIN_SCREEN_LENGTH, room.width - start.x) }; + } + const right = start.x + start.width; + const x = clamp(px, 0, right - MIN_SCREEN_LENGTH); + return { ...start, x, width: right - x }; } diff --git a/src/inventory.ts b/src/inventory.ts index bfc5980..8202726 100644 --- a/src/inventory.ts +++ b/src/inventory.ts @@ -1,8 +1,12 @@ // Pure inventory rules. Everything is derived from the items array. -import type { FurnitureItem, FurnitureType } from "./types"; +import type { FurnitureItem, FurnitureType, FurnitureTypeConfig } from "./types"; export const placedCount = (items: FurnitureItem[], type: FurnitureType): number => items.filter((i) => i.type === type).length; export const remaining = (items: FurnitureItem[], type: FurnitureType, available: number): number => available - placedCount(items, type); + +/** Seats for one item: per-table override if set, else the type-level default. */ +export const effectiveSeats = (item: FurnitureItem, config: FurnitureTypeConfig): number | undefined => + item.seatsOverride ?? config.seatsPerUnit; diff --git a/src/store.ts b/src/store.ts index 3d6a55f..9974fb1 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,39 +1,47 @@ import type { FurnitureItem, FurnitureType, FurnitureTypeConfig, Room } from "./types"; -import { DEFAULT_ROOM, DEFAULT_SIZES } from "./geometry"; +import { DEFAULT_ROOM } from "./geometry"; // Single source of truth. An optimizer can read `state` and dispatch actions. export interface LayoutState { room: Room; items: FurnitureItem[]; configs: Record; + typeOrder: FurnitureType[]; // palette order } export type Action = | { kind: "add"; id: string; type: FurnitureType; x: number; y: number } | { kind: "move"; id: string; x: number; y: number } - | { kind: "resize"; id: string; x: number; y: number; width: number; height: number } + | { kind: "update"; id: string; patch: Partial } + | { kind: "remove"; id: string } | { kind: "setAvailable"; type: FurnitureType; value: number } - | { kind: "setSeats"; value: number }; + | { kind: "setSeats"; type: FurnitureType; value: number } + | { kind: "addConfig"; config: FurnitureTypeConfig }; -export const initialState: LayoutState = { room: DEFAULT_ROOM, items: [], - configs: { - chair: { type: "chair", available: 20 }, - table: { type: "table", available: 6, seatsPerUnit: 8 }, - screen: { type: "screen", available: 2 }, - }, +const BUILT_IN: FurnitureTypeConfig[] = [ + { id: "chair", name: "Chair", shape: "chair", defaultWidth: 0.5, defaultHeight: 0.5, isTable: false, available: 20 }, + { id: "table", name: "Table", shape: "table", defaultWidth: 1.8, defaultHeight: 0.8, isTable: true, available: 6, seatsPerUnit: 8 }, + { id: "screen", name: "Screen", shape: "screen", defaultWidth: 2, defaultHeight: 0.2, isTable: false, available: 2 }, +]; + +export const initialState: LayoutState = { + room: DEFAULT_ROOM, + items: [], + configs: Object.fromEntries(BUILT_IN.map((c) => [c.id, c])), + typeOrder: BUILT_IN.map((c) => c.id), }; export function reducer(state: LayoutState, action: Action): LayoutState { switch (action.kind) { case "add": { - const { width, height } = DEFAULT_SIZES[action.type]; + const cfg = state.configs[action.type]; const item: FurnitureItem = { id: action.id, type: action.type, x: action.x, y: action.y, - width, - height, + width: cfg.defaultWidth, + height: cfg.defaultHeight, rotation: 0, locked: false, }; @@ -42,31 +50,30 @@ export function reducer(state: LayoutState, action: Action): LayoutState { case "move": return { ...state, - items: state.items.map((i) => - i.id === action.id ? { ...i, x: action.x, y: action.y } : i, - ), + items: state.items.map((i) => (i.id === action.id ? { ...i, x: action.x, y: action.y } : i)), }; - case "resize": + case "update": return { ...state, - items: state.items.map((i) => - i.id === action.id - ? { ...i, x: action.x, y: action.y, width: action.width, height: action.height } - : i, - ), + items: state.items.map((i) => (i.id === action.id ? { ...i, ...action.patch } : i)), }; + case "remove": + return { ...state, items: state.items.filter((i) => i.id !== action.id) }; case "setAvailable": return { ...state, - configs: { - ...state.configs, - [action.type]: { ...state.configs[action.type], available: action.value }, - }, + configs: { ...state.configs, [action.type]: { ...state.configs[action.type], available: action.value } }, }; case "setSeats": return { ...state, - configs: { ...state.configs, table: { ...state.configs.table, seatsPerUnit: action.value } }, + configs: { ...state.configs, [action.type]: { ...state.configs[action.type], seatsPerUnit: action.value } }, + }; + case "addConfig": + return { + ...state, + configs: { ...state.configs, [action.config.id]: action.config }, + typeOrder: [...state.typeOrder, action.config.id], }; } } diff --git a/src/types.ts b/src/types.ts index bfce539..79583bf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,22 +1,19 @@ -export type FurnitureType = "chair" | "table" | "screen"; +/** Id of a furniture config ("chair", "table", "screen", "custom-1", ...). */ +export type FurnitureType = string; -export const FURNITURE_TYPES: FurnitureType[] = ["chair", "table", "screen"]; - -export const TYPE_LABEL: Record = { - chair: "Chair", - table: "Table", - screen: "Screen", -}; +/** How a type is drawn. Custom seating/tables reuse the chair/table looks. */ +export type Shape = "chair" | "table" | "screen"; export interface FurnitureItem { id: string; - type: FurnitureType; - x: number; // meters, top-left, room coordinates + type: FurnitureType; // config id + x: number; // meters, top-left of the UNROTATED rect, room coordinates y: number; width: number; // meters height: number; - rotation: number; // degrees, always 0 for now - locked: boolean; // always false for now, reserved + rotation: number; // degrees, rotates around the rect's center + locked: boolean; + seatsOverride?: number; // tables only: overrides the type-level seatsPerUnit } export interface Room { @@ -31,9 +28,14 @@ export interface Rect { height: number; } -// Per-type settings, edited via the palette menu. +// Per-type settings. Built-in and custom furniture are just more configs. export interface FurnitureTypeConfig { - type: FurnitureType; + id: FurnitureType; + name: string; + shape: Shape; + defaultWidth: number; // meters + defaultHeight: number; + isTable: boolean; available: number; // inventory count - seatsPerUnit?: number; // tables only + seatsPerUnit?: number; // type-level seats (tables, couches...) }