@bitovi/vybit 0.4.10 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,553 +0,0 @@
1
- function py(r,e){for(var t=0;t<e.length;t++){const n=e[t];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in r)){const i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(r,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function my(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var _g={exports:{}},Wa={},Cg={exports:{}},Z={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Ci=Symbol.for("react.element"),vy=Symbol.for("react.portal"),yy=Symbol.for("react.fragment"),xy=Symbol.for("react.strict_mode"),wy=Symbol.for("react.profiler"),Sy=Symbol.for("react.provider"),by=Symbol.for("react.context"),_y=Symbol.for("react.forward_ref"),Cy=Symbol.for("react.suspense"),Ty=Symbol.for("react.memo"),ky=Symbol.for("react.lazy"),Yh=Symbol.iterator;function Ey(r){return r===null||typeof r!="object"?null:(r=Yh&&r[Yh]||r["@@iterator"],typeof r=="function"?r:null)}var Tg={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},kg=Object.assign,Eg={};function fs(r,e,t){this.props=r,this.context=e,this.refs=Eg,this.updater=t||Tg}fs.prototype.isReactComponent={};fs.prototype.setState=function(r,e){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,e,"setState")};fs.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function Og(){}Og.prototype=fs.prototype;function Du(r,e,t){this.props=r,this.context=e,this.refs=Eg,this.updater=t||Tg}var Pu=Du.prototype=new Og;Pu.constructor=Du;kg(Pu,fs.prototype);Pu.isPureReactComponent=!0;var Gh=Array.isArray,Dg=Object.prototype.hasOwnProperty,Mu={current:null},Pg={key:!0,ref:!0,__self:!0,__source:!0};function Mg(r,e,t){var n,s={},i=null,o=null;if(e!=null)for(n in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)Dg.call(e,n)&&!Pg.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=t;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];s.children=l}if(r&&r.defaultProps)for(n in a=r.defaultProps,a)s[n]===void 0&&(s[n]=a[n]);return{$$typeof:Ci,type:r,key:i,ref:o,props:s,_owner:Mu.current}}function Oy(r,e){return{$$typeof:Ci,type:r.type,key:e,ref:r.ref,props:r.props,_owner:r._owner}}function ju(r){return typeof r=="object"&&r!==null&&r.$$typeof===Ci}function Dy(r){var e={"=":"=0",":":"=2"};return"$"+r.replace(/[=:]/g,function(t){return e[t]})}var Kh=/\/+/g;function bl(r,e){return typeof r=="object"&&r!==null&&r.key!=null?Dy(""+r.key):e.toString(36)}function Eo(r,e,t,n,s){var i=typeof r;(i==="undefined"||i==="boolean")&&(r=null);var o=!1;if(r===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(r.$$typeof){case Ci:case vy:o=!0}}if(o)return o=r,s=s(o),r=n===""?"."+bl(o,0):n,Gh(s)?(t="",r!=null&&(t=r.replace(Kh,"$&/")+"/"),Eo(s,e,t,"",function(c){return c})):s!=null&&(ju(s)&&(s=Oy(s,t+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(Kh,"$&/")+"/")+r)),e.push(s)),1;if(o=0,n=n===""?".":n+":",Gh(r))for(var a=0;a<r.length;a++){i=r[a];var l=n+bl(i,a);o+=Eo(i,e,t,l,s)}else if(l=Ey(r),typeof l=="function")for(r=l.call(r),a=0;!(i=r.next()).done;)i=i.value,l=n+bl(i,a++),o+=Eo(i,e,t,l,s);else if(i==="object")throw e=String(r),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function Ri(r,e,t){if(r==null)return r;var n=[],s=0;return Eo(r,n,"","",function(i){return e.call(t,i,s++)}),n}function Py(r){if(r._status===-1){var e=r._result;e=e(),e.then(function(t){(r._status===0||r._status===-1)&&(r._status=1,r._result=t)},function(t){(r._status===0||r._status===-1)&&(r._status=2,r._result=t)}),r._status===-1&&(r._status=0,r._result=e)}if(r._status===1)return r._result.default;throw r._result}var Ue={current:null},Oo={transition:null},My={ReactCurrentDispatcher:Ue,ReactCurrentBatchConfig:Oo,ReactCurrentOwner:Mu};function jg(){throw Error("act(...) is not supported in production builds of React.")}Z.Children={map:Ri,forEach:function(r,e,t){Ri(r,function(){e.apply(this,arguments)},t)},count:function(r){var e=0;return Ri(r,function(){e++}),e},toArray:function(r){return Ri(r,function(e){return e})||[]},only:function(r){if(!ju(r))throw Error("React.Children.only expected to receive a single React element child.");return r}};Z.Component=fs;Z.Fragment=yy;Z.Profiler=wy;Z.PureComponent=Du;Z.StrictMode=xy;Z.Suspense=Cy;Z.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=My;Z.act=jg;Z.cloneElement=function(r,e,t){if(r==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+r+".");var n=kg({},r.props),s=r.key,i=r.ref,o=r._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,o=Mu.current),e.key!==void 0&&(s=""+e.key),r.type&&r.type.defaultProps)var a=r.type.defaultProps;for(l in e)Dg.call(e,l)&&!Pg.hasOwnProperty(l)&&(n[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)n.children=t;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];n.children=a}return{$$typeof:Ci,type:r.type,key:s,ref:i,props:n,_owner:o}};Z.createContext=function(r){return r={$$typeof:by,_currentValue:r,_currentValue2:r,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},r.Provider={$$typeof:Sy,_context:r},r.Consumer=r};Z.createElement=Mg;Z.createFactory=function(r){var e=Mg.bind(null,r);return e.type=r,e};Z.createRef=function(){return{current:null}};Z.forwardRef=function(r){return{$$typeof:_y,render:r}};Z.isValidElement=ju;Z.lazy=function(r){return{$$typeof:ky,_payload:{_status:-1,_result:r},_init:Py}};Z.memo=function(r,e){return{$$typeof:Ty,type:r,compare:e===void 0?null:e}};Z.startTransition=function(r){var e=Oo.transition;Oo.transition={};try{r()}finally{Oo.transition=e}};Z.unstable_act=jg;Z.useCallback=function(r,e){return Ue.current.useCallback(r,e)};Z.useContext=function(r){return Ue.current.useContext(r)};Z.useDebugValue=function(){};Z.useDeferredValue=function(r){return Ue.current.useDeferredValue(r)};Z.useEffect=function(r,e){return Ue.current.useEffect(r,e)};Z.useId=function(){return Ue.current.useId()};Z.useImperativeHandle=function(r,e,t){return Ue.current.useImperativeHandle(r,e,t)};Z.useInsertionEffect=function(r,e){return Ue.current.useInsertionEffect(r,e)};Z.useLayoutEffect=function(r,e){return Ue.current.useLayoutEffect(r,e)};Z.useMemo=function(r,e){return Ue.current.useMemo(r,e)};Z.useReducer=function(r,e,t){return Ue.current.useReducer(r,e,t)};Z.useRef=function(r){return Ue.current.useRef(r)};Z.useState=function(r){return Ue.current.useState(r)};Z.useSyncExternalStore=function(r,e,t){return Ue.current.useSyncExternalStore(r,e,t)};Z.useTransition=function(){return Ue.current.useTransition()};Z.version="18.3.1";Cg.exports=Z;var D=Cg.exports;const Rg=my(D),Ag=py({__proto__:null,default:Rg},[D]);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var jy=D,Ry=Symbol.for("react.element"),Ay=Symbol.for("react.fragment"),Ly=Object.prototype.hasOwnProperty,Fy=jy.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ny={key:!0,ref:!0,__self:!0,__source:!0};function Lg(r,e,t){var n,s={},i=null,o=null;t!==void 0&&(i=""+t),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(o=e.ref);for(n in e)Ly.call(e,n)&&!Ny.hasOwnProperty(n)&&(s[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)s[n]===void 0&&(s[n]=e[n]);return{$$typeof:Ry,type:r,key:i,ref:o,props:s,_owner:Fy.current}}Wa.Fragment=Ay;Wa.jsx=Lg;Wa.jsxs=Lg;_g.exports=Wa;var w=_g.exports,pc={},Fg={exports:{}},ft={},Ng={exports:{}},Ig={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(r){function e(k,F){var B=k.length;k.push(F);e:for(;0<B;){var L=B-1>>>1,X=k[L];if(0<s(X,F))k[L]=F,k[B]=X,B=L;else break e}}function t(k){return k.length===0?null:k[0]}function n(k){if(k.length===0)return null;var F=k[0],B=k.pop();if(B!==F){k[0]=B;e:for(var L=0,X=k.length,q=X>>>1;L<q;){var Q=2*(L+1)-1,H=k[Q],K=Q+1,ee=k[K];if(0>s(H,B))K<X&&0>s(ee,H)?(k[L]=ee,k[K]=B,L=K):(k[L]=H,k[Q]=B,L=Q);else if(K<X&&0>s(ee,B))k[L]=ee,k[K]=B,L=K;else break e}}return F}function s(k,F){var B=k.sortIndex-F.sortIndex;return B!==0?B:k.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;r.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,d=3,f=!1,m=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(k){for(var F=t(c);F!==null;){if(F.callback===null)n(c);else if(F.startTime<=k)n(c),F.sortIndex=F.expirationTime,e(l,F);else break;F=t(c)}}function b(k){if(v=!1,y(k),!m)if(t(l)!==null)m=!0,Y(O);else{var F=t(c);F!==null&&W(b,F.startTime-k)}}function O(k,F){m=!1,v&&(v=!1,g(C),C=-1),f=!0;var B=d;try{for(y(F),h=t(l);h!==null&&(!(h.expirationTime>F)||k&&!R());){var L=h.callback;if(typeof L=="function"){h.callback=null,d=h.priorityLevel;var X=L(h.expirationTime<=F);F=r.unstable_now(),typeof X=="function"?h.callback=X:h===t(l)&&n(l),y(F)}else n(l);h=t(l)}if(h!==null)var q=!0;else{var Q=t(c);Q!==null&&W(b,Q.startTime-F),q=!1}return q}finally{h=null,d=B,f=!1}}var S=!1,T=null,C=-1,P=5,j=-1;function R(){return!(r.unstable_now()-j<P)}function I(){if(T!==null){var k=r.unstable_now();j=k;var F=!0;try{F=T(!0,k)}finally{F?U():(S=!1,T=null)}}else S=!1}var U;if(typeof p=="function")U=function(){p(I)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,G=A.port2;A.port1.onmessage=I,U=function(){G.postMessage(null)}}else U=function(){x(I,0)};function Y(k){T=k,S||(S=!0,U())}function W(k,F){C=x(function(){k(r.unstable_now())},F)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(k){k.callback=null},r.unstable_continueExecution=function(){m||f||(m=!0,Y(O))},r.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<k?Math.floor(1e3/k):5},r.unstable_getCurrentPriorityLevel=function(){return d},r.unstable_getFirstCallbackNode=function(){return t(l)},r.unstable_next=function(k){switch(d){case 1:case 2:case 3:var F=3;break;default:F=d}var B=d;d=F;try{return k()}finally{d=B}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(k,F){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var B=d;d=k;try{return F()}finally{d=B}},r.unstable_scheduleCallback=function(k,F,B){var L=r.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?L+B:L):B=L,k){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=B+X,k={id:u++,callback:F,priorityLevel:k,startTime:B,expirationTime:X,sortIndex:-1},B>L?(k.sortIndex=B,e(c,k),t(l)===null&&k===t(c)&&(v?(g(C),C=-1):v=!0,W(b,B-L))):(k.sortIndex=X,e(l,k),m||f||(m=!0,Y(O))),k},r.unstable_shouldYield=R,r.unstable_wrapCallback=function(k){var F=d;return function(){var B=d;d=F;try{return k.apply(this,arguments)}finally{d=B}}}})(Ig);Ng.exports=Ig;var Iy=Ng.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var By=D,dt=Iy;function N(r){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+r,t=1;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Bg=new Set,Zs={};function kn(r,e){is(r,e),is(r+"Capture",e)}function is(r,e){for(Zs[r]=e,r=0;r<e.length;r++)Bg.add(e[r])}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),mc=Object.prototype.hasOwnProperty,zy=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,qh={},Qh={};function Wy(r){return mc.call(Qh,r)?!0:mc.call(qh,r)?!1:zy.test(r)?Qh[r]=!0:(qh[r]=!0,!1)}function Vy(r,e,t,n){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:t!==null?!t.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function Hy(r,e,t,n){if(e===null||typeof e>"u"||Vy(r,e,t,n))return!0;if(n)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ye(r,e,t,n,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=t,this.propertyName=r,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var Le={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){Le[r]=new Ye(r,0,!1,r,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var e=r[0];Le[e]=new Ye(e,1,!1,r[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(r){Le[r]=new Ye(r,2,!1,r.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){Le[r]=new Ye(r,2,!1,r,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){Le[r]=new Ye(r,3,!1,r.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(r){Le[r]=new Ye(r,3,!0,r,null,!1,!1)});["capture","download"].forEach(function(r){Le[r]=new Ye(r,4,!1,r,null,!1,!1)});["cols","rows","size","span"].forEach(function(r){Le[r]=new Ye(r,6,!1,r,null,!1,!1)});["rowSpan","start"].forEach(function(r){Le[r]=new Ye(r,5,!1,r.toLowerCase(),null,!1,!1)});var Ru=/[\-:]([a-z])/g;function Au(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var e=r.replace(Ru,Au);Le[e]=new Ye(e,1,!1,r,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var e=r.replace(Ru,Au);Le[e]=new Ye(e,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(r){var e=r.replace(Ru,Au);Le[e]=new Ye(e,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(r){Le[r]=new Ye(r,1,!1,r.toLowerCase(),null,!1,!1)});Le.xlinkHref=new Ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(r){Le[r]=new Ye(r,1,!1,r.toLowerCase(),null,!0,!0)});function Lu(r,e,t,n){var s=Le.hasOwnProperty(e)?Le[e]:null;(s!==null?s.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(Hy(e,t,s,n)&&(t=null),n||s===null?Wy(e)&&(t===null?r.removeAttribute(e):r.setAttribute(e,""+t)):s.mustUseProperty?r[s.propertyName]=t===null?s.type===3?!1:"":t:(e=s.attributeName,n=s.attributeNamespace,t===null?r.removeAttribute(e):(s=s.type,t=s===3||s===4&&t===!0?"":""+t,n?r.setAttributeNS(n,e,t):r.setAttribute(e,t))))}var Tr=By.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ai=Symbol.for("react.element"),An=Symbol.for("react.portal"),Ln=Symbol.for("react.fragment"),Fu=Symbol.for("react.strict_mode"),vc=Symbol.for("react.profiler"),zg=Symbol.for("react.provider"),Wg=Symbol.for("react.context"),Nu=Symbol.for("react.forward_ref"),yc=Symbol.for("react.suspense"),xc=Symbol.for("react.suspense_list"),Iu=Symbol.for("react.memo"),Mr=Symbol.for("react.lazy"),Vg=Symbol.for("react.offscreen"),Jh=Symbol.iterator;function Cs(r){return r===null||typeof r!="object"?null:(r=Jh&&r[Jh]||r["@@iterator"],typeof r=="function"?r:null)}var ve=Object.assign,_l;function Ls(r){if(_l===void 0)try{throw Error()}catch(t){var e=t.stack.trim().match(/\n( *(at )?)/);_l=e&&e[1]||""}return`
34
- `+_l+r}var Cl=!1;function Tl(r,e){if(!r||Cl)return"";Cl=!0;var t=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var n=c}Reflect.construct(r,[],e)}else{try{e.call()}catch(c){n=c}r.call(e.prototype)}else{try{throw Error()}catch(c){n=c}r()}}catch(c){if(c&&n&&typeof c.stack=="string"){for(var s=c.stack.split(`
35
- `),i=n.stack.split(`
36
- `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=`
37
- `+s[o].replace(" at new "," at ");return r.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",r.displayName)),l}while(1<=o&&0<=a);break}}}finally{Cl=!1,Error.prepareStackTrace=t}return(r=r?r.displayName||r.name:"")?Ls(r):""}function $y(r){switch(r.tag){case 5:return Ls(r.type);case 16:return Ls("Lazy");case 13:return Ls("Suspense");case 19:return Ls("SuspenseList");case 0:case 2:case 15:return r=Tl(r.type,!1),r;case 11:return r=Tl(r.type.render,!1),r;case 1:return r=Tl(r.type,!0),r;default:return""}}function wc(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Ln:return"Fragment";case An:return"Portal";case vc:return"Profiler";case Fu:return"StrictMode";case yc:return"Suspense";case xc:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case Wg:return(r.displayName||"Context")+".Consumer";case zg:return(r._context.displayName||"Context")+".Provider";case Nu:var e=r.render;return r=r.displayName,r||(r=e.displayName||e.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Iu:return e=r.displayName||null,e!==null?e:wc(r.type)||"Memo";case Mr:e=r._payload,r=r._init;try{return wc(r(e))}catch{}}return null}function Xy(r){var e=r.type;switch(r.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=e.render,r=r.displayName||r.name||"",e.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return wc(e);case 8:return e===Fu?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Kr(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Hg(r){var e=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Uy(r){var e=Hg(r)?"checked":"value",t=Object.getOwnPropertyDescriptor(r.constructor.prototype,e),n=""+r[e];if(!r.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var s=t.get,i=t.set;return Object.defineProperty(r,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){n=""+o,i.call(this,o)}}),Object.defineProperty(r,e,{enumerable:t.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){r._valueTracker=null,delete r[e]}}}}function Li(r){r._valueTracker||(r._valueTracker=Uy(r))}function $g(r){if(!r)return!1;var e=r._valueTracker;if(!e)return!0;var t=e.getValue(),n="";return r&&(n=Hg(r)?r.checked?"true":"false":r.value),r=n,r!==t?(e.setValue(r),!0):!1}function qo(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Sc(r,e){var t=e.checked;return ve({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??r._wrapperState.initialChecked})}function Zh(r,e){var t=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;t=Kr(e.value!=null?e.value:t),r._wrapperState={initialChecked:n,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Xg(r,e){e=e.checked,e!=null&&Lu(r,"checked",e,!1)}function bc(r,e){Xg(r,e);var t=Kr(e.value),n=e.type;if(t!=null)n==="number"?(t===0&&r.value===""||r.value!=t)&&(r.value=""+t):r.value!==""+t&&(r.value=""+t);else if(n==="submit"||n==="reset"){r.removeAttribute("value");return}e.hasOwnProperty("value")?_c(r,e.type,t):e.hasOwnProperty("defaultValue")&&_c(r,e.type,Kr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(r.defaultChecked=!!e.defaultChecked)}function ed(r,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+r._wrapperState.initialValue,t||e===r.value||(r.value=e),r.defaultValue=e}t=r.name,t!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,t!==""&&(r.name=t)}function _c(r,e,t){(e!=="number"||qo(r.ownerDocument)!==r)&&(t==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+t&&(r.defaultValue=""+t))}var Fs=Array.isArray;function Kn(r,e,t,n){if(r=r.options,e){e={};for(var s=0;s<t.length;s++)e["$"+t[s]]=!0;for(t=0;t<r.length;t++)s=e.hasOwnProperty("$"+r[t].value),r[t].selected!==s&&(r[t].selected=s),s&&n&&(r[t].defaultSelected=!0)}else{for(t=""+Kr(t),e=null,s=0;s<r.length;s++){if(r[s].value===t){r[s].selected=!0,n&&(r[s].defaultSelected=!0);return}e!==null||r[s].disabled||(e=r[s])}e!==null&&(e.selected=!0)}}function Cc(r,e){if(e.dangerouslySetInnerHTML!=null)throw Error(N(91));return ve({},e,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function td(r,e){var t=e.value;if(t==null){if(t=e.children,e=e.defaultValue,t!=null){if(e!=null)throw Error(N(92));if(Fs(t)){if(1<t.length)throw Error(N(93));t=t[0]}e=t}e==null&&(e=""),t=e}r._wrapperState={initialValue:Kr(t)}}function Ug(r,e){var t=Kr(e.value),n=Kr(e.defaultValue);t!=null&&(t=""+t,t!==r.value&&(r.value=t),e.defaultValue==null&&r.defaultValue!==t&&(r.defaultValue=t)),n!=null&&(r.defaultValue=""+n)}function rd(r){var e=r.textContent;e===r._wrapperState.initialValue&&e!==""&&e!==null&&(r.value=e)}function Yg(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Tc(r,e){return r==null||r==="http://www.w3.org/1999/xhtml"?Yg(e):r==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var Fi,Gg=function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,t,n,s){MSApp.execUnsafeLocalFunction(function(){return r(e,t,n,s)})}:r}(function(r,e){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=e;else{for(Fi=Fi||document.createElement("div"),Fi.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Fi.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;e.firstChild;)r.appendChild(e.firstChild)}});function ei(r,e){if(e){var t=r.firstChild;if(t&&t===r.lastChild&&t.nodeType===3){t.nodeValue=e;return}}r.textContent=e}var zs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Yy=["Webkit","ms","Moz","O"];Object.keys(zs).forEach(function(r){Yy.forEach(function(e){e=e+r.charAt(0).toUpperCase()+r.substring(1),zs[e]=zs[r]})});function Kg(r,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||zs.hasOwnProperty(r)&&zs[r]?(""+e).trim():e+"px"}function qg(r,e){r=r.style;for(var t in e)if(e.hasOwnProperty(t)){var n=t.indexOf("--")===0,s=Kg(t,e[t],n);t==="float"&&(t="cssFloat"),n?r.setProperty(t,s):r[t]=s}}var Gy=ve({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function kc(r,e){if(e){if(Gy[r]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(N(137,r));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(N(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(N(61))}if(e.style!=null&&typeof e.style!="object")throw Error(N(62))}}function Ec(r,e){if(r.indexOf("-")===-1)return typeof e.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Oc=null;function Bu(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Dc=null,qn=null,Qn=null;function nd(r){if(r=Ei(r)){if(typeof Dc!="function")throw Error(N(280));var e=r.stateNode;e&&(e=Ua(e),Dc(r.stateNode,r.type,e))}}function Qg(r){qn?Qn?Qn.push(r):Qn=[r]:qn=r}function Jg(){if(qn){var r=qn,e=Qn;if(Qn=qn=null,nd(r),e)for(r=0;r<e.length;r++)nd(e[r])}}function Zg(r,e){return r(e)}function ep(){}var kl=!1;function tp(r,e,t){if(kl)return r(e,t);kl=!0;try{return Zg(r,e,t)}finally{kl=!1,(qn!==null||Qn!==null)&&(ep(),Jg())}}function ti(r,e){var t=r.stateNode;if(t===null)return null;var n=Ua(t);if(n===null)return null;t=n[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(r=r.type,n=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!n;break e;default:r=!1}if(r)return null;if(t&&typeof t!="function")throw Error(N(231,e,typeof t));return t}var Pc=!1;if(mr)try{var Ts={};Object.defineProperty(Ts,"passive",{get:function(){Pc=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Pc=!1}function Ky(r,e,t,n,s,i,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(t,c)}catch(u){this.onError(u)}}var Ws=!1,Qo=null,Jo=!1,Mc=null,qy={onError:function(r){Ws=!0,Qo=r}};function Qy(r,e,t,n,s,i,o,a,l){Ws=!1,Qo=null,Ky.apply(qy,arguments)}function Jy(r,e,t,n,s,i,o,a,l){if(Qy.apply(this,arguments),Ws){if(Ws){var c=Qo;Ws=!1,Qo=null}else throw Error(N(198));Jo||(Jo=!0,Mc=c)}}function En(r){var e=r,t=r;if(r.alternate)for(;e.return;)e=e.return;else{r=e;do e=r,e.flags&4098&&(t=e.return),r=e.return;while(r)}return e.tag===3?t:null}function rp(r){if(r.tag===13){var e=r.memoizedState;if(e===null&&(r=r.alternate,r!==null&&(e=r.memoizedState)),e!==null)return e.dehydrated}return null}function sd(r){if(En(r)!==r)throw Error(N(188))}function Zy(r){var e=r.alternate;if(!e){if(e=En(r),e===null)throw Error(N(188));return e!==r?null:r}for(var t=r,n=e;;){var s=t.return;if(s===null)break;var i=s.alternate;if(i===null){if(n=s.return,n!==null){t=n;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===t)return sd(s),r;if(i===n)return sd(s),e;i=i.sibling}throw Error(N(188))}if(t.return!==n.return)t=s,n=i;else{for(var o=!1,a=s.child;a;){if(a===t){o=!0,t=s,n=i;break}if(a===n){o=!0,n=s,t=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===t){o=!0,t=i,n=s;break}if(a===n){o=!0,n=i,t=s;break}a=a.sibling}if(!o)throw Error(N(189))}}if(t.alternate!==n)throw Error(N(190))}if(t.tag!==3)throw Error(N(188));return t.stateNode.current===t?r:e}function np(r){return r=Zy(r),r!==null?sp(r):null}function sp(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var e=sp(r);if(e!==null)return e;r=r.sibling}return null}var ip=dt.unstable_scheduleCallback,id=dt.unstable_cancelCallback,e0=dt.unstable_shouldYield,t0=dt.unstable_requestPaint,we=dt.unstable_now,r0=dt.unstable_getCurrentPriorityLevel,zu=dt.unstable_ImmediatePriority,op=dt.unstable_UserBlockingPriority,Zo=dt.unstable_NormalPriority,n0=dt.unstable_LowPriority,ap=dt.unstable_IdlePriority,Va=null,Kt=null;function s0(r){if(Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Va,r,void 0,(r.current.flags&128)===128)}catch{}}var It=Math.clz32?Math.clz32:a0,i0=Math.log,o0=Math.LN2;function a0(r){return r>>>=0,r===0?32:31-(i0(r)/o0|0)|0}var Ni=64,Ii=4194304;function Ns(r){switch(r&-r){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:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function ea(r,e){var t=r.pendingLanes;if(t===0)return 0;var n=0,s=r.suspendedLanes,i=r.pingedLanes,o=t&268435455;if(o!==0){var a=o&~s;a!==0?n=Ns(a):(i&=o,i!==0&&(n=Ns(i)))}else o=t&~s,o!==0?n=Ns(o):i!==0&&(n=Ns(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=t&16),e=r.entangledLanes,e!==0)for(r=r.entanglements,e&=n;0<e;)t=31-It(e),s=1<<t,n|=r[t],e&=~s;return n}function l0(r,e){switch(r){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function c0(r,e){for(var t=r.suspendedLanes,n=r.pingedLanes,s=r.expirationTimes,i=r.pendingLanes;0<i;){var o=31-It(i),a=1<<o,l=s[o];l===-1?(!(a&t)||a&n)&&(s[o]=l0(a,e)):l<=e&&(r.expiredLanes|=a),i&=~a}}function jc(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function lp(){var r=Ni;return Ni<<=1,!(Ni&4194240)&&(Ni=64),r}function El(r){for(var e=[],t=0;31>t;t++)e.push(r);return e}function Ti(r,e,t){r.pendingLanes|=e,e!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,e=31-It(e),r[e]=t}function u0(r,e){var t=r.pendingLanes&~e;r.pendingLanes=e,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=e,r.mutableReadLanes&=e,r.entangledLanes&=e,e=r.entanglements;var n=r.eventTimes;for(r=r.expirationTimes;0<t;){var s=31-It(t),i=1<<s;e[s]=0,n[s]=-1,r[s]=-1,t&=~i}}function Wu(r,e){var t=r.entangledLanes|=e;for(r=r.entanglements;t;){var n=31-It(t),s=1<<n;s&e|r[n]&e&&(r[n]|=e),t&=~s}}var ie=0;function cp(r){return r&=-r,1<r?4<r?r&268435455?16:536870912:4:1}var up,Vu,hp,dp,fp,Rc=!1,Bi=[],zr=null,Wr=null,Vr=null,ri=new Map,ni=new Map,Rr=[],h0="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function od(r,e){switch(r){case"focusin":case"focusout":zr=null;break;case"dragenter":case"dragleave":Wr=null;break;case"mouseover":case"mouseout":Vr=null;break;case"pointerover":case"pointerout":ri.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":ni.delete(e.pointerId)}}function ks(r,e,t,n,s,i){return r===null||r.nativeEvent!==i?(r={blockedOn:e,domEventName:t,eventSystemFlags:n,nativeEvent:i,targetContainers:[s]},e!==null&&(e=Ei(e),e!==null&&Vu(e)),r):(r.eventSystemFlags|=n,e=r.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),r)}function d0(r,e,t,n,s){switch(e){case"focusin":return zr=ks(zr,r,e,t,n,s),!0;case"dragenter":return Wr=ks(Wr,r,e,t,n,s),!0;case"mouseover":return Vr=ks(Vr,r,e,t,n,s),!0;case"pointerover":var i=s.pointerId;return ri.set(i,ks(ri.get(i)||null,r,e,t,n,s)),!0;case"gotpointercapture":return i=s.pointerId,ni.set(i,ks(ni.get(i)||null,r,e,t,n,s)),!0}return!1}function gp(r){var e=ln(r.target);if(e!==null){var t=En(e);if(t!==null){if(e=t.tag,e===13){if(e=rp(t),e!==null){r.blockedOn=e,fp(r.priority,function(){hp(t)});return}}else if(e===3&&t.stateNode.current.memoizedState.isDehydrated){r.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Do(r){if(r.blockedOn!==null)return!1;for(var e=r.targetContainers;0<e.length;){var t=Ac(r.domEventName,r.eventSystemFlags,e[0],r.nativeEvent);if(t===null){t=r.nativeEvent;var n=new t.constructor(t.type,t);Oc=n,t.target.dispatchEvent(n),Oc=null}else return e=Ei(t),e!==null&&Vu(e),r.blockedOn=t,!1;e.shift()}return!0}function ad(r,e,t){Do(r)&&t.delete(e)}function f0(){Rc=!1,zr!==null&&Do(zr)&&(zr=null),Wr!==null&&Do(Wr)&&(Wr=null),Vr!==null&&Do(Vr)&&(Vr=null),ri.forEach(ad),ni.forEach(ad)}function Es(r,e){r.blockedOn===e&&(r.blockedOn=null,Rc||(Rc=!0,dt.unstable_scheduleCallback(dt.unstable_NormalPriority,f0)))}function si(r){function e(s){return Es(s,r)}if(0<Bi.length){Es(Bi[0],r);for(var t=1;t<Bi.length;t++){var n=Bi[t];n.blockedOn===r&&(n.blockedOn=null)}}for(zr!==null&&Es(zr,r),Wr!==null&&Es(Wr,r),Vr!==null&&Es(Vr,r),ri.forEach(e),ni.forEach(e),t=0;t<Rr.length;t++)n=Rr[t],n.blockedOn===r&&(n.blockedOn=null);for(;0<Rr.length&&(t=Rr[0],t.blockedOn===null);)gp(t),t.blockedOn===null&&Rr.shift()}var Jn=Tr.ReactCurrentBatchConfig,ta=!0;function g0(r,e,t,n){var s=ie,i=Jn.transition;Jn.transition=null;try{ie=1,Hu(r,e,t,n)}finally{ie=s,Jn.transition=i}}function p0(r,e,t,n){var s=ie,i=Jn.transition;Jn.transition=null;try{ie=4,Hu(r,e,t,n)}finally{ie=s,Jn.transition=i}}function Hu(r,e,t,n){if(ta){var s=Ac(r,e,t,n);if(s===null)Nl(r,e,n,ra,t),od(r,n);else if(d0(s,r,e,t,n))n.stopPropagation();else if(od(r,n),e&4&&-1<h0.indexOf(r)){for(;s!==null;){var i=Ei(s);if(i!==null&&up(i),i=Ac(r,e,t,n),i===null&&Nl(r,e,n,ra,t),i===s)break;s=i}s!==null&&n.stopPropagation()}else Nl(r,e,n,null,t)}}var ra=null;function Ac(r,e,t,n){if(ra=null,r=Bu(n),r=ln(r),r!==null)if(e=En(r),e===null)r=null;else if(t=e.tag,t===13){if(r=rp(e),r!==null)return r;r=null}else if(t===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;r=null}else e!==r&&(r=null);return ra=r,null}function pp(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(r0()){case zu:return 1;case op:return 4;case Zo:case n0:return 16;case ap:return 536870912;default:return 16}default:return 16}}var Fr=null,$u=null,Po=null;function mp(){if(Po)return Po;var r,e=$u,t=e.length,n,s="value"in Fr?Fr.value:Fr.textContent,i=s.length;for(r=0;r<t&&e[r]===s[r];r++);var o=t-r;for(n=1;n<=o&&e[t-n]===s[i-n];n++);return Po=s.slice(r,1<n?1-n:void 0)}function Mo(r){var e=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&e===13&&(r=13)):r=e,r===10&&(r=13),32<=r||r===13?r:0}function zi(){return!0}function ld(){return!1}function gt(r){function e(t,n,s,i,o){this._reactName=t,this._targetInst=s,this.type=n,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in r)r.hasOwnProperty(a)&&(t=r[a],this[a]=t?t(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?zi:ld,this.isPropagationStopped=ld,this}return ve(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var t=this.nativeEvent;t&&(t.preventDefault?t.preventDefault():typeof t.returnValue!="unknown"&&(t.returnValue=!1),this.isDefaultPrevented=zi)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=zi)},persist:function(){},isPersistent:zi}),e}var gs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xu=gt(gs),ki=ve({},gs,{view:0,detail:0}),m0=gt(ki),Ol,Dl,Os,Ha=ve({},ki,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Uu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Os&&(Os&&r.type==="mousemove"?(Ol=r.screenX-Os.screenX,Dl=r.screenY-Os.screenY):Dl=Ol=0,Os=r),Ol)},movementY:function(r){return"movementY"in r?r.movementY:Dl}}),cd=gt(Ha),v0=ve({},Ha,{dataTransfer:0}),y0=gt(v0),x0=ve({},ki,{relatedTarget:0}),Pl=gt(x0),w0=ve({},gs,{animationName:0,elapsedTime:0,pseudoElement:0}),S0=gt(w0),b0=ve({},gs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),_0=gt(b0),C0=ve({},gs,{data:0}),ud=gt(C0),T0={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},k0={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},E0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function O0(r){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(r):(r=E0[r])?!!e[r]:!1}function Uu(){return O0}var D0=ve({},ki,{key:function(r){if(r.key){var e=T0[r.key]||r.key;if(e!=="Unidentified")return e}return r.type==="keypress"?(r=Mo(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?k0[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Uu,charCode:function(r){return r.type==="keypress"?Mo(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Mo(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),P0=gt(D0),M0=ve({},Ha,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hd=gt(M0),j0=ve({},ki,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Uu}),R0=gt(j0),A0=ve({},gs,{propertyName:0,elapsedTime:0,pseudoElement:0}),L0=gt(A0),F0=ve({},Ha,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),N0=gt(F0),I0=[9,13,27,32],Yu=mr&&"CompositionEvent"in window,Vs=null;mr&&"documentMode"in document&&(Vs=document.documentMode);var B0=mr&&"TextEvent"in window&&!Vs,vp=mr&&(!Yu||Vs&&8<Vs&&11>=Vs),dd=" ",fd=!1;function yp(r,e){switch(r){case"keyup":return I0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xp(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Fn=!1;function z0(r,e){switch(r){case"compositionend":return xp(e);case"keypress":return e.which!==32?null:(fd=!0,dd);case"textInput":return r=e.data,r===dd&&fd?null:r;default:return null}}function W0(r,e){if(Fn)return r==="compositionend"||!Yu&&yp(r,e)?(r=mp(),Po=$u=Fr=null,Fn=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return vp&&e.locale!=="ko"?null:e.data;default:return null}}var V0={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function gd(r){var e=r&&r.nodeName&&r.nodeName.toLowerCase();return e==="input"?!!V0[r.type]:e==="textarea"}function wp(r,e,t,n){Qg(n),e=na(e,"onChange"),0<e.length&&(t=new Xu("onChange","change",null,t,n),r.push({event:t,listeners:e}))}var Hs=null,ii=null;function H0(r){Mp(r,0)}function $a(r){var e=Bn(r);if($g(e))return r}function $0(r,e){if(r==="change")return e}var Sp=!1;if(mr){var Ml;if(mr){var jl="oninput"in document;if(!jl){var pd=document.createElement("div");pd.setAttribute("oninput","return;"),jl=typeof pd.oninput=="function"}Ml=jl}else Ml=!1;Sp=Ml&&(!document.documentMode||9<document.documentMode)}function md(){Hs&&(Hs.detachEvent("onpropertychange",bp),ii=Hs=null)}function bp(r){if(r.propertyName==="value"&&$a(ii)){var e=[];wp(e,ii,r,Bu(r)),tp(H0,e)}}function X0(r,e,t){r==="focusin"?(md(),Hs=e,ii=t,Hs.attachEvent("onpropertychange",bp)):r==="focusout"&&md()}function U0(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return $a(ii)}function Y0(r,e){if(r==="click")return $a(e)}function G0(r,e){if(r==="input"||r==="change")return $a(e)}function K0(r,e){return r===e&&(r!==0||1/r===1/e)||r!==r&&e!==e}var Wt=typeof Object.is=="function"?Object.is:K0;function oi(r,e){if(Wt(r,e))return!0;if(typeof r!="object"||r===null||typeof e!="object"||e===null)return!1;var t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(n=0;n<t.length;n++){var s=t[n];if(!mc.call(e,s)||!Wt(r[s],e[s]))return!1}return!0}function vd(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function yd(r,e){var t=vd(r);r=0;for(var n;t;){if(t.nodeType===3){if(n=r+t.textContent.length,r<=e&&n>=e)return{node:t,offset:e-r};r=n}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=vd(t)}}function _p(r,e){return r&&e?r===e?!0:r&&r.nodeType===3?!1:e&&e.nodeType===3?_p(r,e.parentNode):"contains"in r?r.contains(e):r.compareDocumentPosition?!!(r.compareDocumentPosition(e)&16):!1:!1}function Cp(){for(var r=window,e=qo();e instanceof r.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)r=e.contentWindow;else break;e=qo(r.document)}return e}function Gu(r){var e=r&&r.nodeName&&r.nodeName.toLowerCase();return e&&(e==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||e==="textarea"||r.contentEditable==="true")}function q0(r){var e=Cp(),t=r.focusedElem,n=r.selectionRange;if(e!==t&&t&&t.ownerDocument&&_p(t.ownerDocument.documentElement,t)){if(n!==null&&Gu(t)){if(e=n.start,r=n.end,r===void 0&&(r=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(r,t.value.length);else if(r=(e=t.ownerDocument||document)&&e.defaultView||window,r.getSelection){r=r.getSelection();var s=t.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!r.extend&&i>n&&(s=n,n=i,i=s),s=yd(t,i);var o=yd(t,n);s&&o&&(r.rangeCount!==1||r.anchorNode!==s.node||r.anchorOffset!==s.offset||r.focusNode!==o.node||r.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),r.removeAllRanges(),i>n?(r.addRange(e),r.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),r.addRange(e)))}}for(e=[],r=t;r=r.parentNode;)r.nodeType===1&&e.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t<e.length;t++)r=e[t],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var Q0=mr&&"documentMode"in document&&11>=document.documentMode,Nn=null,Lc=null,$s=null,Fc=!1;function xd(r,e,t){var n=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Fc||Nn==null||Nn!==qo(n)||(n=Nn,"selectionStart"in n&&Gu(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),$s&&oi($s,n)||($s=n,n=na(Lc,"onSelect"),0<n.length&&(e=new Xu("onSelect","select",null,e,t),r.push({event:e,listeners:n}),e.target=Nn)))}function Wi(r,e){var t={};return t[r.toLowerCase()]=e.toLowerCase(),t["Webkit"+r]="webkit"+e,t["Moz"+r]="moz"+e,t}var In={animationend:Wi("Animation","AnimationEnd"),animationiteration:Wi("Animation","AnimationIteration"),animationstart:Wi("Animation","AnimationStart"),transitionend:Wi("Transition","TransitionEnd")},Rl={},Tp={};mr&&(Tp=document.createElement("div").style,"AnimationEvent"in window||(delete In.animationend.animation,delete In.animationiteration.animation,delete In.animationstart.animation),"TransitionEvent"in window||delete In.transitionend.transition);function Xa(r){if(Rl[r])return Rl[r];if(!In[r])return r;var e=In[r],t;for(t in e)if(e.hasOwnProperty(t)&&t in Tp)return Rl[r]=e[t];return r}var kp=Xa("animationend"),Ep=Xa("animationiteration"),Op=Xa("animationstart"),Dp=Xa("transitionend"),Pp=new Map,wd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Zr(r,e){Pp.set(r,e),kn(e,[r])}for(var Al=0;Al<wd.length;Al++){var Ll=wd[Al],J0=Ll.toLowerCase(),Z0=Ll[0].toUpperCase()+Ll.slice(1);Zr(J0,"on"+Z0)}Zr(kp,"onAnimationEnd");Zr(Ep,"onAnimationIteration");Zr(Op,"onAnimationStart");Zr("dblclick","onDoubleClick");Zr("focusin","onFocus");Zr("focusout","onBlur");Zr(Dp,"onTransitionEnd");is("onMouseEnter",["mouseout","mouseover"]);is("onMouseLeave",["mouseout","mouseover"]);is("onPointerEnter",["pointerout","pointerover"]);is("onPointerLeave",["pointerout","pointerover"]);kn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));kn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));kn("onBeforeInput",["compositionend","keypress","textInput","paste"]);kn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));kn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));kn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Is="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ex=new Set("cancel close invalid load scroll toggle".split(" ").concat(Is));function Sd(r,e,t){var n=r.type||"unknown-event";r.currentTarget=t,Jy(n,e,void 0,r),r.currentTarget=null}function Mp(r,e){e=(e&4)!==0;for(var t=0;t<r.length;t++){var n=r[t],s=n.event;n=n.listeners;e:{var i=void 0;if(e)for(var o=n.length-1;0<=o;o--){var a=n[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==i&&s.isPropagationStopped())break e;Sd(s,a,c),i=l}else for(o=0;o<n.length;o++){if(a=n[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==i&&s.isPropagationStopped())break e;Sd(s,a,c),i=l}}}if(Jo)throw r=Mc,Jo=!1,Mc=null,r}function ue(r,e){var t=e[Wc];t===void 0&&(t=e[Wc]=new Set);var n=r+"__bubble";t.has(n)||(jp(e,r,2,!1),t.add(n))}function Fl(r,e,t){var n=0;e&&(n|=4),jp(t,r,n,e)}var Vi="_reactListening"+Math.random().toString(36).slice(2);function ai(r){if(!r[Vi]){r[Vi]=!0,Bg.forEach(function(t){t!=="selectionchange"&&(ex.has(t)||Fl(t,!1,r),Fl(t,!0,r))});var e=r.nodeType===9?r:r.ownerDocument;e===null||e[Vi]||(e[Vi]=!0,Fl("selectionchange",!1,e))}}function jp(r,e,t,n){switch(pp(e)){case 1:var s=g0;break;case 4:s=p0;break;default:s=Hu}t=s.bind(null,e,t,r),s=void 0,!Pc||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),n?s!==void 0?r.addEventListener(e,t,{capture:!0,passive:s}):r.addEventListener(e,t,!0):s!==void 0?r.addEventListener(e,t,{passive:s}):r.addEventListener(e,t,!1)}function Nl(r,e,t,n,s){var i=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var o=n.tag;if(o===3||o===4){var a=n.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=n.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;o=o.return}for(;a!==null;){if(o=ln(a),o===null)return;if(l=o.tag,l===5||l===6){n=i=o;continue e}a=a.parentNode}}n=n.return}tp(function(){var c=i,u=Bu(t),h=[];e:{var d=Pp.get(r);if(d!==void 0){var f=Xu,m=r;switch(r){case"keypress":if(Mo(t)===0)break e;case"keydown":case"keyup":f=P0;break;case"focusin":m="focus",f=Pl;break;case"focusout":m="blur",f=Pl;break;case"beforeblur":case"afterblur":f=Pl;break;case"click":if(t.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=cd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=y0;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=R0;break;case kp:case Ep:case Op:f=S0;break;case Dp:f=L0;break;case"scroll":f=m0;break;case"wheel":f=N0;break;case"copy":case"cut":case"paste":f=_0;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=hd}var v=(e&4)!==0,x=!v&&r==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var p=c,y;p!==null;){y=p;var b=y.stateNode;if(y.tag===5&&b!==null&&(y=b,g!==null&&(b=ti(p,g),b!=null&&v.push(li(p,b,y)))),x)break;p=p.return}0<v.length&&(d=new f(d,m,null,t,u),h.push({event:d,listeners:v}))}}if(!(e&7)){e:{if(d=r==="mouseover"||r==="pointerover",f=r==="mouseout"||r==="pointerout",d&&t!==Oc&&(m=t.relatedTarget||t.fromElement)&&(ln(m)||m[vr]))break e;if((f||d)&&(d=u.window===u?u:(d=u.ownerDocument)?d.defaultView||d.parentWindow:window,f?(m=t.relatedTarget||t.toElement,f=c,m=m?ln(m):null,m!==null&&(x=En(m),m!==x||m.tag!==5&&m.tag!==6)&&(m=null)):(f=null,m=c),f!==m)){if(v=cd,b="onMouseLeave",g="onMouseEnter",p="mouse",(r==="pointerout"||r==="pointerover")&&(v=hd,b="onPointerLeave",g="onPointerEnter",p="pointer"),x=f==null?d:Bn(f),y=m==null?d:Bn(m),d=new v(b,p+"leave",f,t,u),d.target=x,d.relatedTarget=y,b=null,ln(u)===c&&(v=new v(g,p+"enter",m,t,u),v.target=y,v.relatedTarget=x,b=v),x=b,f&&m)t:{for(v=f,g=m,p=0,y=v;y;y=Dn(y))p++;for(y=0,b=g;b;b=Dn(b))y++;for(;0<p-y;)v=Dn(v),p--;for(;0<y-p;)g=Dn(g),y--;for(;p--;){if(v===g||g!==null&&v===g.alternate)break t;v=Dn(v),g=Dn(g)}v=null}else v=null;f!==null&&bd(h,d,f,v,!1),m!==null&&x!==null&&bd(h,x,m,v,!0)}}e:{if(d=c?Bn(c):window,f=d.nodeName&&d.nodeName.toLowerCase(),f==="select"||f==="input"&&d.type==="file")var O=$0;else if(gd(d))if(Sp)O=G0;else{O=U0;var S=X0}else(f=d.nodeName)&&f.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(O=Y0);if(O&&(O=O(r,c))){wp(h,O,t,u);break e}S&&S(r,d,c),r==="focusout"&&(S=d._wrapperState)&&S.controlled&&d.type==="number"&&_c(d,"number",d.value)}switch(S=c?Bn(c):window,r){case"focusin":(gd(S)||S.contentEditable==="true")&&(Nn=S,Lc=c,$s=null);break;case"focusout":$s=Lc=Nn=null;break;case"mousedown":Fc=!0;break;case"contextmenu":case"mouseup":case"dragend":Fc=!1,xd(h,t,u);break;case"selectionchange":if(Q0)break;case"keydown":case"keyup":xd(h,t,u)}var T;if(Yu)e:{switch(r){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Fn?yp(r,t)&&(C="onCompositionEnd"):r==="keydown"&&t.keyCode===229&&(C="onCompositionStart");C&&(vp&&t.locale!=="ko"&&(Fn||C!=="onCompositionStart"?C==="onCompositionEnd"&&Fn&&(T=mp()):(Fr=u,$u="value"in Fr?Fr.value:Fr.textContent,Fn=!0)),S=na(c,C),0<S.length&&(C=new ud(C,r,null,t,u),h.push({event:C,listeners:S}),T?C.data=T:(T=xp(t),T!==null&&(C.data=T)))),(T=B0?z0(r,t):W0(r,t))&&(c=na(c,"onBeforeInput"),0<c.length&&(u=new ud("onBeforeInput","beforeinput",null,t,u),h.push({event:u,listeners:c}),u.data=T))}Mp(h,e)})}function li(r,e,t){return{instance:r,listener:e,currentTarget:t}}function na(r,e){for(var t=e+"Capture",n=[];r!==null;){var s=r,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=ti(r,t),i!=null&&n.unshift(li(r,i,s)),i=ti(r,e),i!=null&&n.push(li(r,i,s))),r=r.return}return n}function Dn(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function bd(r,e,t,n,s){for(var i=e._reactName,o=[];t!==null&&t!==n;){var a=t,l=a.alternate,c=a.stateNode;if(l!==null&&l===n)break;a.tag===5&&c!==null&&(a=c,s?(l=ti(t,i),l!=null&&o.unshift(li(t,l,a))):s||(l=ti(t,i),l!=null&&o.push(li(t,l,a)))),t=t.return}o.length!==0&&r.push({event:e,listeners:o})}var tx=/\r\n?/g,rx=/\u0000|\uFFFD/g;function _d(r){return(typeof r=="string"?r:""+r).replace(tx,`
38
- `).replace(rx,"")}function Hi(r,e,t){if(e=_d(e),_d(r)!==e&&t)throw Error(N(425))}function sa(){}var Nc=null,Ic=null;function Bc(r,e){return r==="textarea"||r==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var zc=typeof setTimeout=="function"?setTimeout:void 0,nx=typeof clearTimeout=="function"?clearTimeout:void 0,Cd=typeof Promise=="function"?Promise:void 0,sx=typeof queueMicrotask=="function"?queueMicrotask:typeof Cd<"u"?function(r){return Cd.resolve(null).then(r).catch(ix)}:zc;function ix(r){setTimeout(function(){throw r})}function Il(r,e){var t=e,n=0;do{var s=t.nextSibling;if(r.removeChild(t),s&&s.nodeType===8)if(t=s.data,t==="/$"){if(n===0){r.removeChild(s),si(e);return}n--}else t!=="$"&&t!=="$?"&&t!=="$!"||n++;t=s}while(t);si(e)}function Hr(r){for(;r!=null;r=r.nextSibling){var e=r.nodeType;if(e===1||e===3)break;if(e===8){if(e=r.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return r}function Td(r){r=r.previousSibling;for(var e=0;r;){if(r.nodeType===8){var t=r.data;if(t==="$"||t==="$!"||t==="$?"){if(e===0)return r;e--}else t==="/$"&&e++}r=r.previousSibling}return null}var ps=Math.random().toString(36).slice(2),Xt="__reactFiber$"+ps,ci="__reactProps$"+ps,vr="__reactContainer$"+ps,Wc="__reactEvents$"+ps,ox="__reactListeners$"+ps,ax="__reactHandles$"+ps;function ln(r){var e=r[Xt];if(e)return e;for(var t=r.parentNode;t;){if(e=t[vr]||t[Xt]){if(t=e.alternate,e.child!==null||t!==null&&t.child!==null)for(r=Td(r);r!==null;){if(t=r[Xt])return t;r=Td(r)}return e}r=t,t=r.parentNode}return null}function Ei(r){return r=r[Xt]||r[vr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Bn(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(N(33))}function Ua(r){return r[ci]||null}var Vc=[],zn=-1;function en(r){return{current:r}}function he(r){0>zn||(r.current=Vc[zn],Vc[zn]=null,zn--)}function ce(r,e){zn++,Vc[zn]=r.current,r.current=e}var qr={},ze=en(qr),Ze=en(!1),yn=qr;function os(r,e){var t=r.type.contextTypes;if(!t)return qr;var n=r.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in t)s[i]=e[i];return n&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=e,r.__reactInternalMemoizedMaskedChildContext=s),s}function et(r){return r=r.childContextTypes,r!=null}function ia(){he(Ze),he(ze)}function kd(r,e,t){if(ze.current!==qr)throw Error(N(168));ce(ze,e),ce(Ze,t)}function Rp(r,e,t){var n=r.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return t;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(N(108,Xy(r)||"Unknown",s));return ve({},t,n)}function oa(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||qr,yn=ze.current,ce(ze,r),ce(Ze,Ze.current),!0}function Ed(r,e,t){var n=r.stateNode;if(!n)throw Error(N(169));t?(r=Rp(r,e,yn),n.__reactInternalMemoizedMergedChildContext=r,he(Ze),he(ze),ce(ze,r)):he(Ze),ce(Ze,t)}var or=null,Ya=!1,Bl=!1;function Ap(r){or===null?or=[r]:or.push(r)}function lx(r){Ya=!0,Ap(r)}function tn(){if(!Bl&&or!==null){Bl=!0;var r=0,e=ie;try{var t=or;for(ie=1;r<t.length;r++){var n=t[r];do n=n(!0);while(n!==null)}or=null,Ya=!1}catch(s){throw or!==null&&(or=or.slice(r+1)),ip(zu,tn),s}finally{ie=e,Bl=!1}}return null}var Wn=[],Vn=0,aa=null,la=0,vt=[],yt=0,xn=null,lr=1,cr="";function sn(r,e){Wn[Vn++]=la,Wn[Vn++]=aa,aa=r,la=e}function Lp(r,e,t){vt[yt++]=lr,vt[yt++]=cr,vt[yt++]=xn,xn=r;var n=lr;r=cr;var s=32-It(n)-1;n&=~(1<<s),t+=1;var i=32-It(e)+s;if(30<i){var o=s-s%5;i=(n&(1<<o)-1).toString(32),n>>=o,s-=o,lr=1<<32-It(e)+s|t<<s|n,cr=i+r}else lr=1<<i|t<<s|n,cr=r}function Ku(r){r.return!==null&&(sn(r,1),Lp(r,1,0))}function qu(r){for(;r===aa;)aa=Wn[--Vn],Wn[Vn]=null,la=Wn[--Vn],Wn[Vn]=null;for(;r===xn;)xn=vt[--yt],vt[yt]=null,cr=vt[--yt],vt[yt]=null,lr=vt[--yt],vt[yt]=null}var ut=null,ct=null,fe=!1,Rt=null;function Fp(r,e){var t=wt(5,null,null,0);t.elementType="DELETED",t.stateNode=e,t.return=r,e=r.deletions,e===null?(r.deletions=[t],r.flags|=16):e.push(t)}function Od(r,e){switch(r.tag){case 5:var t=r.type;return e=e.nodeType!==1||t.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(r.stateNode=e,ut=r,ct=Hr(e.firstChild),!0):!1;case 6:return e=r.pendingProps===""||e.nodeType!==3?null:e,e!==null?(r.stateNode=e,ut=r,ct=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(t=xn!==null?{id:lr,overflow:cr}:null,r.memoizedState={dehydrated:e,treeContext:t,retryLane:1073741824},t=wt(18,null,null,0),t.stateNode=e,t.return=r,r.child=t,ut=r,ct=null,!0):!1;default:return!1}}function Hc(r){return(r.mode&1)!==0&&(r.flags&128)===0}function $c(r){if(fe){var e=ct;if(e){var t=e;if(!Od(r,e)){if(Hc(r))throw Error(N(418));e=Hr(t.nextSibling);var n=ut;e&&Od(r,e)?Fp(n,t):(r.flags=r.flags&-4097|2,fe=!1,ut=r)}}else{if(Hc(r))throw Error(N(418));r.flags=r.flags&-4097|2,fe=!1,ut=r}}}function Dd(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;ut=r}function $i(r){if(r!==ut)return!1;if(!fe)return Dd(r),fe=!0,!1;var e;if((e=r.tag!==3)&&!(e=r.tag!==5)&&(e=r.type,e=e!=="head"&&e!=="body"&&!Bc(r.type,r.memoizedProps)),e&&(e=ct)){if(Hc(r))throw Np(),Error(N(418));for(;e;)Fp(r,e),e=Hr(e.nextSibling)}if(Dd(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(N(317));e:{for(r=r.nextSibling,e=0;r;){if(r.nodeType===8){var t=r.data;if(t==="/$"){if(e===0){ct=Hr(r.nextSibling);break e}e--}else t!=="$"&&t!=="$!"&&t!=="$?"||e++}r=r.nextSibling}ct=null}}else ct=ut?Hr(r.stateNode.nextSibling):null;return!0}function Np(){for(var r=ct;r;)r=Hr(r.nextSibling)}function as(){ct=ut=null,fe=!1}function Qu(r){Rt===null?Rt=[r]:Rt.push(r)}var cx=Tr.ReactCurrentBatchConfig;function Ds(r,e,t){if(r=t.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(t._owner){if(t=t._owner,t){if(t.tag!==1)throw Error(N(309));var n=t.stateNode}if(!n)throw Error(N(147,r));var s=n,i=""+r;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},e._stringRef=i,e)}if(typeof r!="string")throw Error(N(284));if(!t._owner)throw Error(N(290,r))}return r}function Xi(r,e){throw r=Object.prototype.toString.call(e),Error(N(31,r==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":r))}function Pd(r){var e=r._init;return e(r._payload)}function Ip(r){function e(g,p){if(r){var y=g.deletions;y===null?(g.deletions=[p],g.flags|=16):y.push(p)}}function t(g,p){if(!r)return null;for(;p!==null;)e(g,p),p=p.sibling;return null}function n(g,p){for(g=new Map;p!==null;)p.key!==null?g.set(p.key,p):g.set(p.index,p),p=p.sibling;return g}function s(g,p){return g=Yr(g,p),g.index=0,g.sibling=null,g}function i(g,p,y){return g.index=y,r?(y=g.alternate,y!==null?(y=y.index,y<p?(g.flags|=2,p):y):(g.flags|=2,p)):(g.flags|=1048576,p)}function o(g){return r&&g.alternate===null&&(g.flags|=2),g}function a(g,p,y,b){return p===null||p.tag!==6?(p=Ul(y,g.mode,b),p.return=g,p):(p=s(p,y),p.return=g,p)}function l(g,p,y,b){var O=y.type;return O===Ln?u(g,p,y.props.children,b,y.key):p!==null&&(p.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===Mr&&Pd(O)===p.type)?(b=s(p,y.props),b.ref=Ds(g,p,y),b.return=g,b):(b=Io(y.type,y.key,y.props,null,g.mode,b),b.ref=Ds(g,p,y),b.return=g,b)}function c(g,p,y,b){return p===null||p.tag!==4||p.stateNode.containerInfo!==y.containerInfo||p.stateNode.implementation!==y.implementation?(p=Yl(y,g.mode,b),p.return=g,p):(p=s(p,y.children||[]),p.return=g,p)}function u(g,p,y,b,O){return p===null||p.tag!==7?(p=gn(y,g.mode,b,O),p.return=g,p):(p=s(p,y),p.return=g,p)}function h(g,p,y){if(typeof p=="string"&&p!==""||typeof p=="number")return p=Ul(""+p,g.mode,y),p.return=g,p;if(typeof p=="object"&&p!==null){switch(p.$$typeof){case Ai:return y=Io(p.type,p.key,p.props,null,g.mode,y),y.ref=Ds(g,null,p),y.return=g,y;case An:return p=Yl(p,g.mode,y),p.return=g,p;case Mr:var b=p._init;return h(g,b(p._payload),y)}if(Fs(p)||Cs(p))return p=gn(p,g.mode,y,null),p.return=g,p;Xi(g,p)}return null}function d(g,p,y,b){var O=p!==null?p.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return O!==null?null:a(g,p,""+y,b);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Ai:return y.key===O?l(g,p,y,b):null;case An:return y.key===O?c(g,p,y,b):null;case Mr:return O=y._init,d(g,p,O(y._payload),b)}if(Fs(y)||Cs(y))return O!==null?null:u(g,p,y,b,null);Xi(g,y)}return null}function f(g,p,y,b,O){if(typeof b=="string"&&b!==""||typeof b=="number")return g=g.get(y)||null,a(p,g,""+b,O);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Ai:return g=g.get(b.key===null?y:b.key)||null,l(p,g,b,O);case An:return g=g.get(b.key===null?y:b.key)||null,c(p,g,b,O);case Mr:var S=b._init;return f(g,p,y,S(b._payload),O)}if(Fs(b)||Cs(b))return g=g.get(y)||null,u(p,g,b,O,null);Xi(p,b)}return null}function m(g,p,y,b){for(var O=null,S=null,T=p,C=p=0,P=null;T!==null&&C<y.length;C++){T.index>C?(P=T,T=null):P=T.sibling;var j=d(g,T,y[C],b);if(j===null){T===null&&(T=P);break}r&&T&&j.alternate===null&&e(g,T),p=i(j,p,C),S===null?O=j:S.sibling=j,S=j,T=P}if(C===y.length)return t(g,T),fe&&sn(g,C),O;if(T===null){for(;C<y.length;C++)T=h(g,y[C],b),T!==null&&(p=i(T,p,C),S===null?O=T:S.sibling=T,S=T);return fe&&sn(g,C),O}for(T=n(g,T);C<y.length;C++)P=f(T,g,C,y[C],b),P!==null&&(r&&P.alternate!==null&&T.delete(P.key===null?C:P.key),p=i(P,p,C),S===null?O=P:S.sibling=P,S=P);return r&&T.forEach(function(R){return e(g,R)}),fe&&sn(g,C),O}function v(g,p,y,b){var O=Cs(y);if(typeof O!="function")throw Error(N(150));if(y=O.call(y),y==null)throw Error(N(151));for(var S=O=null,T=p,C=p=0,P=null,j=y.next();T!==null&&!j.done;C++,j=y.next()){T.index>C?(P=T,T=null):P=T.sibling;var R=d(g,T,j.value,b);if(R===null){T===null&&(T=P);break}r&&T&&R.alternate===null&&e(g,T),p=i(R,p,C),S===null?O=R:S.sibling=R,S=R,T=P}if(j.done)return t(g,T),fe&&sn(g,C),O;if(T===null){for(;!j.done;C++,j=y.next())j=h(g,j.value,b),j!==null&&(p=i(j,p,C),S===null?O=j:S.sibling=j,S=j);return fe&&sn(g,C),O}for(T=n(g,T);!j.done;C++,j=y.next())j=f(T,g,C,j.value,b),j!==null&&(r&&j.alternate!==null&&T.delete(j.key===null?C:j.key),p=i(j,p,C),S===null?O=j:S.sibling=j,S=j);return r&&T.forEach(function(I){return e(g,I)}),fe&&sn(g,C),O}function x(g,p,y,b){if(typeof y=="object"&&y!==null&&y.type===Ln&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Ai:e:{for(var O=y.key,S=p;S!==null;){if(S.key===O){if(O=y.type,O===Ln){if(S.tag===7){t(g,S.sibling),p=s(S,y.props.children),p.return=g,g=p;break e}}else if(S.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===Mr&&Pd(O)===S.type){t(g,S.sibling),p=s(S,y.props),p.ref=Ds(g,S,y),p.return=g,g=p;break e}t(g,S);break}else e(g,S);S=S.sibling}y.type===Ln?(p=gn(y.props.children,g.mode,b,y.key),p.return=g,g=p):(b=Io(y.type,y.key,y.props,null,g.mode,b),b.ref=Ds(g,p,y),b.return=g,g=b)}return o(g);case An:e:{for(S=y.key;p!==null;){if(p.key===S)if(p.tag===4&&p.stateNode.containerInfo===y.containerInfo&&p.stateNode.implementation===y.implementation){t(g,p.sibling),p=s(p,y.children||[]),p.return=g,g=p;break e}else{t(g,p);break}else e(g,p);p=p.sibling}p=Yl(y,g.mode,b),p.return=g,g=p}return o(g);case Mr:return S=y._init,x(g,p,S(y._payload),b)}if(Fs(y))return m(g,p,y,b);if(Cs(y))return v(g,p,y,b);Xi(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,p!==null&&p.tag===6?(t(g,p.sibling),p=s(p,y),p.return=g,g=p):(t(g,p),p=Ul(y,g.mode,b),p.return=g,g=p),o(g)):t(g,p)}return x}var ls=Ip(!0),Bp=Ip(!1),ca=en(null),ua=null,Hn=null,Ju=null;function Zu(){Ju=Hn=ua=null}function eh(r){var e=ca.current;he(ca),r._currentValue=e}function Xc(r,e,t){for(;r!==null;){var n=r.alternate;if((r.childLanes&e)!==e?(r.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),r===t)break;r=r.return}}function Zn(r,e){ua=r,Ju=Hn=null,r=r.dependencies,r!==null&&r.firstContext!==null&&(r.lanes&e&&(Je=!0),r.firstContext=null)}function bt(r){var e=r._currentValue;if(Ju!==r)if(r={context:r,memoizedValue:e,next:null},Hn===null){if(ua===null)throw Error(N(308));Hn=r,ua.dependencies={lanes:0,firstContext:r}}else Hn=Hn.next=r;return e}var cn=null;function th(r){cn===null?cn=[r]:cn.push(r)}function zp(r,e,t,n){var s=e.interleaved;return s===null?(t.next=t,th(e)):(t.next=s.next,s.next=t),e.interleaved=t,yr(r,n)}function yr(r,e){r.lanes|=e;var t=r.alternate;for(t!==null&&(t.lanes|=e),t=r,r=r.return;r!==null;)r.childLanes|=e,t=r.alternate,t!==null&&(t.childLanes|=e),t=r,r=r.return;return t.tag===3?t.stateNode:null}var jr=!1;function rh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Wp(r,e){r=r.updateQueue,e.updateQueue===r&&(e.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,e){return{eventTime:r,lane:e,tag:0,payload:null,callback:null,next:null}}function $r(r,e,t){var n=r.updateQueue;if(n===null)return null;if(n=n.shared,te&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,yr(r,t)}return s=n.interleaved,s===null?(e.next=e,th(n)):(e.next=s.next,s.next=e),n.interleaved=e,yr(r,t)}function jo(r,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194240)!==0)){var n=e.lanes;n&=r.pendingLanes,t|=n,e.lanes=t,Wu(r,t)}}function Md(r,e){var t=r.updateQueue,n=r.alternate;if(n!==null&&(n=n.updateQueue,t===n)){var s=null,i=null;if(t=t.firstBaseUpdate,t!==null){do{var o={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};i===null?s=i=o:i=i.next=o,t=t.next}while(t!==null);i===null?s=i=e:i=i.next=e}else s=i=e;t={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},r.updateQueue=t;return}r=t.lastBaseUpdate,r===null?t.firstBaseUpdate=e:r.next=e,t.lastBaseUpdate=e}function ha(r,e,t,n){var s=r.updateQueue;jr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?i=c:o.next=c,o=l;var u=r.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(i!==null){var h=s.baseState;o=0,u=c=l=null,a=i;do{var d=a.lane,f=a.eventTime;if((n&d)===d){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var m=r,v=a;switch(d=e,f=t,v.tag){case 1:if(m=v.payload,typeof m=="function"){h=m.call(f,h,d);break e}h=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=v.payload,d=typeof m=="function"?m.call(f,h,d):m,d==null)break e;h=ve({},h,d);break e;case 2:jr=!0}}a.callback!==null&&a.lane!==0&&(r.flags|=64,d=s.effects,d===null?s.effects=[a]:d.push(a))}else f={eventTime:f,lane:d,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=f,l=h):u=u.next=f,o|=d;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;d=a,a=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(u===null&&(l=h),s.baseState=l,s.firstBaseUpdate=c,s.lastBaseUpdate=u,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);Sn|=o,r.lanes=o,r.memoizedState=h}}function jd(r,e,t){if(r=e.effects,e.effects=null,r!==null)for(e=0;e<r.length;e++){var n=r[e],s=n.callback;if(s!==null){if(n.callback=null,n=t,typeof s!="function")throw Error(N(191,s));s.call(n)}}}var Oi={},qt=en(Oi),ui=en(Oi),hi=en(Oi);function un(r){if(r===Oi)throw Error(N(174));return r}function nh(r,e){switch(ce(hi,e),ce(ui,r),ce(qt,Oi),r=e.nodeType,r){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Tc(null,"");break;default:r=r===8?e.parentNode:e,e=r.namespaceURI||null,r=r.tagName,e=Tc(e,r)}he(qt),ce(qt,e)}function cs(){he(qt),he(ui),he(hi)}function Vp(r){un(hi.current);var e=un(qt.current),t=Tc(e,r.type);e!==t&&(ce(ui,r),ce(qt,t))}function sh(r){ui.current===r&&(he(qt),he(ui))}var pe=en(0);function da(r){for(var e=r;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break;for(;e.sibling===null;){if(e.return===null||e.return===r)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var zl=[];function ih(){for(var r=0;r<zl.length;r++)zl[r]._workInProgressVersionPrimary=null;zl.length=0}var Ro=Tr.ReactCurrentDispatcher,Wl=Tr.ReactCurrentBatchConfig,wn=0,me=null,Te=null,De=null,fa=!1,Xs=!1,di=0,ux=0;function Fe(){throw Error(N(321))}function oh(r,e){if(e===null)return!1;for(var t=0;t<e.length&&t<r.length;t++)if(!Wt(r[t],e[t]))return!1;return!0}function ah(r,e,t,n,s,i){if(wn=i,me=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Ro.current=r===null||r.memoizedState===null?gx:px,r=t(n,s),Xs){i=0;do{if(Xs=!1,di=0,25<=i)throw Error(N(301));i+=1,De=Te=null,e.updateQueue=null,Ro.current=mx,r=t(n,s)}while(Xs)}if(Ro.current=ga,e=Te!==null&&Te.next!==null,wn=0,De=Te=me=null,fa=!1,e)throw Error(N(300));return r}function lh(){var r=di!==0;return di=0,r}function Ht(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return De===null?me.memoizedState=De=r:De=De.next=r,De}function _t(){if(Te===null){var r=me.alternate;r=r!==null?r.memoizedState:null}else r=Te.next;var e=De===null?me.memoizedState:De.next;if(e!==null)De=e,Te=r;else{if(r===null)throw Error(N(310));Te=r,r={memoizedState:Te.memoizedState,baseState:Te.baseState,baseQueue:Te.baseQueue,queue:Te.queue,next:null},De===null?me.memoizedState=De=r:De=De.next=r}return De}function fi(r,e){return typeof e=="function"?e(r):e}function Vl(r){var e=_t(),t=e.queue;if(t===null)throw Error(N(311));t.lastRenderedReducer=r;var n=Te,s=n.baseQueue,i=t.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}n.baseQueue=s=i,t.pending=null}if(s!==null){i=s.next,n=n.baseState;var a=o=null,l=null,c=i;do{var u=c.lane;if((wn&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),n=c.hasEagerState?c.eagerState:r(n,c.action);else{var h={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=h,o=n):l=l.next=h,me.lanes|=u,Sn|=u}c=c.next}while(c!==null&&c!==i);l===null?o=n:l.next=a,Wt(n,e.memoizedState)||(Je=!0),e.memoizedState=n,e.baseState=o,e.baseQueue=l,t.lastRenderedState=n}if(r=t.interleaved,r!==null){s=r;do i=s.lane,me.lanes|=i,Sn|=i,s=s.next;while(s!==r)}else s===null&&(t.lanes=0);return[e.memoizedState,t.dispatch]}function Hl(r){var e=_t(),t=e.queue;if(t===null)throw Error(N(311));t.lastRenderedReducer=r;var n=t.dispatch,s=t.pending,i=e.memoizedState;if(s!==null){t.pending=null;var o=s=s.next;do i=r(i,o.action),o=o.next;while(o!==s);Wt(i,e.memoizedState)||(Je=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),t.lastRenderedState=i}return[i,n]}function Hp(){}function $p(r,e){var t=me,n=_t(),s=e(),i=!Wt(n.memoizedState,s);if(i&&(n.memoizedState=s,Je=!0),n=n.queue,ch(Yp.bind(null,t,n,r),[r]),n.getSnapshot!==e||i||De!==null&&De.memoizedState.tag&1){if(t.flags|=2048,gi(9,Up.bind(null,t,n,s,e),void 0,null),Me===null)throw Error(N(349));wn&30||Xp(t,e,s)}return s}function Xp(r,e,t){r.flags|=16384,r={getSnapshot:e,value:t},e=me.updateQueue,e===null?(e={lastEffect:null,stores:null},me.updateQueue=e,e.stores=[r]):(t=e.stores,t===null?e.stores=[r]:t.push(r))}function Up(r,e,t,n){e.value=t,e.getSnapshot=n,Gp(e)&&Kp(r)}function Yp(r,e,t){return t(function(){Gp(e)&&Kp(r)})}function Gp(r){var e=r.getSnapshot;r=r.value;try{var t=e();return!Wt(r,t)}catch{return!0}}function Kp(r){var e=yr(r,1);e!==null&&Bt(e,r,1,-1)}function Rd(r){var e=Ht();return typeof r=="function"&&(r=r()),e.memoizedState=e.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:fi,lastRenderedState:r},e.queue=r,r=r.dispatch=fx.bind(null,me,r),[e.memoizedState,r]}function gi(r,e,t,n){return r={tag:r,create:e,destroy:t,deps:n,next:null},e=me.updateQueue,e===null?(e={lastEffect:null,stores:null},me.updateQueue=e,e.lastEffect=r.next=r):(t=e.lastEffect,t===null?e.lastEffect=r.next=r:(n=t.next,t.next=r,r.next=n,e.lastEffect=r)),r}function qp(){return _t().memoizedState}function Ao(r,e,t,n){var s=Ht();me.flags|=r,s.memoizedState=gi(1|e,t,void 0,n===void 0?null:n)}function Ga(r,e,t,n){var s=_t();n=n===void 0?null:n;var i=void 0;if(Te!==null){var o=Te.memoizedState;if(i=o.destroy,n!==null&&oh(n,o.deps)){s.memoizedState=gi(e,t,i,n);return}}me.flags|=r,s.memoizedState=gi(1|e,t,i,n)}function Ad(r,e){return Ao(8390656,8,r,e)}function ch(r,e){return Ga(2048,8,r,e)}function Qp(r,e){return Ga(4,2,r,e)}function Jp(r,e){return Ga(4,4,r,e)}function Zp(r,e){if(typeof e=="function")return r=r(),e(r),function(){e(null)};if(e!=null)return r=r(),e.current=r,function(){e.current=null}}function em(r,e,t){return t=t!=null?t.concat([r]):null,Ga(4,4,Zp.bind(null,e,r),t)}function uh(){}function tm(r,e){var t=_t();e=e===void 0?null:e;var n=t.memoizedState;return n!==null&&e!==null&&oh(e,n[1])?n[0]:(t.memoizedState=[r,e],r)}function rm(r,e){var t=_t();e=e===void 0?null:e;var n=t.memoizedState;return n!==null&&e!==null&&oh(e,n[1])?n[0]:(r=r(),t.memoizedState=[r,e],r)}function nm(r,e,t){return wn&21?(Wt(t,e)||(t=lp(),me.lanes|=t,Sn|=t,r.baseState=!0),e):(r.baseState&&(r.baseState=!1,Je=!0),r.memoizedState=t)}function hx(r,e){var t=ie;ie=t!==0&&4>t?t:4,r(!0);var n=Wl.transition;Wl.transition={};try{r(!1),e()}finally{ie=t,Wl.transition=n}}function sm(){return _t().memoizedState}function dx(r,e,t){var n=Ur(r);if(t={lane:n,action:t,hasEagerState:!1,eagerState:null,next:null},im(r))om(e,t);else if(t=zp(r,e,t,n),t!==null){var s=$e();Bt(t,r,n,s),am(t,e,n)}}function fx(r,e,t){var n=Ur(r),s={lane:n,action:t,hasEagerState:!1,eagerState:null,next:null};if(im(r))om(e,s);else{var i=r.alternate;if(r.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,t);if(s.hasEagerState=!0,s.eagerState=a,Wt(a,o)){var l=e.interleaved;l===null?(s.next=s,th(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}t=zp(r,e,s,n),t!==null&&(s=$e(),Bt(t,r,n,s),am(t,e,n))}}function im(r){var e=r.alternate;return r===me||e!==null&&e===me}function om(r,e){Xs=fa=!0;var t=r.pending;t===null?e.next=e:(e.next=t.next,t.next=e),r.pending=e}function am(r,e,t){if(t&4194240){var n=e.lanes;n&=r.pendingLanes,t|=n,e.lanes=t,Wu(r,t)}}var ga={readContext:bt,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},gx={readContext:bt,useCallback:function(r,e){return Ht().memoizedState=[r,e===void 0?null:e],r},useContext:bt,useEffect:Ad,useImperativeHandle:function(r,e,t){return t=t!=null?t.concat([r]):null,Ao(4194308,4,Zp.bind(null,e,r),t)},useLayoutEffect:function(r,e){return Ao(4194308,4,r,e)},useInsertionEffect:function(r,e){return Ao(4,2,r,e)},useMemo:function(r,e){var t=Ht();return e=e===void 0?null:e,r=r(),t.memoizedState=[r,e],r},useReducer:function(r,e,t){var n=Ht();return e=t!==void 0?t(e):e,n.memoizedState=n.baseState=e,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:e},n.queue=r,r=r.dispatch=dx.bind(null,me,r),[n.memoizedState,r]},useRef:function(r){var e=Ht();return r={current:r},e.memoizedState=r},useState:Rd,useDebugValue:uh,useDeferredValue:function(r){return Ht().memoizedState=r},useTransition:function(){var r=Rd(!1),e=r[0];return r=hx.bind(null,r[1]),Ht().memoizedState=r,[e,r]},useMutableSource:function(){},useSyncExternalStore:function(r,e,t){var n=me,s=Ht();if(fe){if(t===void 0)throw Error(N(407));t=t()}else{if(t=e(),Me===null)throw Error(N(349));wn&30||Xp(n,e,t)}s.memoizedState=t;var i={value:t,getSnapshot:e};return s.queue=i,Ad(Yp.bind(null,n,i,r),[r]),n.flags|=2048,gi(9,Up.bind(null,n,i,t,e),void 0,null),t},useId:function(){var r=Ht(),e=Me.identifierPrefix;if(fe){var t=cr,n=lr;t=(n&~(1<<32-It(n)-1)).toString(32)+t,e=":"+e+"R"+t,t=di++,0<t&&(e+="H"+t.toString(32)),e+=":"}else t=ux++,e=":"+e+"r"+t.toString(32)+":";return r.memoizedState=e},unstable_isNewReconciler:!1},px={readContext:bt,useCallback:tm,useContext:bt,useEffect:ch,useImperativeHandle:em,useInsertionEffect:Qp,useLayoutEffect:Jp,useMemo:rm,useReducer:Vl,useRef:qp,useState:function(){return Vl(fi)},useDebugValue:uh,useDeferredValue:function(r){var e=_t();return nm(e,Te.memoizedState,r)},useTransition:function(){var r=Vl(fi)[0],e=_t().memoizedState;return[r,e]},useMutableSource:Hp,useSyncExternalStore:$p,useId:sm,unstable_isNewReconciler:!1},mx={readContext:bt,useCallback:tm,useContext:bt,useEffect:ch,useImperativeHandle:em,useInsertionEffect:Qp,useLayoutEffect:Jp,useMemo:rm,useReducer:Hl,useRef:qp,useState:function(){return Hl(fi)},useDebugValue:uh,useDeferredValue:function(r){var e=_t();return Te===null?e.memoizedState=r:nm(e,Te.memoizedState,r)},useTransition:function(){var r=Hl(fi)[0],e=_t().memoizedState;return[r,e]},useMutableSource:Hp,useSyncExternalStore:$p,useId:sm,unstable_isNewReconciler:!1};function Pt(r,e){if(r&&r.defaultProps){e=ve({},e),r=r.defaultProps;for(var t in r)e[t]===void 0&&(e[t]=r[t]);return e}return e}function Uc(r,e,t,n){e=r.memoizedState,t=t(n,e),t=t==null?e:ve({},e,t),r.memoizedState=t,r.lanes===0&&(r.updateQueue.baseState=t)}var Ka={isMounted:function(r){return(r=r._reactInternals)?En(r)===r:!1},enqueueSetState:function(r,e,t){r=r._reactInternals;var n=$e(),s=Ur(r),i=fr(n,s);i.payload=e,t!=null&&(i.callback=t),e=$r(r,i,s),e!==null&&(Bt(e,r,s,n),jo(e,r,s))},enqueueReplaceState:function(r,e,t){r=r._reactInternals;var n=$e(),s=Ur(r),i=fr(n,s);i.tag=1,i.payload=e,t!=null&&(i.callback=t),e=$r(r,i,s),e!==null&&(Bt(e,r,s,n),jo(e,r,s))},enqueueForceUpdate:function(r,e){r=r._reactInternals;var t=$e(),n=Ur(r),s=fr(t,n);s.tag=2,e!=null&&(s.callback=e),e=$r(r,s,n),e!==null&&(Bt(e,r,n,t),jo(e,r,n))}};function Ld(r,e,t,n,s,i,o){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(n,i,o):e.prototype&&e.prototype.isPureReactComponent?!oi(t,n)||!oi(s,i):!0}function lm(r,e,t){var n=!1,s=qr,i=e.contextType;return typeof i=="object"&&i!==null?i=bt(i):(s=et(e)?yn:ze.current,n=e.contextTypes,i=(n=n!=null)?os(r,s):qr),e=new e(t,i),r.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ka,r.stateNode=e,e._reactInternals=r,n&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=i),e}function Fd(r,e,t,n){r=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(t,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(t,n),e.state!==r&&Ka.enqueueReplaceState(e,e.state,null)}function Yc(r,e,t,n){var s=r.stateNode;s.props=t,s.state=r.memoizedState,s.refs={},rh(r);var i=e.contextType;typeof i=="object"&&i!==null?s.context=bt(i):(i=et(e)?yn:ze.current,s.context=os(r,i)),s.state=r.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(Uc(r,e,i,t),s.state=r.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&Ka.enqueueReplaceState(s,s.state,null),ha(r,t,s,n),s.state=r.memoizedState),typeof s.componentDidMount=="function"&&(r.flags|=4194308)}function us(r,e){try{var t="",n=e;do t+=$y(n),n=n.return;while(n);var s=t}catch(i){s=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:r,source:e,stack:s,digest:null}}function $l(r,e,t){return{value:r,source:null,stack:t??null,digest:e??null}}function Gc(r,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var vx=typeof WeakMap=="function"?WeakMap:Map;function cm(r,e,t){t=fr(-1,t),t.tag=3,t.payload={element:null};var n=e.value;return t.callback=function(){ma||(ma=!0,su=n),Gc(r,e)},t}function um(r,e,t){t=fr(-1,t),t.tag=3;var n=r.type.getDerivedStateFromError;if(typeof n=="function"){var s=e.value;t.payload=function(){return n(s)},t.callback=function(){Gc(r,e)}}var i=r.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(t.callback=function(){Gc(r,e),typeof n!="function"&&(Xr===null?Xr=new Set([this]):Xr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),t}function Nd(r,e,t){var n=r.pingCache;if(n===null){n=r.pingCache=new vx;var s=new Set;n.set(e,s)}else s=n.get(e),s===void 0&&(s=new Set,n.set(e,s));s.has(t)||(s.add(t),r=Mx.bind(null,r,e,t),e.then(r,r))}function Id(r){do{var e;if((e=r.tag===13)&&(e=r.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return r;r=r.return}while(r!==null);return null}function Bd(r,e,t,n,s){return r.mode&1?(r.flags|=65536,r.lanes=s,r):(r===e?r.flags|=65536:(r.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(e=fr(-1,1),e.tag=2,$r(t,e,1))),t.lanes|=1),r)}var yx=Tr.ReactCurrentOwner,Je=!1;function We(r,e,t,n){e.child=r===null?Bp(e,null,t,n):ls(e,r.child,t,n)}function zd(r,e,t,n,s){t=t.render;var i=e.ref;return Zn(e,s),n=ah(r,e,t,n,i,s),t=lh(),r!==null&&!Je?(e.updateQueue=r.updateQueue,e.flags&=-2053,r.lanes&=~s,xr(r,e,s)):(fe&&t&&Ku(e),e.flags|=1,We(r,e,n,s),e.child)}function Wd(r,e,t,n,s){if(r===null){var i=t.type;return typeof i=="function"&&!yh(i)&&i.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=i,hm(r,e,i,n,s)):(r=Io(t.type,null,n,e,e.mode,s),r.ref=e.ref,r.return=e,e.child=r)}if(i=r.child,!(r.lanes&s)){var o=i.memoizedProps;if(t=t.compare,t=t!==null?t:oi,t(o,n)&&r.ref===e.ref)return xr(r,e,s)}return e.flags|=1,r=Yr(i,n),r.ref=e.ref,r.return=e,e.child=r}function hm(r,e,t,n,s){if(r!==null){var i=r.memoizedProps;if(oi(i,n)&&r.ref===e.ref)if(Je=!1,e.pendingProps=n=i,(r.lanes&s)!==0)r.flags&131072&&(Je=!0);else return e.lanes=r.lanes,xr(r,e,s)}return Kc(r,e,t,n,s)}function dm(r,e,t){var n=e.pendingProps,s=n.children,i=r!==null?r.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ce(Xn,lt),lt|=t;else{if(!(t&1073741824))return r=i!==null?i.baseLanes|t:t,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:r,cachePool:null,transitions:null},e.updateQueue=null,ce(Xn,lt),lt|=r,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:t,ce(Xn,lt),lt|=n}else i!==null?(n=i.baseLanes|t,e.memoizedState=null):n=t,ce(Xn,lt),lt|=n;return We(r,e,s,t),e.child}function fm(r,e){var t=e.ref;(r===null&&t!==null||r!==null&&r.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function Kc(r,e,t,n,s){var i=et(t)?yn:ze.current;return i=os(e,i),Zn(e,s),t=ah(r,e,t,n,i,s),n=lh(),r!==null&&!Je?(e.updateQueue=r.updateQueue,e.flags&=-2053,r.lanes&=~s,xr(r,e,s)):(fe&&n&&Ku(e),e.flags|=1,We(r,e,t,s),e.child)}function Vd(r,e,t,n,s){if(et(t)){var i=!0;oa(e)}else i=!1;if(Zn(e,s),e.stateNode===null)Lo(r,e),lm(e,t,n),Yc(e,t,n,s),n=!0;else if(r===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,c=t.contextType;typeof c=="object"&&c!==null?c=bt(c):(c=et(t)?yn:ze.current,c=os(e,c));var u=t.getDerivedStateFromProps,h=typeof u=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==c)&&Fd(e,o,n,c),jr=!1;var d=e.memoizedState;o.state=d,ha(e,n,o,s),l=e.memoizedState,a!==n||d!==l||Ze.current||jr?(typeof u=="function"&&(Uc(e,t,u,n),l=e.memoizedState),(a=jr||Ld(e,t,a,n,d,l,c))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=l),o.props=n,o.state=l,o.context=c,n=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{o=e.stateNode,Wp(r,e),a=e.memoizedProps,c=e.type===e.elementType?a:Pt(e.type,a),o.props=c,h=e.pendingProps,d=o.context,l=t.contextType,typeof l=="object"&&l!==null?l=bt(l):(l=et(t)?yn:ze.current,l=os(e,l));var f=t.getDerivedStateFromProps;(u=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==h||d!==l)&&Fd(e,o,n,l),jr=!1,d=e.memoizedState,o.state=d,ha(e,n,o,s);var m=e.memoizedState;a!==h||d!==m||Ze.current||jr?(typeof f=="function"&&(Uc(e,t,f,n),m=e.memoizedState),(c=jr||Ld(e,t,c,n,d,m,l)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,m,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,m,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=m),o.props=n,o.state=m,o.context=l,n=c):(typeof o.componentDidUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===r.memoizedProps&&d===r.memoizedState||(e.flags|=1024),n=!1)}return qc(r,e,t,n,i,s)}function qc(r,e,t,n,s,i){fm(r,e);var o=(e.flags&128)!==0;if(!n&&!o)return s&&Ed(e,t,!1),xr(r,e,i);n=e.stateNode,yx.current=e;var a=o&&typeof t.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,r!==null&&o?(e.child=ls(e,r.child,null,i),e.child=ls(e,null,a,i)):We(r,e,a,i),e.memoizedState=n.state,s&&Ed(e,t,!0),e.child}function gm(r){var e=r.stateNode;e.pendingContext?kd(r,e.pendingContext,e.pendingContext!==e.context):e.context&&kd(r,e.context,!1),nh(r,e.containerInfo)}function Hd(r,e,t,n,s){return as(),Qu(s),e.flags|=256,We(r,e,t,n),e.child}var Qc={dehydrated:null,treeContext:null,retryLane:0};function Jc(r){return{baseLanes:r,cachePool:null,transitions:null}}function pm(r,e,t){var n=e.pendingProps,s=pe.current,i=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=r!==null&&r.memoizedState===null?!1:(s&2)!==0),a?(i=!0,e.flags&=-129):(r===null||r.memoizedState!==null)&&(s|=1),ce(pe,s&1),r===null)return $c(e),r=e.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?(e.mode&1?r.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=n.children,r=n.fallback,i?(n=e.mode,i=e.child,o={mode:"hidden",children:o},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ja(o,n,0,null),r=gn(r,n,t,null),i.return=e,r.return=e,i.sibling=r,e.child=i,e.child.memoizedState=Jc(t),e.memoizedState=Qc,r):hh(e,o));if(s=r.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return xx(r,e,o,n,a,s,t);if(i){i=n.fallback,o=e.mode,s=r.child,a=s.sibling;var l={mode:"hidden",children:n.children};return!(o&1)&&e.child!==s?(n=e.child,n.childLanes=0,n.pendingProps=l,e.deletions=null):(n=Yr(s,l),n.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=Yr(a,i):(i=gn(i,o,t,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,o=r.child.memoizedState,o=o===null?Jc(t):{baseLanes:o.baseLanes|t,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=r.childLanes&~t,e.memoizedState=Qc,n}return i=r.child,r=i.sibling,n=Yr(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=t),n.return=e,n.sibling=null,r!==null&&(t=e.deletions,t===null?(e.deletions=[r],e.flags|=16):t.push(r)),e.child=n,e.memoizedState=null,n}function hh(r,e){return e=Ja({mode:"visible",children:e},r.mode,0,null),e.return=r,r.child=e}function Ui(r,e,t,n){return n!==null&&Qu(n),ls(e,r.child,null,t),r=hh(e,e.pendingProps.children),r.flags|=2,e.memoizedState=null,r}function xx(r,e,t,n,s,i,o){if(t)return e.flags&256?(e.flags&=-257,n=$l(Error(N(422))),Ui(r,e,o,n)):e.memoizedState!==null?(e.child=r.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=Ja({mode:"visible",children:n.children},s,0,null),i=gn(i,s,o,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&ls(e,r.child,null,o),e.child.memoizedState=Jc(o),e.memoizedState=Qc,i);if(!(e.mode&1))return Ui(r,e,o,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var a=n.dgst;return n=a,i=Error(N(419)),n=$l(i,n,void 0),Ui(r,e,o,n)}if(a=(o&r.childLanes)!==0,Je||a){if(n=Me,n!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(n.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,yr(r,s),Bt(n,r,s,-1))}return vh(),n=$l(Error(N(421))),Ui(r,e,o,n)}return s.data==="$?"?(e.flags|=128,e.child=r.child,e=jx.bind(null,r),s._reactRetry=e,null):(r=i.treeContext,ct=Hr(s.nextSibling),ut=e,fe=!0,Rt=null,r!==null&&(vt[yt++]=lr,vt[yt++]=cr,vt[yt++]=xn,lr=r.id,cr=r.overflow,xn=e),e=hh(e,n.children),e.flags|=4096,e)}function $d(r,e,t){r.lanes|=e;var n=r.alternate;n!==null&&(n.lanes|=e),Xc(r.return,e,t)}function Xl(r,e,t,n,s){var i=r.memoizedState;i===null?r.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:t,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=t,i.tailMode=s)}function mm(r,e,t){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(We(r,e,n.children,t),n=pe.current,n&2)n=n&1|2,e.flags|=128;else{if(r!==null&&r.flags&128)e:for(r=e.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&$d(r,t,e);else if(r.tag===19)$d(r,t,e);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}n&=1}if(ce(pe,n),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(t=e.child,s=null;t!==null;)r=t.alternate,r!==null&&da(r)===null&&(s=t),t=t.sibling;t=s,t===null?(s=e.child,e.child=null):(s=t.sibling,t.sibling=null),Xl(e,!1,s,t,i);break;case"backwards":for(t=null,s=e.child,e.child=null;s!==null;){if(r=s.alternate,r!==null&&da(r)===null){e.child=s;break}r=s.sibling,s.sibling=t,t=s,s=r}Xl(e,!0,t,null,i);break;case"together":Xl(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Lo(r,e){!(e.mode&1)&&r!==null&&(r.alternate=null,e.alternate=null,e.flags|=2)}function xr(r,e,t){if(r!==null&&(e.dependencies=r.dependencies),Sn|=e.lanes,!(t&e.childLanes))return null;if(r!==null&&e.child!==r.child)throw Error(N(153));if(e.child!==null){for(r=e.child,t=Yr(r,r.pendingProps),e.child=t,t.return=e;r.sibling!==null;)r=r.sibling,t=t.sibling=Yr(r,r.pendingProps),t.return=e;t.sibling=null}return e.child}function wx(r,e,t){switch(e.tag){case 3:gm(e),as();break;case 5:Vp(e);break;case 1:et(e.type)&&oa(e);break;case 4:nh(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;ce(ca,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(ce(pe,pe.current&1),e.flags|=128,null):t&e.child.childLanes?pm(r,e,t):(ce(pe,pe.current&1),r=xr(r,e,t),r!==null?r.sibling:null);ce(pe,pe.current&1);break;case 19:if(n=(t&e.childLanes)!==0,r.flags&128){if(n)return mm(r,e,t);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),ce(pe,pe.current),n)break;return null;case 22:case 23:return e.lanes=0,dm(r,e,t)}return xr(r,e,t)}var vm,Zc,ym,xm;vm=function(r,e){for(var t=e.child;t!==null;){if(t.tag===5||t.tag===6)r.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};Zc=function(){};ym=function(r,e,t,n){var s=r.memoizedProps;if(s!==n){r=e.stateNode,un(qt.current);var i=null;switch(t){case"input":s=Sc(r,s),n=Sc(r,n),i=[];break;case"select":s=ve({},s,{value:void 0}),n=ve({},n,{value:void 0}),i=[];break;case"textarea":s=Cc(r,s),n=Cc(r,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(r.onclick=sa)}kc(t,n);var o;t=null;for(c in s)if(!n.hasOwnProperty(c)&&s.hasOwnProperty(c)&&s[c]!=null)if(c==="style"){var a=s[c];for(o in a)a.hasOwnProperty(o)&&(t||(t={}),t[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Zs.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in n){var l=n[c];if(a=s!=null?s[c]:void 0,n.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(t||(t={}),t[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(t||(t={}),t[o]=l[o])}else t||(i||(i=[]),i.push(c,t)),t=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Zs.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&ue("scroll",r),i||a===l||(i=[])):(i=i||[]).push(c,l))}t&&(i=i||[]).push("style",t);var c=i;(e.updateQueue=c)&&(e.flags|=4)}};xm=function(r,e,t,n){t!==n&&(e.flags|=4)};function Ps(r,e){if(!fe)switch(r.tailMode){case"hidden":e=r.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?r.tail=null:t.sibling=null;break;case"collapsed":t=r.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e||r.tail===null?r.tail=null:r.tail.sibling=null:n.sibling=null}}function Ne(r){var e=r.alternate!==null&&r.alternate.child===r.child,t=0,n=0;if(e)for(var s=r.child;s!==null;)t|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=r,s=s.sibling;else for(s=r.child;s!==null;)t|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=r,s=s.sibling;return r.subtreeFlags|=n,r.childLanes=t,e}function Sx(r,e,t){var n=e.pendingProps;switch(qu(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ne(e),null;case 1:return et(e.type)&&ia(),Ne(e),null;case 3:return n=e.stateNode,cs(),he(Ze),he(ze),ih(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(r===null||r.child===null)&&($i(e)?e.flags|=4:r===null||r.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Rt!==null&&(au(Rt),Rt=null))),Zc(r,e),Ne(e),null;case 5:sh(e);var s=un(hi.current);if(t=e.type,r!==null&&e.stateNode!=null)ym(r,e,t,n,s),r.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(N(166));return Ne(e),null}if(r=un(qt.current),$i(e)){n=e.stateNode,t=e.type;var i=e.memoizedProps;switch(n[Xt]=e,n[ci]=i,r=(e.mode&1)!==0,t){case"dialog":ue("cancel",n),ue("close",n);break;case"iframe":case"object":case"embed":ue("load",n);break;case"video":case"audio":for(s=0;s<Is.length;s++)ue(Is[s],n);break;case"source":ue("error",n);break;case"img":case"image":case"link":ue("error",n),ue("load",n);break;case"details":ue("toggle",n);break;case"input":Zh(n,i),ue("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},ue("invalid",n);break;case"textarea":td(n,i),ue("invalid",n)}kc(t,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?n.textContent!==a&&(i.suppressHydrationWarning!==!0&&Hi(n.textContent,a,r),s=["children",a]):typeof a=="number"&&n.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&Hi(n.textContent,a,r),s=["children",""+a]):Zs.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&ue("scroll",n)}switch(t){case"input":Li(n),ed(n,i,!0);break;case"textarea":Li(n),rd(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=sa)}n=s,e.updateQueue=n,n!==null&&(e.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Yg(t)),r==="http://www.w3.org/1999/xhtml"?t==="script"?(r=o.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof n.is=="string"?r=o.createElement(t,{is:n.is}):(r=o.createElement(t),t==="select"&&(o=r,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):r=o.createElementNS(r,t),r[Xt]=e,r[ci]=n,vm(r,e,!1,!1),e.stateNode=r;e:{switch(o=Ec(t,n),t){case"dialog":ue("cancel",r),ue("close",r),s=n;break;case"iframe":case"object":case"embed":ue("load",r),s=n;break;case"video":case"audio":for(s=0;s<Is.length;s++)ue(Is[s],r);s=n;break;case"source":ue("error",r),s=n;break;case"img":case"image":case"link":ue("error",r),ue("load",r),s=n;break;case"details":ue("toggle",r),s=n;break;case"input":Zh(r,n),s=Sc(r,n),ue("invalid",r);break;case"option":s=n;break;case"select":r._wrapperState={wasMultiple:!!n.multiple},s=ve({},n,{value:void 0}),ue("invalid",r);break;case"textarea":td(r,n),s=Cc(r,n),ue("invalid",r);break;default:s=n}kc(t,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?qg(r,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&Gg(r,l)):i==="children"?typeof l=="string"?(t!=="textarea"||l!=="")&&ei(r,l):typeof l=="number"&&ei(r,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Zs.hasOwnProperty(i)?l!=null&&i==="onScroll"&&ue("scroll",r):l!=null&&Lu(r,i,l,o))}switch(t){case"input":Li(r),ed(r,n,!1);break;case"textarea":Li(r),rd(r);break;case"option":n.value!=null&&r.setAttribute("value",""+Kr(n.value));break;case"select":r.multiple=!!n.multiple,i=n.value,i!=null?Kn(r,!!n.multiple,i,!1):n.defaultValue!=null&&Kn(r,!!n.multiple,n.defaultValue,!0);break;default:typeof s.onClick=="function"&&(r.onclick=sa)}switch(t){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Ne(e),null;case 6:if(r&&e.stateNode!=null)xm(r,e,r.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(N(166));if(t=un(hi.current),un(qt.current),$i(e)){if(n=e.stateNode,t=e.memoizedProps,n[Xt]=e,(i=n.nodeValue!==t)&&(r=ut,r!==null))switch(r.tag){case 3:Hi(n.nodeValue,t,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Hi(n.nodeValue,t,(r.mode&1)!==0)}i&&(e.flags|=4)}else n=(t.nodeType===9?t:t.ownerDocument).createTextNode(n),n[Xt]=e,e.stateNode=n}return Ne(e),null;case 13:if(he(pe),n=e.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(fe&&ct!==null&&e.mode&1&&!(e.flags&128))Np(),as(),e.flags|=98560,i=!1;else if(i=$i(e),n!==null&&n.dehydrated!==null){if(r===null){if(!i)throw Error(N(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(N(317));i[Xt]=e}else as(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Ne(e),i=!1}else Rt!==null&&(au(Rt),Rt=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=t,e):(n=n!==null,n!==(r!==null&&r.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(r===null||pe.current&1?ke===0&&(ke=3):vh())),e.updateQueue!==null&&(e.flags|=4),Ne(e),null);case 4:return cs(),Zc(r,e),r===null&&ai(e.stateNode.containerInfo),Ne(e),null;case 10:return eh(e.type._context),Ne(e),null;case 17:return et(e.type)&&ia(),Ne(e),null;case 19:if(he(pe),i=e.memoizedState,i===null)return Ne(e),null;if(n=(e.flags&128)!==0,o=i.rendering,o===null)if(n)Ps(i,!1);else{if(ke!==0||r!==null&&r.flags&128)for(r=e.child;r!==null;){if(o=da(r),o!==null){for(e.flags|=128,Ps(i,!1),n=o.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=t,t=e.child;t!==null;)i=t,r=n,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,r=o.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t=t.sibling;return ce(pe,pe.current&1|2),e.child}r=r.sibling}i.tail!==null&&we()>hs&&(e.flags|=128,n=!0,Ps(i,!1),e.lanes=4194304)}else{if(!n)if(r=da(o),r!==null){if(e.flags|=128,n=!0,t=r.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ps(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!fe)return Ne(e),null}else 2*we()-i.renderingStartTime>hs&&t!==1073741824&&(e.flags|=128,n=!0,Ps(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(t=i.last,t!==null?t.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=we(),e.sibling=null,t=pe.current,ce(pe,n?t&1|2:t&1),e):(Ne(e),null);case 22:case 23:return mh(),n=e.memoizedState!==null,r!==null&&r.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?lt&1073741824&&(Ne(e),e.subtreeFlags&6&&(e.flags|=8192)):Ne(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function bx(r,e){switch(qu(e),e.tag){case 1:return et(e.type)&&ia(),r=e.flags,r&65536?(e.flags=r&-65537|128,e):null;case 3:return cs(),he(Ze),he(ze),ih(),r=e.flags,r&65536&&!(r&128)?(e.flags=r&-65537|128,e):null;case 5:return sh(e),null;case 13:if(he(pe),r=e.memoizedState,r!==null&&r.dehydrated!==null){if(e.alternate===null)throw Error(N(340));as()}return r=e.flags,r&65536?(e.flags=r&-65537|128,e):null;case 19:return he(pe),null;case 4:return cs(),null;case 10:return eh(e.type._context),null;case 22:case 23:return mh(),null;case 24:return null;default:return null}}var Yi=!1,Ie=!1,_x=typeof WeakSet=="function"?WeakSet:Set,$=null;function $n(r,e){var t=r.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(n){ye(r,e,n)}else t.current=null}function eu(r,e,t){try{t()}catch(n){ye(r,e,n)}}var Xd=!1;function Cx(r,e){if(Nc=ta,r=Cp(),Gu(r)){if("selectionStart"in r)var t={start:r.selectionStart,end:r.selectionEnd};else e:{t=(t=r.ownerDocument)&&t.defaultView||window;var n=t.getSelection&&t.getSelection();if(n&&n.rangeCount!==0){t=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{t.nodeType,i.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,u=0,h=r,d=null;t:for(;;){for(var f;h!==t||s!==0&&h.nodeType!==3||(a=o+s),h!==i||n!==0&&h.nodeType!==3||(l=o+n),h.nodeType===3&&(o+=h.nodeValue.length),(f=h.firstChild)!==null;)d=h,h=f;for(;;){if(h===r)break t;if(d===t&&++c===s&&(a=o),d===i&&++u===n&&(l=o),(f=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=f}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(Ic={focusedElem:r,selectionRange:t},ta=!1,$=e;$!==null;)if(e=$,r=e.child,(e.subtreeFlags&1028)!==0&&r!==null)r.return=e,$=r;else for(;$!==null;){e=$;try{var m=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,x=m.memoizedState,g=e.stateNode,p=g.getSnapshotBeforeUpdate(e.elementType===e.type?v:Pt(e.type,v),x);g.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var y=e.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(b){ye(e,e.return,b)}if(r=e.sibling,r!==null){r.return=e.return,$=r;break}$=e.return}return m=Xd,Xd=!1,m}function Us(r,e,t){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&r)===r){var i=s.destroy;s.destroy=void 0,i!==void 0&&eu(e,t,i)}s=s.next}while(s!==n)}}function qa(r,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&r)===r){var n=t.create;t.destroy=n()}t=t.next}while(t!==e)}}function tu(r){var e=r.ref;if(e!==null){var t=r.stateNode;switch(r.tag){case 5:r=t;break;default:r=t}typeof e=="function"?e(r):e.current=r}}function wm(r){var e=r.alternate;e!==null&&(r.alternate=null,wm(e)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(e=r.stateNode,e!==null&&(delete e[Xt],delete e[ci],delete e[Wc],delete e[ox],delete e[ax])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Sm(r){return r.tag===5||r.tag===3||r.tag===4}function Ud(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Sm(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function ru(r,e,t){var n=r.tag;if(n===5||n===6)r=r.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(r,e):t.insertBefore(r,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(r,t)):(e=t,e.appendChild(r)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=sa));else if(n!==4&&(r=r.child,r!==null))for(ru(r,e,t),r=r.sibling;r!==null;)ru(r,e,t),r=r.sibling}function nu(r,e,t){var n=r.tag;if(n===5||n===6)r=r.stateNode,e?t.insertBefore(r,e):t.appendChild(r);else if(n!==4&&(r=r.child,r!==null))for(nu(r,e,t),r=r.sibling;r!==null;)nu(r,e,t),r=r.sibling}var je=null,Mt=!1;function Or(r,e,t){for(t=t.child;t!==null;)bm(r,e,t),t=t.sibling}function bm(r,e,t){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Va,t)}catch{}switch(t.tag){case 5:Ie||$n(t,e);case 6:var n=je,s=Mt;je=null,Or(r,e,t),je=n,Mt=s,je!==null&&(Mt?(r=je,t=t.stateNode,r.nodeType===8?r.parentNode.removeChild(t):r.removeChild(t)):je.removeChild(t.stateNode));break;case 18:je!==null&&(Mt?(r=je,t=t.stateNode,r.nodeType===8?Il(r.parentNode,t):r.nodeType===1&&Il(r,t),si(r)):Il(je,t.stateNode));break;case 4:n=je,s=Mt,je=t.stateNode.containerInfo,Mt=!0,Or(r,e,t),je=n,Mt=s;break;case 0:case 11:case 14:case 15:if(!Ie&&(n=t.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&eu(t,e,o),s=s.next}while(s!==n)}Or(r,e,t);break;case 1:if(!Ie&&($n(t,e),n=t.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=t.memoizedProps,n.state=t.memoizedState,n.componentWillUnmount()}catch(a){ye(t,e,a)}Or(r,e,t);break;case 21:Or(r,e,t);break;case 22:t.mode&1?(Ie=(n=Ie)||t.memoizedState!==null,Or(r,e,t),Ie=n):Or(r,e,t);break;default:Or(r,e,t)}}function Yd(r){var e=r.updateQueue;if(e!==null){r.updateQueue=null;var t=r.stateNode;t===null&&(t=r.stateNode=new _x),e.forEach(function(n){var s=Rx.bind(null,r,n);t.has(n)||(t.add(n),n.then(s,s))})}}function Et(r,e){var t=e.deletions;if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];try{var i=r,o=e,a=o;e:for(;a!==null;){switch(a.tag){case 5:je=a.stateNode,Mt=!1;break e;case 3:je=a.stateNode.containerInfo,Mt=!0;break e;case 4:je=a.stateNode.containerInfo,Mt=!0;break e}a=a.return}if(je===null)throw Error(N(160));bm(i,o,s),je=null,Mt=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(c){ye(s,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)_m(e,r),e=e.sibling}function _m(r,e){var t=r.alternate,n=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Et(e,r),Vt(r),n&4){try{Us(3,r,r.return),qa(3,r)}catch(v){ye(r,r.return,v)}try{Us(5,r,r.return)}catch(v){ye(r,r.return,v)}}break;case 1:Et(e,r),Vt(r),n&512&&t!==null&&$n(t,t.return);break;case 5:if(Et(e,r),Vt(r),n&512&&t!==null&&$n(t,t.return),r.flags&32){var s=r.stateNode;try{ei(s,"")}catch(v){ye(r,r.return,v)}}if(n&4&&(s=r.stateNode,s!=null)){var i=r.memoizedProps,o=t!==null?t.memoizedProps:i,a=r.type,l=r.updateQueue;if(r.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&Xg(s,i),Ec(a,o);var c=Ec(a,i);for(o=0;o<l.length;o+=2){var u=l[o],h=l[o+1];u==="style"?qg(s,h):u==="dangerouslySetInnerHTML"?Gg(s,h):u==="children"?ei(s,h):Lu(s,u,h,c)}switch(a){case"input":bc(s,i);break;case"textarea":Ug(s,i);break;case"select":var d=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var f=i.value;f!=null?Kn(s,!!i.multiple,f,!1):d!==!!i.multiple&&(i.defaultValue!=null?Kn(s,!!i.multiple,i.defaultValue,!0):Kn(s,!!i.multiple,i.multiple?[]:"",!1))}s[ci]=i}catch(v){ye(r,r.return,v)}}break;case 6:if(Et(e,r),Vt(r),n&4){if(r.stateNode===null)throw Error(N(162));s=r.stateNode,i=r.memoizedProps;try{s.nodeValue=i}catch(v){ye(r,r.return,v)}}break;case 3:if(Et(e,r),Vt(r),n&4&&t!==null&&t.memoizedState.isDehydrated)try{si(e.containerInfo)}catch(v){ye(r,r.return,v)}break;case 4:Et(e,r),Vt(r);break;case 13:Et(e,r),Vt(r),s=r.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(gh=we())),n&4&&Yd(r);break;case 22:if(u=t!==null&&t.memoizedState!==null,r.mode&1?(Ie=(c=Ie)||u,Et(e,r),Ie=c):Et(e,r),Vt(r),n&8192){if(c=r.memoizedState!==null,(r.stateNode.isHidden=c)&&!u&&r.mode&1)for($=r,u=r.child;u!==null;){for(h=$=u;$!==null;){switch(d=$,f=d.child,d.tag){case 0:case 11:case 14:case 15:Us(4,d,d.return);break;case 1:$n(d,d.return);var m=d.stateNode;if(typeof m.componentWillUnmount=="function"){n=d,t=d.return;try{e=n,m.props=e.memoizedProps,m.state=e.memoizedState,m.componentWillUnmount()}catch(v){ye(n,t,v)}}break;case 5:$n(d,d.return);break;case 22:if(d.memoizedState!==null){Kd(h);continue}}f!==null?(f.return=d,$=f):Kd(h)}u=u.sibling}e:for(u=null,h=r;;){if(h.tag===5){if(u===null){u=h;try{s=h.stateNode,c?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=h.stateNode,l=h.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=Kg("display",o))}catch(v){ye(r,r.return,v)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(v){ye(r,r.return,v)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===r)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===r)break e;for(;h.sibling===null;){if(h.return===null||h.return===r)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Et(e,r),Vt(r),n&4&&Yd(r);break;case 21:break;default:Et(e,r),Vt(r)}}function Vt(r){var e=r.flags;if(e&2){try{e:{for(var t=r.return;t!==null;){if(Sm(t)){var n=t;break e}t=t.return}throw Error(N(160))}switch(n.tag){case 5:var s=n.stateNode;n.flags&32&&(ei(s,""),n.flags&=-33);var i=Ud(r);nu(r,i,s);break;case 3:case 4:var o=n.stateNode.containerInfo,a=Ud(r);ru(r,a,o);break;default:throw Error(N(161))}}catch(l){ye(r,r.return,l)}r.flags&=-3}e&4096&&(r.flags&=-4097)}function Tx(r,e,t){$=r,Cm(r)}function Cm(r,e,t){for(var n=(r.mode&1)!==0;$!==null;){var s=$,i=s.child;if(s.tag===22&&n){var o=s.memoizedState!==null||Yi;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||Ie;a=Yi;var c=Ie;if(Yi=o,(Ie=l)&&!c)for($=s;$!==null;)o=$,l=o.child,o.tag===22&&o.memoizedState!==null?qd(s):l!==null?(l.return=o,$=l):qd(s);for(;i!==null;)$=i,Cm(i),i=i.sibling;$=s,Yi=a,Ie=c}Gd(r)}else s.subtreeFlags&8772&&i!==null?(i.return=s,$=i):Gd(r)}}function Gd(r){for(;$!==null;){var e=$;if(e.flags&8772){var t=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Ie||qa(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Ie)if(t===null)n.componentDidMount();else{var s=e.elementType===e.type?t.memoizedProps:Pt(e.type,t.memoizedProps);n.componentDidUpdate(s,t.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&jd(e,i,n);break;case 3:var o=e.updateQueue;if(o!==null){if(t=null,e.child!==null)switch(e.child.tag){case 5:t=e.child.stateNode;break;case 1:t=e.child.stateNode}jd(e,o,t)}break;case 5:var a=e.stateNode;if(t===null&&e.flags&4){t=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&t.focus();break;case"img":l.src&&(t.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&si(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(N(163))}Ie||e.flags&512&&tu(e)}catch(d){ye(e,e.return,d)}}if(e===r){$=null;break}if(t=e.sibling,t!==null){t.return=e.return,$=t;break}$=e.return}}function Kd(r){for(;$!==null;){var e=$;if(e===r){$=null;break}var t=e.sibling;if(t!==null){t.return=e.return,$=t;break}$=e.return}}function qd(r){for(;$!==null;){var e=$;try{switch(e.tag){case 0:case 11:case 15:var t=e.return;try{qa(4,e)}catch(l){ye(e,t,l)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var s=e.return;try{n.componentDidMount()}catch(l){ye(e,s,l)}}var i=e.return;try{tu(e)}catch(l){ye(e,i,l)}break;case 5:var o=e.return;try{tu(e)}catch(l){ye(e,o,l)}}}catch(l){ye(e,e.return,l)}if(e===r){$=null;break}var a=e.sibling;if(a!==null){a.return=e.return,$=a;break}$=e.return}}var kx=Math.ceil,pa=Tr.ReactCurrentDispatcher,dh=Tr.ReactCurrentOwner,St=Tr.ReactCurrentBatchConfig,te=0,Me=null,Ce=null,Ae=0,lt=0,Xn=en(0),ke=0,pi=null,Sn=0,Qa=0,fh=0,Ys=null,Qe=null,gh=0,hs=1/0,sr=null,ma=!1,su=null,Xr=null,Gi=!1,Nr=null,va=0,Gs=0,iu=null,Fo=-1,No=0;function $e(){return te&6?we():Fo!==-1?Fo:Fo=we()}function Ur(r){return r.mode&1?te&2&&Ae!==0?Ae&-Ae:cx.transition!==null?(No===0&&(No=lp()),No):(r=ie,r!==0||(r=window.event,r=r===void 0?16:pp(r.type)),r):1}function Bt(r,e,t,n){if(50<Gs)throw Gs=0,iu=null,Error(N(185));Ti(r,t,n),(!(te&2)||r!==Me)&&(r===Me&&(!(te&2)&&(Qa|=t),ke===4&&Ar(r,Ae)),tt(r,n),t===1&&te===0&&!(e.mode&1)&&(hs=we()+500,Ya&&tn()))}function tt(r,e){var t=r.callbackNode;c0(r,e);var n=ea(r,r===Me?Ae:0);if(n===0)t!==null&&id(t),r.callbackNode=null,r.callbackPriority=0;else if(e=n&-n,r.callbackPriority!==e){if(t!=null&&id(t),e===1)r.tag===0?lx(Qd.bind(null,r)):Ap(Qd.bind(null,r)),sx(function(){!(te&6)&&tn()}),t=null;else{switch(cp(n)){case 1:t=zu;break;case 4:t=op;break;case 16:t=Zo;break;case 536870912:t=ap;break;default:t=Zo}t=jm(t,Tm.bind(null,r))}r.callbackPriority=e,r.callbackNode=t}}function Tm(r,e){if(Fo=-1,No=0,te&6)throw Error(N(327));var t=r.callbackNode;if(es()&&r.callbackNode!==t)return null;var n=ea(r,r===Me?Ae:0);if(n===0)return null;if(n&30||n&r.expiredLanes||e)e=ya(r,n);else{e=n;var s=te;te|=2;var i=Em();(Me!==r||Ae!==e)&&(sr=null,hs=we()+500,fn(r,e));do try{Dx();break}catch(a){km(r,a)}while(!0);Zu(),pa.current=i,te=s,Ce!==null?e=0:(Me=null,Ae=0,e=ke)}if(e!==0){if(e===2&&(s=jc(r),s!==0&&(n=s,e=ou(r,s))),e===1)throw t=pi,fn(r,0),Ar(r,n),tt(r,we()),t;if(e===6)Ar(r,n);else{if(s=r.current.alternate,!(n&30)&&!Ex(s)&&(e=ya(r,n),e===2&&(i=jc(r),i!==0&&(n=i,e=ou(r,i))),e===1))throw t=pi,fn(r,0),Ar(r,n),tt(r,we()),t;switch(r.finishedWork=s,r.finishedLanes=n,e){case 0:case 1:throw Error(N(345));case 2:on(r,Qe,sr);break;case 3:if(Ar(r,n),(n&130023424)===n&&(e=gh+500-we(),10<e)){if(ea(r,0)!==0)break;if(s=r.suspendedLanes,(s&n)!==n){$e(),r.pingedLanes|=r.suspendedLanes&s;break}r.timeoutHandle=zc(on.bind(null,r,Qe,sr),e);break}on(r,Qe,sr);break;case 4:if(Ar(r,n),(n&4194240)===n)break;for(e=r.eventTimes,s=-1;0<n;){var o=31-It(n);i=1<<o,o=e[o],o>s&&(s=o),n&=~i}if(n=s,n=we()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*kx(n/1960))-n,10<n){r.timeoutHandle=zc(on.bind(null,r,Qe,sr),n);break}on(r,Qe,sr);break;case 5:on(r,Qe,sr);break;default:throw Error(N(329))}}}return tt(r,we()),r.callbackNode===t?Tm.bind(null,r):null}function ou(r,e){var t=Ys;return r.current.memoizedState.isDehydrated&&(fn(r,e).flags|=256),r=ya(r,e),r!==2&&(e=Qe,Qe=t,e!==null&&au(e)),r}function au(r){Qe===null?Qe=r:Qe.push.apply(Qe,r)}function Ex(r){for(var e=r;;){if(e.flags&16384){var t=e.updateQueue;if(t!==null&&(t=t.stores,t!==null))for(var n=0;n<t.length;n++){var s=t[n],i=s.getSnapshot;s=s.value;try{if(!Wt(i(),s))return!1}catch{return!1}}}if(t=e.child,e.subtreeFlags&16384&&t!==null)t.return=e,e=t;else{if(e===r)break;for(;e.sibling===null;){if(e.return===null||e.return===r)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Ar(r,e){for(e&=~fh,e&=~Qa,r.suspendedLanes|=e,r.pingedLanes&=~e,r=r.expirationTimes;0<e;){var t=31-It(e),n=1<<t;r[t]=-1,e&=~n}}function Qd(r){if(te&6)throw Error(N(327));es();var e=ea(r,0);if(!(e&1))return tt(r,we()),null;var t=ya(r,e);if(r.tag!==0&&t===2){var n=jc(r);n!==0&&(e=n,t=ou(r,n))}if(t===1)throw t=pi,fn(r,0),Ar(r,e),tt(r,we()),t;if(t===6)throw Error(N(345));return r.finishedWork=r.current.alternate,r.finishedLanes=e,on(r,Qe,sr),tt(r,we()),null}function ph(r,e){var t=te;te|=1;try{return r(e)}finally{te=t,te===0&&(hs=we()+500,Ya&&tn())}}function bn(r){Nr!==null&&Nr.tag===0&&!(te&6)&&es();var e=te;te|=1;var t=St.transition,n=ie;try{if(St.transition=null,ie=1,r)return r()}finally{ie=n,St.transition=t,te=e,!(te&6)&&tn()}}function mh(){lt=Xn.current,he(Xn)}function fn(r,e){r.finishedWork=null,r.finishedLanes=0;var t=r.timeoutHandle;if(t!==-1&&(r.timeoutHandle=-1,nx(t)),Ce!==null)for(t=Ce.return;t!==null;){var n=t;switch(qu(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&ia();break;case 3:cs(),he(Ze),he(ze),ih();break;case 5:sh(n);break;case 4:cs();break;case 13:he(pe);break;case 19:he(pe);break;case 10:eh(n.type._context);break;case 22:case 23:mh()}t=t.return}if(Me=r,Ce=r=Yr(r.current,null),Ae=lt=e,ke=0,pi=null,fh=Qa=Sn=0,Qe=Ys=null,cn!==null){for(e=0;e<cn.length;e++)if(t=cn[e],n=t.interleaved,n!==null){t.interleaved=null;var s=n.next,i=t.pending;if(i!==null){var o=i.next;i.next=s,n.next=o}t.pending=n}cn=null}return r}function km(r,e){do{var t=Ce;try{if(Zu(),Ro.current=ga,fa){for(var n=me.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}fa=!1}if(wn=0,De=Te=me=null,Xs=!1,di=0,dh.current=null,t===null||t.return===null){ke=1,pi=e,Ce=null;break}e:{var i=r,o=t.return,a=t,l=e;if(e=Ae,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var d=u.alternate;d?(u.updateQueue=d.updateQueue,u.memoizedState=d.memoizedState,u.lanes=d.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=Id(o);if(f!==null){f.flags&=-257,Bd(f,o,a,i,e),f.mode&1&&Nd(i,c,e),e=f,l=c;var m=e.updateQueue;if(m===null){var v=new Set;v.add(l),e.updateQueue=v}else m.add(l);break e}else{if(!(e&1)){Nd(i,c,e),vh();break e}l=Error(N(426))}}else if(fe&&a.mode&1){var x=Id(o);if(x!==null){!(x.flags&65536)&&(x.flags|=256),Bd(x,o,a,i,e),Qu(us(l,a));break e}}i=l=us(l,a),ke!==4&&(ke=2),Ys===null?Ys=[i]:Ys.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var g=cm(i,l,e);Md(i,g);break e;case 1:a=l;var p=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof p.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Xr===null||!Xr.has(y)))){i.flags|=65536,e&=-e,i.lanes|=e;var b=um(i,a,e);Md(i,b);break e}}i=i.return}while(i!==null)}Dm(t)}catch(O){e=O,Ce===t&&t!==null&&(Ce=t=t.return);continue}break}while(!0)}function Em(){var r=pa.current;return pa.current=ga,r===null?ga:r}function vh(){(ke===0||ke===3||ke===2)&&(ke=4),Me===null||!(Sn&268435455)&&!(Qa&268435455)||Ar(Me,Ae)}function ya(r,e){var t=te;te|=2;var n=Em();(Me!==r||Ae!==e)&&(sr=null,fn(r,e));do try{Ox();break}catch(s){km(r,s)}while(!0);if(Zu(),te=t,pa.current=n,Ce!==null)throw Error(N(261));return Me=null,Ae=0,ke}function Ox(){for(;Ce!==null;)Om(Ce)}function Dx(){for(;Ce!==null&&!e0();)Om(Ce)}function Om(r){var e=Mm(r.alternate,r,lt);r.memoizedProps=r.pendingProps,e===null?Dm(r):Ce=e,dh.current=null}function Dm(r){var e=r;do{var t=e.alternate;if(r=e.return,e.flags&32768){if(t=bx(t,e),t!==null){t.flags&=32767,Ce=t;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{ke=6,Ce=null;return}}else if(t=Sx(t,e,lt),t!==null){Ce=t;return}if(e=e.sibling,e!==null){Ce=e;return}Ce=e=r}while(e!==null);ke===0&&(ke=5)}function on(r,e,t){var n=ie,s=St.transition;try{St.transition=null,ie=1,Px(r,e,t,n)}finally{St.transition=s,ie=n}return null}function Px(r,e,t,n){do es();while(Nr!==null);if(te&6)throw Error(N(327));t=r.finishedWork;var s=r.finishedLanes;if(t===null)return null;if(r.finishedWork=null,r.finishedLanes=0,t===r.current)throw Error(N(177));r.callbackNode=null,r.callbackPriority=0;var i=t.lanes|t.childLanes;if(u0(r,i),r===Me&&(Ce=Me=null,Ae=0),!(t.subtreeFlags&2064)&&!(t.flags&2064)||Gi||(Gi=!0,jm(Zo,function(){return es(),null})),i=(t.flags&15990)!==0,t.subtreeFlags&15990||i){i=St.transition,St.transition=null;var o=ie;ie=1;var a=te;te|=4,dh.current=null,Cx(r,t),_m(t,r),q0(Ic),ta=!!Nc,Ic=Nc=null,r.current=t,Tx(t),t0(),te=a,ie=o,St.transition=i}else r.current=t;if(Gi&&(Gi=!1,Nr=r,va=s),i=r.pendingLanes,i===0&&(Xr=null),s0(t.stateNode),tt(r,we()),e!==null)for(n=r.onRecoverableError,t=0;t<e.length;t++)s=e[t],n(s.value,{componentStack:s.stack,digest:s.digest});if(ma)throw ma=!1,r=su,su=null,r;return va&1&&r.tag!==0&&es(),i=r.pendingLanes,i&1?r===iu?Gs++:(Gs=0,iu=r):Gs=0,tn(),null}function es(){if(Nr!==null){var r=cp(va),e=St.transition,t=ie;try{if(St.transition=null,ie=16>r?16:r,Nr===null)var n=!1;else{if(r=Nr,Nr=null,va=0,te&6)throw Error(N(331));var s=te;for(te|=4,$=r.current;$!==null;){var i=$,o=i.child;if($.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for($=c;$!==null;){var u=$;switch(u.tag){case 0:case 11:case 15:Us(8,u,i)}var h=u.child;if(h!==null)h.return=u,$=h;else for(;$!==null;){u=$;var d=u.sibling,f=u.return;if(wm(u),u===c){$=null;break}if(d!==null){d.return=f,$=d;break}$=f}}}var m=i.alternate;if(m!==null){var v=m.child;if(v!==null){m.child=null;do{var x=v.sibling;v.sibling=null,v=x}while(v!==null)}}$=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,$=o;else e:for(;$!==null;){if(i=$,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Us(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,$=g;break e}$=i.return}}var p=r.current;for($=p;$!==null;){o=$;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,$=y;else e:for(o=p;$!==null;){if(a=$,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:qa(9,a)}}catch(O){ye(a,a.return,O)}if(a===o){$=null;break e}var b=a.sibling;if(b!==null){b.return=a.return,$=b;break e}$=a.return}}if(te=s,tn(),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Va,r)}catch{}n=!0}return n}finally{ie=t,St.transition=e}}return!1}function Jd(r,e,t){e=us(t,e),e=cm(r,e,1),r=$r(r,e,1),e=$e(),r!==null&&(Ti(r,1,e),tt(r,e))}function ye(r,e,t){if(r.tag===3)Jd(r,r,t);else for(;e!==null;){if(e.tag===3){Jd(e,r,t);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Xr===null||!Xr.has(n))){r=us(t,r),r=um(e,r,1),e=$r(e,r,1),r=$e(),e!==null&&(Ti(e,1,r),tt(e,r));break}}e=e.return}}function Mx(r,e,t){var n=r.pingCache;n!==null&&n.delete(e),e=$e(),r.pingedLanes|=r.suspendedLanes&t,Me===r&&(Ae&t)===t&&(ke===4||ke===3&&(Ae&130023424)===Ae&&500>we()-gh?fn(r,0):fh|=t),tt(r,e)}function Pm(r,e){e===0&&(r.mode&1?(e=Ii,Ii<<=1,!(Ii&130023424)&&(Ii=4194304)):e=1);var t=$e();r=yr(r,e),r!==null&&(Ti(r,e,t),tt(r,t))}function jx(r){var e=r.memoizedState,t=0;e!==null&&(t=e.retryLane),Pm(r,t)}function Rx(r,e){var t=0;switch(r.tag){case 13:var n=r.stateNode,s=r.memoizedState;s!==null&&(t=s.retryLane);break;case 19:n=r.stateNode;break;default:throw Error(N(314))}n!==null&&n.delete(e),Pm(r,t)}var Mm;Mm=function(r,e,t){if(r!==null)if(r.memoizedProps!==e.pendingProps||Ze.current)Je=!0;else{if(!(r.lanes&t)&&!(e.flags&128))return Je=!1,wx(r,e,t);Je=!!(r.flags&131072)}else Je=!1,fe&&e.flags&1048576&&Lp(e,la,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;Lo(r,e),r=e.pendingProps;var s=os(e,ze.current);Zn(e,t),s=ah(null,e,n,r,s,t);var i=lh();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,et(n)?(i=!0,oa(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,rh(e),s.updater=Ka,e.stateNode=s,s._reactInternals=e,Yc(e,n,r,t),e=qc(null,e,n,!0,i,t)):(e.tag=0,fe&&i&&Ku(e),We(null,e,s,t),e=e.child),e;case 16:n=e.elementType;e:{switch(Lo(r,e),r=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=Lx(n),r=Pt(n,r),s){case 0:e=Kc(null,e,n,r,t);break e;case 1:e=Vd(null,e,n,r,t);break e;case 11:e=zd(null,e,n,r,t);break e;case 14:e=Wd(null,e,n,Pt(n.type,r),t);break e}throw Error(N(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Pt(n,s),Kc(r,e,n,s,t);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Pt(n,s),Vd(r,e,n,s,t);case 3:e:{if(gm(e),r===null)throw Error(N(387));n=e.pendingProps,i=e.memoizedState,s=i.element,Wp(r,e),ha(e,n,null,t);var o=e.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=us(Error(N(423)),e),e=Hd(r,e,n,t,s);break e}else if(n!==s){s=us(Error(N(424)),e),e=Hd(r,e,n,t,s);break e}else for(ct=Hr(e.stateNode.containerInfo.firstChild),ut=e,fe=!0,Rt=null,t=Bp(e,null,n,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(as(),n===s){e=xr(r,e,t);break e}We(r,e,n,t)}e=e.child}return e;case 5:return Vp(e),r===null&&$c(e),n=e.type,s=e.pendingProps,i=r!==null?r.memoizedProps:null,o=s.children,Bc(n,s)?o=null:i!==null&&Bc(n,i)&&(e.flags|=32),fm(r,e),We(r,e,o,t),e.child;case 6:return r===null&&$c(e),null;case 13:return pm(r,e,t);case 4:return nh(e,e.stateNode.containerInfo),n=e.pendingProps,r===null?e.child=ls(e,null,n,t):We(r,e,n,t),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Pt(n,s),zd(r,e,n,s,t);case 7:return We(r,e,e.pendingProps,t),e.child;case 8:return We(r,e,e.pendingProps.children,t),e.child;case 12:return We(r,e,e.pendingProps.children,t),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,ce(ca,n._currentValue),n._currentValue=o,i!==null)if(Wt(i.value,o)){if(i.children===s.children&&!Ze.current){e=xr(r,e,t);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=fr(-1,t&-t),l.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}i.lanes|=t,l=i.alternate,l!==null&&(l.lanes|=t),Xc(i.return,t,e),a.lanes|=t;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(N(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Xc(o,t,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}We(r,e,s.children,t),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,Zn(e,t),s=bt(s),n=n(s),e.flags|=1,We(r,e,n,t),e.child;case 14:return n=e.type,s=Pt(n,e.pendingProps),s=Pt(n.type,s),Wd(r,e,n,s,t);case 15:return hm(r,e,e.type,e.pendingProps,t);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Pt(n,s),Lo(r,e),e.tag=1,et(n)?(r=!0,oa(e)):r=!1,Zn(e,t),lm(e,n,s),Yc(e,n,s,t),qc(null,e,n,!0,r,t);case 19:return mm(r,e,t);case 22:return dm(r,e,t)}throw Error(N(156,e.tag))};function jm(r,e){return ip(r,e)}function Ax(r,e,t,n){this.tag=r,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wt(r,e,t,n){return new Ax(r,e,t,n)}function yh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Lx(r){if(typeof r=="function")return yh(r)?1:0;if(r!=null){if(r=r.$$typeof,r===Nu)return 11;if(r===Iu)return 14}return 2}function Yr(r,e){var t=r.alternate;return t===null?(t=wt(r.tag,e,r.key,r.mode),t.elementType=r.elementType,t.type=r.type,t.stateNode=r.stateNode,t.alternate=r,r.alternate=t):(t.pendingProps=e,t.type=r.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=r.flags&14680064,t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,e=r.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=r.sibling,t.index=r.index,t.ref=r.ref,t}function Io(r,e,t,n,s,i){var o=2;if(n=r,typeof r=="function")yh(r)&&(o=1);else if(typeof r=="string")o=5;else e:switch(r){case Ln:return gn(t.children,s,i,e);case Fu:o=8,s|=8;break;case vc:return r=wt(12,t,e,s|2),r.elementType=vc,r.lanes=i,r;case yc:return r=wt(13,t,e,s),r.elementType=yc,r.lanes=i,r;case xc:return r=wt(19,t,e,s),r.elementType=xc,r.lanes=i,r;case Vg:return Ja(t,s,i,e);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case zg:o=10;break e;case Wg:o=9;break e;case Nu:o=11;break e;case Iu:o=14;break e;case Mr:o=16,n=null;break e}throw Error(N(130,r==null?r:typeof r,""))}return e=wt(o,t,e,s),e.elementType=r,e.type=n,e.lanes=i,e}function gn(r,e,t,n){return r=wt(7,r,n,e),r.lanes=t,r}function Ja(r,e,t,n){return r=wt(22,r,n,e),r.elementType=Vg,r.lanes=t,r.stateNode={isHidden:!1},r}function Ul(r,e,t){return r=wt(6,r,null,e),r.lanes=t,r}function Yl(r,e,t){return e=wt(4,r.children!==null?r.children:[],r.key,e),e.lanes=t,e.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},e}function Fx(r,e,t,n,s){this.tag=e,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=El(0),this.expirationTimes=El(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=El(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function xh(r,e,t,n,s,i,o,a,l){return r=new Fx(r,e,t,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=wt(3,null,null,e),r.current=i,i.stateNode=r,i.memoizedState={element:n,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},rh(i),r}function Nx(r,e,t){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:An,key:n==null?null:""+n,children:r,containerInfo:e,implementation:t}}function Rm(r){if(!r)return qr;r=r._reactInternals;e:{if(En(r)!==r||r.tag!==1)throw Error(N(170));var e=r;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(et(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(N(171))}if(r.tag===1){var t=r.type;if(et(t))return Rp(r,t,e)}return e}function Am(r,e,t,n,s,i,o,a,l){return r=xh(t,n,!0,r,s,i,o,a,l),r.context=Rm(null),t=r.current,n=$e(),s=Ur(t),i=fr(n,s),i.callback=e??null,$r(t,i,s),r.current.lanes=s,Ti(r,s,n),tt(r,n),r}function Za(r,e,t,n){var s=e.current,i=$e(),o=Ur(s);return t=Rm(t),e.context===null?e.context=t:e.pendingContext=t,e=fr(i,o),e.payload={element:r},n=n===void 0?null:n,n!==null&&(e.callback=n),r=$r(s,e,o),r!==null&&(Bt(r,s,o,i),jo(r,s,o)),o}function xa(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function Zd(r,e){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var t=r.retryLane;r.retryLane=t!==0&&t<e?t:e}}function wh(r,e){Zd(r,e),(r=r.alternate)&&Zd(r,e)}function Ix(){return null}var Lm=typeof reportError=="function"?reportError:function(r){console.error(r)};function Sh(r){this._internalRoot=r}el.prototype.render=Sh.prototype.render=function(r){var e=this._internalRoot;if(e===null)throw Error(N(409));Za(r,e,null,null)};el.prototype.unmount=Sh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var e=r.containerInfo;bn(function(){Za(null,r,null,null)}),e[vr]=null}};function el(r){this._internalRoot=r}el.prototype.unstable_scheduleHydration=function(r){if(r){var e=dp();r={blockedOn:null,target:r,priority:e};for(var t=0;t<Rr.length&&e!==0&&e<Rr[t].priority;t++);Rr.splice(t,0,r),t===0&&gp(r)}};function bh(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function tl(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function ef(){}function Bx(r,e,t,n,s){if(s){if(typeof n=="function"){var i=n;n=function(){var c=xa(o);i.call(c)}}var o=Am(e,n,r,0,null,!1,!1,"",ef);return r._reactRootContainer=o,r[vr]=o.current,ai(r.nodeType===8?r.parentNode:r),bn(),o}for(;s=r.lastChild;)r.removeChild(s);if(typeof n=="function"){var a=n;n=function(){var c=xa(l);a.call(c)}}var l=xh(r,0,!1,null,null,!1,!1,"",ef);return r._reactRootContainer=l,r[vr]=l.current,ai(r.nodeType===8?r.parentNode:r),bn(function(){Za(e,l,t,n)}),l}function rl(r,e,t,n,s){var i=t._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=xa(o);a.call(l)}}Za(e,o,r,s)}else o=Bx(t,e,r,s,n);return xa(o)}up=function(r){switch(r.tag){case 3:var e=r.stateNode;if(e.current.memoizedState.isDehydrated){var t=Ns(e.pendingLanes);t!==0&&(Wu(e,t|1),tt(e,we()),!(te&6)&&(hs=we()+500,tn()))}break;case 13:bn(function(){var n=yr(r,1);if(n!==null){var s=$e();Bt(n,r,1,s)}}),wh(r,1)}};Vu=function(r){if(r.tag===13){var e=yr(r,134217728);if(e!==null){var t=$e();Bt(e,r,134217728,t)}wh(r,134217728)}};hp=function(r){if(r.tag===13){var e=Ur(r),t=yr(r,e);if(t!==null){var n=$e();Bt(t,r,e,n)}wh(r,e)}};dp=function(){return ie};fp=function(r,e){var t=ie;try{return ie=r,e()}finally{ie=t}};Dc=function(r,e,t){switch(e){case"input":if(bc(r,t),e=t.name,t.type==="radio"&&e!=null){for(t=r;t.parentNode;)t=t.parentNode;for(t=t.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<t.length;e++){var n=t[e];if(n!==r&&n.form===r.form){var s=Ua(n);if(!s)throw Error(N(90));$g(n),bc(n,s)}}}break;case"textarea":Ug(r,t);break;case"select":e=t.value,e!=null&&Kn(r,!!t.multiple,e,!1)}};Zg=ph;ep=bn;var zx={usingClientEntryPoint:!1,Events:[Ei,Bn,Ua,Qg,Jg,ph]},Ms={findFiberByHostInstance:ln,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Wx={bundleType:Ms.bundleType,version:Ms.version,rendererPackageName:Ms.rendererPackageName,rendererConfig:Ms.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Tr.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=np(r),r===null?null:r.stateNode},findFiberByHostInstance:Ms.findFiberByHostInstance||Ix,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ki=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ki.isDisabled&&Ki.supportsFiber)try{Va=Ki.inject(Wx),Kt=Ki}catch{}}ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zx;ft.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bh(e))throw Error(N(200));return Nx(r,e,null,t)};ft.createRoot=function(r,e){if(!bh(r))throw Error(N(299));var t=!1,n="",s=Lm;return e!=null&&(e.unstable_strictMode===!0&&(t=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=xh(r,1,!1,null,null,t,!1,n,s),r[vr]=e.current,ai(r.nodeType===8?r.parentNode:r),new Sh(e)};ft.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var e=r._reactInternals;if(e===void 0)throw typeof r.render=="function"?Error(N(188)):(r=Object.keys(r).join(","),Error(N(268,r)));return r=np(e),r=r===null?null:r.stateNode,r};ft.flushSync=function(r){return bn(r)};ft.hydrate=function(r,e,t){if(!tl(e))throw Error(N(200));return rl(null,r,e,!0,t)};ft.hydrateRoot=function(r,e,t){if(!bh(r))throw Error(N(405));var n=t!=null&&t.hydratedSources||null,s=!1,i="",o=Lm;if(t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),e=Am(e,null,r,1,t??null,s,!1,i,o),r[vr]=e.current,ai(r),n)for(r=0;r<n.length;r++)t=n[r],s=t._getVersion,s=s(t._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[t,s]:e.mutableSourceEagerHydrationData.push(t,s);return new el(e)};ft.render=function(r,e,t){if(!tl(e))throw Error(N(200));return rl(null,r,e,!1,t)};ft.unmountComponentAtNode=function(r){if(!tl(r))throw Error(N(40));return r._reactRootContainer?(bn(function(){rl(null,null,r,!1,function(){r._reactRootContainer=null,r[vr]=null})}),!0):!1};ft.unstable_batchedUpdates=ph;ft.unstable_renderSubtreeIntoContainer=function(r,e,t,n){if(!tl(t))throw Error(N(200));if(r==null||r._reactInternals===void 0)throw Error(N(38));return rl(r,e,t,!1,n)};ft.version="18.3.1-next-f1338f8080-20240426";function Fm(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Fm)}catch(r){console.error(r)}}Fm(),Fg.exports=ft;var nl=Fg.exports,tf=nl;pc.createRoot=tf.createRoot,pc.hydrateRoot=tf.hydrateRoot;function Gl(r){return r==="colors"?"color":r!==null?"scalar":"enum"}const rf=[{prefix:"px-",category:"spacing",themeKey:"spacing"},{prefix:"py-",category:"spacing",themeKey:"spacing"},{prefix:"pt-",category:"spacing",themeKey:"spacing"},{prefix:"pr-",category:"spacing",themeKey:"spacing"},{prefix:"pb-",category:"spacing",themeKey:"spacing"},{prefix:"pl-",category:"spacing",themeKey:"spacing"},{prefix:"ps-",category:"spacing",themeKey:"spacing"},{prefix:"pe-",category:"spacing",themeKey:"spacing"},{prefix:"p-",category:"spacing",themeKey:"spacing"},{prefix:"mx-",category:"spacing",themeKey:"spacing"},{prefix:"my-",category:"spacing",themeKey:"spacing"},{prefix:"mt-",category:"spacing",themeKey:"spacing"},{prefix:"mr-",category:"spacing",themeKey:"spacing"},{prefix:"mb-",category:"spacing",themeKey:"spacing"},{prefix:"ml-",category:"spacing",themeKey:"spacing"},{prefix:"ms-",category:"spacing",themeKey:"spacing"},{prefix:"me-",category:"spacing",themeKey:"spacing"},{prefix:"m-",category:"spacing",themeKey:"spacing"},{prefix:"gap-x-",category:"spacing",themeKey:"spacing"},{prefix:"gap-y-",category:"spacing",themeKey:"spacing"},{prefix:"gap-",category:"spacing",themeKey:"spacing"},{prefix:"space-x-",category:"spacing",themeKey:"spacing"},{prefix:"space-y-",category:"spacing",themeKey:"spacing"},{prefix:"min-w-",category:"sizing",themeKey:"spacing"},{prefix:"max-w-",category:"sizing",themeKey:"spacing"},{prefix:"min-h-",category:"sizing",themeKey:"spacing"},{prefix:"max-h-",category:"sizing",themeKey:"spacing"},{prefix:"size-",category:"sizing",themeKey:"spacing"},{prefix:"w-",category:"sizing",themeKey:"spacing"},{prefix:"h-",category:"sizing",themeKey:"spacing"},{prefix:"bg-",category:"color",themeKey:"colors"},{prefix:"ring-",category:"color",themeKey:"colors"},{prefix:"outline-",category:"color",themeKey:"colors"},{prefix:"fill-",category:"color",themeKey:"colors"},{prefix:"stroke-",category:"color",themeKey:"colors"},{prefix:"decoration-",category:"color",themeKey:"colors"},{prefix:"font-",category:"typography",themeKey:"fontWeight"},{prefix:"leading-",category:"typography",themeKey:"lineHeight"},{prefix:"tracking-",category:"typography",themeKey:"letterSpacing"},{prefix:"rounded-tl-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-tr-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-br-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-bl-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-t-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-r-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-b-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-l-",category:"borders",themeKey:"borderRadius"},{prefix:"rounded-",category:"borders",themeKey:"borderRadius"},{prefix:"border-t-",category:"borders",themeKey:"borderWidth"},{prefix:"border-r-",category:"borders",themeKey:"borderWidth"},{prefix:"border-b-",category:"borders",themeKey:"borderWidth"},{prefix:"border-l-",category:"borders",themeKey:"borderWidth"},{prefix:"opacity-",category:"effects",themeKey:null},{prefix:"shadow-",category:"effects",themeKey:null},{prefix:"inset-",category:"layout",themeKey:"spacing"},{prefix:"top-",category:"layout",themeKey:"spacing"},{prefix:"right-",category:"layout",themeKey:"spacing"},{prefix:"bottom-",category:"layout",themeKey:"spacing"},{prefix:"left-",category:"layout",themeKey:"spacing"},{prefix:"z-",category:"layout",themeKey:null},{prefix:"basis-",category:"flexbox",themeKey:"spacing"},{prefix:"grid-cols-",category:"flexbox",themeKey:null},{prefix:"grid-rows-",category:"flexbox",themeKey:null},{prefix:"col-span-",category:"flexbox",themeKey:null},{prefix:"row-span-",category:"flexbox",themeKey:null},{prefix:"order-",category:"flexbox",themeKey:null}].sort((r,e)=>e.prefix.length-r.prefix.length),Vx=new Set(["0","2","4","8"]),Hx=new Set(["solid","dashed","dotted","double","hidden","none"]),$x=new Set(["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","9xl"]),Xx=new Set(["left","center","right","justify","start","end"]),Ux={rounded:{category:"borders",themeKey:"borderRadius"},border:{category:"borders",themeKey:"borderWidth"},shadow:{category:"effects",themeKey:null},underline:{category:"typography",themeKey:null},overline:{category:"typography",themeKey:null},"line-through":{category:"typography",themeKey:null},"no-underline":{category:"typography",themeKey:null},uppercase:{category:"typography",themeKey:null},lowercase:{category:"typography",themeKey:null},capitalize:{category:"typography",themeKey:null},"normal-case":{category:"typography",themeKey:null},truncate:{category:"typography",themeKey:null},italic:{category:"typography",themeKey:null},"not-italic":{category:"typography",themeKey:null},block:{category:"layout",themeKey:null},"inline-block":{category:"layout",themeKey:null},inline:{category:"layout",themeKey:null},flex:{category:"layout",themeKey:null},"inline-flex":{category:"layout",themeKey:null},grid:{category:"layout",themeKey:null},"inline-grid":{category:"layout",themeKey:null},hidden:{category:"layout",themeKey:null},table:{category:"layout",themeKey:null},contents:{category:"layout",themeKey:null},static:{category:"layout",themeKey:null},fixed:{category:"layout",themeKey:null},absolute:{category:"layout",themeKey:null},relative:{category:"layout",themeKey:null},sticky:{category:"layout",themeKey:null},"flex-row":{category:"flexbox",themeKey:null},"flex-row-reverse":{category:"flexbox",themeKey:null},"flex-col":{category:"flexbox",themeKey:null},"flex-col-reverse":{category:"flexbox",themeKey:null},"flex-wrap":{category:"flexbox",themeKey:null},"flex-wrap-reverse":{category:"flexbox",themeKey:null},"flex-nowrap":{category:"flexbox",themeKey:null},"flex-1":{category:"flexbox",themeKey:null},"flex-auto":{category:"flexbox",themeKey:null},"flex-initial":{category:"flexbox",themeKey:null},"flex-none":{category:"flexbox",themeKey:null},grow:{category:"flexbox",themeKey:null},"grow-0":{category:"flexbox",themeKey:null},shrink:{category:"flexbox",themeKey:null},"shrink-0":{category:"flexbox",themeKey:null},"justify-start":{category:"flexbox",themeKey:null},"justify-end":{category:"flexbox",themeKey:null},"justify-center":{category:"flexbox",themeKey:null},"justify-between":{category:"flexbox",themeKey:null},"justify-around":{category:"flexbox",themeKey:null},"justify-evenly":{category:"flexbox",themeKey:null},"justify-stretch":{category:"flexbox",themeKey:null},"items-start":{category:"flexbox",themeKey:null},"items-end":{category:"flexbox",themeKey:null},"items-center":{category:"flexbox",themeKey:null},"items-baseline":{category:"flexbox",themeKey:null},"items-stretch":{category:"flexbox",themeKey:null},"self-auto":{category:"flexbox",themeKey:null},"self-start":{category:"flexbox",themeKey:null},"self-end":{category:"flexbox",themeKey:null},"self-center":{category:"flexbox",themeKey:null},"self-stretch":{category:"flexbox",themeKey:null},"self-baseline":{category:"flexbox",themeKey:null}},Yx=/^(sm:|md:|lg:|xl:|2xl:|hover:|focus:|active:|disabled:|visited:|first:|last:|odd:|even:|group-hover:|focus-within:|focus-visible:|dark:|motion-safe:|motion-reduce:)+/;function Gx(r){return Yx.test(r)}function Kx(r){return $x.has(r)?{category:"typography",valueType:"scalar",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:"fontSize"}:Xx.has(r)?{category:"typography",valueType:"enum",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:null}:{category:"color",valueType:"color",prefix:"text-",value:r,fullClass:`text-${r}`,themeKey:"colors"}}function qx(r){return Vx.has(r)?{category:"borders",valueType:"scalar",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:"borderWidth"}:Hx.has(r)?{category:"borders",valueType:"enum",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:null}:{category:"color",valueType:"color",prefix:"border-",value:r,fullClass:`border-${r}`,themeKey:"colors"}}function Qx(r){const e=[],t=r.trim().split(/\s+/).filter(Boolean);for(const n of t){if(Gx(n))continue;const s=Ux[n];if(s){e.push({category:s.category,valueType:Gl(s.themeKey),prefix:n,value:"",fullClass:n,themeKey:s.themeKey});continue}if(n.startsWith("text-")){const i=n.slice(5),o=Kx(i);o&&e.push(o);continue}if(n.startsWith("border-")){const i=n.slice(7);let o=!1;for(const a of rf)if(a.prefix!=="border-"&&n.startsWith(a.prefix)){o=!0,e.push({category:a.category,valueType:Gl(a.themeKey),prefix:a.prefix,value:n.slice(a.prefix.length),fullClass:n,themeKey:a.themeKey});break}if(!o){const a=qx(i);a&&e.push(a)}continue}for(const i of rf)if(n.startsWith(i.prefix)){e.push({category:i.category,valueType:Gl(i.themeKey),prefix:i.prefix,value:n.slice(i.prefix.length),fullClass:n,themeKey:i.themeKey});break}}return e}let ir=null,wa=!1;const Bo=[],zo=[],Wo=[];function Jx(){return window.location.origin.replace(/^http/,"ws")}function _h(){if(ir)return;const r=Jx();ir=new WebSocket(r),ir.addEventListener("open",()=>{wa=!0,ur({type:"REGISTER",role:"panel"});for(const e of zo)e()}),ir.addEventListener("close",()=>{wa=!1,ir=null;for(const e of Wo)e();setTimeout(()=>_h(),3e3)}),ir.addEventListener("message",e=>{try{const t=JSON.parse(e.data);for(const n of Bo)n(t)}catch(t){console.error("[tw-panel] Failed to parse message:",t)}}),ir.addEventListener("error",e=>{console.error("[tw-panel] WebSocket error:",e)})}function ur(r){wa&&ir&&ir.send(JSON.stringify(r))}function Pe(r,e){ur({...e,to:r})}function Nm(r){return Bo.push(r),()=>{const e=Bo.indexOf(r);e!==-1&&Bo.splice(e,1)}}function Im(r){return zo.push(r),()=>{const e=zo.indexOf(r);e!==-1&&zo.splice(e,1)}}function Zx(r){return Wo.push(r),()=>{const e=Wo.indexOf(r);e!==-1&&Wo.splice(e,1)}}function e1(){return wa}function sl(){return typeof window<"u"}function ms(r){return Ch(r)?(r.nodeName||"").toLowerCase():"#document"}function ht(r){var e;return(r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function er(r){var e;return(e=(Ch(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function Ch(r){return sl()?r instanceof Node||r instanceof ht(r).Node:!1}function Se(r){return sl()?r instanceof Element||r instanceof ht(r).Element:!1}function tr(r){return sl()?r instanceof HTMLElement||r instanceof ht(r).HTMLElement:!1}function lu(r){return!sl()||typeof ShadowRoot>"u"?!1:r instanceof ShadowRoot||r instanceof ht(r).ShadowRoot}function Di(r){const{overflow:e,overflowX:t,overflowY:n,display:s}=Ct(r);return/auto|scroll|overlay|hidden|clip/.test(e+n+t)&&s!=="inline"&&s!=="contents"}function t1(r){return/^(table|td|th)$/.test(ms(r))}function il(r){try{if(r.matches(":popover-open"))return!0}catch{}try{return r.matches(":modal")}catch{return!1}}const r1=/transform|translate|scale|rotate|perspective|filter/,n1=/paint|layout|strict|content/,nn=r=>!!r&&r!=="none";let Kl;function Th(r){const e=Se(r)?Ct(r):r;return nn(e.transform)||nn(e.translate)||nn(e.scale)||nn(e.rotate)||nn(e.perspective)||!ol()&&(nn(e.backdropFilter)||nn(e.filter))||r1.test(e.willChange||"")||n1.test(e.contain||"")}function s1(r){let e=wr(r);for(;tr(e)&&!gr(e);){if(Th(e))return e;if(il(e))return null;e=wr(e)}return null}function ol(){return Kl==null&&(Kl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Kl}function gr(r){return/^(html|body|#document)$/.test(ms(r))}function Ct(r){return ht(r).getComputedStyle(r)}function al(r){return Se(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function wr(r){if(ms(r)==="html")return r;const e=r.assignedSlot||r.parentNode||lu(r)&&r.host||er(r);return lu(e)?e.host:e}function Bm(r){const e=wr(r);return gr(e)?r.ownerDocument?r.ownerDocument.body:r.body:tr(e)&&Di(e)?e:Bm(e)}function Gr(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=Bm(r),i=s===((n=r.ownerDocument)==null?void 0:n.body),o=ht(s);if(i){const a=cu(o);return e.concat(o,o.visualViewport||[],Di(s)?s:[],a&&t?Gr(a):[])}else return e.concat(s,Gr(s,[],t))}function cu(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}const Sa=Math.min,pn=Math.max,ba=Math.round,qi=Math.floor,Qt=r=>({x:r,y:r}),i1={left:"right",right:"left",bottom:"top",top:"bottom"};function nf(r,e,t){return pn(r,Sa(e,t))}function ll(r,e){return typeof r=="function"?r(e):r}function _n(r){return r.split("-")[0]}function cl(r){return r.split("-")[1]}function zm(r){return r==="x"?"y":"x"}function Wm(r){return r==="y"?"height":"width"}function Ir(r){const e=r[0];return e==="t"||e==="b"?"y":"x"}function Vm(r){return zm(Ir(r))}function o1(r,e,t){t===void 0&&(t=!1);const n=cl(r),s=Vm(r),i=Wm(s);let o=s==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=_a(o)),[o,_a(o)]}function a1(r){const e=_a(r);return[uu(r),e,uu(e)]}function uu(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}const sf=["left","right"],of=["right","left"],l1=["top","bottom"],c1=["bottom","top"];function u1(r,e,t){switch(r){case"top":case"bottom":return t?e?of:sf:e?sf:of;case"left":case"right":return e?l1:c1;default:return[]}}function h1(r,e,t,n){const s=cl(r);let i=u1(_n(r),t==="start",n);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(uu)))),i}function _a(r){const e=_n(r);return i1[e]+r.slice(e.length)}function d1(r){return{top:0,right:0,bottom:0,left:0,...r}}function f1(r){return typeof r!="number"?d1(r):{top:r,right:r,bottom:r,left:r}}function Ca(r){const{x:e,y:t,width:n,height:s}=r;return{width:n,height:s,top:t,left:e,right:e+n,bottom:t+s,x:e,y:t}}/*!
41
- * tabbable 6.4.0
42
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
43
- */var g1=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],hu=g1.join(","),Hm=typeof Element>"u",mi=Hm?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ta=!Hm&&Element.prototype.getRootNode?function(r){var e;return r==null||(e=r.getRootNode)===null||e===void 0?void 0:e.call(r)}:function(r){return r==null?void 0:r.ownerDocument},ka=function(e,t){var n;t===void 0&&(t=!0);var s=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),i=s===""||s==="true",o=i||t&&e&&(typeof e.closest=="function"?e.closest("[inert]"):ka(e.parentNode));return o},p1=function(e){var t,n=e==null||(t=e.getAttribute)===null||t===void 0?void 0:t.call(e,"contenteditable");return n===""||n==="true"},m1=function(e,t,n){if(ka(e))return[];var s=Array.prototype.slice.apply(e.querySelectorAll(hu));return t&&mi.call(e,hu)&&s.unshift(e),s=s.filter(n),s},du=function(e,t,n){for(var s=[],i=Array.from(e);i.length;){var o=i.shift();if(!ka(o,!1))if(o.tagName==="SLOT"){var a=o.assignedElements(),l=a.length?a:o.children,c=du(l,!0,n);n.flatten?s.push.apply(s,c):s.push({scopeParent:o,candidates:c})}else{var u=mi.call(o,hu);u&&n.filter(o)&&(t||!e.includes(o))&&s.push(o);var h=o.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(o),d=!ka(h,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(o));if(h&&d){var f=du(h===!0?o.children:h.children,!0,n);n.flatten?s.push.apply(s,f):s.push({scopeParent:o,candidates:f})}else i.unshift.apply(i,o.children)}}return s},$m=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Xm=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||p1(e))&&!$m(e)?0:e.tabIndex},v1=function(e,t){var n=Xm(e);return n<0&&t&&!$m(e)?0:n},y1=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},Um=function(e){return e.tagName==="INPUT"},x1=function(e){return Um(e)&&e.type==="hidden"},w1=function(e){var t=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return t},S1=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]},b1=function(e){if(!e.name)return!0;var t=e.form||Ta(e),n=function(a){return t.querySelectorAll('input[type="radio"][name="'+a+'"]')},s;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")s=n(window.CSS.escape(e.name));else try{s=n(e.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var i=S1(s,e.form);return!i||i===e},_1=function(e){return Um(e)&&e.type==="radio"},C1=function(e){return _1(e)&&!b1(e)},T1=function(e){var t,n=e&&Ta(e),s=(t=n)===null||t===void 0?void 0:t.host,i=!1;if(n&&n!==e){var o,a,l;for(i=!!((o=s)!==null&&o!==void 0&&(a=o.ownerDocument)!==null&&a!==void 0&&a.contains(s)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!i&&s;){var c,u,h;n=Ta(s),s=(c=n)===null||c===void 0?void 0:c.host,i=!!((u=s)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(s))}}return i},af=function(e){var t=e.getBoundingClientRect(),n=t.width,s=t.height;return n===0&&s===0},k1=function(e,t){var n=t.displayCheck,s=t.getShadowRoot;if(n==="full-native"&&"checkVisibility"in e){var i=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(e).visibility==="hidden")return!0;var o=mi.call(e,"details>summary:first-of-type"),a=o?e.parentElement:e;if(mi.call(a,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof s=="function"){for(var l=e;e;){var c=e.parentElement,u=Ta(e);if(c&&!c.shadowRoot&&s(c)===!0)return af(e);e.assignedSlot?e=e.assignedSlot:!c&&u!==e.ownerDocument?e=u.host:e=c}e=l}if(T1(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return af(e);return!1},E1=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var n=0;n<t.children.length;n++){var s=t.children.item(n);if(s.tagName==="LEGEND")return mi.call(t,"fieldset[disabled] *")?!0:!s.contains(e)}return!0}t=t.parentElement}return!1},O1=function(e,t){return!(t.disabled||x1(t)||k1(t,e)||w1(t)||E1(t))},lf=function(e,t){return!(C1(t)||Xm(t)<0||!O1(e,t))},D1=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},Ym=function(e){var t=[],n=[];return e.forEach(function(s,i){var o=!!s.scopeParent,a=o?s.scopeParent:s,l=v1(a,o),c=o?Ym(s.candidates):a;l===0?o?t.push.apply(t,c):t.push(a):n.push({documentOrder:i,tabIndex:l,item:s,isScope:o,content:c})}),n.sort(y1).reduce(function(s,i){return i.isScope?s.push.apply(s,i.content):s.push(i.content),s},[]).concat(t)},Gm=function(e,t){t=t||{};var n;return t.getShadowRoot?n=du([e],t.includeContainer,{filter:lf.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:D1}):n=m1(e,t.includeContainer,lf.bind(null,t)),Ym(n)};function P1(){return/apple/i.test(navigator.vendor)}function M1(r){let e=r.activeElement;for(;((t=e)==null||(t=t.shadowRoot)==null?void 0:t.activeElement)!=null;){var t;e=e.shadowRoot.activeElement}return e}function fu(r,e){if(!r||!e)return!1;const t=e.getRootNode==null?void 0:e.getRootNode();if(r.contains(e))return!0;if(t&&lu(t)){let n=e;for(;n;){if(r===n)return!0;n=n.parentNode||n.host}}return!1}function js(r){return"composedPath"in r?r.composedPath()[0]:r.target}function ql(r,e){if(e==null)return!1;if("composedPath"in r)return r.composedPath().includes(e);const t=r;return t.target!=null&&e.contains(t.target)}function j1(r){return r.matches("html,body")}function vi(r){return(r==null?void 0:r.ownerDocument)||document}function Vo(r,e,t){return t===void 0&&(t=!0),r.filter(s=>{var i;return s.parentId===e&&(!t||((i=s.context)==null?void 0:i.open))}).flatMap(s=>[s,...Vo(r,s.id,t)])}function R1(r){return"nativeEvent"in r}var A1=typeof document<"u",L1=function(){},mn=A1?D.useLayoutEffect:L1;const F1={...Ag},N1=F1.useInsertionEffect,I1=N1||(r=>r());function jn(r){const e=D.useRef(()=>{});return I1(()=>{e.current=r}),D.useCallback(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return e.current==null?void 0:e.current(...n)},[])}const Km=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function qm(r,e){const t=Gm(r,Km()),n=t.length;if(n===0)return;const s=M1(vi(r)),i=t.indexOf(s),o=i===-1?e===1?0:n-1:i+e;return t[o]}function B1(r){return qm(vi(r).body,1)||r}function z1(r){return qm(vi(r).body,-1)||r}function Ql(r,e){const t=e||r.currentTarget,n=r.relatedTarget;return!n||!fu(t,n)}function W1(r){Gm(r,Km()).forEach(t=>{t.dataset.tabindex=t.getAttribute("tabindex")||"",t.setAttribute("tabindex","-1")})}function cf(r){r.querySelectorAll("[data-tabindex]").forEach(t=>{const n=t.dataset.tabindex;delete t.dataset.tabindex,n?t.setAttribute("tabindex",n):t.removeAttribute("tabindex")})}function uf(r,e,t){let{reference:n,floating:s}=r;const i=Ir(e),o=Vm(e),a=Wm(o),l=_n(e),c=i==="y",u=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,d=n[a]/2-s[a]/2;let f;switch(l){case"top":f={x:u,y:n.y-s.height};break;case"bottom":f={x:u,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:h};break;case"left":f={x:n.x-s.width,y:h};break;default:f={x:n.x,y:n.y}}switch(cl(e)){case"start":f[o]-=d*(t&&c?-1:1);break;case"end":f[o]+=d*(t&&c?-1:1);break}return f}async function V1(r,e){var t;e===void 0&&(e={});const{x:n,y:s,platform:i,rects:o,elements:a,strategy:l}=r,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:f=0}=ll(e,r),m=f1(f),x=a[d?h==="floating"?"reference":"floating":h],g=Ca(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(x)))==null||t?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),p=h==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),b=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},O=Ca(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:p,offsetParent:y,strategy:l}):p);return{top:(g.top-O.top+m.top)/b.y,bottom:(O.bottom-g.bottom+m.bottom)/b.y,left:(g.left-O.left+m.left)/b.x,right:(O.right-g.right+m.right)/b.x}}const H1=50,$1=async(r,e,t)=>{const{placement:n="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=o.detectOverflow?o:{...o,detectOverflow:V1},l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:r,floating:e,strategy:s}),{x:u,y:h}=uf(c,n,l),d=n,f=0;const m={};for(let v=0;v<i.length;v++){const x=i[v];if(!x)continue;const{name:g,fn:p}=x,{x:y,y:b,data:O,reset:S}=await p({x:u,y:h,initialPlacement:n,placement:d,strategy:s,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});u=y??u,h=b??h,m[g]={...m[g],...O},S&&f<H1&&(f++,typeof S=="object"&&(S.placement&&(d=S.placement),S.rects&&(c=S.rects===!0?await o.getElementRects({reference:r,floating:e,strategy:s}):S.rects),{x:u,y:h}=uf(c,d,l)),v=-1)}return{x:u,y:h,placement:d,strategy:s,middlewareData:m}},X1=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...x}=ll(r,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const g=_n(s),p=Ir(a),y=_n(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(c.floating)),O=d||(y||!v?[_a(a)]:a1(a)),S=m!=="none";!d&&S&&O.push(...h1(a,v,m,b));const T=[a,...O],C=await l.detectOverflow(e,x),P=[];let j=((n=i.flip)==null?void 0:n.overflows)||[];if(u&&P.push(C[g]),h){const A=o1(s,o,b);P.push(C[A[0]],C[A[1]])}if(j=[...j,{placement:s,overflows:P}],!P.every(A=>A<=0)){var R,I;const A=(((R=i.flip)==null?void 0:R.index)||0)+1,G=T[A];if(G&&(!(h==="alignment"?p!==Ir(G):!1)||j.every(k=>Ir(k.placement)===p?k.overflows[0]>0:!0)))return{data:{index:A,overflows:j},reset:{placement:G}};let Y=(I=j.filter(W=>W.overflows[0]<=0).sort((W,k)=>W.overflows[1]-k.overflows[1])[0])==null?void 0:I.placement;if(!Y)switch(f){case"bestFit":{var U;const W=(U=j.filter(k=>{if(S){const F=Ir(k.placement);return F===p||F==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(F=>F>0).reduce((F,B)=>F+B,0)]).sort((k,F)=>k[1]-F[1])[0])==null?void 0:U[0];W&&(Y=W);break}case"initialPlacement":Y=a;break}if(s!==Y)return{reset:{placement:Y}}}return{}}}},U1=new Set(["left","top"]);async function Y1(r,e){const{placement:t,platform:n,elements:s}=r,i=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=_n(t),a=cl(t),l=Ir(t)==="y",c=U1.has(o)?-1:1,u=i&&l?-1:1,h=ll(e,r);let{mainAxis:d,crossAxis:f,alignmentAxis:m}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof m=="number"&&(f=a==="end"?m*-1:m),l?{x:f*u,y:d*c}:{x:d*c,y:f*u}}const G1=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await Y1(e,r);return o===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},K1=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){const{x:t,y:n,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:g=>{let{x:p,y}=g;return{x:p,y}}},...c}=ll(r,e),u={x:t,y:n},h=await i.detectOverflow(e,c),d=Ir(_n(s)),f=zm(d);let m=u[f],v=u[d];if(o){const g=f==="y"?"top":"left",p=f==="y"?"bottom":"right",y=m+h[g],b=m-h[p];m=nf(y,m,b)}if(a){const g=d==="y"?"top":"left",p=d==="y"?"bottom":"right",y=v+h[g],b=v-h[p];v=nf(y,v,b)}const x=l.fn({...e,[f]:m,[d]:v});return{...x,data:{x:x.x-t,y:x.y-n,enabled:{[f]:o,[d]:a}}}}}};function Qm(r){const e=Ct(r);let t=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=tr(r),i=s?r.offsetWidth:t,o=s?r.offsetHeight:n,a=ba(t)!==i||ba(n)!==o;return a&&(t=i,n=o),{width:t,height:n,$:a}}function kh(r){return Se(r)?r:r.contextElement}function ts(r){const e=kh(r);if(!tr(e))return Qt(1);const t=e.getBoundingClientRect(),{width:n,height:s,$:i}=Qm(e);let o=(i?ba(t.width):t.width)/n,a=(i?ba(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const q1=Qt(0);function Jm(r){const e=ht(r);return!ol()||!e.visualViewport?q1:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Q1(r,e,t){return e===void 0&&(e=!1),!t||e&&t!==ht(r)?!1:e}function Cn(r,e,t,n){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=r.getBoundingClientRect(),i=kh(r);let o=Qt(1);e&&(n?Se(n)&&(o=ts(n)):o=ts(r));const a=Q1(i,t,n)?Jm(i):Qt(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,h=s.height/o.y;if(i){const d=ht(i),f=n&&Se(n)?ht(n):n;let m=d,v=cu(m);for(;v&&n&&f!==m;){const x=ts(v),g=v.getBoundingClientRect(),p=Ct(v),y=g.left+(v.clientLeft+parseFloat(p.paddingLeft))*x.x,b=g.top+(v.clientTop+parseFloat(p.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,h*=x.y,l+=y,c+=b,m=ht(v),v=cu(m)}}return Ca({width:u,height:h,x:l,y:c})}function ul(r,e){const t=al(r).scrollLeft;return e?e.left+t:Cn(er(r)).left+t}function Zm(r,e){const t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-ul(r,t),s=t.top+e.scrollTop;return{x:n,y:s}}function J1(r){let{elements:e,rect:t,offsetParent:n,strategy:s}=r;const i=s==="fixed",o=er(n),a=e?il(e.floating):!1;if(n===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=Qt(1);const u=Qt(0),h=tr(n);if((h||!h&&!i)&&((ms(n)!=="body"||Di(o))&&(l=al(n)),h)){const f=Cn(n);c=ts(n),u.x=f.x+n.clientLeft,u.y=f.y+n.clientTop}const d=o&&!h&&!i?Zm(o,l):Qt(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:t.y*c.y-l.scrollTop*c.y+u.y+d.y}}function Z1(r){return Array.from(r.getClientRects())}function ew(r){const e=er(r),t=al(r),n=r.ownerDocument.body,s=pn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=pn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+ul(r);const a=-t.scrollTop;return Ct(n).direction==="rtl"&&(o+=pn(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:o,y:a}}const hf=25;function tw(r,e){const t=ht(r),n=er(r),s=t.visualViewport;let i=n.clientWidth,o=n.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const u=ol();(!u||u&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=ul(n);if(c<=0){const u=n.ownerDocument,h=u.body,d=getComputedStyle(h),f=u.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,m=Math.abs(n.clientWidth-h.clientWidth-f);m<=hf&&(i-=m)}else c<=hf&&(i+=c);return{width:i,height:o,x:a,y:l}}function rw(r,e){const t=Cn(r,!0,e==="fixed"),n=t.top+r.clientTop,s=t.left+r.clientLeft,i=tr(r)?ts(r):Qt(1),o=r.clientWidth*i.x,a=r.clientHeight*i.y,l=s*i.x,c=n*i.y;return{width:o,height:a,x:l,y:c}}function df(r,e,t){let n;if(e==="viewport")n=tw(r,t);else if(e==="document")n=ew(er(r));else if(Se(e))n=rw(e,t);else{const s=Jm(r);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Ca(n)}function ev(r,e){const t=wr(r);return t===e||!Se(t)||gr(t)?!1:Ct(t).position==="fixed"||ev(t,e)}function nw(r,e){const t=e.get(r);if(t)return t;let n=Gr(r,[],!1).filter(a=>Se(a)&&ms(a)!=="body"),s=null;const i=Ct(r).position==="fixed";let o=i?wr(r):r;for(;Se(o)&&!gr(o);){const a=Ct(o),l=Th(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Di(o)&&!l&&ev(r,o))?n=n.filter(u=>u!==o):s=a,o=wr(o)}return e.set(r,n),n}function sw(r){let{element:e,boundary:t,rootBoundary:n,strategy:s}=r;const o=[...t==="clippingAncestors"?il(e)?[]:nw(e,this._c):[].concat(t),n],a=df(e,o[0],s);let l=a.top,c=a.right,u=a.bottom,h=a.left;for(let d=1;d<o.length;d++){const f=df(e,o[d],s);l=pn(f.top,l),c=Sa(f.right,c),u=Sa(f.bottom,u),h=pn(f.left,h)}return{width:c-h,height:u-l,x:h,y:l}}function iw(r){const{width:e,height:t}=Qm(r);return{width:e,height:t}}function ow(r,e,t){const n=tr(e),s=er(e),i=t==="fixed",o=Cn(r,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=Qt(0);function c(){l.x=ul(s)}if(n||!n&&!i)if((ms(e)!=="body"||Di(s))&&(a=al(e)),n){const f=Cn(e,!0,i,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&c();i&&!n&&s&&c();const u=s&&!n&&!i?Zm(s,a):Qt(0),h=o.left+a.scrollLeft-l.x-u.x,d=o.top+a.scrollTop-l.y-u.y;return{x:h,y:d,width:o.width,height:o.height}}function Jl(r){return Ct(r).position==="static"}function ff(r,e){if(!tr(r)||Ct(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return er(r)===t&&(t=t.ownerDocument.body),t}function tv(r,e){const t=ht(r);if(il(r))return t;if(!tr(r)){let s=wr(r);for(;s&&!gr(s);){if(Se(s)&&!Jl(s))return s;s=wr(s)}return t}let n=ff(r,e);for(;n&&t1(n)&&Jl(n);)n=ff(n,e);return n&&gr(n)&&Jl(n)&&!Th(n)?t:n||s1(r)||t}const aw=async function(r){const e=this.getOffsetParent||tv,t=this.getDimensions,n=await t(r.floating);return{reference:ow(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function lw(r){return Ct(r).direction==="rtl"}const cw={convertOffsetParentRelativeRectToViewportRelativeRect:J1,getDocumentElement:er,getClippingRect:sw,getOffsetParent:tv,getElementRects:aw,getClientRects:Z1,getDimensions:iw,getScale:ts,isElement:Se,isRTL:lw};function rv(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function uw(r,e){let t=null,n;const s=er(r);function i(){var a;clearTimeout(n),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=r.getBoundingClientRect(),{left:u,top:h,width:d,height:f}=c;if(a||e(),!d||!f)return;const m=qi(h),v=qi(s.clientWidth-(u+d)),x=qi(s.clientHeight-(h+f)),g=qi(u),y={rootMargin:-m+"px "+-v+"px "+-x+"px "+-g+"px",threshold:pn(0,Sa(1,l))||1};let b=!0;function O(S){const T=S[0].intersectionRatio;if(T!==l){if(!b)return o();T?o(!1,T):n=setTimeout(()=>{o(!1,1e-7)},1e3)}T===1&&!rv(c,r.getBoundingClientRect())&&o(),b=!1}try{t=new IntersectionObserver(O,{...y,root:s.ownerDocument})}catch{t=new IntersectionObserver(O,y)}t.observe(r)}return o(!0),i}function hw(r,e,t,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,c=kh(r),u=s||i?[...c?Gr(c):[],...e?Gr(e):[]]:[];u.forEach(g=>{s&&g.addEventListener("scroll",t,{passive:!0}),i&&g.addEventListener("resize",t)});const h=c&&a?uw(c,t):null;let d=-1,f=null;o&&(f=new ResizeObserver(g=>{let[p]=g;p&&p.target===c&&f&&e&&(f.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(e)})),t()}),c&&!l&&f.observe(c),e&&f.observe(e));let m,v=l?Cn(r):null;l&&x();function x(){const g=Cn(r);v&&!rv(v,g)&&t(),v=g,m=requestAnimationFrame(x)}return t(),()=>{var g;u.forEach(p=>{s&&p.removeEventListener("scroll",t),i&&p.removeEventListener("resize",t)}),h==null||h(),(g=f)==null||g.disconnect(),f=null,l&&cancelAnimationFrame(m)}}const dw=G1,fw=K1,gw=X1,pw=(r,e,t)=>{const n=new Map,s={platform:cw,...t},i={...s.platform,_c:n};return $1(r,e,{...s,platform:i})};var mw=typeof document<"u",vw=function(){},Ho=mw?D.useLayoutEffect:vw;function Ea(r,e){if(r===e)return!0;if(typeof r!=typeof e)return!1;if(typeof r=="function"&&r.toString()===e.toString())return!0;let t,n,s;if(r&&e&&typeof r=="object"){if(Array.isArray(r)){if(t=r.length,t!==e.length)return!1;for(n=t;n--!==0;)if(!Ea(r[n],e[n]))return!1;return!0}if(s=Object.keys(r),t=s.length,t!==Object.keys(e).length)return!1;for(n=t;n--!==0;)if(!{}.hasOwnProperty.call(e,s[n]))return!1;for(n=t;n--!==0;){const i=s[n];if(!(i==="_owner"&&r.$$typeof)&&!Ea(r[i],e[i]))return!1}return!0}return r!==r&&e!==e}function nv(r){return typeof window>"u"?1:(r.ownerDocument.defaultView||window).devicePixelRatio||1}function gf(r,e){const t=nv(r);return Math.round(e*t)/t}function Zl(r){const e=D.useRef(r);return Ho(()=>{e.current=r}),e}function yw(r){r===void 0&&(r={});const{placement:e="bottom",strategy:t="absolute",middleware:n=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=r,[u,h]=D.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,f]=D.useState(n);Ea(d,n)||f(n);const[m,v]=D.useState(null),[x,g]=D.useState(null),p=D.useCallback(k=>{k!==S.current&&(S.current=k,v(k))},[]),y=D.useCallback(k=>{k!==T.current&&(T.current=k,g(k))},[]),b=i||m,O=o||x,S=D.useRef(null),T=D.useRef(null),C=D.useRef(u),P=l!=null,j=Zl(l),R=Zl(s),I=Zl(c),U=D.useCallback(()=>{if(!S.current||!T.current)return;const k={placement:e,strategy:t,middleware:d};R.current&&(k.platform=R.current),pw(S.current,T.current,k).then(F=>{const B={...F,isPositioned:I.current!==!1};A.current&&!Ea(C.current,B)&&(C.current=B,nl.flushSync(()=>{h(B)}))})},[d,e,t,R,I]);Ho(()=>{c===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,h(k=>({...k,isPositioned:!1})))},[c]);const A=D.useRef(!1);Ho(()=>(A.current=!0,()=>{A.current=!1}),[]),Ho(()=>{if(b&&(S.current=b),O&&(T.current=O),b&&O){if(j.current)return j.current(b,O,U);U()}},[b,O,U,j,P]);const G=D.useMemo(()=>({reference:S,floating:T,setReference:p,setFloating:y}),[p,y]),Y=D.useMemo(()=>({reference:b,floating:O}),[b,O]),W=D.useMemo(()=>{const k={position:t,left:0,top:0};if(!Y.floating)return k;const F=gf(Y.floating,u.x),B=gf(Y.floating,u.y);return a?{...k,transform:"translate("+F+"px, "+B+"px)",...nv(Y.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:F,top:B}},[t,a,Y.floating,u.x,u.y]);return D.useMemo(()=>({...u,update:U,refs:G,elements:Y,floatingStyles:W}),[u,U,G,Y,W])}const xw=(r,e)=>{const t=dw(r);return{name:t.name,fn:t.fn,options:[r,e]}},ww=(r,e)=>{const t=fw(r);return{name:t.name,fn:t.fn,options:[r,e]}},Sw=(r,e)=>{const t=gw(r);return{name:t.name,fn:t.fn,options:[r,e]}},bw="data-floating-ui-focusable",pf="active",mf="selected",_w={...Ag};let vf=!1,Cw=0;const yf=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Cw++;function Tw(){const[r,e]=D.useState(()=>vf?yf():void 0);return mn(()=>{r==null&&e(yf())},[]),D.useEffect(()=>{vf=!0},[]),r}const kw=_w.useId,sv=kw||Tw;function Ew(){const r=new Map;return{emit(e,t){var n;(n=r.get(e))==null||n.forEach(s=>s(t))},on(e,t){r.has(e)||r.set(e,new Set),r.get(e).add(t)},off(e,t){var n;(n=r.get(e))==null||n.delete(t)}}}const Ow=D.createContext(null),Dw=D.createContext(null),Pw=()=>{var r;return((r=D.useContext(Ow))==null?void 0:r.id)||null},iv=()=>D.useContext(Dw);function Eh(r){return"data-floating-ui-"+r}const Mw={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},xf=D.forwardRef(function(e,t){const[n,s]=D.useState();mn(()=>{P1()&&s("button")},[]);const i={ref:t,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[Eh("focus-guard")]:"",style:Mw};return w.jsx("span",{...e,...i})}),jw={clipPath:"inset(50%)",position:"fixed",top:0,left:0},ov=D.createContext(null),wf=Eh("portal");function Rw(r){r===void 0&&(r={});const{id:e,root:t}=r,n=sv(),s=Lw(),[i,o]=D.useState(null),a=D.useRef(null);return mn(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{a.current=null})},[i]),mn(()=>{if(!n||a.current)return;const l=e?document.getElementById(e):null;if(!l)return;const c=document.createElement("div");c.id=n,c.setAttribute(wf,""),l.appendChild(c),a.current=c,o(c)},[e,n]),mn(()=>{if(t===null||!n||a.current)return;let l=t||(s==null?void 0:s.portalNode);l&&!Ch(l)&&(l=l.current),l=l||document.body;let c=null;e&&(c=document.createElement("div"),c.id=e,l.appendChild(c));const u=document.createElement("div");u.id=n,u.setAttribute(wf,""),l=c||l,l.appendChild(u),a.current=u,o(u)},[e,t,n,s]),i}function Aw(r){const{children:e,id:t,root:n,preserveTabOrder:s=!0}=r,i=Rw({id:t,root:n}),[o,a]=D.useState(null),l=D.useRef(null),c=D.useRef(null),u=D.useRef(null),h=D.useRef(null),d=o==null?void 0:o.modal,f=o==null?void 0:o.open,m=!!o&&!o.modal&&o.open&&s&&!!(n||i);return D.useEffect(()=>{if(!i||!s||d)return;function v(x){i&&Ql(x)&&(x.type==="focusin"?cf:W1)(i)}return i.addEventListener("focusin",v,!0),i.addEventListener("focusout",v,!0),()=>{i.removeEventListener("focusin",v,!0),i.removeEventListener("focusout",v,!0)}},[i,s,d]),D.useEffect(()=>{i&&(f||cf(i))},[f,i]),w.jsxs(ov.Provider,{value:D.useMemo(()=>({preserveTabOrder:s,beforeOutsideRef:l,afterOutsideRef:c,beforeInsideRef:u,afterInsideRef:h,portalNode:i,setFocusManagerState:a}),[s,i]),children:[m&&i&&w.jsx(xf,{"data-type":"outside",ref:l,onFocus:v=>{if(Ql(v,i)){var x;(x=u.current)==null||x.focus()}else{const g=o?o.domReference:null,p=z1(g);p==null||p.focus()}}}),m&&i&&w.jsx("span",{"aria-owns":i.id,style:jw}),i&&nl.createPortal(e,i),m&&i&&w.jsx(xf,{"data-type":"outside",ref:c,onFocus:v=>{if(Ql(v,i)){var x;(x=h.current)==null||x.focus()}else{const g=o?o.domReference:null,p=B1(g);p==null||p.focus(),o!=null&&o.closeOnFocusOut&&(o==null||o.onOpenChange(!1,v.nativeEvent,"focus-out"))}}})]})}const Lw=()=>D.useContext(ov),Fw={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Nw={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Sf=r=>{var e,t;return{escapeKey:typeof r=="boolean"?r:(e=r==null?void 0:r.escapeKey)!=null?e:!1,outsidePress:typeof r=="boolean"?r:(t=r==null?void 0:r.outsidePress)!=null?t:!0}};function Iw(r,e){e===void 0&&(e={});const{open:t,onOpenChange:n,elements:s,dataRef:i}=r,{enabled:o=!0,escapeKey:a=!0,outsidePress:l=!0,outsidePressEvent:c="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:d=!1,bubbles:f,capture:m}=e,v=iv(),x=jn(typeof l=="function"?l:()=>!1),g=typeof l=="function"?x:l,p=D.useRef(!1),{escapeKey:y,outsidePress:b}=Sf(f),{escapeKey:O,outsidePress:S}=Sf(m),T=D.useRef(!1),C=jn(A=>{var G;if(!t||!o||!a||A.key!=="Escape"||T.current)return;const Y=(G=i.current.floatingContext)==null?void 0:G.nodeId,W=v?Vo(v.nodesRef.current,Y):[];if(!y&&(A.stopPropagation(),W.length>0)){let k=!0;if(W.forEach(F=>{var B;if((B=F.context)!=null&&B.open&&!F.context.dataRef.current.__escapeKeyBubbles){k=!1;return}}),!k)return}n(!1,R1(A)?A.nativeEvent:A,"escape-key")}),P=jn(A=>{var G;const Y=()=>{var W;C(A),(W=js(A))==null||W.removeEventListener("keydown",Y)};(G=js(A))==null||G.addEventListener("keydown",Y)}),j=jn(A=>{var G;const Y=i.current.insideReactTree;i.current.insideReactTree=!1;const W=p.current;if(p.current=!1,c==="click"&&W||Y||typeof g=="function"&&!g(A))return;const k=js(A),F="["+Eh("inert")+"]",B=vi(s.floating).querySelectorAll(F);let L=Se(k)?k:null;for(;L&&!gr(L);){const H=wr(L);if(gr(H)||!Se(H))break;L=H}if(B.length&&Se(k)&&!j1(k)&&!fu(k,s.floating)&&Array.from(B).every(H=>!fu(L,H)))return;if(tr(k)&&U){const H=gr(k),K=Ct(k),ee=/auto|scroll/,ae=H||ee.test(K.overflowX),z=H||ee.test(K.overflowY),oe=ae&&k.clientWidth>0&&k.scrollWidth>k.clientWidth,Ge=z&&k.clientHeight>0&&k.scrollHeight>k.clientHeight,Ke=K.direction==="rtl",ot=Ge&&(Ke?A.offsetX<=k.offsetWidth-k.clientWidth:A.offsetX>k.clientWidth),gy=oe&&A.offsetY>k.clientHeight;if(ot||gy)return}const X=(G=i.current.floatingContext)==null?void 0:G.nodeId,q=v&&Vo(v.nodesRef.current,X).some(H=>{var K;return ql(A,(K=H.context)==null?void 0:K.elements.floating)});if(ql(A,s.floating)||ql(A,s.domReference)||q)return;const Q=v?Vo(v.nodesRef.current,X):[];if(Q.length>0){let H=!0;if(Q.forEach(K=>{var ee;if((ee=K.context)!=null&&ee.open&&!K.context.dataRef.current.__outsidePressBubbles){H=!1;return}}),!H)return}n(!1,A,"outside-press")}),R=jn(A=>{var G;const Y=()=>{var W;j(A),(W=js(A))==null||W.removeEventListener(c,Y)};(G=js(A))==null||G.addEventListener(c,Y)});D.useEffect(()=>{if(!t||!o)return;i.current.__escapeKeyBubbles=y,i.current.__outsidePressBubbles=b;let A=-1;function G(B){n(!1,B,"ancestor-scroll")}function Y(){window.clearTimeout(A),T.current=!0}function W(){A=window.setTimeout(()=>{T.current=!1},ol()?5:0)}const k=vi(s.floating);a&&(k.addEventListener("keydown",O?P:C,O),k.addEventListener("compositionstart",Y),k.addEventListener("compositionend",W)),g&&k.addEventListener(c,S?R:j,S);let F=[];return d&&(Se(s.domReference)&&(F=Gr(s.domReference)),Se(s.floating)&&(F=F.concat(Gr(s.floating))),!Se(s.reference)&&s.reference&&s.reference.contextElement&&(F=F.concat(Gr(s.reference.contextElement)))),F=F.filter(B=>{var L;return B!==((L=k.defaultView)==null?void 0:L.visualViewport)}),F.forEach(B=>{B.addEventListener("scroll",G,{passive:!0})}),()=>{a&&(k.removeEventListener("keydown",O?P:C,O),k.removeEventListener("compositionstart",Y),k.removeEventListener("compositionend",W)),g&&k.removeEventListener(c,S?R:j,S),F.forEach(B=>{B.removeEventListener("scroll",G)}),window.clearTimeout(A)}},[i,s,a,g,c,t,n,d,o,y,b,C,O,P,j,S,R]),D.useEffect(()=>{i.current.insideReactTree=!1},[i,g,c]);const I=D.useMemo(()=>({onKeyDown:C,...u&&{[Fw[h]]:A=>{n(!1,A.nativeEvent,"reference-press")},...h!=="click"&&{onClick(A){n(!1,A.nativeEvent,"reference-press")}}}}),[C,n,u,h]),U=D.useMemo(()=>{function A(G){G.button===0&&(p.current=!0)}return{onKeyDown:C,onMouseDown:A,onMouseUp:A,[Nw[c]]:()=>{i.current.insideReactTree=!0}}},[C,c,i]);return D.useMemo(()=>o?{reference:I,floating:U}:{},[o,I,U])}function Bw(r){const{open:e=!1,onOpenChange:t,elements:n}=r,s=sv(),i=D.useRef({}),[o]=D.useState(()=>Ew()),a=Pw()!=null,[l,c]=D.useState(n.reference),u=jn((f,m,v)=>{i.current.openEvent=f?m:void 0,o.emit("openchange",{open:f,event:m,reason:v,nested:a}),t==null||t(f,m,v)}),h=D.useMemo(()=>({setPositionReference:c}),[]),d=D.useMemo(()=>({reference:l||n.reference||null,floating:n.floating||null,domReference:n.reference}),[l,n.reference,n.floating]);return D.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:d,events:o,floatingId:s,refs:h}),[e,u,d,o,s,h])}function zw(r){r===void 0&&(r={});const{nodeId:e}=r,t=Bw({...r,elements:{reference:null,floating:null,...r.elements}}),n=r.rootContext||t,s=n.elements,[i,o]=D.useState(null),[a,l]=D.useState(null),u=(s==null?void 0:s.domReference)||i,h=D.useRef(null),d=iv();mn(()=>{u&&(h.current=u)},[u]);const f=yw({...r,elements:{...s,...a&&{reference:a}}}),m=D.useCallback(y=>{const b=Se(y)?{getBoundingClientRect:()=>y.getBoundingClientRect(),getClientRects:()=>y.getClientRects(),contextElement:y}:y;l(b),f.refs.setReference(b)},[f.refs]),v=D.useCallback(y=>{(Se(y)||y===null)&&(h.current=y,o(y)),(Se(f.refs.reference.current)||f.refs.reference.current===null||y!==null&&!Se(y))&&f.refs.setReference(y)},[f.refs]),x=D.useMemo(()=>({...f.refs,setReference:v,setPositionReference:m,domReference:h}),[f.refs,v,m]),g=D.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),p=D.useMemo(()=>({...f,...n,refs:x,elements:g,nodeId:e}),[f,x,g,e,n]);return mn(()=>{n.dataRef.current.floatingContext=p;const y=d==null?void 0:d.nodesRef.current.find(b=>b.id===e);y&&(y.context=p)}),D.useMemo(()=>({...f,context:p,refs:x,elements:g}),[f,x,g,p])}function ec(r,e,t){const n=new Map,s=t==="item";let i=r;if(s&&r){const{[pf]:o,[mf]:a,...l}=r;i=l}return{...t==="floating"&&{tabIndex:-1,[bw]:""},...i,...e.map(o=>{const a=o?o[t]:null;return typeof a=="function"?r?a(r):null:a}).concat(r).reduce((o,a)=>(a&&Object.entries(a).forEach(l=>{let[c,u]=l;if(!(s&&[pf,mf].includes(c)))if(c.indexOf("on")===0){if(n.has(c)||n.set(c,[]),typeof u=="function"){var h;(h=n.get(c))==null||h.push(u),o[c]=function(){for(var d,f=arguments.length,m=new Array(f),v=0;v<f;v++)m[v]=arguments[v];return(d=n.get(c))==null?void 0:d.map(x=>x(...m)).find(x=>x!==void 0)}}}else o[c]=u}),o),{})}}function Ww(r){r===void 0&&(r=[]);const e=r.map(a=>a==null?void 0:a.reference),t=r.map(a=>a==null?void 0:a.floating),n=r.map(a=>a==null?void 0:a.item),s=D.useCallback(a=>ec(a,r,"reference"),e),i=D.useCallback(a=>ec(a,r,"floating"),t),o=D.useCallback(a=>ec(a,r,"item"),n);return D.useMemo(()=>({getReferenceProps:s,getFloatingProps:i,getItemProps:o}),[s,i,o])}const Vw=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],Hw=["50","100","200","300","400","500","600","700","800","900","950"];function tc({prefix:r,currentValue:e,colors:t,locked:n,lockedValue:s,onHover:i,onLeave:o,onClick:a}){return w.jsxs("div",{className:"p-2 bg-bv-surface border border-bv-border rounded-md my-2",onMouseLeave:()=>{n||o()},children:[w.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[w.jsx("span",{className:"w-[52px] text-[10px] text-bv-muted text-right pr-1.5 shrink-0"}),["black","white","transparent"].map(l=>t[l]!==void 0?w.jsx(bf,{prefix:r,colorName:l,colorValue:t[l],isCurrent:l===e,isLocked:s===`${r}${l}`,locked:n,onHover:i,onClick:a},l):null)]}),Vw.map(l=>{const c=t[l];return!c||typeof c!="object"?null:w.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[w.jsx("span",{className:"w-[52px] text-[10px] text-bv-muted text-right pr-1.5 shrink-0",children:l}),Hw.map(u=>c[u]!==void 0?w.jsx(bf,{prefix:r,colorName:`${l}-${u}`,colorValue:c[u],isCurrent:`${l}-${u}`===e,isLocked:s===`${r}${l}-${u}`,locked:n,onHover:i,onClick:a},`${l}-${u}`):null)]},l)})]})}function bf({prefix:r,colorName:e,colorValue:t,isCurrent:n,isLocked:s,locked:i,onHover:o,onClick:a}){const l=`${r}${e}`,c=s?"outline outline-2 outline-offset-2 outline-bv-teal border-transparent":n?"outline outline-2 outline-offset-2 outline-bv-orange border-transparent":i?"border-transparent":"border-transparent hover:border-bv-text hover:scale-110 hover:z-10",u=e==="transparent"?{background:"repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 50% / 8px 8px"}:{backgroundColor:t};return w.jsx("div",{title:l,className:`w-5 h-5 rounded cursor-pointer border-2 shrink-0 transition-[border-color,transform] ${c}`,style:u,onMouseEnter:()=>{i||o(l)},onClick:h=>{h.stopPropagation(),a(l)}})}const $w=4,Xw=10;function Qi({values:r,currentValue:e,lockedValue:t,locked:n,ghost:s,onStart:i,onHover:o,onLeave:a,onClick:l}){const[c,u]=D.useState(!1),[h,d]=D.useState(null),f=D.useRef(null),m=D.useRef(null),v=D.useRef(null),x=t!==null&&r.includes(t),g=h!==null?r[h]:x?t:e;D.useEffect(()=>{if(!c)return;const C=P=>{var j;(j=m.current)!=null&&j.contains(P.target)||(u(!1),a())};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[c,a]),D.useEffect(()=>{var C,P;c&&v.current&&((P=(C=v.current).scrollIntoView)==null||P.call(C,{block:"nearest"}))},[c]);const p=n&&!x;function y(C){if(p)return;i==null||i();const P=x?t:e,j=r.indexOf(P);f.current={startX:C.clientX,startIndex:j>=0?j:0,didScrub:!1},C.currentTarget.setPointerCapture(C.pointerId),C.preventDefault()}function b(C){const P=f.current;if(!P)return;const j=C.clientX-P.startX;if(!P.didScrub&&Math.abs(j)>$w&&(P.didScrub=!0,u(!1)),P.didScrub){const R=Math.round(j/Xw),I=Math.max(0,Math.min(r.length-1,P.startIndex+R));d(I),o(r[I])}}function O(){const C=f.current;C&&(C.didScrub&&h!==null?l(r[h]):C.didScrub||u(P=>(P&&a(),!P)),d(null),f.current=null)}const S=h!==null,T=S?"border-bv-teal bg-bv-teal/9 text-bv-teal":x?"border-bv-border bg-bv-surface-hi text-bv-text hover:border-bv-teal hover:bg-bv-teal/9 hover:text-bv-teal":c?"border-bv-border bg-bv-surface-hi text-bv-text":p?"bg-bv-surface text-bv-text-mid border-transparent":s?"border-dashed border-bv-border text-bv-muted bg-transparent hover:border-bv-teal hover:text-bv-teal":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:bg-bv-teal/9 hover:text-bv-teal";return w.jsxs("div",{ref:m,className:"relative inline-block",children:[w.jsxs("div",{className:`group select-none px-2 py-0.5 rounded text-[11px] font-mono border transition-colors ${p?"cursor-default":"cursor-ew-resize"} ${T}`,onPointerDown:y,onPointerMove:b,onPointerUp:O,children:[!p&&w.jsx("span",{className:`inline-block mr-0.5 text-[9px] transition-opacity ${S?"opacity-100":"opacity-0 group-hover:opacity-50"}`,children:"‹"}),g,!p&&w.jsx("span",{className:`inline-block ml-0.5 text-[9px] transition-opacity ${S?"opacity-100":"opacity-0 group-hover:opacity-50"}`,children:"›"})]}),c&&w.jsx("div",{className:"absolute z-50 top-full left-0 mt-0.5 max-h-52 overflow-y-auto bg-bv-bg border border-bv-border rounded-md shadow-md min-w-[5rem]",onMouseLeave:a,children:r.map(C=>{const P=C===(t??e),j=P?"bg-bv-teal/9 text-bv-teal":"text-bv-text-mid hover:bg-bv-surface hover:text-bv-text";return w.jsx("div",{ref:P?v:void 0,className:`px-2 py-[3px] text-[11px] font-mono cursor-pointer ${j}`,onMouseEnter:()=>o(C),onClick:R=>{R.stopPropagation(),l(C),u(!1)},children:C},C)})})]})}const Uw={px:.0625};function _f(r){return isNaN(Number(r))?Uw[r]??1/0:Number(r)}function Ji(r,e,t){return e==="spacing"&&(t!=null&&t.spacing)?Object.keys(t.spacing).sort((s,i)=>_f(s)-_f(i)).map(s=>`${r}${s}`):e==="fontSize"?["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"]:e==="fontWeight"?["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"]:e==="borderRadius"?["rounded-none","rounded-sm","rounded","rounded-md","rounded-lg","rounded-xl","rounded-2xl","rounded-3xl","rounded-full"]:e==="lineHeight"?["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"]:e==="letterSpacing"?["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"]:[]}const Yw=4,Gw=10;function av({placeholder:r,values:e,currentValue:t,displayValue:n,formatValue:s,axis:i="x",disabled:o,onHover:a,onLeave:l,onClick:c,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f}){const[m,v]=D.useState(!1),[x,g]=D.useState(null),[p,y]=D.useState(null),b=D.useRef(null),O=D.useRef(null),S=D.useRef(null),T=t!=null,C=t?e.indexOf(t):-1,P=p!==null?e[p]:null,j=P?s?s(P):P:n??r;D.useEffect(()=>{var F;if(!m){g(null);return}const k=(F=O.current)==null?void 0:F.getBoundingClientRect();k&&g({top:k.bottom+4,left:k.left+k.width/2})},[m]),D.useEffect(()=>{if(!m)return;const k=F=>{var B;(B=O.current)!=null&&B.contains(F.target)||(v(!1),f==null||f(),l==null||l())};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[m,l,f]),D.useEffect(()=>{var k,F;m&&S.current&&((F=(k=S.current).scrollIntoView)==null||F.call(k,{block:"nearest"}))},[m]);function R(k){var B,L;if(o)return;k.preventDefault(),k.stopPropagation();const F=C>=0?C:0;b.current={startX:k.clientX,startY:k.clientY,startIndex:F,didScrub:!1},(L=(B=k.target).setPointerCapture)==null||L.call(B,k.pointerId)}function I(k){const F=b.current;if(!F)return;const B=i==="y"?-(k.clientY-F.startY):k.clientX-F.startX;if(!F.didScrub&&Math.abs(B)>Yw&&(F.didScrub=!0,v(!1),u==null||u()),F.didScrub){const L=Math.round(B/Gw),X=Math.max(0,Math.min(e.length-1,F.startIndex+L));y(X),a==null||a(e[X])}}function U(){const k=b.current;k&&(k.didScrub&&p!==null?(c==null||c(e[p]),y(null),b.current=null,h==null||h()):k.didScrub||(y(null),b.current=null,v(F=>F?(f==null||f(),l==null||l(),!1):(d==null||d(),!0))))}const A=p!==null,Y=["bm-slot",T||A?"bm-has-val":"",A?"bm-scrubbing":""].filter(Boolean).join(" "),W=o?"default":i==="y"?"ns-resize":"ew-resize";return w.jsxs("span",{ref:O,className:Y,style:{position:"relative",cursor:W},onPointerDown:R,onPointerMove:I,onPointerUp:U,role:"button",tabIndex:o?-1:0,children:[j,m&&x&&nl.createPortal(w.jsx("div",{className:"bm-mini-dropdown",style:{position:"fixed",top:x.top,left:x.left,transform:"translateX(-50%)"},onClick:k=>k.stopPropagation(),onMouseLeave:()=>l==null?void 0:l(),onMouseDown:k=>k.stopPropagation(),children:e.map(k=>{const F=k===t;return w.jsx("div",{ref:F?S:void 0,className:`bm-mini-dropdown-item${F?" bm-active":""}`,onMouseEnter:()=>a==null?void 0:a(k),onClick:B=>{B.stopPropagation(),c==null||c(k),v(!1),f==null||f()},children:k},k)})}),document.body)]})}function Cf(r,e){const n={padding:"p",margin:"m",border:"border-",outline:"outline-"}[e];return r.startsWith(n)?r.slice(n.length):r}function Kw({value:r,placeholder:e,layer:t,frozen:n,scaleValues:s,axis:i,onClick:o,onValueChange:a,onValueHover:l,onValueLeave:c,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f}){const m=r!=null,v=m?Cf(r,t):null;if(s&&s.length>0)return w.jsx(av,{placeholder:e,values:s,currentValue:r,displayValue:v,formatValue:g=>Cf(g,t),axis:i,disabled:n,onHover:l,onLeave:c,onClick:a,onScrubStart:u,onScrubEnd:h,onOpen:d,onClose:f});const x=`bm-slot${m?" bm-has-val":""}`;return w.jsx("span",{className:x,onClick:n?void 0:g=>o==null?void 0:o(g.currentTarget),role:"button",tabIndex:n?-1:0,children:v??e})}const qw={top:["y","t"],right:["r"],bottom:["b"],left:["x","l"],tr:["color"],bl:["style"],br:["offset"]},Qw={margin:["top","right","bottom","left"],outline:["top","right","bottom","left","tr","bl","br"],border:["top","right","bottom","left","tr","bl"],padding:["top","right","bottom","left"]},Jw={top:"y",bottom:"y",left:"x",right:"x",tr:"x",bl:"x",br:"x"};function Zw({layer:r,classState:e,shorthandValue:t,shorthandScaleValues:n,slots:s,isHovered:i,frozen:o,onHoverChange:a,onSlotClick:l,onSlotChange:c,onSlotHover:u,onScrubStart:h,onScrubEnd:d,onSlotOpen:f,onSlotClose:m,children:v}){const x=`bm-layer bm-${r}${i?" bm-hovered":""}`,[g,p]=D.useState(null),y=new Map(s.map(j=>[j.key,j])),b=(e==="shorthand"||e==="mixed")&&t,O=n&&n.length>0?w.jsx("span",{className:"bm-name bm-name-scrubber",children:w.jsx(av,{placeholder:r,values:n,currentValue:b?t:null,displayValue:b?t:null,formatValue:j=>j,axis:"x",disabled:o,onHover:j=>u==null?void 0:u("shorthand",j),onLeave:()=>u==null?void 0:u("shorthand",null),onClick:j=>c==null?void 0:c("shorthand",j),onScrubStart:()=>{h==null||h()},onScrubEnd:d,onOpen:()=>{p("__shorthand__"),f==null||f()},onClose:()=>{p(null),m==null||m()}})}):b?w.jsx("span",{className:"bm-name",children:w.jsx("span",{className:"bm-val",onClick:j=>l==null?void 0:l("shorthand",j.currentTarget),children:t})}):w.jsx("span",{className:"bm-name",children:r}),T=(Qw[r]??[]).map(j=>{const I=(qw[j]??[]).map(W=>y.get(W)).filter(W=>W!=null);if(I.length===0)return null;const U=I.some(W=>W.value!=null),G=`bm-slot-group bm-sg-${j}${U?" bm-has-values":""}${g===j?" bm-sg-active":""}`,Y=Jw[j];return w.jsx("div",{className:G,children:I.map(W=>w.jsx(Kw,{slotKey:W.key,value:W.value,placeholder:W.placeholder,layer:r,isExpanded:i,frozen:o,scaleValues:W.scaleValues,axis:Y,onClick:k=>l==null?void 0:l(W.key,k),onValueChange:c?k=>c(W.key,k):void 0,onValueHover:u?k=>u(W.key,k):void 0,onValueLeave:u?()=>u(W.key,null):void 0,onScrubStart:h,onScrubEnd:d,onOpen:()=>{p(j),f==null||f()},onClose:()=>{p(null),m==null||m()}},W.key))},j)}),C=j=>{j.stopPropagation(),o||a(!0)},P=j=>{const R=j.relatedTarget,I=j.currentTarget;R&&I.contains(R)||o||a(!1)};return w.jsxs("div",{className:x,onMouseOver:C,onMouseOut:P,"data-layer":r,children:[O,T,v]})}const Tf=["margin","outline","border","padding"];function eS({layers:r,frozen:e=!1,onSlotClick:t,onSlotChange:n,onSlotHover:s,onEditStart:i}){const[o,a]=D.useState(null),[l,c]=D.useState(null),u=e||l!==null,h=new Map(r.map(g=>[g.layer,g])),d=(g,p)=>{u||a(p?g:null)},f=(g,p,y)=>{u||t==null||t(g,p,y)};let v=w.jsx("div",{className:"bm-content"});for(let g=Tf.length-1;g>=0;g--){const p=Tf[g],y=h.get(p);y&&(v=w.jsx(Zw,{layer:y.layer,classState:y.classState,shorthandValue:y.shorthandValue,shorthandScaleValues:y.shorthandScaleValues,slots:y.slots,isHovered:o===p||l===p,frozen:u,onHoverChange:b=>d(p,b),onSlotClick:(b,O)=>f(p,b,O),onSlotChange:n?(b,O)=>n(p,b,O):void 0,onSlotHover:s?(b,O)=>s(p,b,O):void 0,onScrubStart:()=>{c(p),i==null||i()},onScrubEnd:()=>c(null),onSlotOpen:()=>{c(p),i==null||i()},onSlotClose:()=>c(null),children:v}))}const x=`bm-root${u?" bm-frozen":""}`;return w.jsx("div",{className:x,children:v})}const tS={margin:{shorthand:"m",x:"mx",y:"my",t:"mt",r:"mr",b:"mb",l:"ml"},outline:{shorthand:"outline",x:"outline-x",y:"outline-y",t:"outline-t",r:"outline-r",b:"outline-b",l:"outline-l"},border:{shorthand:"border",x:"border-x",y:"border-y",t:"border-t",r:"border-r",b:"border-b",l:"border-l"},padding:{shorthand:"p",x:"px",y:"py",t:"pt",r:"pr",b:"pb",l:"pl"}},rS=["y","t","r","b","x","l"];function nS(r){const e=rS.map(t=>({key:t,placeholder:t}));return(r==="border"||r==="outline")&&e.push({key:"color",placeholder:"color"},{key:"style",placeholder:"style"}),r==="outline"&&e.push({key:"offset",placeholder:"offset"}),e}function sS(r,e){const t=tS[r],n=nS(r),s=e[t.shorthand]??null,i=s!=null?s===""?t.shorthand:`${t.shorthand}-${s}`:null,o=n.map(({key:d,placeholder:f})=>{let m;if(d==="color"){const g=r==="outline"?"outline-color":"border-color";m=g in e?g:void 0}else if(d==="style"){const g=r==="outline"?"outline-style":"border-style";m=g in e?g:void 0}else d==="offset"?m="outline-offset"in e?"outline-offset":void 0:m=t[d];const v=m?e[m]??null:null;let x;return(d==="color"||d==="style")&&v!=null?x=`${r==="outline"?"outline":"border"}-${v}`:x=v!=null&&m?`${m}-${v}`:null,{key:d,value:x,placeholder:f}}),a=i!=null,l=o.some(d=>(d.key==="x"||d.key==="y")&&d.value!=null),c=o.some(d=>(d.key==="t"||d.key==="r"||d.key==="b"||d.key==="l")&&d.value!=null),u=l||c;let h;return!a&&!u?h="none":a&&!u?h="shorthand":!a&&l&&!c?h="axis":a?h="mixed":h="individual",{layer:r,classState:h,shorthandValue:i,slots:o}}const gu=["px","0","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96"],lv=["0","","2","3","4","5","6","8","10","12","16","20","24","32","40","48","56","64"],iS=["solid","dashed","dotted","double","hidden","none"];function oS(r,e,t){var o,a,l;if(e==="color")return[];if(e==="style"){const c=r==="outline"?"outline":"border";return iS.map(u=>`${c}-${u}`)}let n;r==="border"||r==="outline"?e==="offset"?n=(o=t==null?void 0:t.theme)!=null&&o.spacing?Object.keys(t.theme.spacing):gu:n=(a=t==null?void 0:t.theme)!=null&&a.borderWidth?Object.keys(t.theme.borderWidth):lv:n=(l=t==null?void 0:t.theme)!=null&&l.spacing?Object.keys(t.theme.spacing):gu;const i={margin:{shorthand:"m",t:"mt",r:"mr",b:"mb",l:"ml",x:"mx",y:"my"},padding:{shorthand:"p",t:"pt",r:"pr",b:"pb",l:"pl",x:"px",y:"py"},border:{t:"border-t",r:"border-r",b:"border-b",l:"border-l",x:"border-x",y:"border-y",offset:"outline-offset"},outline:{t:"outline-t",r:"outline-r",b:"outline-b",l:"outline-l",x:"outline-x",y:"outline-y",offset:"outline-offset"}}[r][e];return i?n.map(c=>c===""?i:`${i}-${c}`):[]}function Zi(r,e){const t={};for(const o of r){let a=o.prefix.replace(/-$/,"");a==="border"&&o.themeKey==="colors"?a="border-color":a==="border"&&o.themeKey===null&&o.valueType==="enum"?a="border-style":a==="outline"&&o.themeKey==="colors"&&(a="outline-color"),t[a]=o.value}const n={margin:"m",padding:"p",border:"border",outline:"outline"},s={margin:!1,padding:!1,border:!0,outline:!1};return["margin","outline","border","padding"].map(o=>{var h,d;const a=sS(o,t),l=a.slots.map(f=>{const m=oS(o,f.key,e);return m.length>0?{...f,scaleValues:m}:f}),u=(s[o]?(h=e==null?void 0:e.theme)!=null&&h.borderWidth?Object.keys(e.theme.borderWidth):lv:(d=e==null?void 0:e.theme)!=null&&d.spacing?Object.keys(e.theme.spacing):gu).map(f=>f===""?n[o]:`${n[o]}-${f}`);return{...a,slots:l,shorthandScaleValues:u}})}function aS({label:r,availableProperties:e=[],onAddProperty:t,isEmpty:n=!1,children:s}){const[i,o]=D.useState(!1),a=D.useRef(null);D.useEffect(()=>{if(!i)return;function c(u){a.current&&!a.current.contains(u.target)&&o(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);function l(c){t==null||t(c),o(!1)}return w.jsxs("div",{className:"mb-1",children:[w.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[w.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),w.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:r}),e.length>0&&w.jsxs("div",{className:"relative ml-auto",ref:a,children:[w.jsx("button",{type:"button","aria-label":`Add ${r} property`,className:`w-[18px] h-[18px] flex items-center justify-center rounded text-[11px] leading-none border transition-colors cursor-pointer ${i?"border-bv-teal text-bv-teal bg-bv-teal/10":"border-bv-border text-bv-muted bg-transparent hover:border-bv-teal hover:text-bv-teal hover:bg-bv-teal/10"}`,onClick:()=>o(c=>!c),children:"+"}),i&&w.jsx("div",{className:"absolute z-50 top-[calc(100%+2px)] right-0 bg-bv-bg border border-bv-border rounded-md shadow-[0_4px_16px_rgba(0,0,0,0.10)] min-w-[180px] py-1",children:e.map(c=>w.jsxs("button",{type:"button",className:"w-full px-2.5 py-[5px] text-[11px] font-[family-name:var(--font-ui)] text-bv-text-mid flex items-center gap-1.5 transition-colors hover:bg-bv-teal/10 hover:text-bv-teal cursor-pointer border-none bg-transparent text-left",onClick:()=>l(c.prefix),children:[c.name,w.jsx("span",{className:"font-mono text-[10px] text-bv-muted group-hover:text-bv-teal/60",children:c.prefixHint})]},c.prefix))})]})]}),n?w.jsxs("div",{className:"text-[10px] text-bv-muted italic mb-2",children:["No ",r.toLowerCase()," classes — click + to add"]}):w.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:s}),w.jsx("hr",{className:"border-none border-t border-bv-border my-1"})]})}const kf={spacing:"Spacing",sizing:"Sizing",typography:"Typography",color:"Color",borders:"Borders",effects:"Effects",layout:"Layout",flexbox:"Flexbox & Grid"},Ef=new Set(["m-","mx-","my-","mt-","mr-","mb-","ml-","ms-","me-","p-","px-","py-","pt-","pr-","pb-","pl-","ps-","pe-","border-","border-t-","border-r-","border-b-","border-l-","outline-","outline-offset-","rounded-","rounded-t-","rounded-r-","rounded-b-","rounded-l-","rounded-tl-","rounded-tr-","rounded-br-","rounded-bl-","gap-","gap-x-","gap-y-","space-x-","space-y-"]),Of=new Set(["border","rounded"]),lS=[{name:"Font size",prefixHint:"text-{size}",prefix:"text-size"},{name:"Font weight",prefixHint:"font-*",prefix:"font-"},{name:"Text color",prefixHint:"text-{color}",prefix:"text-color"},{name:"Text align",prefixHint:"text-{align}",prefix:"text-align"},{name:"Line height",prefixHint:"leading-*",prefix:"leading-"},{name:"Letter spacing",prefixHint:"tracking-*",prefix:"tracking-"}],cS=[{name:"Width",prefixHint:"w-*",prefix:"w-"},{name:"Height",prefixHint:"h-*",prefix:"h-"},{name:"Min width",prefixHint:"min-w-*",prefix:"min-w-"},{name:"Max width",prefixHint:"max-w-*",prefix:"max-w-"},{name:"Min height",prefixHint:"min-h-*",prefix:"min-h-"},{name:"Max height",prefixHint:"max-h-*",prefix:"max-h-"},{name:"Size",prefixHint:"size-*",prefix:"size-"}],uS=[{name:"Background color",prefixHint:"bg-{color}",prefix:"bg-"}],Df=["sizing","typography","color"],$o={"w-":{parserPrefix:"w-",themeKey:"spacing",valueType:"scalar"},"h-":{parserPrefix:"h-",themeKey:"spacing",valueType:"scalar"},"min-w-":{parserPrefix:"min-w-",themeKey:"spacing",valueType:"scalar"},"max-w-":{parserPrefix:"max-w-",themeKey:"spacing",valueType:"scalar"},"min-h-":{parserPrefix:"min-h-",themeKey:"spacing",valueType:"scalar"},"max-h-":{parserPrefix:"max-h-",themeKey:"spacing",valueType:"scalar"},"size-":{parserPrefix:"size-",themeKey:"spacing",valueType:"scalar"},"font-":{parserPrefix:"font-",themeKey:"fontWeight",valueType:"scalar"},"text-size":{parserPrefix:"text-",themeKey:"fontSize",valueType:"scalar"},"text-color":{parserPrefix:"text-",themeKey:"colors",valueType:"color"},"text-align":{parserPrefix:"text-",themeKey:null,valueType:"enum"},"leading-":{parserPrefix:"leading-",themeKey:"lineHeight",valueType:"scalar"},"tracking-":{parserPrefix:"tracking-",themeKey:"letterSpacing",valueType:"scalar"},"bg-":{parserPrefix:"bg-",themeKey:"colors",valueType:"color"}};function hS(r,e,t,n){const s=new Set(e.map(i=>i.prefix));return r.filter(i=>{if(t.has(i.prefix)||n!=null&&n.has(i.prefix))return!1;const o=$o[i.prefix],a=(o==null?void 0:o.parserPrefix)??i.prefix;return!s.has(a)})}function dS(r){const e=new Map;for(const t of r){const n=e.get(t.category)||[];n.push(t),e.set(t.category,n)}return e}function fS({componentName:r,instanceCount:e,parsedClasses:t,tailwindConfig:n,patchManager:s}){var B;const[i,o]=D.useState(null),[a,l]=D.useState(new Map),[c,u]=D.useState(null),h=D.useRef(null),{refs:d,floatingStyles:f,context:m}=zw({open:c!==null,onOpenChange:L=>{L||u(null)},placement:"bottom-start",middleware:[xw(4),Sw(),ww({padding:8})],whileElementsMounted:hw}),v=Iw(m),{getFloatingProps:x}=Ww([v]);D.useEffect(()=>{c!=null&&c.anchorEl&&d.setReference(c.anchorEl)},[c==null?void 0:c.anchorEl]);const[g,p]=D.useState(new Set),y=D.useRef(t.map(L=>L.fullClass).join(" ")),b=t.map(L=>L.fullClass).join(" ");D.useEffect(()=>{y.current!==b&&(y.current=b,l(new Map),u(null),p(new Set))});const O=r,S=s.patches.filter(L=>L.status==="staged"),T=new Set(S.filter(L=>L.originalClass==="").map(L=>L.property));function C(L){return a.size===0?L:L.map(X=>{const q=a.get(`${X.layer}-shorthand`),Q=X.slots.map(ee=>{const ae=a.get(`${X.layer}-${ee.key}`);return ae!==void 0?{...ee,value:ae}:ee}),H=q??X.shorthandValue;let K=X.classState;return q!==void 0&&(K=Q.some(ae=>ae.value!=null)?"mixed":"shorthand"),{...X,shorthandValue:H,classState:K,slots:Q}})}const P=dS(t);function j(L,X){s.preview(L,X)}function R(){s.revertPreview()}function I(L,X,q){s.stage(O,L,X,q)}function U(L){s.revertPreview(),Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),o(L)}function A(L,X){s.preview(L.fullClass,X)}function G(L){s.revertPreview()}function Y(L){p(X=>new Set(X).add(L))}function W(L,X){s.preview("",X)}function k(L){s.revertPreview()}function F(L,X){const q=$o[L];s.stage(O,(q==null?void 0:q.parserPrefix)??L,"",X),p(Q=>{const H=new Set(Q);return H.delete(L),H})}return w.jsxs("div",{className:"p-3",children:[w.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[w.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),w.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:"Box Model"})]}),w.jsxs("div",{className:"mb-4",children:[w.jsx(eS,{layers:C(Zi(t,n)),onEditStart:()=>{Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),u(null)},onSlotClick:(L,X,q)=>{var ae;if(X!=="color"||!q){u(null);return}const Q=Zi(t,n).find(z=>z.layer===L),H=`${L}-color`,K=a.get(H)??((ae=Q==null?void 0:Q.slots.find(z=>z.key==="color"))==null?void 0:ae.value)??"",ee=L==="outline"?"outline-":"border-";u(z=>(z==null?void 0:z.layer)===L?null:{layer:L,prefix:ee,currentClass:K,staged:!1,anchorEl:q})},onSlotHover:(L,X,q)=>{var Q;if(q===null)s.revertPreview();else{const H=`${L}-${X}`,K=Zi(t,n).find(ae=>ae.layer===L),ee=X==="shorthand"?a.get(H)??(K==null?void 0:K.shorthandValue):a.get(H)??((Q=K==null?void 0:K.slots.find(ae=>ae.key===X))==null?void 0:Q.value);s.preview(ee??"",q)}},onSlotChange:(L,X,q)=>{var ee;const Q=`${L}-${X}`,H=Zi(t,n).find(ae=>ae.layer===L),K=X==="shorthand"?a.get(Q)??(H==null?void 0:H.shorthandValue):a.get(Q)??((ee=H==null?void 0:H.slots.find(ae=>ae.key===X))==null?void 0:ee.value);I(`${L}-${X}`,K??"",q),l(ae=>new Map(ae).set(Q,q))}}),c&&w.jsx(Aw,{children:w.jsx("div",{ref:d.setFloating,style:{...f,zIndex:9999},...x(),children:w.jsx(tc,{prefix:c.prefix,currentValue:c.currentClass.startsWith(c.prefix)?c.currentClass.slice(c.prefix.length):"",colors:(n==null?void 0:n.colors)||{},locked:!1,lockedValue:((B=S.find(L=>L.property===c.prefix))==null?void 0:B.newClass)??null,onHover:L=>{h.current=L,s.preview(c.currentClass,L)},onLeave:()=>{c.staged&&h.current?(s.preview(h.current,c.currentClass),h.current=null):s.revertPreview()},onClick:L=>{const X=`${c.layer}-color`;I(c.prefix,c.currentClass,L),l(q=>new Map(q).set(X,L)),u(q=>q?{...q,currentClass:L,staged:!0}:null)}})})})]}),Df.map(L=>{var ae;const q=(P.get(L)||[]).filter(z=>!Ef.has(z.prefix)&&!Of.has(z.fullClass)),Q={typography:lS,sizing:cS,color:uS},H=hS(Q[L]||[],q,g,T),K=(Q[L]||[]).filter(z=>g.has(z.prefix)).map(z=>z.prefix),ee=(Q[L]||[]).filter(z=>T.has(z.prefix)).map(z=>z.prefix);return w.jsxs(aS,{label:L==="color"?"Backgrounds":kf[L]||L,availableProperties:H,onAddProperty:Y,isEmpty:q.length===0&&K.length===0&&ee.length===0,children:[q.map(z=>{var oe;if(z.valueType==="scalar"){const Ge=Ji(z.prefix,z.themeKey,n);if(Ge.length>0){const Ke=((oe=S.find(ot=>ot.property===z.prefix))==null?void 0:oe.newClass)??null;return w.jsx(Qi,{values:Ge,currentValue:z.fullClass,lockedValue:Ke,locked:!1,onStart:()=>Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:ot=>A(z,ot),onLeave:()=>G(),onClick:ot=>I(z.prefix,z.fullClass,ot)},z.fullClass)}}return w.jsx("div",{className:`px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border transition-colors ${(i==null?void 0:i.fullClass)===z.fullClass?"border-bv-border bg-bv-surface-hi text-bv-text":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:text-bv-teal"}`,onClick:()=>U(z),children:z.fullClass},z.fullClass)}),(Q[L]||[]).filter(z=>T.has(z.prefix)).map(z=>{const oe=$o[z.prefix];if(!oe||oe.valueType!=="scalar")return null;const Ge=Ji(oe.parserPrefix,oe.themeKey,n);if(Ge.length===0)return null;const Ke=S.find(ot=>ot.property===(oe.parserPrefix??z.prefix));return w.jsx(Qi,{values:Ge,currentValue:(Ke==null?void 0:Ke.newClass)??Ge[Math.floor(Ge.length/2)],lockedValue:(Ke==null?void 0:Ke.newClass)??null,locked:!1,onStart:()=>Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:ot=>W(z.prefix,ot),onLeave:()=>k(z.prefix),onClick:ot=>F(z.prefix,ot)},`staged-${z.prefix}`)}),K.map(z=>{const oe=$o[z];if(!oe)return null;if(oe.valueType==="scalar"){const Ge=Ji(oe.parserPrefix,oe.themeKey,n);if(Ge.length>0)return w.jsx(Qi,{values:Ge,currentValue:Ge[Math.floor(Ge.length/2)],lockedValue:null,locked:!1,ghost:!0,onStart:()=>Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:Ke=>W(z,Ke),onLeave:()=>k(),onClick:Ke=>F(z,Ke)},`pending-${z}`)}return oe.valueType==="color"?w.jsxs("div",{"data-testid":`pending-ghost-${z}`,className:"px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border border-dashed border-bv-border text-bv-muted hover:border-bv-teal hover:text-bv-teal transition-colors",onClick:()=>{o({category:"color",valueType:"color",prefix:oe.parserPrefix,value:"",fullClass:"",themeKey:"colors"})},children:[oe.parserPrefix,"color"]},`pending-${z}`):null}),i&&q.some(z=>z.fullClass===i.fullClass)&&i.valueType==="color"&&w.jsx(tc,{prefix:i.prefix,currentValue:i.value,colors:(n==null?void 0:n.colors)||{},locked:!1,lockedValue:((ae=S.find(z=>z.property===i.prefix))==null?void 0:ae.newClass)??null,onHover:z=>j(i.fullClass,z),onLeave:R,onClick:z=>I(i.prefix,i.fullClass,z)})]},L)}),Array.from(P).filter(([L])=>!Df.includes(L)).map(([L,X])=>{var Q;const q=X.filter(H=>!Ef.has(H.prefix)&&!Of.has(H.fullClass));return q.length===0?null:w.jsxs("div",{children:[w.jsxs("div",{className:"mt-3 mb-1 flex items-center gap-1.5",children:[w.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),w.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:kf[L]||L})]}),w.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:q.map(H=>{var K;if(H.valueType==="scalar"){const ee=Ji(H.prefix,H.themeKey,n);if(ee.length>0){const ae=((K=S.find(z=>z.property===H.prefix))==null?void 0:K.newClass)??null;return w.jsx(Qi,{values:ee,currentValue:H.fullClass,lockedValue:ae,locked:!1,onStart:()=>Pe("overlay",{type:"CLEAR_HIGHLIGHTS"}),onHover:z=>A(H,z),onLeave:()=>G(),onClick:z=>I(H.prefix,H.fullClass,z)},H.fullClass)}}return w.jsx("div",{className:`px-2 py-0.5 rounded cursor-pointer text-[11px] font-mono border transition-colors ${(i==null?void 0:i.fullClass)===H.fullClass?"border-bv-border bg-bv-surface-hi text-bv-text":"bg-bv-surface text-bv-text-mid border-transparent hover:border-bv-teal hover:text-bv-teal"}`,onClick:()=>U(H),children:H.fullClass},H.fullClass)})}),i&&q.some(H=>H.fullClass===i.fullClass)&&i.valueType==="color"&&w.jsx(tc,{prefix:i.prefix,currentValue:i.value,colors:(n==null?void 0:n.colors)||{},locked:!1,lockedValue:((Q=S.find(H=>H.property===i.prefix))==null?void 0:Q.newClass)??null,onHover:H=>j(i.fullClass,H),onLeave:R,onClick:H=>I(i.prefix,i.fullClass,H)})]},L)})]})}function gS(){const[r,e]=D.useState([]),[t,n]=D.useState({draft:0,committed:0,implementing:0,implemented:0,partial:0,error:0}),[s,i]=D.useState({draft:[],commits:[]}),[o,a]=D.useState(!1),l=D.useRef(r);l.current=r;const c=D.useRef(s);c.current=s;const u=D.useCallback((S,T)=>{Pe("overlay",{type:"PATCH_PREVIEW",oldClass:S,newClass:T})},[]),h=D.useCallback(()=>{Pe("overlay",{type:"PATCH_REVERT"})},[]),d=D.useCallback((S,T,C,P)=>{if(P===C){e(R=>R.filter(I=>!(I.kind==="class-change"&&I.elementKey===S&&I.property===T))),Pe("overlay",{type:"PATCH_REVERT"});return}const j=crypto.randomUUID();e(R=>{const I=R.filter(A=>!(A.kind==="class-change"&&A.elementKey===S&&A.property===T)),U={id:j,kind:"class-change",elementKey:S,status:"staged",originalClass:C,newClass:P,property:T,timestamp:new Date().toISOString()};return[...I,U]}),Pe("overlay",{type:"PATCH_STAGE",id:j,oldClass:C,newClass:P,property:T})},[]),f=D.useCallback((S,T,C)=>{const P=crypto.randomUUID(),j=C?{name:C}:void 0;e(R=>{const I={id:P,kind:"message",elementKey:T,status:"staged",originalClass:"",newClass:"",property:"",timestamp:new Date().toISOString(),message:S,component:j};return[...R,I]}),ur(j?{type:"MESSAGE_STAGE",id:P,message:S,elementKey:T,component:j}:{type:"MESSAGE_STAGE",id:P,message:S,elementKey:T})},[]),m=D.useCallback(()=>{const S=c.current.draft.map(P=>P.id),T=l.current.filter(P=>P.status==="staged").map(P=>P.id),C=Array.from(new Set([...S,...T]));C.length!==0&&(ur({type:"PATCH_COMMIT",ids:C}),e([]))},[]),v=D.useCallback(S=>{e(T=>T.filter(C=>C.id!==S)),ur({type:"DISCARD_DRAFTS",ids:[S]}),Pe("overlay",{type:"PATCH_REVERT"})},[]),x=D.useCallback(()=>{const S=c.current.draft.map(P=>P.id),T=l.current.filter(P=>P.status==="staged").map(P=>P.id),C=Array.from(new Set([...S,...T]));e([]),C.length>0&&ur({type:"DISCARD_DRAFTS",ids:C}),Pe("overlay",{type:"PATCH_REVERT"})},[]),g=D.useCallback(()=>{},[]),p=D.useCallback(S=>{n({draft:S.draftCount,committed:S.committedCount,implementing:S.implementingCount,implemented:S.implementedCount,partial:S.partialCount,error:S.errorCount}),i({draft:S.draft,commits:S.commits}),a(!!S.agentWaiting)},[]),y=D.useCallback(S=>{n({draft:S.staged,committed:S.committed,implementing:S.implementing,implemented:S.implemented,partial:0,error:0})},[]),b=r.filter(S=>S.status==="staged").length,O={draft:Math.max(b,t.draft),committed:t.committed,implementing:t.implementing,implemented:t.implemented,partial:t.partial,error:t.error};return{patches:r,counts:O,queueState:s,agentWaiting:o,preview:u,revertPreview:h,stage:d,stageMessage:f,commitAll:m,discard:v,discardAll:x,reset:g,handleQueueUpdate:p,handlePatchUpdate:y}}function eo({label:r,count:e,items:t,activeColor:n,onCommit:s,onDiscard:i,onCommitAll:o,onDiscardAll:a}){const[l,c]=D.useState(!1),u=D.useRef(null),h=D.useRef(null),[d,f]=D.useState(void 0);D.useEffect(()=>{if(!l||!h.current)return;const g=h.current.getBoundingClientRect(),p=220,y=window.innerWidth,b=4;let O=g.left+g.width/2-p/2;O=Math.max(b,Math.min(O,y-p-b)),f(O-g.left)},[l]),D.useEffect(()=>{if(!l)return;function x(g){u.current&&!u.current.contains(g.target)&&c(!1)}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[l]),D.useEffect(()=>{if(!l)return;function x(g){g.key==="Escape"&&c(!1)}return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[l]);const m=e>0,v=s||i||o||a;return w.jsxs("div",{ref:u,className:"relative",children:[w.jsxs("button",{ref:h,className:`text-[11px] tabular-nums border-none bg-transparent cursor-pointer px-0 py-0 ${m?`${n} font-medium`:"text-bv-muted"} ${m?"hover:underline":""}`,onClick:()=>m&&c(!l),disabled:!m,type:"button",children:[e," ",r]}),l&&w.jsxs("div",{className:"absolute bottom-full mb-1 min-w-[220px] bg-bv-surface border border-bv-border rounded-lg shadow-lg overflow-hidden flex flex-col z-[9999]",style:d!==void 0?{left:`${d}px`}:void 0,children:[w.jsxs("div",{className:"px-3 py-1.5 border-b border-bv-border text-[11px] font-semibold text-bv-text-mid uppercase tracking-wide",children:[r," (",e,")"]}),w.jsx("div",{className:"flex-1 overflow-auto",children:t.length===0?w.jsx("div",{className:"px-3 py-2 text-[11px] text-bv-muted italic",children:"No patches"}):t.map(x=>{var y,b;const g="kind"in x&&x.kind==="message",p="kind"in x&&x.kind==="design";return w.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-bv-border last:border-b-0 group",children:[w.jsxs("div",{className:"flex-1 min-w-0",children:[!g&&!p&&((y=x.component)==null?void 0:y.name)&&w.jsx("div",{className:"text-[10px] text-bv-muted truncate",children:x.component.name}),p?w.jsxs("div",{className:"text-[11px] text-bv-text",children:[w.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[w.jsx("span",{children:"✏️"}),w.jsxs("span",{className:"truncate",children:["Drawing",(b=x.component)!=null&&b.name?` in ${x.component.name}`:""]})]}),"image"in x&&x.image&&w.jsx("img",{src:x.image,alt:"Design drawing",className:"w-full max-h-16 object-contain rounded border border-bv-border bg-white"})]}):g?w.jsxs("div",{className:"text-[11px] text-bv-text truncate",children:[w.jsx("span",{className:"mr-1",children:"💬"}),'"',"message"in x&&x.message||"",'"']}):w.jsx("div",{className:"text-[11px] font-mono text-bv-text truncate",children:x.originalClass?w.jsxs(w.Fragment,{children:[w.jsx("span",{className:"line-through text-bv-muted",children:x.originalClass})," → ",w.jsx("span",{className:"text-bv-teal",children:x.newClass})]}):w.jsxs("span",{className:"text-bv-teal",children:["+",x.newClass]})})]}),(s||i)&&w.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[s&&w.jsx("button",{className:"text-[10px] px-1.5 py-0.5 rounded border-none cursor-pointer bg-bv-teal text-white hover:bg-bv-teal-dark transition-colors",onClick:O=>{O.stopPropagation(),s(x.id)},title:"Commit to Agent",type:"button",children:"✓"}),i&&w.jsx("button",{className:"text-[10px] px-1.5 py-0.5 rounded border-none cursor-pointer bg-transparent text-bv-muted hover:text-bv-orange hover:bg-bv-surface-hi transition-colors",onClick:O=>{O.stopPropagation(),i(x.id)},title:"Discard",type:"button",children:"✕"})]})]},x.id)})}),v&&t.length>0&&(o||a)&&w.jsxs("div",{className:"flex gap-2 px-3 py-1.5 border-t border-bv-border",children:[o&&w.jsx("button",{className:"text-[10px] px-2 py-1 rounded border-none cursor-pointer font-semibold bg-bv-teal text-white hover:bg-bv-teal-dark transition-colors",onClick:()=>{o(),c(!1)},type:"button",children:"Commit All"}),a&&w.jsx("button",{className:"text-[10px] px-2 py-1 rounded cursor-pointer font-semibold bg-transparent border border-bv-border text-bv-text-mid hover:text-bv-orange hover:border-bv-orange transition-colors",onClick:()=>{a(),c(!1)},type:"button",children:"Discard All"})]})]})]})}function Pf({tabs:r,activeTab:e,onTabChange:t}){const[n,s]=D.useState(null);return w.jsx("div",{className:"relative flex border-b border-bv-border px-3",children:r.map(i=>{const o=i.id===e,a=i.disabled===!0;return w.jsxs("div",{className:"relative",onMouseEnter:()=>a&&i.tooltip&&s(i.id),onMouseLeave:()=>s(null),children:[w.jsxs("button",{type:"button",className:`relative px-3 py-2 text-[12px] font-medium font-[family-name:var(--font-ui)] border-none bg-transparent cursor-pointer transition-colors ${a?"text-bv-muted cursor-not-allowed":o?"text-bv-text":"text-bv-text-mid hover:text-bv-text"}`,disabled:a,onClick:()=>!a&&t(i.id),"aria-selected":o,role:"tab",children:[i.label,o&&w.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-[2px] bg-bv-teal"})]}),n===i.id&&i.tooltip&&w.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-[10px] text-white bg-bv-text rounded whitespace-nowrap z-[9999]",children:i.tooltip})]},i.id)})})}function Mf({draft:r,currentElementKey:e,onAddMessage:t,onDiscard:n}){const[s,i]=D.useState(""),o=D.useRef(null);D.useEffect(()=>{var h;(h=o.current)==null||h.focus()},[]);const a=r.filter(h=>h.kind==="message"),l=!!s.trim()&&!!e;function c(){var d;const h=s.trim();!h||!e||(t(h,e),i(""),(d=o.current)==null||d.focus())}function u(h){(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),c())}return w.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[w.jsxs("div",{className:"flex flex-col gap-2",children:[w.jsx("textarea",{ref:o,className:"w-full min-h-[80px] p-2 bg-bv-bg border border-bv-border rounded text-[13px] font-[family-name:var(--font-ui)] text-bv-text placeholder:text-bv-muted resize-y focus:outline-none focus:border-bv-teal",placeholder:e?"Add context for the AI agent…":"Select an element to add contextual message…",value:s,onChange:h=>i(h.target.value),onKeyDown:u,disabled:!e}),w.jsx("div",{className:"flex items-center justify-end",children:w.jsx("button",{type:"button",className:"px-3 py-1 text-[11px] font-semibold rounded bg-bv-teal text-white border-none cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",disabled:!l,onClick:c,children:"Add Message"})})]}),a.length>0&&w.jsxs("div",{className:"flex flex-col gap-1",children:[w.jsxs("div",{className:"flex items-center gap-1.5",children:[w.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-bv-teal opacity-50 shrink-0"}),w.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[1px] text-bv-text-mid",children:"Staged Messages"})]}),a.map(h=>{var d;return w.jsxs("div",{className:"flex items-start gap-2 p-2 bg-bv-surface rounded border border-bv-border group",children:[w.jsx("span",{className:"text-[12px] shrink-0 mt-0.5",children:"💬"}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"text-[12px] font-[family-name:var(--font-ui)] text-bv-text break-words",children:['"',h.message,'"']}),h.elementKey&&w.jsx("div",{className:"text-[11px] text-bv-text-mid mt-0.5",children:((d=h.component)==null?void 0:d.name)||h.elementKey})]}),w.jsx("button",{type:"button",className:"shrink-0 text-[10px] px-1 py-0.5 rounded border-none cursor-pointer bg-transparent text-bv-muted hover:text-bv-orange transition-colors opacity-0 group-hover:opacity-100",onClick:()=>n(h.id),title:"Discard",children:"✕"})]},h.id)})]})]})}const pu=[{name:"popover",label:"Popover",icon:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[w.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),w.jsx("rect",{x:"4",y:"4",width:"8",height:"6",rx:"1",fill:"currentColor"})]})},{name:"sidebar",label:"Sidebar",icon:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[w.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),w.jsx("rect",{x:"9",y:"1",width:"6",height:"14",rx:"1.5",fill:"currentColor",opacity:"0.85"})]})},{name:"modal",label:"Modal",icon:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[w.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",fill:"currentColor",opacity:"0.12"}),w.jsx("rect",{x:"3",y:"4",width:"10",height:"8",rx:"1",fill:"currentColor",opacity:"0.9"})]})},{name:"popup",label:"Popup",icon:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[w.jsx("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1.5",stroke:"currentColor",strokeWidth:"1.1",opacity:"0.3"}),w.jsx("rect",{x:"8",y:"8",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.85"})]})}],cv="tw-panel-container";function pS(){try{const r=localStorage.getItem(cv);if(r&&pu.some(e=>e.name===r))return r}catch{}return"popover"}function jf(){const[r,e]=D.useState(pS),[t,n]=D.useState(!1),s=D.useRef(null);D.useEffect(()=>{function a(l){s.current&&!s.current.contains(l.target)&&n(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]);function i(a){if(a!==r){try{localStorage.setItem(cv,a)}catch{}e(a),Pe("overlay",{type:"SWITCH_CONTAINER",container:a})}n(!1)}const o=pu.find(a=>a.name===r);return w.jsxs("div",{ref:s,className:"relative",children:[w.jsx("button",{title:"Change container",onClick:()=>n(a=>!a),className:"w-7 h-7 flex items-center justify-center rounded border border-transparent text-bv-text-mid bg-transparent cursor-pointer transition-colors hover:bg-bv-surface hover:border-bv-border hover:text-bv-text",children:o.icon}),t&&w.jsxs("div",{className:"absolute top-[calc(100%+4px)] right-0 bg-white border border-bv-border rounded-lg shadow-[0_4px_16px_rgba(0,0,0,0.12)] p-1.5 flex flex-col gap-px min-w-[148px] z-50",children:[w.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.8px] text-bv-muted px-2 pt-1 pb-1.5",children:"Container"}),pu.map(a=>w.jsxs("button",{onClick:()=>i(a.name),className:`flex items-center gap-2 px-2 py-1.5 rounded text-[12px] cursor-pointer border-none w-full text-left transition-colors ${a.name===r?"bg-bv-teal/9 text-bv-teal":"bg-transparent text-bv-text-mid hover:bg-bv-surface hover:text-bv-text"}`,children:[a.icon,a.label]},a.name))]})]})}function mS({componentName:r}){const e=t=>{Pe("overlay",{type:"INSERT_DESIGN_CANVAS",insertMode:t})};return w.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[w.jsx("div",{className:"text-[11px] text-bv-text-mid leading-relaxed",children:"Insert a drawing canvas into the page to visually sketch a new UI element. The sketch will be queued as a change for an AI agent to implement."}),w.jsxs("div",{className:"flex flex-col gap-1.5",children:[w.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted",children:"Insert Drawing Canvas"}),w.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[w.jsxs("button",{onClick:()=>e("before"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[w.jsx("span",{className:"text-[13px]",children:"↑"}),"Before element"]}),w.jsxs("button",{onClick:()=>e("after"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[w.jsx("span",{className:"text-[13px]",children:"↓"}),"After element"]}),w.jsxs("button",{onClick:()=>e("first-child"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[w.jsx("span",{className:"text-[13px]",children:"⤒"}),"First child"]}),w.jsxs("button",{onClick:()=>e("last-child"),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-bv-border bg-bv-bg text-[11px] text-bv-text-mid cursor-pointer hover:bg-bv-teal/5 hover:border-bv-teal hover:text-bv-teal transition-all",children:[w.jsx("span",{className:"text-[13px]",children:"⤓"}),"Last child"]})]})]}),w.jsxs("div",{className:"text-[9px] text-bv-muted italic",children:["The canvas will be injected relative to the selected ",w.jsxs("span",{className:"font-mono",children:["<",r,">"]})," element."]})]})}function _(r,e,t){return(e=function(n){var s=function(i,o){if(typeof i!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}(n,"string");return typeof s=="symbol"?s:s+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Rf(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function E(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Rf(Object(t),!0).forEach(function(n){_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Rf(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function de(r,e){if(r==null)return{};var t,n,s=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||{}.propertyIsEnumerable.call(r,t)&&(s[t]=r[t])}return s}function rr(r,e){return e||(e=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(e)}}))}class Af{constructor(){_(this,"browserShadowBlurConstant",1),_(this,"DPI",96),_(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),_(this,"perfLimitSizeTotal",2097152),_(this,"maxCacheSideLimit",4096),_(this,"minCacheSideLimit",256),_(this,"disableStyleCopyPaste",!1),_(this,"enableGLFiltering",!0),_(this,"textureSize",4096),_(this,"forceGLPutImageData",!1),_(this,"cachesBoundsOfCurve",!1),_(this,"fontPaths",{}),_(this,"NUM_FRACTION_DIGITS",4)}}const re=new class extends Af{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=E(E({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(r=>{delete this.fontPaths[r]})}clearFonts(){this.fontPaths={}}restoreDefaults(r){const e=new Af,t=(r==null?void 0:r.reduce((n,s)=>(n[s]=e[s],n),{}))||e;this.configure(t)}},Qr=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return console[r]("fabric",...t)};class Gt extends Error{constructor(e,t){super("fabric: ".concat(e),t)}}class vS extends Gt{constructor(e){super("".concat(e," 'options.signal' is in 'aborted' state"))}}class yS{}class xS extends yS{testPrecision(e,t){const n="precision ".concat(t,` float;
44
- void main(){}`),s=e.createShader(e.FRAGMENT_SHADER);return!!s&&(e.shaderSource(s,n),e.compileShader(s),!!e.getShaderParameter(s,e.COMPILE_STATUS))}queryWebGL(e){const t=e.getContext("webgl");t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(n=>this.testPrecision(t,n)),t.getExtension("WEBGL_lose_context").loseContext(),Qr("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}}const wS={};let Lf;const Zt=()=>Lf||(Lf={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new xS,dispose(){},copyPasteData:wS}),vs=()=>Zt().document,hl=()=>Zt().window,uv=()=>{var r;return Math.max((r=re.devicePixelRatio)!==null&&r!==void 0?r:hl().devicePixelRatio,1)},Ks=new class{constructor(){_(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(r){let{fontFamily:e,fontStyle:t,fontWeight:n}=r;e=e.toLowerCase();const s=this.charWidthsCache;s.has(e)||s.set(e,new Map);const i=s.get(e),o="".concat(t.toLowerCase(),"_").concat((n+"").toLowerCase());return i.has(o)||i.set(o,new Map),i.get(o)}clearFontCache(r){r?this.charWidthsCache.delete((r||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(r){const{perfLimitSizeTotal:e}=re,t=Math.sqrt(e*r);return[Math.floor(t),Math.floor(e/t)]}},mu="6.9.1";function Xo(){}const Pi=Math.PI/2,Oa=2*Math.PI,Oh=Math.PI/180,Xe=Object.freeze([1,0,0,1,0,0]),Dh=16,Dr=.4477152502,J="center",se="left",rt="top",vu="bottom",xe="right",nt="none",Ph=/\r?\n/,hv="moving",dl="scaling",dv="rotating",Mh="rotate",fv="skewing",yi="resizing",SS="modifyPoly",bS="modifyPath",Da="changed",fl="scale",it="scaleX",Tt="scaleY",ys="skewX",xs="skewY",Ee="fill",st="stroke",Pa="modified",Pn="json",rc="svg",V=new class{constructor(){this[Pn]=new Map,this[rc]=new Map}has(r){return this[Pn].has(r)}getClass(r){const e=this[Pn].get(r);if(!e)throw new Gt("No class registered for ".concat(r));return e}setClass(r,e){e?this[Pn].set(e,r):(this[Pn].set(r.type,r),this[Pn].set(r.type.toLowerCase(),r))}getSVGClass(r){return this[rc].get(r)}setSVGClass(r,e){this[rc].set(e??r.type.toLowerCase(),r)}},Ma=new class extends Array{remove(r){const e=this.indexOf(r);e>-1&&this.splice(e,1)}cancelAll(){const r=this.splice(0);return r.forEach(e=>e.abort()),r}cancelByCanvas(r){if(!r)return[];const e=this.filter(t=>{var n;return t.target===r||typeof t.target=="object"&&((n=t.target)===null||n===void 0?void 0:n.canvas)===r});return e.forEach(t=>t.abort()),e}cancelByTarget(r){if(!r)return[];const e=this.filter(t=>t.target===r);return e.forEach(t=>t.abort()),e}};class _S{constructor(){_(this,"__eventListeners",{})}on(e,t){if(this.__eventListeners||(this.__eventListeners={}),typeof e=="object")return Object.entries(e).forEach(n=>{let[s,i]=n;this.on(s,i)}),()=>this.off(e);if(t){const n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}return()=>!1}once(e,t){if(typeof e=="object"){const n=[];return Object.entries(e).forEach(s=>{let[i,o]=s;n.push(this.once(i,o))}),()=>n.forEach(s=>s())}if(t){const n=this.on(e,function(){for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];t.call(this,...i),n()});return n}return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){const n=this.__eventListeners[e],s=n.indexOf(t);s>-1&&n.splice(s,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(const n in this.__eventListeners)this._removeEventListener(n);else typeof e=="object"?Object.entries(e).forEach(n=>{let[s,i]=n;this._removeEventListener(s,i)}):this._removeEventListener(e,t)}fire(e,t){var n;if(!this.__eventListeners)return;const s=(n=this.__eventListeners[e])===null||n===void 0?void 0:n.concat();if(s)for(let i=0;i<s.length;i++)s[i].call(this,t||{})}}const Rn=(r,e)=>{const t=r.indexOf(e);return t!==-1&&r.splice(t,1),r},Sr=r=>{if(r===0)return 1;switch(Math.abs(r)/Pi){case 1:case 3:return 0;case 2:return-1}return Math.cos(r)},br=r=>{if(r===0)return 0;const e=r/Pi,t=Math.sign(r);switch(e){case 1:return t;case 2:return 0;case 3:return-t}return Math.sin(r)};class M{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof e=="object"?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(e){return new M(this.x+e.x,this.y+e.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(e){return new M(this.x+e,this.y+e)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(e){return new M(this.x-e.x,this.y-e.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(e){return new M(this.x-e,this.y-e)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(e){return new M(this.x*e.x,this.y*e.y)}scalarMultiply(e){return new M(this.x*e,this.y*e)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(e){return new M(this.x/e.x,this.y/e.y)}scalarDivide(e){return new M(this.x/e,this.y/e)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return t=Math.max(Math.min(1,t),0),new M(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}distanceFrom(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(e){return new M(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new M(Math.max(this.x,e.x),Math.max(this.y,e.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){const t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new M(this.x,this.y)}rotate(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jh;const n=br(e),s=Sr(e),i=this.subtract(t);return new M(i.x*s-i.y*n,i.x*n+i.y*s).add(t)}transform(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new M(e[0]*this.x+e[2]*this.y+(t?0:e[4]),e[1]*this.x+e[3]*this.y+(t?0:e[5]))}}const jh=new M(0,0),Uo=r=>!!r&&Array.isArray(r._objects);function gv(r){class e extends r{constructor(){super(...arguments),_(this,"_objects",[])}_onObjectAdded(n){}_onObjectRemoved(n){}_onStackOrderChanged(n){}add(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(n){for(var s=arguments.length,i=new Array(s>1?s-1:0),o=1;o<s;o++)i[o-1]=arguments[o];return this._objects.splice(n,0,...i),i.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const n=this._objects,s=[];for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach(l=>{const c=n.indexOf(l);c!==-1&&(n.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(n){this.getObjects().forEach((s,i,o)=>n(s,i,o))}getObjects(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(n){return this._objects[n]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(n,s){return!!this._objects.includes(n)||!!s&&this._objects.some(i=>i instanceof e&&i.contains(n,!0))}complexity(){return this._objects.reduce((n,s)=>n+=s.complexity?s.complexity():0,0)}sendObjectToBack(n){return!(!n||n===this._objects[0])&&(Rn(this._objects,n),this._objects.unshift(n),this._onStackOrderChanged(n),!0)}bringObjectToFront(n){return!(!n||n===this._objects[this._objects.length-1])&&(Rn(this._objects,n),this._objects.push(n),this._onStackOrderChanged(n),!0)}sendObjectBackwards(n,s){if(!n)return!1;const i=this._objects.indexOf(n);if(i!==0){const o=this.findNewLowerIndex(n,i,s);return Rn(this._objects,n),this._objects.splice(o,0,n),this._onStackOrderChanged(n),!0}return!1}bringObjectForward(n,s){if(!n)return!1;const i=this._objects.indexOf(n);if(i!==this._objects.length-1){const o=this.findNewUpperIndex(n,i,s);return Rn(this._objects,n),this._objects.splice(o,0,n),this._onStackOrderChanged(n),!0}return!1}moveObjectTo(n,s){return n!==this._objects[s]&&(Rn(this._objects,n),this._objects.splice(s,0,n),this._onStackOrderChanged(n),!0)}findNewLowerIndex(n,s,i){let o;if(i){o=s;for(let a=s-1;a>=0;--a)if(n.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(n,s,i){let o;if(i){o=s;for(let a=s+1;a<this._objects.length;++a)if(n.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(n){let{left:s,top:i,width:o,height:a}=n,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],u=new M(s,i),h=u.add(new M(o,a));for(let d=this._objects.length-1;d>=0;d--){const f=this._objects[d];f.selectable&&f.visible&&(l&&f.intersectsWithRect(u,h)||f.isContainedWithinRect(u,h)||l&&f.containsPoint(u)||l&&f.containsPoint(h))&&c.push(f)}return c}}return e}class pv extends _S{_setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const t in e)this.set(t,e[t])}_setObject(e){for(const t in e)this._set(t,e[t])}set(e,t){return typeof e=="object"?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){const t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this}get(e){return this[e]}}function Yo(r){return hl().requestAnimationFrame(r)}function CS(r){return hl().cancelAnimationFrame(r)}let TS=0;const Jr=()=>TS++,_r=()=>{const r=vs().createElement("canvas");if(!r||r.getContext===void 0)throw new Gt("Failed to create `canvas` element");return r},kS=()=>vs().createElement("img"),kt=r=>{const e=_r();return e.width=r.width,e.height=r.height,e},mv=(r,e,t)=>r.toDataURL("image/".concat(e),t),vv=(r,e,t)=>new Promise((n,s)=>{r.toBlob(n,"image/".concat(e),t)}),be=r=>r*Oh,Cr=r=>r/Oh,ES=r=>r.every((e,t)=>e===Xe[t]),qe=(r,e,t)=>new M(r).transform(e,t),Ft=r=>{const e=1/(r[0]*r[3]-r[1]*r[2]),t=[e*r[3],-e*r[1],-e*r[2],e*r[0],0,0],{x:n,y:s}=new M(r[4],r[5]).transform(t,!0);return t[4]=-n,t[5]=-s,t},Re=(r,e,t)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],t?0:r[0]*e[4]+r[2]*e[5]+r[4],t?0:r[1]*e[4]+r[3]*e[5]+r[5]],Rh=(r,e)=>r.reduceRight((t,n)=>n&&t?Re(n,t,e):n||t,void 0)||Xe.concat(),yv=r=>{let[e,t]=r;return Math.atan2(t,e)},ja=r=>{const e=yv(r),t=Math.pow(r[0],2)+Math.pow(r[1],2),n=Math.sqrt(t),s=(r[0]*r[3]-r[2]*r[1])/n,i=Math.atan2(r[0]*r[2]+r[1]*r[3],t);return{angle:Cr(e),scaleX:n,scaleY:s,skewX:Cr(i),skewY:0,translateX:r[4]||0,translateY:r[5]||0}},Mi=function(r){return[1,0,0,1,r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function ws(){let{angle:r=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:e=0,y:t=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=be(r),s=Sr(n),i=br(n);return[s,i,-i,s,e?e-(s*e-i*t):0,t?t-(i*e+s*t):0]}const Ah=function(r){return[r,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:r,0,0]},xv=r=>Math.tan(be(r)),wv=r=>[1,0,xv(r),1,0,0],Sv=r=>[1,xv(r),0,1,0,0],gl=r=>{let{scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:s=!1,skewX:i=0,skewY:o=0}=r,a=Ah(n?-e:e,s?-t:t);return i&&(a=Re(a,wv(i),!0)),o&&(a=Re(a,Sv(o),!0)),a},OS=r=>{const{translateX:e=0,translateY:t=0,angle:n=0}=r;let s=Mi(e,t);n&&(s=Re(s,ws({angle:n})));const i=gl(r);return ES(i)||(s=Re(s,i)),s},Go=function(r){let{signal:e,crossOrigin:t=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(n,s){if(e&&e.aborted)return s(new vS("loadImage"));const i=kS();let o;e&&(o=function(l){i.src="",s(l)},e.addEventListener("abort",o,{once:!0}));const a=function(){i.onload=i.onerror=null,o&&(e==null||e.removeEventListener("abort",o)),n(i)};r?(i.onload=a,i.onerror=function(){o&&(e==null||e.removeEventListener("abort",o)),s(new Gt("Error loading ".concat(i.src)))},t&&(i.crossOrigin=t),i.src=r):a()})},xi=function(r){let{signal:e,reviver:t=Xo}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((n,s)=>{const i=[];e&&e.addEventListener("abort",s,{once:!0}),Promise.all(r.map(o=>V.getClass(o.type).fromObject(o,{signal:e}).then(a=>(t(o,a),i.push(a),a)))).then(n).catch(o=>{i.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{e&&e.removeEventListener("abort",s)})})},pl=function(r){let{signal:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((t,n)=>{const s=[];e&&e.addEventListener("abort",n,{once:!0});const i=Object.values(r).map(a=>a&&a.type&&V.has(a.type)?xi([a],{signal:e}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(r);Promise.all(i).then(a=>a.reduce((l,c,u)=>(l[o[u]]=c,l),{})).then(t).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),n(a)}).finally(()=>{e&&e.removeEventListener("abort",n)})})},Ss=function(r){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((e,t)=>(t in r&&(e[t]=r[t]),e),{})},Lh=(r,e)=>Object.keys(r).reduce((t,n)=>(e(r[n],n,r)&&(t[n]=r[n]),t),{}),le=(r,e)=>parseFloat(Number(r).toFixed(e)),wi=r=>"matrix("+r.map(e=>le(e,re.NUM_FRACTION_DIGITS)).join(" ")+")",xt=r=>!!r&&r.toLive!==void 0,Ff=r=>!!r&&typeof r.toObject=="function",Nf=r=>!!r&&r.offsetX!==void 0&&"source"in r,an=r=>!!r&&"multiSelectionStacking"in r;function bv(r){const e=r&&Lt(r);let t=0,n=0;if(!r||!e)return{left:t,top:n};let s=r;const i=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===e?(t=o.scrollLeft||i.scrollLeft||0,n=o.scrollTop||i.scrollTop||0):(t+=s.scrollLeft||0,n+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:t,top:n}}const Lt=r=>r.ownerDocument||null,_v=r=>{var e;return((e=r.ownerDocument)===null||e===void 0?void 0:e.defaultView)||null},Cv=function(r,e,t){let{width:n,height:s}=t,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;r.width=n,r.height=s,i>1&&(r.setAttribute("width",(n*i).toString()),r.setAttribute("height",(s*i).toString()),e.scale(i,i))},yu=(r,e)=>{let{width:t,height:n}=e;t&&(r.style.width=typeof t=="number"?"".concat(t,"px"):t),n&&(r.style.height=typeof n=="number"?"".concat(n,"px"):n)};function If(r){return r.onselectstart!==void 0&&(r.onselectstart=()=>!1),r.style.userSelect=nt,r}class Tv{constructor(e){_(this,"_originalCanvasStyle",void 0),_(this,"lower",void 0);const t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext("2d")}}createLowerCanvas(e){const t=(n=e)&&n.getContext!==void 0?e:e&&vs().getElementById(e)||_r();var n;if(t.hasAttribute("data-fabric"))throw new Gt("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=t.style.cssText,t.setAttribute("data-fabric","main"),t.classList.add("lower-canvas"),t}cleanupDOM(e){let{width:t,height:n}=e;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(t)),s.setAttribute("height","".concat(n)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(e,t){const{el:n,ctx:s}=this.lower;Cv(n,s,e,t)}setCSSDimensions(e){yu(this.lower.el,e)}calcOffset(){return function(e){var t;const n=e&&Lt(e),s={left:0,top:0};if(!n)return s;const i=((t=_v(e))===null||t===void 0?void 0:t.getComputedStyle(e,null))||{};s.left+=parseInt(i.borderLeftWidth,10)||0,s.top+=parseInt(i.borderTopWidth,10)||0,s.left+=parseInt(i.paddingLeft,10)||0,s.top+=parseInt(i.paddingTop,10)||0;let o={left:0,top:0};const a=n.documentElement;e.getBoundingClientRect!==void 0&&(o=e.getBoundingClientRect());const l=bv(e);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}}(this.lower.el)}dispose(){Zt().dispose(this.lower.el),delete this.lower}}const DS={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Xe]},PS=["objects"];class ji extends gv(pv){get lowerCanvasEl(){var e;return(e=this.elements.lower)===null||e===void 0?void 0:e.el}get contextContainer(){var e;return(e=this.elements.lower)===null||e===void 0?void 0:e.ctx}static getDefaults(){return ji.ownDefaults}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new Tv(e)}add(){const e=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}insertAt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];const i=super.insertAt(e,...n);return n.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),i}remove(){const e=super.remove(...arguments);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(Qr("warn",`Canvas is trying to add an object that belongs to a different canvas.
45
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set("canvas",this),e.setCoords(),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e){e._set("canvas",void 0),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?uv():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(e,t){return this.setDimensions({width:e},t)}setHeight(e,t){return this.setDimensions({height:e},t)}_setDimensionsImpl(e){let{cssOnly:t=!1,backstoreOnly:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!t){const s=E({width:this.width,height:this.height},e);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){const n=e,s=[...this.viewportTransform],i=qe(e,Ft(s));s[0]=t,s[3]=t;const o=qe(i,s);s[4]+=n.x-o.x,s[5]+=n.y-o.y,this.setViewportTransform(s)}setZoom(e){this.zoomToPoint(new M(0,0),e)}absolutePan(e){const t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new M(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Yo(()=>this.renderAndReset()))}calcViewportBoundaries(){const e=this.width,t=this.height,n=Ft(this.viewportTransform),s=qe({x:0,y:0},n),i=qe({x:e,y:t},n),o=s.min(i),a=s.max(i);return this.vptCoords={tl:o,tr:new M(a.x,o.y),bl:new M(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(CS(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;const n=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality="best",this.fire("before:render",{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,s)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire("after:render",{ctx:e}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(e,t){const n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation="destination-in",t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,s=t.length;n<s;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){const n=this["".concat(t,"Color")],s=this["".concat(t,"Image")],i=this.viewportTransform,o=this["".concat(t,"Vpt")];if(!n&&!s)return;const a=xt(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=a?n.toLive(e):n,o&&e.transform(...i),a){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);const l=n.gradientTransform||n.patternTransform;l&&e.transform(...l)}e.fill(),e.restore()}if(s){e.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&e.transform(...i),s.render(e),this.skipOffscreen=l,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,"background")}_renderOverlay(e){this._renderBackgroundOrOverlay(e,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new M(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new M(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new M(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new M(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new M(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return qe(this.getCenterPoint(),Ft(this.viewportTransform))}_centerObject(e,t){e.setXY(t,J,J),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod("toObject",e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod("toDatalessObject",e)}_toObjectMethod(e,t){const n=this.clipPath,s=n&&!n.excludeFromExport?this._toObject(n,e,t):null;return E(E(E({version:mu},Ss(this,t)),{},{objects:this._objects.filter(i=>!i.excludeFromExport).map(i=>this._toObject(i,e,t))},this.__serializeBgOverlay(e,t)),s?{clipPath:s}:null)}_toObject(e,t,n){let s;this.includeDefaultValues||(s=e.includeDefaultValues,e.includeDefaultValues=!1);const i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=!!s),i}__serializeBgOverlay(e,t){const n={},s=this.backgroundImage,i=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return xt(o)?o.excludeFromExport||(n.background=o.toObject(t)):o&&(n.background=o),xt(a)?a.excludeFromExport||(n.overlay=a.toObject(t)):a&&(n.overlay=a),s&&!s.excludeFromExport&&(n.backgroundImage=this._toObject(s,e,t)),i&&!i.excludeFromExport&&(n.overlayImage=this._toObject(i,e,t)),n}toSVG(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;e.reviver=t;const n=[];return this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this.clipPath&&n.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
46
- `)),this._setSVGBgOverlayColor(n,"background"),this._setSVGBgOverlayImage(n,"backgroundImage",t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
47
- `),this._setSVGBgOverlayColor(n,"overlay"),this._setSVGBgOverlayImage(n,"overlayImage",t),n.push("</svg>"),n.join("")}_setSVGPreamble(e,t){t.suppressPreamble||e.push('<?xml version="1.0" encoding="',t.encoding||"UTF-8",`" standalone="no" ?>
48
- `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
49
- `)}_setSVGHeader(e,t){const n=t.width||"".concat(this.width),s=t.height||"".concat(this.height),i=re.NUM_FRACTION_DIGITS,o=t.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(le(-l[4]/l[0],i)," ").concat(le(-l[5]/l[3],i)," ").concat(le(this.width/l[0],i)," ").concat(le(this.height/l[3],i),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');e.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',s,'" ',a,`xml:space="preserve">
50
- `,"<desc>Created with Fabric.js ",mu,`</desc>
51
- `,`<defs>
52
- `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
53
- `)}createSVGClipPathMarkup(e){const t=this.clipPath;return t?(t.clipPathId="CLIPPATH_".concat(Jr()),'<clipPath id="'.concat(t.clipPathId,`" >
54
- `).concat(t.toClipPathSVG(e.reviver),`</clipPath>
55
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(e=>{const t=this["".concat(e,"Color")];if(xt(t)){const n=this["".concat(e,"Vpt")],s=this.viewportTransform,i={isType:()=>!1,width:this.width/(n?s[0]:1),height:this.height/(n?s[3]:1)};return t.toSVG(i,{additionalTransform:n?wi(s):""})}}).join("")}createSVGFontFacesMarkup(){const e=[],t={},n=re.fontPaths;this._objects.forEach(function i(o){e.push(o),Uo(o)&&o._objects.forEach(i)}),e.forEach(i=>{if(!(o=i)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=i;!t[l]&&n[l]&&(t[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(u=>{let{fontFamily:h=""}=u;!t[h]&&n[h]&&(t[h]=!0)})}))});const s=Object.keys(t).map(i=>` @font-face {
56
- font-family: '`.concat(i,`';
57
- src: url('`).concat(n[i],`');
58
- }
59
- `)).join("");return s?` <style type="text/css"><![CDATA[
60
- `.concat(s,`]]></style>
61
- `):""}_setSVGObjects(e,t){this.forEachObject(n=>{n.excludeFromExport||this._setSVGObject(e,n,t)})}_setSVGObject(e,t,n){e.push(t.toSVG(n))}_setSVGBgOverlayImage(e,t,n){const s=this[t];s&&!s.excludeFromExport&&s.toSVG&&e.push(s.toSVG(n))}_setSVGBgOverlayColor(e,t){const n=this["".concat(t,"Color")];if(n)if(xt(n)){const s=n.repeat||"",i=this.width,o=this.height,a=this["".concat(t,"Vpt")]?wi(Ft(this.viewportTransform)):"";e.push('<rect transform="'.concat(a," translate(").concat(i/2,",").concat(o/2,')" x="').concat(n.offsetX-i/2,'" y="').concat(n.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Nf(n)?i:n.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Nf(n)?o:n.source.height,'" fill="url(#SVGID_').concat(n.id,`)"></rect>
62
- `))}else e.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',n,'"',`></rect>
63
- `)}loadFromJSON(e,t){let{signal:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e)return Promise.reject(new Gt("`json` is undefined"));const s=typeof e=="string"?JSON.parse(e):e,{objects:i=[]}=s,o=de(s,PS),{backgroundImage:a,background:l,overlayImage:c,overlay:u,clipPath:h}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([xi(i,{reviver:t,signal:n}),pl({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:u,clipPath:h},{signal:n})]).then(f=>{let[m,v]=f;return this.clear(),this.add(...m),this.set(o),this.set(v),this.renderOnAddRemove=d,this})}clone(e){const t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){const e=kt(this);return new this.constructor(e)}toDataURL(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:t="png",quality:n=1,multiplier:s=1,enableRetinaScaling:i=!1}=e,o=s*(i?this.getRetinaScaling():1);return mv(this.toCanvasElement(o,e),t,n)}toBlob(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:t="png",quality:n=1,multiplier:s=1,enableRetinaScaling:i=!1}=e,o=s*(i?this.getRetinaScaling():1);return vv(this.toCanvasElement(o,e),t,n)}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:t,height:n,left:s,top:i,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(t||this.width)*e,l=(n||this.height)*e,c=this.getZoom(),u=this.width,h=this.height,d=this.skipControlsDrawing,f=c*e,m=this.viewportTransform,v=[f,0,0,f,(m[4]-(s||0))*e,(m[5]-(i||0))*e],x=this.enableRetinaScaling,g=kt({width:a,height:l}),p=o?this._objects.filter(y=>o(y)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=v,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),p),this.viewportTransform=m,this.width=u,this.height=h,this.calcViewportBoundaries(),this.enableRetinaScaling=x,this.skipControlsDrawing=d,g}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Ma.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{const n=()=>{this.destroy(),e(!0)};n.kill=t,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=n:n()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}_(ji,"ownDefaults",DS);const MS=["touchstart","touchmove","touchend"],jS=r=>{const e=bv(r.target),t=function(n){const s=n.changedTouches;return s&&s[0]?s[0]:n}(r);return new M(t.clientX+e.left,t.clientY+e.top)},xu=r=>MS.includes(r.type)||r.pointerType==="touch",Bf=r=>{r.preventDefault(),r.stopPropagation()},pr=r=>{let e=0,t=0,n=0,s=0;for(let i=0,o=r.length;i<o;i++){const{x:a,y:l}=r[i];(a>n||!i)&&(n=a),(a<e||!i)&&(e=a),(l>s||!i)&&(s=l),(l<t||!i)&&(t=l)}return{left:e,top:t,width:n-e,height:s-t}},RS=["translateX","translateY","scaleX","scaleY"],AS=(r,e)=>Ra(r,Re(e,r.calcOwnMatrix())),Ra=(r,e)=>{const t=ja(e),{translateX:n,translateY:s,scaleX:i,scaleY:o}=t,a=de(t,RS),l=new M(n,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:i,scaleY:o}),r.setPositionByOrigin(l,J,J)},LS=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},kv=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Fh=(r,e,t)=>{const n=r/2,s=e/2,i=[new M(-n,-s),new M(n,-s),new M(-n,s),new M(n,s)].map(a=>a.transform(t)),o=pr(i);return new M(o.width,o.height)},ml=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Xe;return Re(Ft(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xe),r)},rs=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xe,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xe;return r.transform(ml(e,t))},FS=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xe,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xe;return r.transform(ml(e,t),!0)},NS=(r,e,t)=>{const n=ml(e,t);return Ra(r,Re(n,r.calcOwnMatrix())),n},Ev=(r,e)=>{var t;const{transform:{target:n}}=e;(t=n.canvas)===null||t===void 0||t.fire("object:".concat(r),E(E({},e),{},{target:n})),n.fire(r,e)},IS={left:-.5,top:-.5,center:0,bottom:.5,right:.5},_e=r=>typeof r=="string"?IS[r]:r-.5,Aa="not-allowed";function Ov(r){return _e(r.originX)===_e(J)&&_e(r.originY)===_e(J)}function zf(r){return .5-_e(r)}const zt=(r,e)=>r[e],Dv=(r,e,t,n)=>({e:r,transform:e,pointer:new M(t,n)});function Pv(r,e){const t=r.getTotalAngle()+Cr(Math.atan2(e.y,e.x))+360;return Math.round(t%360/45)}function Nh(r,e,t,n,s){var i;let{target:o,corner:a}=r;const l=o.controls[a],c=((i=o.canvas)===null||i===void 0?void 0:i.getZoom())||1,u=o.padding/c,h=function(d,f,m,v){const x=d.getRelativeCenterPoint(),g=m!==void 0&&v!==void 0?d.translateToGivenOrigin(x,J,J,m,v):new M(d.left,d.top);return(d.angle?f.rotate(-be(d.angle),x):f).subtract(g)}(o,new M(n,s),e,t);return h.x>=u&&(h.x-=u),h.x<=-u&&(h.x+=u),h.y>=u&&(h.y-=u),h.y<=u&&(h.y+=u),h.x-=l.offsetX,h.y-=l.offsetY,h}const BS=(r,e,t,n)=>{const{target:s,offsetX:i,offsetY:o}=e,a=t-i,l=n-o,c=!zt(s,"lockMovementX")&&s.left!==a,u=!zt(s,"lockMovementY")&&s.top!==l;return c&&s.set(se,a),u&&s.set(rt,l),(c||u)&&Ev(hv,Dv(r,e,t,n)),c||u},La=r=>r.replace(/\s+/g," "),Wf={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},nc=(r,e,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+6*(e-r)*t:t<.5?e:t<2/3?r+(e-r)*(2/3-t)*6:r),Vf=(r,e,t,n)=>{r/=255,e/=255,t/=255;const s=Math.max(r,e,t),i=Math.min(r,e,t);let o,a;const l=(s+i)/2;if(s===i)o=a=0;else{const c=s-i;switch(a=l>.5?c/(2-s-i):c/(s+i),s){case r:o=(e-t)/c+(e<t?6:0);break;case e:o=(t-r)/c+2;break;case t:o=(r-e)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),n]},Hf=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},to=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),$f=r=>{let[e,t,n,s=1]=r;const i=Math.round(.3*e+.59*t+.11*n);return[i,i,i,s]};class ne{constructor(e){if(_(this,"isUnrecognised",!1),e)if(e instanceof ne)this.setSource([...e._source]);else if(Array.isArray(e)){const[t,n,s,i=1]=e;this.setSource([t,n,s,i])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(e){return(e=e.toLowerCase())in Wf&&(e=Wf[e]),e==="transparent"?[255,255,255,0]:ne.sourceFromHex(e)||ne.sourceFromRgb(e)||ne.sourceFromHsl(e)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(e){this._source=e}toRgb(){const[e,t,n]=this.getSource();return"rgb(".concat(e,",").concat(t,",").concat(n,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[e,t,n]=Vf(...this.getSource());return"hsl(".concat(e,",").concat(t,"%,").concat(n,"%)")}toHsla(){const[e,t,n,s]=Vf(...this.getSource());return"hsla(".concat(e,",").concat(t,"%,").concat(n,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[e,t,n,s]=this.getSource();return"".concat(to(e)).concat(to(t)).concat(to(n)).concat(to(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(e){return this._source[3]=e,this}toGrayscale(){return this.setSource($f(this.getSource())),this}toBlackWhite(e){const[t,,,n]=$f(this.getSource()),s=t<(e||127)?0:255;return this.setSource([s,s,s,n]),this}overlayWith(e){e instanceof ne||(e=new ne(e));const t=this.getSource(),n=e.getSource(),[s,i,o]=t.map((a,l)=>Math.round(.5*a+.5*n[l]));return this.setSource([s,i,o,t[3]]),this}static fromRgb(e){return ne.fromRgba(e)}static fromRgba(e){return new ne(ne.sourceFromRgb(e))}static sourceFromRgb(e){const t=La(e).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(t){const[n,s,i]=t.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[n,s,i,Hf(t[4])]}}static fromHsl(e){return ne.fromHsla(e)}static fromHsla(e){return new ne(ne.sourceFromHsl(e))}static sourceFromHsl(e){const t=La(e).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!t)return;const n=(ne.parseAngletoDegrees(t[1])%360+360)%360/360,s=parseFloat(t[2])/100,i=parseFloat(t[3])/100;let o,a,l;if(s===0)o=a=l=i;else{const c=i<=.5?i*(s+1):i+s-i*s,u=2*i-c;o=nc(u,c,n+1/3),a=nc(u,c,n),l=nc(u,c,n-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Hf(t[4])]}static fromHex(e){return new ne(ne.sourceFromHex(e))}static sourceFromHex(e){if(e.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const t=e.slice(e.indexOf("#")+1);let n;n=t.length<=4?t.split("").map(l=>l+l):t.match(/.{2}/g);const[s,i,o,a=255]=n.map(l=>parseInt(l,16));return[s,i,o,a/255]}}static parseAngletoDegrees(e){const t=e.toLowerCase(),n=parseFloat(t);return t.includes("rad")?Cr(n):t.includes("turn")?360*n:n}}const ns=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Dh;const t=/\D{0,2}$/.exec(r),n=parseFloat(r),s=re.DPI;switch(t==null?void 0:t[0]){case"mm":return n*s/25.4;case"cm":return n*s/2.54;case"in":return n*s;case"pt":return n*s/72;case"pc":return n*s/72*12;case"em":return n*e;default:return n}},zS=r=>{const[e,t]=r.trim().split(" "),[n,s]=(i=e)&&i!==nt?[i.slice(1,4),i.slice(5,8)]:i===nt?[i,i]:["Mid","Mid"];var i;return{meetOrSlice:t||"meet",alignX:n,alignY:s}},Si=function(r,e){let t,n,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(e)if(e.toLive)t="url(#SVGID_".concat(e.id,")");else{const i=new ne(e),o=i.getAlpha();t=i.toRgb(),o!==1&&(n=o.toString())}else t="none";return s?"".concat(r,": ").concat(t,"; ").concat(n?"".concat(r,"-opacity: ").concat(n,"; "):""):"".concat(r,'="').concat(t,'" ').concat(n?"".concat(r,'-opacity="').concat(n,'" '):"")};class Mv{getSvgStyles(e){const t=this.fillRule?this.fillRule:"nonzero",n=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):nt,i=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",u=this.visible?"":" visibility: hidden;",h=e?"":this.getSvgFilter(),d=Si(Ee,this.fill);return[Si(st,this.stroke),"stroke-width: ",n,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",i,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",t,"; ","opacity: ",c,";",h,u].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const n=e?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(wi(n));return"".concat(s).concat(t,'" ')}_toSVG(e){return[""]}toSVG(e){return this._createBaseSVGMarkup(this._toSVG(e),{reviver:e})}toClipPathSVG(e){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(e),{reviver:e})}_createBaseClipPathSVGMarkup(e){let{reviver:t,additionalTransform:n=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),i=e.indexOf("COMMON_PARTS");return e[i]=s,t?t(e.join("")):e.join("")}_createBaseSVGMarkup(e){let{noStyle:t,reviver:n,withShadow:s,additionalTransform:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=t?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",u=l&&l.absolutePositioned,h=this.stroke,d=this.fill,f=this.shadow,m=[],v=e.indexOf("COMMON_PARTS");let x;l&&(l.clipPathId="CLIPPATH_".concat(Jr()),x='<clipPath id="'.concat(l.clipPathId,`" >
64
- `).concat(l.toClipPathSVG(n),`</clipPath>
65
- `)),u&&m.push("<g ",a,this.getSvgCommons(),` >
66
- `),m.push("<g ",this.getSvgTransform(!1),u?"":a+this.getSvgCommons(),` >
67
- `);const g=[o,c,t?"":this.addPaintOrder()," ",i?'transform="'.concat(i,'" '):""].join("");return e[v]=g,xt(d)&&m.push(d.toSVG(this)),xt(h)&&m.push(h.toSVG(this)),f&&m.push(f.toSVG(this)),l&&m.push(x),m.push(e.join("")),m.push(`</g>
68
- `),u&&m.push(`</g>
69
- `),n?n(m.join("")):m.join("")}addPaintOrder(){return this.paintFirst!==Ee?' paint-order="'.concat(this.paintFirst,'" '):""}}function vl(r){return new RegExp("^("+r.join("|")+")\\b","i")}const Tn="textDecorationThickness",jv=["fontSize","fontWeight","fontFamily","fontStyle"],Rv=["underline","overline","linethrough"],Av=[...jv,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Lv=[...Av,...Rv,"textBackgroundColor","direction",Tn],WS=[...jv,...Rv,st,"strokeWidth",Ee,"deltaY","textBackgroundColor",Tn],VS={_reNewline:Ph,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:se,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:se,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Tn]:66.667},Ut="justify",Fa="justify-left",qs="justify-right",Qs="justify-center";var Xf,Uf,Yf;const Nt=String.raw(Xf||(Xf=rr(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),sc=String.raw(Uf||(Uf=rr(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),HS=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Nt+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Nt+"))?\\s+(.*)"),$S={cx:se,x:se,r:"radius",cy:rt,y:rt,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":Tn},ic="font-size",oc="clip-path";vl(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);vl(["symbol","image","marker","pattern","view","svg"]);const Gf=vl(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(Yf||(Yf=rr(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Nt,sc,Nt,sc,Nt,sc,Nt));const XS=new M(1,0),Fv=new M,Nv=(r,e)=>r.rotate(e),wu=(r,e)=>new M(e).subtract(r),Su=r=>r.distanceFrom(Fv),bu=(r,e)=>Math.atan2(Js(r,e),YS(r,e)),US=r=>bu(XS,r),Ih=r=>r.eq(Fv)?r:r.scalarDivide(Su(r)),Iv=function(r){let e=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Ih(new M(-r.y,r.x).scalarMultiply(e?1:-1))},Js=(r,e)=>r.x*e.y-r.y*e.x,YS=(r,e)=>r.x*e.x+r.y*e.y,Kf=(r,e,t)=>{if(r.eq(e)||r.eq(t))return!0;const n=Js(e,t),s=Js(e,r),i=Js(t,r);return n>=0?s>=0&&i<=0:!(s<=0&&i>=0)},qf="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Qf=new RegExp("(?:\\s|^)"+qf+qf+"("+Nt+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Jt{constructor(e){const t=typeof e=="string"?Jt.parseShadow(e):e;Object.assign(this,Jt.ownDefaults,t),this.id=Jr()}static parseShadow(e){const t=e.trim(),[,n=0,s=0,i=0]=(Qf.exec(t)||[]).map(o=>parseFloat(o)||0);return{color:(t.replace(Qf,"")||"rgb(0,0,0)").trim(),offsetX:n,offsetY:s,blur:i}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(e){const t=Nv(new M(this.offsetX,this.offsetY),be(-e.angle)),n=new ne(this.color);let s=40,i=40;return e.width&&e.height&&(s=100*le((Math.abs(t.x)+this.blur)/e.width,re.NUM_FRACTION_DIGITS)+20,i=100*le((Math.abs(t.y)+this.blur)/e.height,re.NUM_FRACTION_DIGITS)+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(i,'%" height="').concat(100+2*i,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
70
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(le(this.blur?this.blur/2:0,re.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
71
- <feOffset dx="`).concat(le(t.x,re.NUM_FRACTION_DIGITS),'" dy="').concat(le(t.y,re.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
72
- <feFlood flood-color="`).concat(n.toRgb(),'" flood-opacity="').concat(n.getAlpha(),`"/>
73
- <feComposite in2="oBlur" operator="in" />
74
- <feMerge>
75
- <feMergeNode></feMergeNode>
76
- <feMergeNode in="SourceGraphic"></feMergeNode>
77
- </feMerge>
78
- </filter>
79
- `)}toObject(){const e={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},t=Jt.ownDefaults;return this.includeDefaultValues?e:Lh(e,(n,s)=>n!==t[s])}static async fromObject(e){return new this(e)}}_(Jt,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),_(Jt,"type","shadow"),V.setClass(Jt,"shadow");const ds=(r,e,t)=>Math.max(r,Math.min(e,t)),GS=[rt,se,it,Tt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",ys,xs],kr=[Ee,st,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],KS={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:se,originY:rt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Ee,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},qS=(r,e,t,n)=>-t*Math.cos(r/n*Pi)+t+e,QS=()=>!1;class Bh{constructor(e){let{startValue:t,byValue:n,duration:s=500,delay:i=0,easing:o=qS,onStart:a=Xo,onChange:l=Xo,onComplete:c=Xo,abort:u=QS,target:h}=e;_(this,"_state","pending"),_(this,"durationProgress",0),_(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=i,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=u,this.target=h,this.startValue=t,this.byValue=n,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const e=t=>{this._state==="pending"&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Yo(e),this.delay):Yo(e)}tick(e){const t=(e||+new Date)-this.startTime,n=Math.min(t,this.duration);this.durationProgress=n/this.duration;const{value:s,valueProgress:i}=this.calculate(n);this.value=Object.freeze(s),this.valueProgress=i,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):t>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Yo(this.tick)))}register(){Ma.push(this)}unregister(){Ma.remove(this)}abort(){this._state="aborted",this.unregister()}}const JS=["startValue","endValue"];class ZS extends Bh{constructor(e){let{startValue:t=0,endValue:n=100}=e;super(E(E({},de(e,JS)),{},{startValue:t,byValue:n-t}))}calculate(e){const t=this.easing(e,this.startValue,this.byValue,this.duration);return{value:t,valueProgress:Math.abs((t-this.startValue)/this.byValue)}}}const eb=["startValue","endValue"];class tb extends Bh{constructor(e){let{startValue:t=[0],endValue:n=[100]}=e;super(E(E({},de(e,eb)),{},{startValue:t,byValue:n.map((s,i)=>s-t[i])}))}calculate(e){const t=this.startValue.map((n,s)=>this.easing(e,n,this.byValue[s],this.duration,s));return{value:t,valueProgress:Math.abs((t[0]-this.startValue[0])/this.byValue[0])}}}const rb=["startValue","endValue","easing","onChange","onComplete","abort"],nb=(r,e,t,n)=>e+t*(1-Math.cos(r/n*Pi)),ac=r=>r&&((e,t,n)=>r(new ne(e).toRgba(),t,n));class sb extends Bh{constructor(e){let{startValue:t,endValue:n,easing:s=nb,onChange:i,onComplete:o,abort:a}=e,l=de(e,rb);const c=new ne(t).getSource(),u=new ne(n).getSource();super(E(E({},l),{},{startValue:c,byValue:u.map((h,d)=>h-c[d]),easing:s,onChange:ac(i),onComplete:ac(o),abort:ac(a)}))}calculate(e){const[t,n,s,i]=this.startValue.map((a,l)=>this.easing(e,a,this.byValue[l],this.duration,l)),o=[...[t,n,s].map(Math.round),ds(0,i,1)];return{value:o,valueProgress:o.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function Bv(r){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(r)?new tb(r):new ZS(r);return e.start(),e}function ib(r){const e=new sb(r);return e.start(),e}class ge{constructor(e){this.status=e,this.points=[]}includes(e){return this.points.some(t=>t.eq(e))}append(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.points=this.points.concat(t.filter(s=>!this.includes(s))),this}static isPointContained(e,t,n){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(t.eq(n))return e.eq(t);if(t.x===n.x)return e.x===t.x&&(s||e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y));if(t.y===n.y)return e.y===t.y&&(s||e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x));{const i=wu(t,n),o=wu(t,e).divide(i);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(e,t){const n=new M(e).setX(Math.min(e.x-1,...t.map(i=>i.x)));let s=0;for(let i=0;i<t.length;i++){const o=this.intersectSegmentSegment(t[i],t[(i+1)%t.length],e,n);if(o.includes(e))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(e,t,n,s){let i=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=t.x-e.x,l=t.y-e.y,c=s.x-n.x,u=s.y-n.y,h=e.x-n.x,d=e.y-n.y,f=c*d-u*h,m=a*d-l*h,v=u*a-c*l;if(v!==0){const x=f/v,g=m/v;return(i||0<=x&&x<=1)&&(o||0<=g&&g<=1)?new ge("Intersection").append(new M(e.x+x*a,e.y+x*l)):new ge}if(f===0||m===0){const x=i||o||ge.isPointContained(e,n,s)||ge.isPointContained(t,n,s)||ge.isPointContained(n,e,t)||ge.isPointContained(s,e,t);return new ge(x?"Coincident":void 0)}return new ge("Parallel")}static intersectSegmentLine(e,t,n,s){return ge.intersectLineLine(e,t,n,s,!1,!0)}static intersectSegmentSegment(e,t,n,s){return ge.intersectLineLine(e,t,n,s,!1,!1)}static intersectLinePolygon(e,t,n){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const i=new ge,o=n.length;for(let a,l,c,u=0;u<o;u++){if(a=n[u],l=n[(u+1)%o],c=ge.intersectLineLine(e,t,a,l,s,!1),c.status==="Coincident")return c;i.append(...c.points)}return i.points.length>0&&(i.status="Intersection"),i}static intersectSegmentPolygon(e,t,n){return ge.intersectLinePolygon(e,t,n,!1)}static intersectPolygonPolygon(e,t){const n=new ge,s=e.length,i=[];for(let o=0;o<s;o++){const a=e[o],l=e[(o+1)%s],c=ge.intersectSegmentPolygon(a,l,t);c.status==="Coincident"?(i.push(c),n.append(a,l)):n.append(...c.points)}return i.length>0&&i.length===e.length?new ge("Coincident"):(n.points.length>0&&(n.status="Intersection"),n)}static intersectPolygonRectangle(e,t,n){const s=t.min(n),i=t.max(n),o=new M(i.x,s.y),a=new M(s.x,i.y);return ge.intersectPolygonPolygon(e,[s,o,i,a])}}class ob extends pv{getX(){return this.getXY().x}setX(e){this.setXY(this.getXY().setX(e))}getY(){return this.getXY().y}setY(e){this.setXY(this.getXY().setY(e))}getRelativeX(){return this.left}setRelativeX(e){this.left=e}getRelativeY(){return this.top}setRelativeY(e){this.top=e}getXY(){const e=this.getRelativeXY();return this.group?qe(e,this.group.calcTransformMatrix()):e}setXY(e,t,n){this.group&&(e=qe(e,Ft(this.group.calcTransformMatrix()))),this.setRelativeXY(e,t,n)}getRelativeXY(){return new M(this.left,this.top)}setRelativeXY(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(e,t,n)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:e,tr:t,br:n,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),i=[e,t,n,s];if(this.group){const o=this.group.calcTransformMatrix();return i.map(a=>qe(a,o))}return i}intersectsWithRect(e,t){return ge.intersectPolygonRectangle(this.getCoords(),e,t).status==="Intersection"}intersectsWithObject(e){const t=ge.intersectPolygonPolygon(this.getCoords(),e.getCoords());return t.status==="Intersection"||t.status==="Coincident"||e.isContainedWithinObject(this)||this.isContainedWithinObject(e)}isContainedWithinObject(e){return this.getCoords().every(t=>e.containsPoint(t))}isContainedWithinRect(e,t){const{left:n,top:s,width:i,height:o}=this.getBoundingRect();return n>=e.x&&n+i<=t.x&&s>=e.y&&s+o<=t.y}isOverlapping(e){return this.intersectsWithObject(e)||this.isContainedWithinObject(e)||e.isContainedWithinObject(this)}containsPoint(e){return ge.isPointInPolygon(e,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:e,br:t}=this.canvas.vptCoords;return!!this.getCoords().some(n=>n.x<=t.x&&n.x>=e.x&&n.y<=t.y&&n.y>=e.y)||!!this.intersectsWithRect(e,t)||this.containsPoint(e.midPointFrom(t))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:e,br:t}=this.canvas.vptCoords;return this.intersectsWithRect(e,t)?!0:this.getCoords().every(n=>(n.x>=t.x||n.x<=e.x)&&(n.y>=t.y||n.y<=e.y))&&this.containsPoint(e.midPointFrom(t))}getBoundingRect(){return pr(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(e){this._set(it,e),this._set(Tt,e),this.setCoords()}scaleToWidth(e){const t=this.getBoundingRect().width/this.getScaledWidth();return this.scale(e/this.width/t)}scaleToHeight(e){const t=this.getBoundingRect().height/this.getScaledHeight();return this.scale(e/this.height/t)}getCanvasRetinaScaling(){var e;return((e=this.canvas)===null||e===void 0?void 0:e.getRetinaScaling())||1}getTotalAngle(){return this.group?Cr(yv(this.calcTransformMatrix())):this.angle}getViewportTransform(){var e;return((e=this.canvas)===null||e===void 0?void 0:e.viewportTransform)||Xe.concat()}calcACoords(){const e=ws({angle:this.angle}),{x:t,y:n}=this.getRelativeCenterPoint(),s=Mi(t,n),i=Re(s,e),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:qe({x:-a,y:-l},i),tr:qe({x:a,y:-l},i),bl:qe({x:-a,y:l},i),br:qe({x:a,y:l},i)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=[];return!e&&this.group&&(t=this.group.transformMatrixKey(e)),t.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,_e(this.originX),_e(this.originY)),t}calcTransformMatrix(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.calcOwnMatrix();if(e||!this.group)return t;const n=this.transformMatrixKey(e),s=this.matrixCache;return s&&s.key.every((i,o)=>i===n[o])?s.value:(this.group&&(t=Re(this.group.calcTransformMatrix(!1),t)),this.matrixCache={key:n,value:t},t)}calcOwnMatrix(){const e=this.transformMatrixKey(!0),t=this.ownMatrixCache;if(t&&t.key===e)return t.value;const n=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:n.x,translateY:n.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},i=OS(s);return this.ownMatrixCache={key:e,value:i},i}_getNonTransformedDimensions(){return new M(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(e){return this._getTransformedDimensions(e).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=E({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},e),n=t.strokeWidth;let s=n,i=0;this.strokeUniform&&(s=0,i=n);const o=t.width+s,a=t.height+s;let l;return l=t.skewX===0&&t.skewY===0?new M(o*t.scaleX,a*t.scaleY):Fh(o,a,gl(t)),l.scalarAdd(i)}translateToGivenOrigin(e,t,n,s,i){let o=e.x,a=e.y;const l=_e(s)-_e(t),c=_e(i)-_e(n);if(l||c){const u=this._getTransformedDimensions();o+=l*u.x,a+=c*u.y}return new M(o,a)}translateToCenterPoint(e,t,n){if(t===J&&n===J)return e;const s=this.translateToGivenOrigin(e,t,n,J,J);return this.angle?s.rotate(be(this.angle),e):s}translateToOriginPoint(e,t,n){const s=this.translateToGivenOrigin(e,J,J,t,n);return this.angle?s.rotate(be(this.angle),e):s}getCenterPoint(){const e=this.getRelativeCenterPoint();return this.group?qe(e,this.group.calcTransformMatrix()):e}getRelativeCenterPoint(){return this.translateToCenterPoint(new M(this.left,this.top),this.originX,this.originY)}getPointByOrigin(e,t){return this.translateToOriginPoint(this.getRelativeCenterPoint(),e,t)}setPositionByOrigin(e,t,n){const s=this.translateToCenterPoint(e,t,n),i=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:i.x,top:i.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),se,rt)}}const ab=["type"],lb=["extraParam"];let nr=class Ko extends ob{static getDefaults(){return Ko.ownDefaults}get type(){const e=this.constructor.type;return e==="FabricObject"?"object":e.toLowerCase()}set type(e){Qr("warn","Setting type has no effect",e)}constructor(e){super(),_(this,"_cacheContext",null),Object.assign(this,Ko.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=_r(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(e){const t=e.width,n=e.height,s=re.maxCacheSideLimit,i=re.minCacheSideLimit;if(t<=s&&n<=s&&t*n<=re.perfLimitSizeTotal)return t<i&&(e.width=i),n<i&&(e.height=i),e;const o=t/n,[a,l]=Ks.limitDimsByArea(o),c=ds(i,a,s),u=ds(i,l,s);return t>c&&(e.zoomX/=t/c,e.width=c,e.capped=!0),n>u&&(e.zoomY/=n/u,e.height=u,e.capped=!0),e}_getCacheCanvasDimensions(){const e=this.getTotalObjectScaling(),t=this._getTransformedDimensions({skewX:0,skewY:0}),n=t.x*e.x/this.scaleX,s=t.y*e.y/this.scaleY;return{width:Math.ceil(n+2),height:Math.ceil(s+2),zoomX:e.x,zoomY:e.y,x:n,y:s}}_updateCacheCanvas(){const e=this._cacheCanvas,t=this._cacheContext,{width:n,height:s,zoomX:i,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=n!==e.width||s!==e.height,u=this.zoomX!==i||this.zoomY!==o;if(!e||!t)return!1;if(c||u){n!==e.width||s!==e.height?(e.width=n,e.height=s):(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height));const h=a/2,d=l/2;return this.cacheTranslationX=Math.round(e.width/2-h)+h,this.cacheTranslationY=Math.round(e.height/2-d)+d,t.translate(this.cacheTranslationX,this.cacheTranslationY),t.scale(i,o),this.zoomX=i,this.zoomY=o,!0}return!1}setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(e)}transform(e){const t=this.group&&!this.group._transformDone||this.group&&this.canvas&&e===this.canvas.contextTop,n=this.calcTransformMatrix(!t);e.transform(n[0],n[1],n[2],n[3],n[4],n[5])}getObjectScaling(){if(!this.group)return new M(Math.abs(this.scaleX),Math.abs(this.scaleY));const e=ja(this.calcTransformMatrix());return new M(Math.abs(e.scaleX),Math.abs(e.scaleY))}getTotalObjectScaling(){const e=this.getObjectScaling();if(this.canvas){const t=this.canvas.getZoom(),n=this.getCanvasRetinaScaling();return e.scalarMultiply(t*n)}return e}getObjectOpacity(){let e=this.opacity;return this.group&&(e*=this.group.getObjectOpacity()),e}_constrainScale(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e===0?1e-4:e}_set(e,t){e!==it&&e!==Tt||(t=this._constrainScale(t)),e===it&&t<0?(this.flipX=!this.flipX,t*=-1):e==="scaleY"&&t<0?(this.flipY=!this.flipY,t*=-1):e!=="shadow"||!t||t instanceof Jt||(t=new Jt(t));const n=this[e]!==t;return this[e]=t,n&&this.constructor.cacheProperties.includes(e)&&(this.dirty=!0),this.parent&&(this.dirty||n&&this.constructor.stateProperties.includes(e))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(e){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(e.save(),this._setupCompositeOperation(e),this.drawSelectionBackground(e),this.transform(e),this._setOpacity(e),this._setShadow(e),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(e)):(this._removeCacheCanvas(),this.drawObject(e,!1,{}),this.dirty=!1),e.restore())}drawSelectionBackground(e){}renderCache(e){if(e=e||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:t,zoomY:n,cacheTranslationX:s,cacheTranslationY:i}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,e.forClipping,{zoomX:t,zoomY:n,cacheTranslationX:s,cacheTranslationY:i,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===st&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(e,t,n){e.save(),t.inverted?e.globalCompositeOperation="destination-out":e.globalCompositeOperation="destination-in",e.setTransform(1,0,0,1,0,0),e.drawImage(n,0,0),e.restore()}drawObject(e,t,n){const s=this.fill,i=this.stroke;t?(this.fill="black",this.stroke="",this._setClippingProperties(e)):this._renderBackground(e),this._render(e),this._drawClipPath(e,this.clipPath,n),this.fill=s,this.stroke=i}createClipPathLayer(e,t){const n=kt(t),s=n.getContext("2d");if(s.translate(t.cacheTranslationX,t.cacheTranslationY),s.scale(t.zoomX,t.zoomY),e._cacheCanvas=n,t.parentClipPaths.forEach(i=>{i.transform(s)}),t.parentClipPaths.push(e),e.absolutePositioned){const i=Ft(this.calcTransformMatrix());s.transform(i[0],i[1],i[2],i[3],i[4],i[5])}return e.transform(s),e.drawObject(s,!0,t),n}_drawClipPath(e,t,n){if(!t)return;t._transformDone=!0;const s=this.createClipPathLayer(t,n);this.drawClipPathOnCache(e,t,s)}drawCacheOnCanvas(e){e.scale(1/this.zoomX,1/this.zoomY),e.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const t=this._cacheCanvas,n=this._cacheContext;return!(!t||!n||e||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(t&&n&&!e&&(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()),!0)}_renderBackground(e){if(!this.backgroundColor)return;const t=this._getNonTransformedDimensions();e.fillStyle=this.backgroundColor,e.fillRect(-t.x/2,-t.y/2,t.x,t.y),this._removeShadow(e)}_setOpacity(e){this.group&&!this.group._transformDone?e.globalAlpha=this.getObjectOpacity():e.globalAlpha*=this.opacity}_setStrokeStyles(e,t){const n=t.stroke;n&&(e.lineWidth=t.strokeWidth,e.lineCap=t.strokeLineCap,e.lineDashOffset=t.strokeDashOffset,e.lineJoin=t.strokeLineJoin,e.miterLimit=t.strokeMiterLimit,xt(n)?n.gradientUnits==="percentage"||n.gradientTransform||n.patternTransform?this._applyPatternForTransformedGradient(e,n):(e.strokeStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.strokeStyle=t.stroke)}_setFillStyles(e,t){let{fill:n}=t;n&&(xt(n)?(e.fillStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.fillStyle=n)}_setClippingProperties(e){e.globalAlpha=1,e.strokeStyle="transparent",e.fillStyle="#000000"}_setLineDash(e,t){t&&t.length!==0&&e.setLineDash(t)}_setShadow(e){if(!this.shadow)return;const t=this.shadow,n=this.canvas,s=this.getCanvasRetinaScaling(),[i,,,o]=(n==null?void 0:n.viewportTransform)||Xe,a=i*s,l=o*s,c=t.nonScaling?new M(1,1):this.getObjectScaling();e.shadowColor=t.color,e.shadowBlur=t.blur*re.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,e.shadowOffsetX=t.offsetX*a*c.x,e.shadowOffsetY=t.offsetY*l*c.y}_removeShadow(e){this.shadow&&(e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0)}_applyPatternGradientTransform(e,t){if(!xt(t))return{offsetX:0,offsetY:0};const n=t.gradientTransform||t.patternTransform,s=-this.width/2+t.offsetX||0,i=-this.height/2+t.offsetY||0;return t.gradientUnits==="percentage"?e.transform(this.width,0,0,this.height,s,i):e.transform(1,0,0,1,s,i),n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),{offsetX:s,offsetY:i}}_renderPaintInOrder(e){this.paintFirst===st?(this._renderStroke(e),this._renderFill(e)):(this._renderFill(e),this._renderStroke(e))}_render(e){}_renderFill(e){this.fill&&(e.save(),this._setFillStyles(e,this),this.fillRule==="evenodd"?e.fill("evenodd"):e.fill(),e.restore())}_renderStroke(e){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this.strokeUniform){const t=this.getObjectScaling();e.scale(1/t.x,1/t.y)}this._setLineDash(e,this.strokeDashArray),this._setStrokeStyles(e,this),e.stroke(),e.restore()}}_applyPatternForTransformedGradient(e,t){var n;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/i,a=s.y/this.scaleY/i,l=kt({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/i,s.zoomY/this.scaleY/i),this._applyPatternGradientTransform(c,t),c.fillStyle=t.toLive(e),c.fill(),e.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),e.scale(i*this.scaleX/s.zoomX,i*this.scaleY/s.zoomY),e.strokeStyle=(n=c.createPattern(l,"no-repeat"))!==null&&n!==void 0?n:"")}_findCenterFromElement(){return new M(this.left+this.width/2,this.top+this.height/2)}clone(e){const t=this.toObject(e);return this.constructor.fromObject(t)}cloneAsImage(e){const t=this.toCanvasElement(e);return new(V.getClass("image"))(t)}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=kv(this),n=this.group,s=this.shadow,i=Math.abs,o=e.enableRetinaScaling?uv():1,a=(e.multiplier||1)*o,l=e.canvasProvider||(p=>new ji(p,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,e.withoutTransform&&LS(this),e.withoutShadow&&(this.shadow=null),e.viewportTransform&&NS(this,this.getViewportTransform()),this.setCoords();const c=_r(),u=this.getBoundingRect(),h=this.shadow,d=new M;if(h){const p=h.blur,y=h.nonScaling?new M(1,1):this.getObjectScaling();d.x=2*Math.round(i(h.offsetX)+p)*i(y.x),d.y=2*Math.round(i(h.offsetY)+p)*i(y.y)}const f=u.width+d.x,m=u.height+d.y;c.width=Math.ceil(f),c.height=Math.ceil(m);const v=l(c);e.format==="jpeg"&&(v.backgroundColor="#fff"),this.setPositionByOrigin(new M(v.width/2,v.height/2),J,J);const x=this.canvas;v._objects=[this],this.set("canvas",v),this.setCoords();const g=v.toCanvasElement(a||1,e);return this.set("canvas",x),this.shadow=s,n&&(this.group=n),this.set(t),this.setCoords(),v._objects=[],v.destroy(),g}toDataURL(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mv(this.toCanvasElement(e),e.format||"png",e.quality||1)}toBlob(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return vv(this.toCanvasElement(e),e.format||"png",e.quality||1)}isType(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.includes(this.constructor.type)||t.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(e){const{centeredRotation:t,originX:n,originY:s}=this;if(t){const{x:i,y:o}=this.getRelativeCenterPoint();this.originX=J,this.originY=J,this.left=i,this.top=o}if(this.set("angle",e),t){const{x:i,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),n,s);this.left=i,this.top=o,this.originX=n,this.originY=s}}setOnGroup(){}_setupCompositeOperation(e){this.globalCompositeOperation&&(e.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Ma.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Zt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(e,t){return Object.entries(e).reduce((n,s)=>{let[i,o]=s;return n[i]=this._animate(i,o,t),n},{})}_animate(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=e.split("."),i=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=n,u=E(E({},n),{},{target:this,startValue:a??s.reduce((h,d)=>h[d],this),endValue:t,abort:o==null?void 0:o.bind(this),onChange:(h,d,f)=>{s.reduce((m,v,x)=>(x===s.length-1&&(m[v]=h),m[v]),this),l&&l(h,d,f)},onComplete:(h,d,f)=>{this.setCoords(),c&&c(h,d,f)}});return i?ib(u):Bv(u)}isDescendantOf(e){const{parent:t,group:n}=this;return t===e||n===e||!!t&&t.isDescendantOf(e)||!!n&&n!==t&&n.isDescendantOf(e)}getAncestors(){const e=[];let t=this;do t=t.parent,t&&e.push(t);while(t);return e}findCommonAncestors(e){if(this===e)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const t=this.getAncestors(),n=e.getAncestors();if(t.length===0&&n.length>0&&this===n[n.length-1])return{fork:[],otherFork:[e,...n.slice(0,n.length-1)],common:[this]};for(let s,i=0;i<t.length;i++){if(s=t[i],s===e)return{fork:[this,...t.slice(0,i)],otherFork:[],common:t.slice(i)};for(let o=0;o<n.length;o++){if(this===n[o])return{fork:[],otherFork:[e,...n.slice(0,o)],common:[this,...t]};if(s===n[o])return{fork:[this,...t.slice(0,i)],otherFork:[e,...n.slice(0,o)],common:t.slice(i)}}}return{fork:[this,...t],otherFork:[e,...n],common:[]}}hasCommonAncestors(e){const t=this.findCommonAncestors(e);return t&&!!t.common.length}isInFrontOf(e){if(this===e)return;const t=this.findCommonAncestors(e);if(t.fork.includes(e))return!0;if(t.otherFork.includes(this))return!1;const n=t.common[0]||this.canvas;if(!n)return;const s=t.fork.pop(),i=t.otherFork.pop(),o=n._objects.indexOf(s),a=n._objects.indexOf(i);return o>-1&&o>a}toObject(){const e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Ko.customProperties,this.constructor.customProperties||[]);let t;const n=re.NUM_FRACTION_DIGITS,{clipPath:s,fill:i,stroke:o,shadow:a,strokeDashArray:l,left:c,top:u,originX:h,originY:d,width:f,height:m,strokeWidth:v,strokeLineCap:x,strokeDashOffset:g,strokeLineJoin:p,strokeUniform:y,strokeMiterLimit:b,scaleX:O,scaleY:S,angle:T,flipX:C,flipY:P,opacity:j,visible:R,backgroundColor:I,fillRule:U,paintFirst:A,globalCompositeOperation:G,skewX:Y,skewY:W}=this;s&&!s.excludeFromExport&&(t=s.toObject(e.concat("inverted","absolutePositioned")));const k=B=>le(B,n),F=E(E({},Ss(this,e)),{},{type:this.constructor.type,version:mu,originX:h,originY:d,left:k(c),top:k(u),width:k(f),height:k(m),fill:Ff(i)?i.toObject():i,stroke:Ff(o)?o.toObject():o,strokeWidth:k(v),strokeDashArray:l&&l.concat(),strokeLineCap:x,strokeDashOffset:g,strokeLineJoin:p,strokeUniform:y,strokeMiterLimit:k(b),scaleX:k(O),scaleY:k(S),angle:k(T),flipX:C,flipY:P,opacity:k(j),shadow:a&&a.toObject(),visible:R,backgroundColor:I,fillRule:U,paintFirst:A,globalCompositeOperation:G,skewX:k(Y),skewY:k(W)},t?{clipPath:t}:null);return this.includeDefaultValues?F:this._removeDefaultValues(F)}toDatalessObject(e){return this.toObject(e)}_removeDefaultValues(e){const t=this.constructor.getDefaults(),n=Object.keys(t).length>0?t:Object.getPrototypeOf(this);return Lh(e,(s,i)=>{if(i===se||i===rt||i==="type")return!0;const o=n[i];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(e){let t=de(e,ab),n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=n,i=de(n,lb);return pl(t,i).then(o=>s?(delete o[s],new this(t[s],o)):new this(o))}static fromObject(e,t){return this._fromObject(e,t)}};_(nr,"stateProperties",GS),_(nr,"cacheProperties",kr),_(nr,"ownDefaults",KS),_(nr,"type","FabricObject"),_(nr,"colorProperties",[Ee,st,"backgroundColor"]),_(nr,"customProperties",[]),V.setClass(nr),V.setClass(nr,"object");const bs=(r,e,t)=>(n,s,i,o)=>{const a=e(n,s,i,o);return a&&Ev(r,E(E({},Dv(n,s,i,o)),t)),a};function _s(r){return(e,t,n,s)=>{const{target:i,originX:o,originY:a}=t,l=i.getRelativeCenterPoint(),c=i.translateToOriginPoint(l,o,a),u=r(e,t,n,s);return i.setPositionByOrigin(c,t.originX,t.originY),u}}const Jf=bs(yi,_s((r,e,t,n)=>{const s=Nh(e,e.originX,e.originY,t,n);if(_e(e.originX)===_e(J)||_e(e.originX)===_e(xe)&&s.x<0||_e(e.originX)===_e(se)&&s.x>0){const{target:i}=e,o=i.strokeWidth/(i.strokeUniform?i.scaleX:1),a=Ov(e)?2:1,l=i.width,c=Math.abs(s.x*a/i.scaleX)-o;return i.set("width",Math.max(c,1)),l!==i.width}return!1}));function cb(r,e,t,n,s){n=n||{};const i=this.sizeX||n.cornerSize||s.cornerSize,o=this.sizeY||n.cornerSize||s.cornerSize,a=n.transparentCorners!==void 0?n.transparentCorners:s.transparentCorners,l=a?st:Ee,c=!a&&(n.cornerStrokeColor||s.cornerStrokeColor);let u,h=e,d=t;r.save(),r.fillStyle=n.cornerColor||s.cornerColor||"",r.strokeStyle=n.cornerStrokeColor||s.cornerStrokeColor||"",i>o?(u=i,r.scale(1,o/i),d=t*i/o):o>i?(u=o,r.scale(i/o,1),h=e*o/i):u=i,r.beginPath(),r.arc(h,d,u/2,0,Oa,!1),r[l](),c&&r.stroke(),r.restore()}function ub(r,e,t,n,s){n=n||{};const i=this.sizeX||n.cornerSize||s.cornerSize,o=this.sizeY||n.cornerSize||s.cornerSize,a=n.transparentCorners!==void 0?n.transparentCorners:s.transparentCorners,l=a?st:Ee,c=!a&&(n.cornerStrokeColor||s.cornerStrokeColor),u=i/2,h=o/2;r.save(),r.fillStyle=n.cornerColor||s.cornerColor||"",r.strokeStyle=n.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(e,t);const d=s.getTotalAngle();r.rotate(be(d)),r["".concat(l,"Rect")](-u,-h,i,o),c&&r.strokeRect(-u,-h,i,o),r.restore()}class Dt{constructor(e){_(this,"visible",!0),_(this,"actionName",fl),_(this,"angle",0),_(this,"x",0),_(this,"y",0),_(this,"offsetX",0),_(this,"offsetY",0),_(this,"sizeX",0),_(this,"sizeY",0),_(this,"touchSizeX",0),_(this,"touchSizeY",0),_(this,"cursorStyle","crosshair"),_(this,"withConnection",!1),Object.assign(this,e)}shouldActivate(e,t,n,s){var i;let{tl:o,tr:a,br:l,bl:c}=s;return((i=t.canvas)===null||i===void 0?void 0:i.getActiveObject())===t&&t.isControlVisible(e)&&ge.isPointInPolygon(n,[o,a,l,c])}getActionHandler(e,t,n){return this.actionHandler}getMouseDownHandler(e,t,n){return this.mouseDownHandler}getMouseUpHandler(e,t,n){return this.mouseUpHandler}cursorStyleHandler(e,t,n){return t.cursorStyle}getActionName(e,t,n){return t.actionName}getVisibility(e,t){var n,s;return(n=(s=e._controlsVisibility)===null||s===void 0?void 0:s[t])!==null&&n!==void 0?n:this.visible}setVisibility(e,t,n){this.visible=e}positionHandler(e,t,n,s){return new M(this.x*e.x+this.offsetX,this.y*e.y+this.offsetY).transform(t)}calcCornerCoords(e,t,n,s,i,o){const a=Rh([Mi(n,s),ws({angle:e}),Ah((i?this.touchSizeX:this.sizeX)||t,(i?this.touchSizeY:this.sizeY)||t)]);return{tl:new M(-.5,-.5).transform(a),tr:new M(.5,-.5).transform(a),br:new M(.5,.5).transform(a),bl:new M(-.5,.5).transform(a)}}render(e,t,n,s,i){((s=s||{}).cornerStyle||i.cornerStyle)==="circle"?cb.call(this,e,t,n,s,i):ub.call(this,e,t,n,s,i)}}const hb=(r,e,t)=>t.lockRotation?Aa:e.cursorStyle,db=bs(dv,_s((r,e,t,n)=>{let{target:s,ex:i,ey:o,theta:a,originX:l,originY:c}=e;const u=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(zt(s,"lockRotation"))return!1;const h=Math.atan2(o-u.y,i-u.x),d=Math.atan2(n-u.y,t-u.x);let f=Cr(d-h+a);if(s.snapAngle&&s.snapAngle>0){const v=s.snapAngle,x=s.snapThreshold||v,g=Math.ceil(f/v)*v,p=Math.floor(f/v)*v;Math.abs(f-p)<x?f=p:Math.abs(f-g)<x&&(f=g)}f<0&&(f=360+f),f%=360;const m=s.angle!==f;return s.angle=f,m}));function zv(r,e){const t=e.canvas,n=r[t.uniScaleKey];return t.uniformScaling&&!n||!t.uniformScaling&&n}function Wv(r,e,t){const n=zt(r,"lockScalingX"),s=zt(r,"lockScalingY");if(n&&s||!e&&(n||s)&&t||n&&e==="x"||s&&e==="y")return!0;const{width:i,height:o,strokeWidth:a}=r;return i===0&&a===0&&e!=="y"||o===0&&a===0&&e!=="x"}const fb=["e","se","s","sw","w","nw","n","ne","e"],Bs=(r,e,t)=>{const n=zv(r,t);if(Wv(t,e.x!==0&&e.y===0?"x":e.x===0&&e.y!==0?"y":"",n))return Aa;const s=Pv(t,e);return"".concat(fb[s],"-resize")};function zh(r,e,t,n){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const i=e.target,o=s.by,a=zv(r,i);let l,c,u,h,d,f;if(Wv(i,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,u=e.scaleY*e.gestureScale;else{if(l=Nh(e,e.originX,e.originY,t,n),d=o!=="y"?Math.sign(l.x||e.signX||1):1,f=o!=="x"?Math.sign(l.y||e.signY||1):1,e.signX||(e.signX=d),e.signY||(e.signY=f),zt(i,"lockScalingFlip")&&(e.signX!==d||e.signY!==f))return!1;if(h=i._getTransformedDimensions(),a&&!o){const x=Math.abs(l.x)+Math.abs(l.y),{original:g}=e,p=x/(Math.abs(h.x*g.scaleX/i.scaleX)+Math.abs(h.y*g.scaleY/i.scaleY));c=g.scaleX*p,u=g.scaleY*p}else c=Math.abs(l.x*i.scaleX/h.x),u=Math.abs(l.y*i.scaleY/h.y);Ov(e)&&(c*=2,u*=2),e.signX!==d&&o!=="y"&&(e.originX=zf(e.originX),c*=-1,e.signX=d),e.signY!==f&&o!=="x"&&(e.originY=zf(e.originY),u*=-1,e.signY=f)}const m=i.scaleX,v=i.scaleY;return o?(o==="x"&&i.set(it,c),o==="y"&&i.set(Tt,u)):(!zt(i,"lockScalingX")&&i.set(it,c),!zt(i,"lockScalingY")&&i.set(Tt,u)),m!==i.scaleX||v!==i.scaleY}const ro=bs(dl,_s((r,e,t,n)=>zh(r,e,t,n))),gb=bs(dl,_s((r,e,t,n)=>zh(r,e,t,n,{by:"x"}))),pb=bs(dl,_s((r,e,t,n)=>zh(r,e,t,n,{by:"y"}))),mb=["target","ex","ey","skewingSide"],lc={x:{counterAxis:"y",scale:it,skew:ys,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Tt,skew:xs,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},vb=["ns","nesw","ew","nwse"],yb=(r,e,t)=>{if(e.x!==0&&zt(t,"lockSkewingY")||e.y!==0&&zt(t,"lockSkewingX"))return Aa;const n=Pv(t,e)%4;return"".concat(vb[n],"-resize")};function Vv(r,e,t,n,s){const{target:i}=t,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:u}=lc[r];if(zt(i,l))return!1;const{origin:h,flip:d}=lc[o],f=_e(t[h])*(i[d]?-1:1),m=-Math.sign(f)*(i[u]?-1:1),v=.5*-((i[c]===0&&Nh(t,J,J,n,s)[r]>0||i[c]>0?1:-1)*m)+.5;return bs(fv,_s((g,p,y,b)=>function(O,S,T){let{target:C,ex:P,ey:j,skewingSide:R}=S,I=de(S,mb);const{skew:U}=lc[O],A=T.subtract(new M(P,j)).divide(new M(C.scaleX,C.scaleY))[O],G=C[U],Y=I[U],W=Math.tan(be(Y)),k=O==="y"?C._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:C._getTransformedDimensions({scaleX:1,scaleY:1}).y,F=2*A*R/Math.max(k,1)+W,B=Cr(Math.atan(F));C.set(U,B);const L=G!==C[U];if(L&&O==="y"){const{skewX:X,scaleX:q}=C,Q=C._getTransformedDimensions({skewY:G}),H=C._getTransformedDimensions(),K=X!==0?Q.x/H.x:1;K!==1&&C.set(it,K*q)}return L}(r,p,new M(y,b))))(e,E(E({},t),{},{[a]:v,skewingSide:m}),n,s)}const xb=(r,e,t,n)=>Vv("x",r,e,t,n),wb=(r,e,t,n)=>Vv("y",r,e,t,n);function yl(r,e){return r[e.canvas.altActionKey]}const no=(r,e,t)=>{const n=yl(r,t);return e.x===0?n?ys:Tt:e.y===0?n?xs:it:""},Un=(r,e,t)=>yl(r,t)?yb(0,e,t):Bs(r,e,t),Zf=(r,e,t,n)=>yl(r,e.target)?wb(r,e,t,n):gb(r,e,t,n),eg=(r,e,t,n)=>yl(r,e.target)?xb(r,e,t,n):pb(r,e,t,n),Hv=()=>({ml:new Dt({x:-.5,y:0,cursorStyleHandler:Un,actionHandler:Zf,getActionName:no}),mr:new Dt({x:.5,y:0,cursorStyleHandler:Un,actionHandler:Zf,getActionName:no}),mb:new Dt({x:0,y:.5,cursorStyleHandler:Un,actionHandler:eg,getActionName:no}),mt:new Dt({x:0,y:-.5,cursorStyleHandler:Un,actionHandler:eg,getActionName:no}),tl:new Dt({x:-.5,y:-.5,cursorStyleHandler:Bs,actionHandler:ro}),tr:new Dt({x:.5,y:-.5,cursorStyleHandler:Bs,actionHandler:ro}),bl:new Dt({x:-.5,y:.5,cursorStyleHandler:Bs,actionHandler:ro}),br:new Dt({x:.5,y:.5,cursorStyleHandler:Bs,actionHandler:ro}),mtr:new Dt({x:0,y:-.5,actionHandler:db,cursorStyleHandler:hb,offsetY:-40,withConnection:!0,actionName:Mh})}),Sb=()=>({mr:new Dt({x:.5,y:0,actionHandler:Jf,cursorStyleHandler:Un,actionName:yi}),ml:new Dt({x:-.5,y:0,actionHandler:Jf,cursorStyleHandler:Un,actionName:yi})}),bb=()=>E(E({},Hv()),Sb());class bi extends nr{static getDefaults(){return E(E({},super.getDefaults()),bi.ownDefaults)}constructor(e){super(),Object.assign(this,this.constructor.createControls(),bi.ownDefaults),this.setOptions(e)}static createControls(){return{controls:Hv()}}_updateCacheCanvas(){const e=this.canvas;if(this.noScaleCache&&e&&e._currentTransform){const t=e._currentTransform,n=t.target,s=t.action;if(this===n&&s&&s.startsWith(fl))return!1}return super._updateCacheCanvas()}getActiveControl(){const e=this.__corner;return e?{key:e,control:this.controls[e],coord:this.oCoords[e]}:void 0}findControl(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const n=Object.entries(this.oCoords);for(let s=n.length-1;s>=0;s--){const[i,o]=n[s],a=this.controls[i];if(a.shouldActivate(i,this,e,t?o.touchCorner:o.corner))return this.__corner=i,{key:i,control:a,coord:this.oCoords[i]}}}calcOCoords(){const e=this.getViewportTransform(),t=this.getCenterPoint(),n=Mi(t.x,t.y),s=ws({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),i=Re(n,s),o=Re(e,i),a=Re(o,[1/e[0],0,0,1/e[3],0,0]),l=this.group?ja(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),u={};return this.forEachControl((h,d)=>{const f=h.positionHandler(c,a,this,h);u[d]=Object.assign(f,this._calcCornerCoords(h,f))}),u}_calcCornerCoords(e,t){const n=this.getTotalAngle();return{corner:e.calcCornerCoords(n,this.cornerSize,t.x,t.y,!1,this),touchCorner:e.calcCornerCoords(n,this.touchCornerSize,t.x,t.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(e){for(const t in this.controls)e(this.controls[t],t,this)}drawSelectionBackground(e){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;e.save();const t=this.getRelativeCenterPoint(),n=this._calculateCurrentDimensions(),s=this.getViewportTransform();e.translate(t.x,t.y),e.scale(1/s[0],1/s[3]),e.rotate(be(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore()}strokeBorders(e,t){e.strokeRect(-t.x/2,-t.y/2,t.x,t.y)}_drawBorders(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=E({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},n);e.save(),e.strokeStyle=s.borderColor,this._setLineDash(e,s.borderDashArray),this.strokeBorders(e,t),s.hasControls&&this.drawControlsConnectingLines(e,t),e.restore()}_renderControls(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:n,hasControls:s}=this,i=E({hasBorders:n,hasControls:s},t),o=this.getViewportTransform(),a=i.hasBorders,l=i.hasControls,c=Re(o,this.calcTransformMatrix()),u=ja(c);e.save(),e.translate(u.translateX,u.translateY),e.lineWidth=this.borderScaleFactor,this.group===this.parent&&(e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(u.angle-=180),e.rotate(be(this.group?u.angle:this.angle)),a&&this.drawBorders(e,u,t),l&&this.drawControls(e,t),e.restore()}drawBorders(e,t,n){let s;if(n&&n.forActiveSelection||this.group){const i=Fh(this.width,this.height,gl(t)),o=this.isStrokeAccountedForInDimensions()?jh:(this.strokeUniform?new M().scalarAdd(this.canvas?this.canvas.getZoom():1):new M(t.scaleX,t.scaleY)).scalarMultiply(this.strokeWidth);s=i.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(e,s,n)}drawControlsConnectingLines(e,t){let n=!1;e.beginPath(),this.forEachControl((s,i)=>{s.withConnection&&s.getVisibility(this,i)&&(n=!0,e.moveTo(s.x*t.x,s.y*t.y),e.lineTo(s.x*t.x+s.offsetX,s.y*t.y+s.offsetY))}),n&&e.stroke()}drawControls(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};e.save();const n=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:i,cornerColor:o}=this,a=E({cornerStrokeColor:s,cornerDashArray:i,cornerColor:o},t);e.setTransform(n,0,0,n,0,0),e.strokeStyle=e.fillStyle=a.cornerColor,this.transparentCorners||(e.strokeStyle=a.cornerStrokeColor),this._setLineDash(e,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const u=this.oCoords[c];l.render(e,u.x,u.y,a,this)}}),e.restore()}isControlVisible(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)}setControlVisible(e,t){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[e]=t}setControlsVisibility(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(e).forEach(t=>{let[n,s]=t;return this.setControlVisible(n,s)})}clearContextTop(e){if(!this.canvas)return;const t=this.canvas.contextTop;if(!t)return;const n=this.canvas.viewportTransform;t.save(),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this.transform(t);const s=this.width+4,i=this.height+4;return t.clearRect(-s/2,-i/2,s,i),e||t.restore(),t}onDeselect(e){return!1}onSelect(e){return!1}shouldStartDragging(e){return!1}onDragStart(e){return!1}canDrop(e){return!1}renderDragSourceEffect(e){}renderDropTargetEffect(e){}}function $v(r,e){return e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}),r}_(bi,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Be extends bi{}$v(Be,[Mv]),V.setClass(Be),V.setClass(Be,"object");const _b=(r,e,t,n)=>{const s=2*(n=Math.round(n))+1,{data:i}=r.getImageData(e-n,t-n,s,s);for(let o=3;o<i.length;o+=4)if(i[o]>0)return!1;return!0};class Xv{constructor(e){this.options=e,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new M(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new M(1/this.options.scaleX,1/this.options.scaleY):new M(1,1)}createSideVector(e,t){const n=wu(e,t);return this.options.strokeUniform?n.multiply(this.scale):n}projectOrthogonally(e,t,n){return this.applySkew(e.add(this.calcOrthogonalProjection(e,t,n)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(e){const t=new M(e);return t.y+=t.x*Math.tan(be(this.options.skewY)),t.x+=t.y*Math.tan(be(this.options.skewX)),t}scaleUnitVector(e,t){return e.multiply(this.strokeUniformScalar).scalarMultiply(t)}}const Cb=new M;class ss extends Xv{static getOrthogonalRotationFactor(e,t){const n=t?bu(e,t):US(e);return Math.abs(n)<Pi?-1:1}constructor(e,t,n,s){super(s),_(this,"AB",void 0),_(this,"AC",void 0),_(this,"alpha",void 0),_(this,"bisector",void 0),this.A=new M(e),this.B=new M(t),this.C=new M(n),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=bu(this.AB,this.AC),this.bisector=Ih(Nv(this.AB.eq(Cb)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(e,t),i=Iv(s),o=ss.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,n*o)}projectBevel(){const e=[];return(this.alpha%Oa==0?[this.B]:[this.B,this.C]).forEach(t=>{e.push(this.projectOrthogonally(this.A,t)),e.push(this.projectOrthogonally(this.A,t,-this.strokeProjectionMagnitude))}),e}projectMiter(){const e=[],t=Math.abs(this.alpha),n=1/Math.sin(t/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*n),i=this.options.strokeUniform?Su(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Su(s)/this.strokeProjectionMagnitude<=i&&e.push(this.applySkew(this.A.add(s))),e.push(...this.projectBevel()),e}projectRoundNoSkew(e,t){const n=[],s=new M(ss.getOrthogonalRotationFactor(this.bisector),ss.getOrthogonalRotationFactor(new M(this.bisector.y,this.bisector.x)));return[new M(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new M(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(i=>{Kf(i,e,t)&&n.push(this.A.add(i))}),n}projectRoundWithSkew(e,t){const n=[],{skewX:s,skewY:i,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new M(Math.tan(be(s)),Math.tan(be(i))),u=this.strokeProjectionMagnitude,h=l?u/a/Math.sqrt(1/a**2+1/o**2*c.y**2):u/Math.sqrt(1+c.y**2),d=new M(Math.sqrt(Math.max(u**2-h**2,0)),h),f=l?u/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):u/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),m=new M(f,Math.sqrt(Math.max(u**2-f**2,0)));return[m,m.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(v=>this.applySkew(l?v.multiply(this.strokeUniformScalar):v)).forEach(v=>{Kf(v,e,t)&&n.push(this.applySkew(this.A).add(v))}),n}projectRound(){const e=[];e.push(...this.projectBevel());const t=this.alpha%Oa==0,n=this.applySkew(this.A),s=e[t?0:2].subtract(n),i=e[t?1:0].subtract(n),o=t?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Js(s,o)>0,l=a?s:i,c=a?i:s;return this.isSkewed()?e.push(...this.projectRoundWithSkew(l,c)):e.push(...this.projectRoundNoSkew(l,c)),e}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e,angle:this.alpha,bisector:this.bisector}))}}class tg extends Xv{constructor(e,t,n){super(n),this.A=new M(e),this.T=new M(t)}calcOrthogonalProjection(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(e,t);return this.scaleUnitVector(Iv(s),n)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const e=[];if(!this.isSkewed()&&this.A.eq(this.T)){const t=new M(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.applySkew(this.A.add(t)),this.applySkew(this.A.subtract(t)))}else e.push(...new ss(this.A,this.T,this.T,this.options).projectRound());return e}projectSquare(){const e=[];if(this.A.eq(this.T)){const t=new M(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.A.add(t),this.A.subtract(t))}else{const t=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),n=this.scaleUnitVector(Ih(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(n);e.push(s.add(t),s.subtract(t))}return e.map(t=>this.applySkew(t))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e}))}}const Tb=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const n=[];if(r.length===0)return n;const s=r.reduce((i,o)=>(i[i.length-1].eq(o)||i.push(new M(o)),i),[new M(r[0])]);if(s.length===1)t=!0;else if(!t){const i=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,a=>!a.eq(i));s.splice(o+1)}return s.forEach((i,o,a)=>{let l,c;o===0?(c=a[1],l=t?i:a[a.length-1]):o===a.length-1?(l=a[o-1],c=t?i:a[0]):(l=a[o-1],c=a[o+1]),t&&a.length===1?n.push(...new tg(i,i,e).project()):!t||o!==0&&o!==a.length-1?n.push(...new ss(i,l,c,e).project()):n.push(...new tg(i,o===0?c:l,e).project())}),n},Wh=r=>{const e={};return Object.keys(r).forEach(t=>{e[t]={},Object.keys(r[t]).forEach(n=>{e[t][n]=E({},r[t][n])})}),e},kb=r=>r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Rs;const Vh=r=>{if(Rs||Rs||(Rs="Intl"in hl()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Rs){const e=Rs.segment(r);return Array.from(e).map(t=>{let{segment:n}=t;return n})}return Eb(r)},Eb=r=>{const e=[];for(let t,n=0;n<r.length;n++)(t=Ob(r,n))!==!1&&e.push(t);return e},Ob=(r,e)=>{const t=r.charCodeAt(e);if(isNaN(t))return"";if(t<55296||t>57343)return r.charAt(e);if(55296<=t&&t<=56319){if(r.length<=e+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(e+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(e)+r.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";const n=r.charCodeAt(e-1);if(55296>n||n>56319)throw"Low surrogate without preceding high surrogate";return!1},Hh=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==e.fill||r.stroke!==e.stroke||r.strokeWidth!==e.strokeWidth||r.fontSize!==e.fontSize||r.fontFamily!==e.fontFamily||r.fontWeight!==e.fontWeight||r.fontStyle!==e.fontStyle||r.textDecorationThickness!==e.textDecorationThickness||r.textBackgroundColor!==e.textBackgroundColor||r.deltaY!==e.deltaY||t&&(r.overline!==e.overline||r.underline!==e.underline||r.linethrough!==e.linethrough)},Db=(r,e)=>{const t=e.split(`
80
- `),n=[];let s=-1,i={};r=Wh(r);for(let o=0;o<t.length;o++){const a=Vh(t[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Hh(i,c,!0)?n.push({start:s,end:s+1,style:c}):n[n.length-1].end++),i=c||{}}else s+=a.length,i={}}return n},Pb=(r,e)=>{if(!Array.isArray(r))return Wh(r);const t=e.split(Ph),n={};let s=-1,i=0;for(let o=0;o<t.length;o++){const a=Vh(t[o]);for(let l=0;l<a.length;l++)s++,r[i]&&r[i].start<=s&&s<r[i].end&&(n[o]=n[o]||{},n[o][l]=E({},r[i].style),s===r[i].end-1&&i++)}return n},rn=["display","transform",Ee,"fill-opacity","fill-rule","opacity",st,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function rg(r,e){const t=r.nodeName,n=r.getAttribute("class"),s=r.getAttribute("id"),i="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+t,"i"),e=e.replace(o,""),s&&e.length&&(o=new RegExp("#"+s+i,"i"),e=e.replace(o,"")),n&&e.length){const a=n.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+i,"i"),e=e.replace(o,"")}return e.length===0}function Mb(r,e){let t=!0;const n=rg(r,e.pop());return n&&e.length&&(t=function(s,i){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&i.length;)a&&(o=i.pop()),a=rg(s=s.parentElement,o);return i.length===0}(r,e)),n&&t&&e.length===0}const jb=r=>{var e;return(e=$S[r])!==null&&e!==void 0?e:r},Rb=new RegExp("(".concat(Nt,")"),"gi"),Ab=r=>La(r.replace(Rb," $1 ").replace(/,/gi," "));var ng,sg,ig,og,ag,lg,cg;const He="(".concat(Nt,")"),Lb=String.raw(ng||(ng=rr(["(skewX)(",")"],["(skewX)\\(","\\)"])),He),Fb=String.raw(sg||(sg=rr(["(skewY)(",")"],["(skewY)\\(","\\)"])),He),Nb=String.raw(ig||(ig=rr(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),He,He,He),Ib=String.raw(og||(og=rr(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),He,He),Bb=String.raw(ag||(ag=rr(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),He,He),zb=String.raw(lg||(lg=rr(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),He,He,He,He,He,He),$h="(?:".concat(zb,"|").concat(Bb,"|").concat(Nb,"|").concat(Ib,"|").concat(Lb,"|").concat(Fb,")"),Wb="(?:".concat($h,"*)"),Vb=String.raw(cg||(cg=rr(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Wb),Hb=new RegExp(Vb),$b=new RegExp($h),Xb=new RegExp($h,"g");function _u(r){const e=[];if(!(r=Ab(r).replace(/\s*([()])\s*/gi,"$1"))||r&&!Hb.test(r))return[...Xe];for(const t of r.matchAll(Xb)){const n=$b.exec(t[0]);if(!n)continue;let s=Xe;const i=n.filter(m=>!!m),[,o,...a]=i,[l,c,u,h,d,f]=a.map(m=>parseFloat(m));switch(o){case"translate":s=Mi(l,c);break;case Mh:s=ws({angle:l},{x:c,y:u});break;case fl:s=Ah(l,c);break;case ys:s=wv(l);break;case xs:s=Sv(l);break;case"matrix":s=[l,c,u,h,d,f]}e.push(s)}return Rh(e)}function Ub(r,e,t,n){const s=Array.isArray(e);let i,o=e;if(r!==Ee&&r!==st||e!==nt){if(r==="strokeUniform")return e==="non-scaling-stroke";if(r==="strokeDashArray")o=e===nt?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(r==="transformMatrix")o=t&&t.transformMatrix?Re(t.transformMatrix,_u(e)):_u(e);else if(r==="visible")o=e!==nt&&e!=="hidden",t&&t.visible===!1&&(o=!1);else if(r==="opacity")o=parseFloat(e),t&&t.opacity!==void 0&&(o*=t.opacity);else if(r==="textAnchor")o=e==="start"?se:e==="end"?xe:J;else if(r==="charSpacing"||r===Tn)i=ns(e,n)/n*1e3;else if(r==="paintFirst"){const a=e.indexOf(Ee),l=e.indexOf(st);o=Ee,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=st)}else{if(r==="href"||r==="xlink:href"||r==="font"||r==="id")return e;if(r==="imageSmoothing")return e==="optimizeQuality";i=s?e.map(ns):ns(e,n)}}else o="";return!s&&isNaN(i)?o:i}function Yb(r,e){const t=r.match(HS);if(!t)return;const n=t[1],s=t[3],i=t[4],o=t[5],a=t[6];n&&(e.fontStyle=n),s&&(e.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),i&&(e.fontSize=ns(i)),a&&(e.fontFamily=a),o&&(e.lineHeight=o==="normal"?1:o)}function Gb(r,e){r.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;const[n,s]=t.split(":");e[n.trim().toLowerCase()]=s.trim()})}function Kb(r){const e={},t=r.getAttribute("style");return t&&(typeof t=="string"?Gb(t,e):function(n,s){Object.entries(n).forEach(i=>{let[o,a]=i;a!==void 0&&(s[o.toLowerCase()]=a)})}(t,e)),e}const qb={stroke:"strokeOpacity",fill:"fillOpacity"};function Er(r,e,t){if(!r)return{};let n,s={},i=Dh;r.parentNode&&Gf.test(r.parentNode.nodeName)&&(s=Er(r.parentElement,e,t),s.fontSize&&(n=i=ns(s.fontSize)));const o=E(E(E({},e.reduce((c,u)=>{const h=r.getAttribute(u);return h&&(c[u]=h),c},{})),function(c){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h={};for(const d in u)Mb(c,d.split(" "))&&(h=E(E({},h),u[d]));return h}(r,t)),Kb(r));o[oc]&&r.setAttribute(oc,o[oc]),o[ic]&&(n=ns(o[ic],i),o[ic]="".concat(n));const a={};for(const c in o){const u=jb(c),h=Ub(u,o[c],s,n);a[u]=h}a&&a.font&&Yb(a.font,a);const l=E(E({},s),a);return Gf.test(r.nodeName)?l:function(c){const u=Be.getDefaults();return Object.entries(qb).forEach(h=>{let[d,f]=h;if(c[f]===void 0||c[d]==="")return;if(c[d]===void 0){if(!u[d])return;c[d]=u[d]}if(c[d].indexOf("url(")===0)return;const m=new ne(c[d]);c[d]=m.setAlpha(le(m.getAlpha()*c[f],2)).toRgba()}),c}(l)}const Qb=["left","top","width","height","visible"],Uv=["rx","ry"];class At extends Be{static getDefaults(){return E(E({},super.getDefaults()),At.ownDefaults)}constructor(e){super(),Object.assign(this,At.ownDefaults),this.setOptions(e),this._initRxRy()}_initRxRy(){const{rx:e,ry:t}=this;e&&!t?this.ry=e:t&&!e&&(this.rx=t)}_render(e){const{width:t,height:n}=this,s=-t/2,i=-n/2,o=this.rx?Math.min(this.rx,t/2):0,a=this.ry?Math.min(this.ry,n/2):0,l=o!==0||a!==0;e.beginPath(),e.moveTo(s+o,i),e.lineTo(s+t-o,i),l&&e.bezierCurveTo(s+t-Dr*o,i,s+t,i+Dr*a,s+t,i+a),e.lineTo(s+t,i+n-a),l&&e.bezierCurveTo(s+t,i+n-Dr*a,s+t-Dr*o,i+n,s+t-o,i+n),e.lineTo(s+o,i+n),l&&e.bezierCurveTo(s+Dr*o,i+n,s,i+n-Dr*a,s,i+n-a),e.lineTo(s,i+a),l&&e.bezierCurveTo(s,i+Dr*a,s+Dr*o,i,s+o,i),e.closePath(),this._renderPaintInOrder(e)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Uv,...e])}_toSVG(){const{width:e,height:t,rx:n,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-e/2,'" y="').concat(-t/2,'" rx="').concat(n,'" ry="').concat(s,'" width="').concat(e,'" height="').concat(t,`" />
81
- `)]}static async fromElement(e,t,n){const s=Er(e,this.ATTRIBUTE_NAMES,n),{left:i=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,u=de(s,Qb);return new this(E(E(E({},t),u),{},{left:i,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}_(At,"type","Rect"),_(At,"cacheProperties",[...kr,...Uv]),_(At,"ownDefaults",{rx:0,ry:0}),_(At,"ATTRIBUTE_NAMES",[...rn,"x","y","rx","ry","width","height"]),V.setClass(At),V.setSVGClass(At);const hr="initialization",Na="added",Xh="removed",Ia="imperative",Yv=(r,e)=>{const{strokeUniform:t,strokeWidth:n,width:s,height:i,group:o}=e,a=o&&o!==r?ml(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),u=t&&c?FS(new M(n,n),void 0,r.calcTransformMatrix()):jh,h=!t&&c?n:0,d=Fh(s+h,i+h,Rh([a,e.calcOwnMatrix()],!0)).add(u).scalarDivide(2);return[l.subtract(d),l.add(d)]};class xl{calcLayoutResult(e,t){if(this.shouldPerformLayout(e))return this.calcBoundingBox(t,e)}shouldPerformLayout(e){let{type:t,prevStrategy:n,strategy:s}=e;return t===hr||t===Ia||!!n&&s!==n}shouldLayoutClipPath(e){let{type:t,target:{clipPath:n}}=e;return t!==hr&&n&&!n.absolutePositioned}getInitialSize(e,t){return t.size}calcBoundingBox(e,t){const{type:n,target:s}=t;if(n===Ia&&t.overrides)return t.overrides;if(e.length===0)return;const{left:i,top:o,width:a,height:l}=pr(e.map(h=>Yv(s,h)).reduce((h,d)=>h.concat(d),[])),c=new M(a,l),u=new M(i,o).add(c.scalarDivide(2));if(n===hr){const h=this.getInitialSize(t,{size:c,center:u});return{center:u,relativeCorrection:new M(0,0),size:h}}return{center:u.transform(s.calcOwnMatrix()),size:c}}}_(xl,"type","strategy");class Cu extends xl{shouldPerformLayout(e){return!0}}_(Cu,"type","fit-content"),V.setClass(Cu);const Jb=["strategy"],Zb=["target","strategy","bubbles","prevStrategy"],Gv="layoutManager";class _i{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Cu;_(this,"strategy",void 0),this.strategy=e,this._subscriptions=new Map}performLayout(e){const t=E(E({bubbles:!0,strategy:this.strategy},e),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(t);const n=this.getLayoutResult(t);n&&this.commitLayout(t,n),this.onAfterLayout(t,n),this._prevLayoutStrategy=t.strategy}attachHandlers(e,t){const{target:n}=t;return[Pa,hv,yi,dv,dl,fv,Da,SS,bS].map(s=>e.on(s,i=>this.performLayout(s===Pa?{type:"object_modified",trigger:s,e:i,target:n}:{type:"object_modifying",trigger:s,e:i,target:n})))}subscribe(e,t){this.unsubscribe(e,t);const n=this.attachHandlers(e,t);this._subscriptions.set(e,n)}unsubscribe(e,t){(this._subscriptions.get(e)||[]).forEach(n=>n()),this._subscriptions.delete(e)}unsubscribeTargets(e){e.targets.forEach(t=>this.unsubscribe(t,e))}subscribeTargets(e){e.targets.forEach(t=>this.subscribe(t,e))}onBeforeLayout(e){const{target:t,type:n}=e,{canvas:s}=t;if(n===hr||n===Na?this.subscribeTargets(e):n===Xh&&this.unsubscribeTargets(e),t.fire("layout:before",{context:e}),s&&s.fire("object:layout:before",{target:t,context:e}),n===Ia&&e.deep){const i=de(e,Jb);t.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(E(E({},i),{},{bubbles:!1,target:o})))}}getLayoutResult(e){const{target:t,strategy:n,type:s}=e,i=n.calcLayoutResult(e,t.getObjects());if(!i)return;const o=s===hr?new M:t.getRelativeCenterPoint(),{center:a,correction:l=new M,relativeCorrection:c=new M}=i,u=o.subtract(a).add(l).transform(s===hr?Xe:Ft(t.calcOwnMatrix()),!0).add(c);return{result:i,prevCenter:o,nextCenter:a,offset:u}}commitLayout(e,t){const{target:n}=e,{result:{size:s},nextCenter:i}=t;var o,a;n.set({width:s.x,height:s.y}),this.layoutObjects(e,t),e.type===hr?n.set({left:(o=e.x)!==null&&o!==void 0?o:i.x+s.x*_e(n.originX),top:(a=e.y)!==null&&a!==void 0?a:i.y+s.y*_e(n.originY)}):(n.setPositionByOrigin(i,J,J),n.setCoords(),n.set("dirty",!0))}layoutObjects(e,t){const{target:n}=e;n.forEachObject(s=>{s.group===n&&this.layoutObject(e,t,s)}),e.strategy.shouldLayoutClipPath(e)&&this.layoutObject(e,t,n.clipPath)}layoutObject(e,t,n){let{offset:s}=t;n.set({left:n.left+s.x,top:n.top+s.y})}onAfterLayout(e,t){const{target:n,strategy:s,bubbles:i,prevStrategy:o}=e,a=de(e,Zb),{canvas:l}=n;n.fire("layout:after",{context:e,result:t}),l&&l.fire("object:layout:after",{context:e,result:t,target:n});const c=n.parent;i&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(n),c.layoutManager.performLayout(E(E({},a),{},{target:c}))),n.set("dirty",!0)}dispose(){const{_subscriptions:e}=this;e.forEach(t=>t.forEach(n=>n())),e.clear()}toObject(){return{type:Gv,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}V.setClass(_i,Gv);const e_=["type","objects","layoutManager"];class t_ extends _i{performLayout(){}}class vn extends gv(Be){static getDefaults(){return E(E({},super.getDefaults()),vn.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_(this,"_activeObjects",[]),_(this,"__objectSelectionTracker",void 0),_(this,"__objectSelectionDisposer",void 0),Object.assign(this,vn.ownDefaults),this.setOptions(t),this.groupInit(e,t)}groupInit(e,t){var n;this._objects=[...e],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(s=>{this.enterGroup(s,!1)}),this.layoutManager=(n=t.layoutManager)!==null&&n!==void 0?n:new _i,this.layoutManager.performLayout({type:hr,target:this,targets:[...e],x:t.left,y:t.top})}canEnterGroup(e){return e===this||this.isDescendantOf(e)?(Qr("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(e)===-1||(Qr("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(e){return e.filter((t,n,s)=>this.canEnterGroup(t)&&s.indexOf(t)===n)}add(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const s=this._filterObjectsBeforeEnteringGroup(t),i=super.add(...s);return this._onAfterObjectsChange(Na,s),i}insertAt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];const i=this._filterObjectsBeforeEnteringGroup(n),o=super.insertAt(e,...i);return this._onAfterObjectsChange(Na,i),o}remove(){const e=super.remove(...arguments);return this._onAfterObjectsChange(Xh,e),e}_onObjectAdded(e){this.enterGroup(e,!0),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e,t){this.exitGroup(e,t),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onAfterObjectsChange(e,t){this.layoutManager.performLayout({type:e,targets:t,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(e,t){const n=this[e];return super._set(e,t),e==="canvas"&&n!==t&&(this._objects||[]).forEach(s=>{s._set(e,t)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(e,t){let{target:n}=t;const s=this._activeObjects;if(e)s.push(n),this._set("dirty",!0);else if(s.length>0){const i=s.indexOf(n);i>-1&&(s.splice(i,1),this._set("dirty",!0))}}_watchObject(e,t){e&&this._watchObject(!1,t),e?(t.on("selected",this.__objectSelectionTracker),t.on("deselected",this.__objectSelectionDisposer)):(t.off("selected",this.__objectSelectionTracker),t.off("deselected",this.__objectSelectionDisposer))}enterGroup(e,t){e.group&&e.group.remove(e),e._set("parent",this),this._enterGroup(e,t)}_enterGroup(e,t){t&&Ra(e,Re(Ft(this.calcTransformMatrix()),e.calcTransformMatrix())),this._shouldSetNestedCoords()&&e.setCoords(),e._set("group",this),e._set("canvas",this.canvas),this._watchObject(!0,e);const n=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();n&&(n===e||e.isDescendantOf(n))&&this._activeObjects.push(e)}exitGroup(e,t){this._exitGroup(e,t),e._set("parent",void 0),e._set("canvas",void 0)}_exitGroup(e,t){e._set("group",void 0),t||(Ra(e,Re(this.calcTransformMatrix(),e.calcTransformMatrix())),e.setCoords()),this._watchObject(!1,e);const n=this._activeObjects.length>0?this._activeObjects.indexOf(e):-1;n>-1&&this._activeObjects.splice(n,1)}shouldCache(){const e=Be.prototype.shouldCache.call(this);if(e){for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1}return e}willDrawShadow(){if(super.willDrawShadow())return!0;for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(e,t,n){this._renderBackground(e);for(let i=0;i<this._objects.length;i++){var s;const o=this._objects[i];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(e.save(),e.transform(...Ft(this.calcTransformMatrix())),o.render(e),e.restore()):o.group===this&&o.render(e)}this._drawClipPath(e,this.clipPath,n)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(e=>e.setCoords())}triggerLayout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(E({target:this,type:Ia},e))}render(e){this._transformDone=!0,super.render(e),this._transformDone=!1}__serializeObjects(e,t){const n=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const i=s.includeDefaultValues;s.includeDefaultValues=n;const o=s[e||"toObject"](t);return s.includeDefaultValues=i,o})}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=this.layoutManager.toObject();return E(E(E({},super.toObject(["subTargetCheck","interactive",...e])),t.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:t}:{}),{},{objects:this.__serializeObjects("toObject",e)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(e=>{this._watchObject(!1,e),e.dispose()}),super.dispose()}_createSVGBgRect(e){if(!this.backgroundColor)return"";const t=At.prototype._toSVG.call(this),n=t.indexOf("COMMON_PARTS");t[n]='for="group" ';const s=t.join("");return e?e(s):s}_toSVG(e){const t=["<g ","COMMON_PARTS",` >
82
- `],n=this._createSVGBgRect(e);n&&t.push(" ",n);for(let s=0;s<this._objects.length;s++)t.push(" ",this._objects[s].toSVG(e));return t.push(`</g>
83
- `),t}getSvgStyles(){const e=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",t=this.visible?"":" visibility: hidden;";return[e,this.getSvgFilter(),t].join("")}toClipPathSVG(e){const t=[],n=this._createSVGBgRect(e);n&&t.push(" ",n);for(let s=0;s<this._objects.length;s++)t.push(" ",this._objects[s].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject(e,t){let{type:n,objects:s=[],layoutManager:i}=e,o=de(e,e_);return Promise.all([xi(s,t),pl(o,t)]).then(a=>{let[l,c]=a;const u=new this(l,E(E(E({},o),c),{},{layoutManager:new t_}));if(i){const h=V.getClass(i.type),d=V.getClass(i.strategy);u.layoutManager=new h(new d)}else u.layoutManager=new _i;return u.layoutManager.subscribeTargets({type:hr,target:u,targets:u.getObjects()}),u.setCoords(),u})}}_(vn,"type","Group"),_(vn,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),V.setClass(vn);const r_=(r,e)=>Math.min(e.width/r.width,e.height/r.height),n_=(r,e)=>Math.max(e.width/r.width,e.height/r.height),Tu="\\s*,?\\s*",As="".concat(Tu,"(").concat(Nt,")"),s_="".concat(As).concat(As).concat(As).concat(Tu,"([01])").concat(Tu,"([01])").concat(As).concat(As),i_={m:"l",M:"L"},o_=(r,e,t,n,s,i,o,a,l,c,u)=>{const h=Sr(r),d=br(r),f=Sr(e),m=br(e),v=t*s*f-n*i*m+o,x=n*s*f+t*i*m+a;return["C",c+l*(-t*s*d-n*i*h),u+l*(-n*s*d+t*i*h),v+l*(t*s*m+n*i*f),x+l*(n*s*m-t*i*f),v,x]},ug=(r,e,t,n)=>{const s=Math.atan2(e,r),i=Math.atan2(n,t);return i>=s?i-s:2*Math.PI-(s-i)};function hg(r,e,t,n,s,i,o,a){let l;if(re.cachesBoundsOfCurve&&(l=[...arguments].join(),Ks.boundsOfCurveCache[l]))return Ks.boundsOfCurveCache[l];const c=Math.sqrt,u=Math.abs,h=[],d=[[0,0],[0,0]];let f=6*r-12*t+6*s,m=-3*r+9*t-9*s+3*o,v=3*t-3*r;for(let b=0;b<2;++b){if(b>0&&(f=6*e-12*n+6*i,m=-3*e+9*n-9*i+3*a,v=3*n-3*e),u(m)<1e-12){if(u(f)<1e-12)continue;const P=-v/f;0<P&&P<1&&h.push(P);continue}const O=f*f-4*v*m;if(O<0)continue;const S=c(O),T=(-f+S)/(2*m);0<T&&T<1&&h.push(T);const C=(-f-S)/(2*m);0<C&&C<1&&h.push(C)}let x=h.length;const g=x,p=Kv(r,e,t,n,s,i,o,a);for(;x--;){const{x:b,y:O}=p(h[x]);d[0][x]=b,d[1][x]=O}d[0][g]=r,d[1][g]=e,d[0][g+1]=o,d[1][g+1]=a;const y=[new M(Math.min(...d[0]),Math.min(...d[1])),new M(Math.max(...d[0]),Math.max(...d[1]))];return re.cachesBoundsOfCurve&&(Ks.boundsOfCurveCache[l]=y),y}const a_=(r,e,t)=>{let[n,s,i,o,a,l,c,u]=t;const h=((d,f,m,v,x,g,p)=>{if(m===0||v===0)return[];let y=0,b=0,O=0;const S=Math.PI,T=p*Oh,C=br(T),P=Sr(T),j=.5*(-P*d-C*f),R=.5*(-P*f+C*d),I=m**2,U=v**2,A=R**2,G=j**2,Y=I*U-I*A-U*G;let W=Math.abs(m),k=Math.abs(v);if(Y<0){const oe=Math.sqrt(1-Y/(I*U));W*=oe,k*=oe}else O=(x===g?-1:1)*Math.sqrt(Y/(I*A+U*G));const F=O*W*R/k,B=-O*k*j/W,L=P*F-C*B+.5*d,X=C*F+P*B+.5*f;let q=ug(1,0,(j-F)/W,(R-B)/k),Q=ug((j-F)/W,(R-B)/k,(-j-F)/W,(-R-B)/k);g===0&&Q>0?Q-=2*S:g===1&&Q<0&&(Q+=2*S);const H=Math.ceil(Math.abs(Q/S*2)),K=[],ee=Q/H,ae=8/3*Math.sin(ee/4)*Math.sin(ee/4)/Math.sin(ee/2);let z=q+ee;for(let oe=0;oe<H;oe++)K[oe]=o_(q,z,P,C,W,k,L,X,ae,y,b),y=K[oe][5],b=K[oe][6],q=z,z+=ee;return K})(c-r,u-e,s,i,a,l,o);for(let d=0,f=h.length;d<f;d++)h[d][1]+=r,h[d][2]+=e,h[d][3]+=r,h[d][4]+=e,h[d][5]+=r,h[d][6]+=e;return h},l_=r=>{let e=0,t=0,n=0,s=0;const i=[];let o,a=0,l=0;for(const c of r){const u=[...c];let h;switch(u[0]){case"l":u[1]+=e,u[2]+=t;case"L":e=u[1],t=u[2],h=["L",e,t];break;case"h":u[1]+=e;case"H":e=u[1],h=["L",e,t];break;case"v":u[1]+=t;case"V":t=u[1],h=["L",e,t];break;case"m":u[1]+=e,u[2]+=t;case"M":e=u[1],t=u[2],n=u[1],s=u[2],h=["M",e,t];break;case"c":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t,u[5]+=e,u[6]+=t;case"C":a=u[3],l=u[4],e=u[5],t=u[6],h=["C",u[1],u[2],a,l,e,t];break;case"s":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t;case"S":o==="C"?(a=2*e-a,l=2*t-l):(a=e,l=t),e=u[3],t=u[4],h=["C",a,l,u[1],u[2],e,t],a=h[3],l=h[4];break;case"q":u[1]+=e,u[2]+=t,u[3]+=e,u[4]+=t;case"Q":a=u[1],l=u[2],e=u[3],t=u[4],h=["Q",a,l,e,t];break;case"t":u[1]+=e,u[2]+=t;case"T":o==="Q"?(a=2*e-a,l=2*t-l):(a=e,l=t),e=u[1],t=u[2],h=["Q",a,l,e,t];break;case"a":u[6]+=e,u[7]+=t;case"A":a_(e,t,u).forEach(d=>i.push(d)),e=u[6],t=u[7];break;case"z":case"Z":e=n,t=s,h=["Z"]}h?(i.push(h),o=h[0]):o=""}return i},Ba=(r,e,t,n)=>Math.sqrt((t-r)**2+(n-e)**2),Kv=(r,e,t,n,s,i,o,a)=>l=>{const c=l**3,u=(f=>3*f**2*(1-f))(l),h=(f=>3*f*(1-f)**2)(l),d=(f=>(1-f)**3)(l);return new M(o*c+s*u+t*h+r*d,a*c+i*u+n*h+e*d)},qv=r=>r**2,Qv=r=>2*r*(1-r),Jv=r=>(1-r)**2,c_=(r,e,t,n,s,i,o,a)=>l=>{const c=qv(l),u=Qv(l),h=Jv(l),d=3*(h*(t-r)+u*(s-t)+c*(o-s)),f=3*(h*(n-e)+u*(i-n)+c*(a-i));return Math.atan2(f,d)},u_=(r,e,t,n,s,i)=>o=>{const a=qv(o),l=Qv(o),c=Jv(o);return new M(s*a+t*l+r*c,i*a+n*l+e*c)},h_=(r,e,t,n,s,i)=>o=>{const a=1-o,l=2*(a*(t-r)+o*(s-t)),c=2*(a*(n-e)+o*(i-n));return Math.atan2(c,l)},dg=(r,e,t)=>{let n=new M(e,t),s=0;for(let i=1;i<=100;i+=1){const o=r(i/100);s+=Ba(n.x,n.y,o.x,o.y),n=o}return s},d_=(r,e)=>{let t,n=0,s=0,i={x:r.x,y:r.y},o=E({},i),a=.01,l=0;const c=r.iterator,u=r.angleFinder;for(;s<e&&a>1e-4;)o=c(n),l=n,t=Ba(i.x,i.y,o.x,o.y),t+s>e?(n-=a,a/=2):(i=o,n+=a,s+=t);return E(E({},o),{},{angle:u(l)})},Zv=r=>{let e,t,n=0,s=0,i=0,o=0,a=0;const l=[];for(const c of r){const u={x:s,y:i,command:c[0],length:0};switch(c[0]){case"M":t=u,t.x=o=s=c[1],t.y=a=i=c[2];break;case"L":t=u,t.length=Ba(s,i,c[1],c[2]),s=c[1],i=c[2];break;case"C":e=Kv(s,i,c[1],c[2],c[3],c[4],c[5],c[6]),t=u,t.iterator=e,t.angleFinder=c_(s,i,c[1],c[2],c[3],c[4],c[5],c[6]),t.length=dg(e,s,i),s=c[5],i=c[6];break;case"Q":e=u_(s,i,c[1],c[2],c[3],c[4]),t=u,t.iterator=e,t.angleFinder=h_(s,i,c[1],c[2],c[3],c[4]),t.length=dg(e,s,i),s=c[3],i=c[4];break;case"Z":t=u,t.destX=o,t.destY=a,t.length=Ba(s,i,o,a),s=o,i=a}n+=t.length,l.push(t)}return l.push({length:n,x:s,y:i}),l},f_=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Zv(r),n=0;for(;e-t[n].length>0&&n<t.length-2;)e-=t[n].length,n++;const s=t[n],i=e/s.length,o=r[n];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return E(E({},new M(s.x,s.y).lerp(new M(s.destX,s.destY),i)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return E(E({},new M(s.x,s.y).lerp(new M(o[1],o[2]),i)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return d_(s,e)}},g_=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),fg=new RegExp(s_,"g"),p_=new RegExp(Nt,"gi"),m_={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},v_=r=>{var e;const t=[],n=(e=r.match(g_))!==null&&e!==void 0?e:[];for(const s of n){const i=s[0];if(i==="z"||i==="Z"){t.push([i]);continue}const o=m_[i.toLowerCase()];let a=[];if(i==="a"||i==="A"){fg.lastIndex=0;for(let l=null;l=fg.exec(s);)a.push(...l.slice(1))}else a=s.match(p_)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),u=i_[i];c[0]=l>0&&u?u:i;for(let h=0;h<o;h++)c[h+1]=parseFloat(a[l+h]);t.push(c)}}return t},y_=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=new M(r[0]),n=new M(r[1]),s=1,i=0;const o=[],a=r.length,l=a>2;let c;for(l&&(s=r[2].x<n.x?-1:r[2].x===n.x?0:1,i=r[2].y<n.y?-1:r[2].y===n.y?0:1),o.push(["M",t.x-s*e,t.y-i*e]),c=1;c<a;c++){if(!t.eq(n)){const u=t.midPointFrom(n);o.push(["Q",t.x,t.y,u.x,u.y])}t=r[c],c+1<r.length&&(n=r[c+1])}return l&&(s=t.x>r[c-2].x?1:t.x===r[c-2].x?0:-1,i=t.y>r[c-2].y?1:t.y===r[c-2].y?0:-1),o.push(["L",t.x+s*e,t.y+i*e]),o},ey=(r,e)=>r.map(t=>t.map((n,s)=>s===0||e===void 0?n:le(n,e)).join(" ")).join(" ");function ku(r,e){const t=r.style;t&&e&&(typeof e=="string"?t.cssText+=";"+e:Object.entries(e).forEach(n=>{let[s,i]=n;return t.setProperty(s,i)}))}class x_ extends Tv{constructor(e){let{allowTouchScrolling:t=!1,containerClass:n=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(e),_(this,"upper",void 0),_(this,"container",void 0);const{el:s}=this.lower,i=this.createUpperCanvas();this.upper={el:i,ctx:i.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:t}),this.applyCanvasStyle(i,{allowTouchScrolling:t,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(n),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,i),this.container=o}createUpperCanvas(){const{el:e}=this.lower,t=_r();return t.className=e.className,t.classList.remove("lower-canvas"),t.classList.add("upper-canvas"),t.setAttribute("data-fabric","top"),t.style.cssText=e.style.cssText,t.setAttribute("draggable","true"),t}createContainerElement(){const e=vs().createElement("div");return e.setAttribute("data-fabric","wrapper"),ku(e,{position:"relative"}),If(e),e}applyCanvasStyle(e,t){const{styles:n,allowTouchScrolling:s}=t;ku(e,E(E({},n),{},{"touch-action":s?"manipulation":nt})),If(e)}setDimensions(e,t){super.setDimensions(e,t);const{el:n,ctx:s}=this.upper;Cv(n,s,e,t)}setCSSDimensions(e){super.setCSSDimensions(e),yu(this.upper.el,e),yu(this.container,e)}cleanupDOM(e){const t=this.container,{el:n}=this.lower,{el:s}=this.upper;super.cleanupDOM(e),t.removeChild(s),t.removeChild(n),t.parentNode&&t.parentNode.replaceChild(n,t)}dispose(){super.dispose(),Zt().dispose(this.upper.el),delete this.upper,delete this.container}}class wl extends ji{constructor(){super(...arguments),_(this,"targets",[]),_(this,"_hoveredTargets",[]),_(this,"_currentTransform",null),_(this,"_groupSelector",null),_(this,"contextTopDirty",!1)}static getDefaults(){return E(E({},super.getDefaults()),wl.ownDefaults)}get upperCanvasEl(){var e;return(e=this.elements.upper)===null||e===void 0?void 0:e.el}get contextTop(){var e;return(e=this.elements.upper)===null||e===void 0?void 0:e.ctx}get wrapperEl(){return this.elements.container}initElements(e){this.elements=new x_(e,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(e){this._objectsToRender=void 0,super._onObjectAdded(e)}_onObjectRemoved(e){this._objectsToRender=void 0,e===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[e]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[e]}),e.fire("deselected",{target:e})),e===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(e)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const e=this._activeObject;return!this.preserveObjectStacking&&e?this._objects.filter(t=>!t.group&&t!==e).concat(e):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(e){e.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(e),this.contextTopDirty=!0),e.restore()}renderTop(){const e=this.contextTop;this.clearContext(e),this.renderTopLayer(e),this.fire("after:render",{ctx:e})}setTargetFindTolerance(e){e=Math.round(e),this.targetFindTolerance=e;const t=this.getRetinaScaling(),n=Math.ceil((2*e+1)*t);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=n,this.pixelFindContext.scale(t,t)}isTargetTransparent(e,t,n){const s=this.targetFindTolerance,i=this.pixelFindContext;this.clearContext(i),i.save(),i.translate(-t+s,-n+s),i.transform(...this.viewportTransform);const o=e.selectionBackgroundColor;e.selectionBackgroundColor="",e.render(i),e.selectionBackgroundColor=o,i.restore();const a=Math.round(s*this.getRetinaScaling());return _b(i,a,a,a)}_isSelectionKeyPressed(e){const t=this.selectionKey;return!!t&&(Array.isArray(t)?!!t.find(n=>!!n&&e[n]===!0):e[t])}_shouldClearSelection(e,t){const n=this.getActiveObjects(),s=this._activeObject;return!!(!t||t&&s&&n.length>1&&n.indexOf(t)===-1&&s!==t&&!this._isSelectionKeyPressed(e)||t&&!t.evented||t&&!t.selectable&&s&&s!==t)}_shouldCenterTransform(e,t,n){if(!e)return;let s;return t===fl||t===it||t===Tt||t===yi?s=this.centeredScaling||e.centeredScaling:t===Mh&&(s=this.centeredRotation||e.centeredRotation),s?!n:n}_getOriginFromCorner(e,t){const n={x:e.originX,y:e.originY};return t&&(["ml","tl","bl"].includes(t)?n.x=xe:["mr","tr","br"].includes(t)&&(n.x=se),["tl","mt","tr"].includes(t)?n.y=vu:["bl","mb","br"].includes(t)&&(n.y=rt)),n}_setupCurrentTransform(e,t,n){var s;const i=t.group?rs(this.getScenePoint(e),void 0,t.group.calcTransformMatrix()):this.getScenePoint(e),{key:o="",control:a}=t.getActiveControl()||{},l=n&&a?(s=a.getActionHandler(e,t,a))===null||s===void 0?void 0:s.bind(a):BS,c=((f,m,v,x)=>{if(!m||!f)return"drag";const g=x.controls[m];return g.getActionName(v,g,x)})(n,o,e,t),u=e[this.centeredKey],h=this._shouldCenterTransform(t,c,u)?{x:J,y:J}:this._getOriginFromCorner(t,o),d={target:t,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,offsetX:i.x-t.left,offsetY:i.y-t.top,originX:h.x,originY:h.y,ex:i.x,ey:i.y,lastX:i.x,lastY:i.y,theta:be(t.angle),width:t.width,height:t.height,shiftKey:e.shiftKey,altKey:u,original:E(E({},kv(t)),{},{originX:h.x,originY:h.y})};this._currentTransform=d,this.fire("before:transform",{e,transform:d})}setCursor(e){this.upperCanvasEl.style.cursor=e}_drawSelection(e){const{x:t,y:n,deltaX:s,deltaY:i}=this._groupSelector,o=new M(t,n).transform(this.viewportTransform),a=new M(t+s,n+i).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),u=Math.min(o.y,a.y),h=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(e.fillStyle=this.selectionColor,e.fillRect(c,u,h-c,d-u)),this.selectionLineWidth&&this.selectionBorderColor&&(e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor,c+=l,u+=l,h-=l,d-=l,Be.prototype._setLineDash.call(this,e,this.selectionDashArray),e.strokeRect(c,u,h-c,d-u))}findTarget(e){if(this.skipTargetFind)return;const t=this.getViewportPoint(e),n=this._activeObject,s=this.getActiveObjects();if(this.targets=[],n&&s.length>=1){if(n.findControl(t,xu(e))||s.length>1&&this.searchPossibleTargets([n],t))return n;if(n===this.searchPossibleTargets([n],t)){if(this.preserveObjectStacking){const i=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,t);return e[this.altSelectionKey]&&o&&o!==n?(this.targets=i,n):o}return n}}return this.searchPossibleTargets(this._objects,t)}_pointIsInObjectSelectionArea(e,t){let n=e.getCoords();const s=this.getZoom(),i=e.padding/s;if(i){const[o,a,l,c]=n,u=Math.atan2(a.y-o.y,a.x-o.x),h=Sr(u)*i,d=br(u)*i,f=h+d,m=h-d;n=[new M(o.x-m,o.y-f),new M(a.x+f,a.y-m),new M(l.x+m,l.y+f),new M(c.x-f,c.y+m)]}return ge.isPointInPolygon(t,n)}_checkTarget(e,t){return!!(e&&e.visible&&e.evented&&this._pointIsInObjectSelectionArea(e,rs(t,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing||!this.isTargetTransparent(e,t.x,t.y)))}_searchPossibleTargets(e,t){let n=e.length;for(;n--;){const s=e[n];if(this._checkTarget(s,t)){if(Uo(s)&&s.subTargetCheck){const i=this._searchPossibleTargets(s._objects,t);i&&this.targets.push(i)}return s}}}searchPossibleTargets(e,t){const n=this._searchPossibleTargets(e,t);if(n&&Uo(n)&&n.interactive&&this.targets[0]){const s=this.targets;for(let i=s.length-1;i>0;i--){const o=s[i];if(!Uo(o)||!o.interactive)return o}return s[0]}return n}getViewportPoint(e){return this._pointer?this._pointer:this.getPointer(e,!0)}getScenePoint(e){return this._absolutePointer?this._absolutePointer:this.getPointer(e)}getPointer(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const n=this.upperCanvasEl,s=n.getBoundingClientRect();let i=jS(e),o=s.width||0,a=s.height||0;o&&a||(rt in s&&vu in s&&(a=Math.abs(s.top-s.bottom)),xe in s&&se in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),i.x=i.x-this._offset.left,i.y=i.y-this._offset.top,t||(i=rs(i,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(i.x/=l,i.y/=l);const c=o===0||a===0?new M(1,1):new M(n.width/o,n.height/a);return i.multiply(c)}_setDimensionsImpl(e,t){this._resetTransformEventData(),super._setDimensionsImpl(e,t),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=_r(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const e=this._activeObject;return an(e)?e.getObjects():e?[e]:[]}_fireSelectionEvents(e,t){let n=!1,s=!1;const i=this.getActiveObjects(),o=[],a=[];e.forEach(l=>{i.includes(l)||(n=!0,l.fire("deselected",{e:t,target:l}),a.push(l))}),i.forEach(l=>{e.includes(l)||(n=!0,l.fire("selected",{e:t,target:l}),o.push(l))}),e.length>0&&i.length>0?(s=!0,n&&this.fire("selection:updated",{e:t,selected:o,deselected:a})):i.length>0?(s=!0,this.fire("selection:created",{e:t,selected:o})):e.length>0&&(s=!0,this.fire("selection:cleared",{e:t,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(e,t){const n=this.getActiveObjects(),s=this._setActiveObject(e,t);return this._fireSelectionEvents(n,t),s}_setActiveObject(e,t){const n=this._activeObject;return n!==e&&!(!this._discardActiveObject(t,e)&&this._activeObject)&&!e.onSelect({e:t})&&(this._activeObject=e,an(e)&&n!==e&&e.set("canvas",this),e.setCoords(),!0)}_discardActiveObject(e,t){const n=this._activeObject;return!!n&&!n.onDeselect({e,object:t})&&(this._currentTransform&&this._currentTransform.target===n&&this.endCurrentTransform(e),an(n)&&n===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(e){const t=this.getActiveObjects(),n=this.getActiveObject();t.length&&this.fire("before:selection:cleared",{e,deselected:[n]});const s=this._discardActiveObject(e);return this._fireSelectionEvents(t,e),s}endCurrentTransform(e){const t=this._currentTransform;this._finalizeCurrentTransform(e),t&&t.target&&(t.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(e){const t=this._currentTransform,n=t.target,s={e,target:n,transform:t,action:t.action};n._scaling&&(n._scaling=!1),n.setCoords(),t.actionPerformed&&(this.fire("object:modified",s),n.fire(Pa,s))}setViewportTransform(e){super.setViewportTransform(e);const t=this._activeObject;t&&t.setCoords()}destroy(){const e=this._activeObject;an(e)&&(e.removeAll(),e.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(e){const t=this._activeObject;t&&t._renderControls(e)}_toObject(e,t,n){const s=this._realizeGroupTransformOnObject(e),i=super._toObject(e,t,n);return e.set(s),i}_realizeGroupTransformOnObject(e){const{group:t}=e;if(t&&an(t)&&this._activeObject===t){const n=Ss(e,["angle","flipX","flipY",se,it,Tt,ys,xs,rt]);return AS(e,t.calcOwnMatrix()),n}return{}}_setSVGObject(e,t,n){const s=this._realizeGroupTransformOnObject(t);super._setSVGObject(e,t,n),t.set(s)}}_(wl,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class w_{constructor(e){_(this,"targets",[]),_(this,"__disposer",void 0);const t=()=>{const{hiddenTextarea:s}=e.getActiveObject()||{};s&&s.focus()},n=e.upperCanvasEl;n.addEventListener("click",t),this.__disposer=()=>n.removeEventListener("click",t)}exitTextEditing(){this.target=void 0,this.targets.forEach(e=>{e.isEditing&&e.exitEditing()})}add(e){this.targets.push(e)}remove(e){this.unregister(e),Rn(this.targets,e)}register(e){this.target=e}unregister(e){e===this.target&&(this.target=void 0)}onMouseMove(e){var t;!((t=this.target)===null||t===void 0)&&t.isEditing&&this.target.updateSelectionOnMouseMove(e)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const S_=["target","oldTarget","fireCanvas","e"],at={passive:!1},Mn=(r,e)=>{const t=r.getViewportPoint(e),n=r.getScenePoint(e);return{viewportPoint:t,scenePoint:n,pointer:t,absolutePointer:n}},Pr=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return r.addEventListener(...t)},pt=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return r.removeEventListener(...t)},b_={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class Eu extends wl{constructor(e){super(e,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),_(this,"_isClick",void 0),_(this,"textEditingManager",new w_(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(Pr,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(e,t){const n=this.upperCanvasEl,s=this._getEventPrefix();e(_v(n),"resize",this._onResize),e(n,s+"down",this._onMouseDown),e(n,"".concat(s,"move"),this._onMouseMove,at),e(n,"".concat(s,"out"),this._onMouseOut),e(n,"".concat(s,"enter"),this._onMouseEnter),e(n,"wheel",this._onMouseWheel,{passive:!1}),e(n,"contextmenu",this._onContextMenu),e(n,"click",this._onClick),e(n,"dblclick",this._onClick),e(n,"dragstart",this._onDragStart),e(n,"dragend",this._onDragEnd),e(n,"dragover",this._onDragOver),e(n,"dragenter",this._onDragEnter),e(n,"dragleave",this._onDragLeave),e(n,"drop",this._onDrop),this.enablePointerEvents||e(n,"touchstart",this._onTouchStart,at)}removeListeners(){this.addOrRemove(pt,"remove");const e=this._getEventPrefix(),t=Lt(this.upperCanvasEl);pt(t,"".concat(e,"up"),this._onMouseUp),pt(t,"touchend",this._onTouchEnd,at),pt(t,"".concat(e,"move"),this._onMouseMove,at),pt(t,"touchmove",this._onMouseMove,at),clearTimeout(this._willAddMouseDown)}_onMouseWheel(e){this.__onMouseWheel(e)}_onMouseOut(e){const t=this._hoveredTarget,n=E({e},Mn(this,e));this.fire("mouse:out",E(E({},n),{},{target:t})),this._hoveredTarget=void 0,t&&t.fire("mouseout",E({},n)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",E(E({},n),{},{target:s})),s&&s.fire("mouseout",E({},n))}),this._hoveredTargets=[]}_onMouseEnter(e){this._currentTransform||this.findTarget(e)||(this.fire("mouse:over",E({e},Mn(this,e))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(e){this._isClick=!1;const t=this.getActiveObject();if(t&&t.onDragStart(e)){this._dragSource=t;const n={e,target:t};return this.fire("dragstart",n),t.fire("dragstart",n),void Pr(this.upperCanvasEl,"drag",this._onDragProgress)}Bf(e)}_renderDragEffects(e,t,n){let s=!1;const i=this._dropTarget;i&&i!==t&&i!==n&&(i.clearContextTop(),s=!0),t==null||t.clearContextTop(),n!==t&&(n==null||n.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),t&&(o.save(),t.transform(o),t.renderDragSourceEffect(e),o.restore(),s=!0),n&&(o.save(),n.transform(o),n.renderDropTargetEffect(e),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(e){const t=!!e.dataTransfer&&e.dataTransfer.dropEffect!==nt,n=t?this._activeObject:void 0,s={e,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:t,dropTarget:n};pt(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(e)}_onDragProgress(e){const t={e,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",t),this._dragSource&&this._dragSource.fire("drag",t)}findDragTargets(e){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(e)),targets:[...this.targets]}}_onDragOver(e){const t="dragover",{target:n,targets:s}=this.findDragTargets(e),i=this._dragSource,o={e,target:n,subTargets:s,dragSource:i,canDrop:!1,dropTarget:void 0};let a;this.fire(t,o),this._fireEnterLeaveEvents(n,o),n&&(n.canDrop(e)&&(a=n),n.fire(t,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(e)&&(a=c),c.fire(t,o)}this._renderDragEffects(e,i,a),this._dropTarget=a}_onDragEnter(e){const{target:t,targets:n}=this.findDragTargets(e),s={e,target:t,subTargets:n,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(t,s)}_onDragLeave(e){const t={e,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",t),this._fireEnterLeaveEvents(void 0,t),this._renderDragEffects(e,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(e){const{target:t,targets:n}=this.findDragTargets(e),s=this._basicEventHandler("drop:before",E({e,target:t,subTargets:n,dragSource:this._dragSource},Mn(this,e)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(e){const t=this.findTarget(e),n=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e,target:t,subTargets:n});return this.stopContextMenu&&Bf(e),this._basicEventHandler("contextmenu",s),!1}_onClick(e){const t=e.detail;t>3||t<2||(this._cacheTransformEventData(e),t==2&&e.type==="dblclick"&&this._handleEvent(e,"dblclick"),t==3&&this._handleEvent(e,"tripleclick"),this._resetTransformEventData())}getPointerId(e){const t=e.changedTouches;return t?t[0]&&t[0].identifier:this.enablePointerEvents?e.pointerId:-1}_isMainEvent(e){return e.isPrimary===!0||e.isPrimary!==!1&&(e.type==="touchend"&&e.touches.length===0||!e.changedTouches||e.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(e){let t=!this.allowTouchScrolling;const n=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(e)),this.__onMouseDown(e),(this.isDrawingMode||n&&this._target===n)&&(t=!0),t&&e.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,i=this._getEventPrefix(),o=Lt(s);Pr(o,"touchend",this._onTouchEnd,at),t&&Pr(o,"touchmove",this._onMouseMove,at),pt(s,"".concat(i,"down"),this._onMouseDown)}_onMouseDown(e){this.__onMouseDown(e),this._resetTransformEventData();const t=this.upperCanvasEl,n=this._getEventPrefix();pt(t,"".concat(n,"move"),this._onMouseMove,at);const s=Lt(t);Pr(s,"".concat(n,"up"),this._onMouseUp),Pr(s,"".concat(n,"move"),this._onMouseMove,at)}_onTouchEnd(e){if(e.touches.length>0)return;this.__onMouseUp(e),this._resetTransformEventData(),delete this.mainTouchId;const t=this._getEventPrefix(),n=Lt(this.upperCanvasEl);pt(n,"touchend",this._onTouchEnd,at),pt(n,"touchmove",this._onMouseMove,at),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{Pr(this.upperCanvasEl,"".concat(t,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(e){this.__onMouseUp(e),this._resetTransformEventData();const t=this.upperCanvasEl,n=this._getEventPrefix();if(this._isMainEvent(e)){const s=Lt(this.upperCanvasEl);pt(s,"".concat(n,"up"),this._onMouseUp),pt(s,"".concat(n,"move"),this._onMouseMove,at),Pr(t,"".concat(n,"move"),this._onMouseMove,at)}}_onMouseMove(e){const t=this.getActiveObject();!this.allowTouchScrolling&&(!t||!t.shouldStartDragging(e))&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(e){const t=this.getActiveObject();return!!t!=!!e||t&&e&&t!==e}__onMouseUp(e){var t;this._cacheTransformEventData(e),this._handleEvent(e,"up:before");const n=this._currentTransform,s=this._isClick,i=this._target,{button:o}=e;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(e,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(e);if(!this._isMainEvent(e))return;let a,l,c=!1;if(n&&(this._finalizeCurrentTransform(e),c=n.actionPerformed),!s){const u=i===this._activeObject;this.handleSelection(e),c||(c=this._shouldRender(i)||!u&&i===this._activeObject)}if(i){const u=i.findControl(this.getViewportPoint(e),xu(e)),{key:h,control:d}=u||{};if(l=h,i.selectable&&i!==this._activeObject&&i.activeOn==="up")this.setActiveObject(i,e),c=!0;else if(d){const f=d.getMouseUpHandler(e,i,d);f&&(a=this.getScenePoint(e),f.call(d,e,n,a.x,a.y))}i.isMoving=!1}if(n&&(n.target!==i||n.corner!==l)){const u=n.target&&n.target.controls[n.corner],h=u&&u.getMouseUpHandler(e,n.target,u);a=a||this.getScenePoint(e),h&&h.call(u,e,n,a.x,a.y)}this._setCursorFromEvent(e,i),this._handleEvent(e,"up"),this._groupSelector=null,this._currentTransform=null,i&&(i.__corner=void 0),c?this.requestRenderAll():s||(t=this._activeObject)!==null&&t!==void 0&&t.isEditing||this.renderTop()}_basicEventHandler(e,t){const{target:n,subTargets:s=[]}=t;this.fire(e,t),n&&n.fire(e,t);for(let i=0;i<s.length;i++)s[i]!==n&&s[i].fire(e,t);return t}_handleEvent(e,t,n){const s=this._target,i=this.targets||[],o=E(E(E({e,target:s,subTargets:i},Mn(this,e)),{},{transform:this._currentTransform},t==="up:before"||t==="up"?{isClick:this._isClick,currentTarget:this.findTarget(e),currentSubTargets:this.targets}:{}),t==="down:before"||t==="down"?n:{});this.fire("mouse:".concat(t),o),s&&s.fire("mouse".concat(t),o);for(let a=0;a<i.length;a++)i[a]!==s&&i[a].fire("mouse".concat(t),o)}_onMouseDownInDrawingMode(e){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(e),this.requestRenderAll());const t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(t,{e,pointer:t}),this._handleEvent(e,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(e){if(this._isCurrentlyDrawing){const t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(t,{e,pointer:t})}this.setCursor(this.freeDrawingCursor),this._handleEvent(e,"move")}_onMouseUpInDrawingMode(e){const t=this.getScenePoint(e);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e,pointer:t}):this._isCurrentlyDrawing=!1,this._handleEvent(e,"up")}__onMouseDown(e){this._isClick=!0,this._cacheTransformEventData(e),this._handleEvent(e,"down:before");let t=this._target,n=!!t&&t===this._activeObject;const{button:s}=e;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(e,"down",{alreadySelected:n}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(e);if(!this._isMainEvent(e)||this._currentTransform)return;let i=this._shouldRender(t),o=!1;if(this.handleMultiSelection(e,t)?(t=this._activeObject,o=!0,i=!0):this._shouldClearSelection(e,t)&&this.discardActiveObject(e),this.selection&&(!t||!t.selectable&&!t.isEditing&&t!==this._activeObject)){const a=this.getScenePoint(e);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(n=!!t&&t===this._activeObject,t){t.selectable&&t.activeOn==="down"&&this.setActiveObject(t,e);const a=t.findControl(this.getViewportPoint(e),xu(e));if(t===this._activeObject&&(a||!o)){this._setupCurrentTransform(e,t,n);const l=a?a.control:void 0,c=this.getScenePoint(e),u=l&&l.getMouseDownHandler(e,t,l);u&&u.call(l,e,this._currentTransform,c.x,c.y)}}i&&(this._objectsToRender=void 0),this._handleEvent(e,"down",{alreadySelected:n}),i&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(e){this._resetTransformEventData(),this._pointer=this.getViewportPoint(e),this._absolutePointer=rs(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(e)}__onMouseMove(e){if(this._isClick=!1,this._cacheTransformEventData(e),this._handleEvent(e,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(e);if(!this._isMainEvent(e))return;const t=this._groupSelector;if(t){const n=this.getScenePoint(e);t.deltaX=n.x-t.x,t.deltaY=n.y-t.y,this.renderTop()}else if(this._currentTransform)this._transformObject(e);else{const n=this.findTarget(e);this._setCursorFromEvent(e,n),this._fireOverOutEvents(e,n)}this.textEditingManager.onMouseMove(e),this._handleEvent(e,"move"),this._resetTransformEventData()}_fireOverOutEvents(e,t){const n=this._hoveredTarget,s=this._hoveredTargets,i=this.targets,o=Math.max(s.length,i.length);this.fireSyntheticInOutEvents("mouse",{e,target:t,oldTarget:n,fireCanvas:!0});for(let a=0;a<o;a++)i[a]===t||s[a]&&s[a]===n||this.fireSyntheticInOutEvents("mouse",{e,target:i[a],oldTarget:s[a]});this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(e,t){const n=this._draggedoverTarget,s=this._hoveredTargets,i=this.targets,o=Math.max(s.length,i.length);this.fireSyntheticInOutEvents("drag",E(E({},t),{},{target:e,oldTarget:n,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",E(E({},t),{},{target:i[a],oldTarget:s[a]}));this._draggedoverTarget=e}fireSyntheticInOutEvents(e,t){let{target:n,oldTarget:s,fireCanvas:i,e:o}=t,a=de(t,S_);const{targetIn:l,targetOut:c,canvasIn:u,canvasOut:h}=b_[e],d=s!==n;if(s&&d){const f=E(E({},a),{},{e:o,target:s,nextTarget:n},Mn(this,o));i&&this.fire(h,f),s.fire(c,f)}if(n&&d){const f=E(E({},a),{},{e:o,target:n,previousTarget:s},Mn(this,o));i&&this.fire(u,f),n.fire(l,f)}}__onMouseWheel(e){this._cacheTransformEventData(e),this._handleEvent(e,"wheel"),this._resetTransformEventData()}_transformObject(e){const t=this.getScenePoint(e),n=this._currentTransform,s=n.target,i=s.group?rs(t,void 0,s.group.calcTransformMatrix()):t;n.shiftKey=e.shiftKey,n.altKey=!!this.centeredKey&&e[this.centeredKey],this._performTransformAction(e,n,i),n.actionPerformed&&this.requestRenderAll()}_performTransformAction(e,t,n){const{action:s,actionHandler:i,target:o}=t,a=!!i&&i(e,t,n.x,n.y);a&&o.setCoords(),s==="drag"&&a&&(t.target.isMoving=!0,this.setCursor(t.target.moveCursor||this.moveCursor)),t.actionPerformed=t.actionPerformed||a}_setCursorFromEvent(e,t){if(!t)return void this.setCursor(this.defaultCursor);let n=t.hoverCursor||this.hoverCursor;const s=an(this._activeObject)?this._activeObject:null,i=(!s||t.group!==s)&&t.findControl(this.getViewportPoint(e));if(i){const o=i.control;this.setCursor(o.cursorStyleHandler(e,o,t))}else t.subTargetCheck&&this.targets.concat().reverse().map(o=>{n=o.hoverCursor||n}),this.setCursor(n)}handleMultiSelection(e,t){const n=this._activeObject,s=an(n);if(n&&this._isSelectionKeyPressed(e)&&this.selection&&t&&t.selectable&&(n!==t||s)&&(s||!t.isDescendantOf(n)&&!n.isDescendantOf(t))&&!t.onSelect({e})&&!n.getActiveControl()){if(s){const i=n.getObjects();if(t===n){const o=this.getViewportPoint(e);if(!(t=this.searchPossibleTargets(i,o)||this.searchPossibleTargets(this._objects,o))||!t.selectable)return!1}t.group===n?(n.remove(t),this._hoveredTarget=t,this._hoveredTargets=[...this.targets],n.size()===1&&this._setActiveObject(n.item(0),e)):(n.multiSelectAdd(t),this._hoveredTarget=n,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(i,e)}else{n.isEditing&&n.exitEditing();const i=new(V.getClass("ActiveSelection"))([],{canvas:this});i.multiSelectAdd(n,t),this._hoveredTarget=i,this._setActiveObject(i,e),this._fireSelectionEvents([n],e)}return!0}return!1}handleSelection(e){if(!this.selection||!this._groupSelector)return!1;const{x:t,y:n,deltaX:s,deltaY:i}=this._groupSelector,o=new M(t,n),a=o.add(new M(s,i)),l=o.min(a),c=o.max(a).subtract(l),u=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),h=o.eq(a)?u[0]?[u[0]]:[]:u.length>1?u.filter(d=>!d.onSelect({e})).reverse():u;if(h.length===1)this.setActiveObject(h[0],e);else if(h.length>1){const d=V.getClass("ActiveSelection");this.setActiveObject(new d(h,{canvas:this}),e)}return this._groupSelector=null,!0}toCanvasElement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;const{upper:n}=this.elements;n.ctx=void 0;const s=super.toCanvasElement(e,t);return n.ctx=n.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const ty={x1:0,y1:0,x2:0,y2:0},__=E(E({},ty),{},{r1:0,r2:0}),Yn=(r,e)=>isNaN(r)&&typeof e=="number"?e:r;function ry(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function ny(r,e){const t=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(ry(r)?100:1):NaN;return ds(0,Yn(t,e),1)}const C_=/\s*;\s*/,T_=/\s*:\s*/;function k_(r,e){let t,n;const s=r.getAttribute("style");if(s){const o=s.split(C_);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(T_).map(u=>u.trim());l==="stop-color"?t=c:l==="stop-opacity"&&(n=c)}}const i=new ne(t||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:ny(r.getAttribute("offset"),0),color:i.toRgb(),opacity:Yn(parseFloat(n||r.getAttribute("stop-opacity")||""),1)*i.getAlpha()*e}}function E_(r,e){const t=[],n=r.getElementsByTagName("stop"),s=ny(e,1);for(let i=n.length;i--;)t.push(k_(n[i],s));return t}function sy(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function iy(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ot(r,e){return r.getAttribute(e)}function O_(r,e){return function(t,n){let s,{width:i,height:o,gradientUnits:a}=n;return Object.entries(t).reduce((l,c)=>{let[u,h]=c;if(h==="Infinity")s=1;else if(h==="-Infinity")s=0;else{const d=typeof h=="string";s=d?parseFloat(h):h,d&&ry(h)&&(s*=.01,a==="pixels"&&(u!=="x1"&&u!=="x2"&&u!=="r2"||(s*=i),u!=="y1"&&u!=="y2"||(s*=o)))}return l[u]=s,l},{})}(sy(r)==="linear"?function(t){return{x1:Ot(t,"x1")||0,y1:Ot(t,"y1")||0,x2:Ot(t,"x2")||"100%",y2:Ot(t,"y2")||0}}(r):function(t){return{x1:Ot(t,"fx")||Ot(t,"cx")||"50%",y1:Ot(t,"fy")||Ot(t,"cy")||"50%",r1:0,x2:Ot(t,"cx")||"50%",y2:Ot(t,"cy")||"50%",r2:Ot(t,"r")||"50%"}}(r),E(E({},e),{},{gradientUnits:iy(r)}))}class so{constructor(e){const{type:t="linear",gradientUnits:n="pixels",coords:s={},colorStops:i=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=e||{};Object.assign(this,{type:t,gradientUnits:n,coords:E(E({},t==="radial"?__:ty),s),colorStops:i,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Jr()):Jr()})}addColorStop(e){for(const t in e){const n=new ne(e[t]);this.colorStops.push({offset:parseFloat(t),color:n.toRgb(),opacity:n.getAlpha()})}return this}toObject(e){return E(E({},Ss(this,e)),{},{type:this.type,coords:E({},this.coords),colorStops:this.colorStops.map(t=>E({},t)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(e){let{additionalTransform:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[],s=this.gradientTransform?this.gradientTransform.concat():Xe.concat(),i=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(h=>E({},h)).sort((h,d)=>h.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;i==="objectBoundingBox"?(a/=e.width,l/=e.height):(a+=e.width/2,l+=e.height/2),(c=e)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=e.pathOffset.x,l-=e.pathOffset.y),s[4]-=a,s[5]-=l;const u=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(i,'"'),'gradientTransform="'.concat(t?t+" ":"").concat(wi(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:h,y1:d,x2:f,y2:m}=this.coords;n.push("<linearGradient ",u,' x1="',h,'" y1="',d,'" x2="',f,'" y2="',m,`">
84
- `)}else if(this.type==="radial"){const{x1:h,y1:d,x2:f,y2:m,r1:v,r2:x}=this.coords,g=v>x;n.push("<radialGradient ",u,' cx="',g?h:f,'" cy="',g?d:m,'" r="',g?v:x,'" fx="',g?f:h,'" fy="',g?m:d,`">
85
- `),g&&(o.reverse(),o.forEach(y=>{y.offset=1-y.offset}));const p=Math.min(v,x);if(p>0){const y=p/Math.max(v,x);o.forEach(b=>{b.offset+=y*(1-b.offset)})}}return o.forEach(h=>{let{color:d,offset:f,opacity:m}=h;n.push("<stop ",'offset="',100*f+"%",'" style="stop-color:',d,m!==void 0?";stop-opacity: "+m:";",`"/>
86
- `)}),n.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
87
- `),n.join("")}toLive(e){const{x1:t,y1:n,x2:s,y2:i,r1:o,r2:a}=this.coords,l=this.type==="linear"?e.createLinearGradient(t,n,s,i):e.createRadialGradient(t,n,o,s,i,a);return this.colorStops.forEach(c=>{let{color:u,opacity:h,offset:d}=c;l.addColorStop(d,h!==void 0?new ne(u).setAlpha(h).toRgba():u)}),l}static async fromObject(e){const{colorStops:t,gradientTransform:n}=e;return new this(E(E({},e),{},{colorStops:t?t.map(s=>E({},s)):void 0,gradientTransform:n?[...n]:void 0}))}static fromElement(e,t,n){const s=iy(e),i=t._findCenterFromElement();return new this(E({id:e.getAttribute("id")||void 0,type:sy(e),coords:O_(e,{width:n.viewBoxWidth||n.width,height:n.viewBoxHeight||n.height}),colorStops:E_(e,n.opacity),gradientUnits:s,gradientTransform:_u(e.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:t.width/2-i.x,offsetY:t.height/2-i.y}:{offsetX:0,offsetY:0}))}}_(so,"type","Gradient"),V.setClass(so,"gradient"),V.setClass(so,"linear"),V.setClass(so,"radial");const D_=["type","source","patternTransform"];class cc{get type(){return"pattern"}set type(e){Qr("warn","Setting type has no effect",e)}constructor(e){_(this,"repeat","repeat"),_(this,"offsetX",0),_(this,"offsetY",0),_(this,"crossOrigin",""),this.id=Jr(),Object.assign(this,e)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(e){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?e.createPattern(this.source,this.repeat):null}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:t,crossOrigin:n}=this;return E(E({},Ss(this,e)),{},{type:"pattern",source:this.sourceToString(),repeat:t,crossOrigin:n,offsetX:le(this.offsetX,re.NUM_FRACTION_DIGITS),offsetY:le(this.offsetY,re.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(e){let{width:t,height:n}=e;const{source:s,repeat:i,id:o}=this,a=Yn(this.offsetX/t,0),l=Yn(this.offsetY/n,0),c=i==="repeat-y"||i==="no-repeat"?1+Math.abs(a||0):Yn(s.width/t,0),u=i==="repeat-x"||i==="no-repeat"?1+Math.abs(l||0):Yn(s.height/n,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(u,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
88
- `)}static async fromObject(e,t){let{type:n,source:s,patternTransform:i}=e,o=de(e,D_);const a=await Go(s,E(E({},t),{},{crossOrigin:o.crossOrigin}));return new this(E(E({},o),{},{patternTransform:i&&i.slice(0),source:a}))}}_(cc,"type","Pattern"),V.setClass(cc),V.setClass(cc,"pattern");class P_{constructor(e){_(this,"color","rgb(0, 0, 0)"),_(this,"width",1),_(this,"shadow",null),_(this,"strokeLineCap","round"),_(this,"strokeLineJoin","round"),_(this,"strokeMiterLimit",10),_(this,"strokeDashArray",null),_(this,"limitedToCanvasSize",!1),this.canvas=e}_setBrushStyles(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeDashArray||[])}_saveAndTransform(e){const t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new ne(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const e=this.canvas,t=this.shadow,n=e.contextTop,s=e.getZoom()*e.getRetinaScaling();n.shadowColor=t.color,n.shadowBlur=t.blur*s,n.shadowOffsetX=t.offsetX*s,n.shadowOffsetY=t.offsetY*s}_resetShadow(){const e=this.canvas.contextTop;e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}_isOutSideCanvas(e){return e.x<0||e.x>this.canvas.getWidth()||e.y<0||e.y>this.canvas.getHeight()}}const M_=["path","left","top"],j_=["d"];class Lr extends Be{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:n,left:s,top:i}=t,o=de(t,M_);super(),Object.assign(this,Lr.ownDefaults),this.setOptions(o),this._setPath(e||[],!0),typeof s=="number"&&this.set(se,s),typeof i=="number"&&this.set(rt,i)}_setPath(e,t){this.path=l_(Array.isArray(e)?e:v_(e)),this.setBoundingBox(t)}_findCenterFromElement(){const e=this._calcBoundsFromPath();return new M(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){const t=-this.pathOffset.x,n=-this.pathOffset.y;e.beginPath();for(const s of this.path)switch(s[0]){case"L":e.lineTo(s[1]+t,s[2]+n);break;case"M":e.moveTo(s[1]+t,s[2]+n);break;case"C":e.bezierCurveTo(s[1]+t,s[2]+n,s[3]+t,s[4]+n,s[5]+t,s[6]+n);break;case"Q":e.quadraticCurveTo(s[1]+t,s[2]+n,s[3]+t,s[4]+n);break;case"Z":e.closePath()}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return E(E({},super.toObject(e)),{},{path:this.path.map(t=>t.slice())})}toDatalessObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){const e=ey(this.path,re.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(e,`" stroke-linecap="round" />
89
- `)]}_getOffsetTransform(){const e=re.NUM_FRACTION_DIGITS;return" translate(".concat(le(-this.pathOffset.x,e),", ").concat(le(-this.pathOffset.y,e),")")}toClipPathSVG(e){const t=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){const t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){const{width:t,height:n,pathOffset:s}=this._calcDimensions();this.set({width:t,height:n,pathOffset:s}),e&&this.setPositionByOrigin(s,J,J)}_calcBoundsFromPath(){const e=[];let t=0,n=0,s=0,i=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],i=o[2],e.push({x:t,y:n},{x:s,y:i});break;case"M":s=o[1],i=o[2],t=s,n=i;break;case"C":e.push(...hg(s,i,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],i=o[6];break;case"Q":e.push(...hg(s,i,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],i=o[4];break;case"Z":s=t,i=n}return pr(e)}_calcDimensions(){const e=this._calcBoundsFromPath();return E(E({},e),{},{pathOffset:new M(e.left+e.width/2,e.top+e.height/2)})}static fromObject(e){return this._fromObject(e,{extraParam:"path"})}static async fromElement(e,t,n){const s=Er(e,this.ATTRIBUTE_NAMES,n),{d:i}=s;return new this(i,E(E(E({},de(s,j_)),t),{},{left:void 0,top:void 0}))}}_(Lr,"type","Path"),_(Lr,"cacheProperties",[...kr,"path","fillRule"]),_(Lr,"ATTRIBUTE_NAMES",[...rn,"d"]),V.setClass(Lr),V.setSVGClass(Lr);class za extends P_{constructor(e){super(e),_(this,"decimate",.4),_(this,"drawStraightLine",!1),_(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(e,t,n){const s=t.midPointFrom(n);return e.quadraticCurveTo(t.x,t.y,s.x,s.y),s}onMouseDown(e,t){let{e:n}=t;this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],this._prepareForDrawing(e),this._addPoint(e),this._render())}onMouseMove(e,t){let{e:n}=t;if(this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(e))&&this._addPoint(e)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const s=this._points,i=s.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=za.drawSegment(o,s[i-2],s[i-1]),o.stroke(),o.restore()}}onMouseUp(e){let{e:t}=e;return!this.canvas._isMainEvent(t)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(e){this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)}_addPoint(e){return!(this._points.length>1&&e.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(e),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,t=this._points[0],n=this._points[1];if(this._saveAndTransform(e),e.beginPath(),this._points.length===2&&t.x===n.x&&t.y===n.y){const s=this.width/1e3;t.x-=s,n.x+=s}e.moveTo(t.x,t.y);for(let s=1;s<this._points.length;s++)za.drawSegment(e,t,n),t=this._points[s],n=this._points[s+1];e.lineTo(t.x,t.y),e.stroke(),e.restore()}convertPointsToSVGPath(e){const t=this.width/1e3;return y_(e,t)}createPath(e){const t=new Lr(e,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,t.shadow=new Jt(this.shadow)),t}decimatePoints(e,t){if(e.length<=2)return e;let n,s=e[0];const i=this.canvas.getZoom(),o=Math.pow(t/i,2),a=e.length-1,l=[s];for(let c=1;c<a-1;c++)n=Math.pow(s.x-e[c].x,2)+Math.pow(s.y-e[c].y,2),n>=o&&(s=e[c],l.push(s));return l.push(e[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const e=this.convertPointsToSVGPath(this._points);if(function(n){return ey(n)==="M 0 0 Q 0 0 0 0 L 0 0"}(e))return void this.canvas.requestRenderAll();const t=this.createPath(e);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:t}),this.canvas.add(t),this.canvas.requestRenderAll(),t.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:t})}}const R_=["left","top","radius"],oy=["radius","startAngle","endAngle","counterClockwise"];class $t extends Be{static getDefaults(){return E(E({},super.getDefaults()),$t.ownDefaults)}constructor(e){super(),Object.assign(this,$t.ownDefaults),this.setOptions(e)}_set(e,t){return super._set(e,t),e==="radius"&&this.setRadius(t),this}_render(e){e.beginPath(),e.arc(0,0,this.radius,be(this.startAngle),be(this.endAngle),this.counterClockwise),this._renderPaintInOrder(e)}getRadiusX(){return this.get("radius")*this.get(it)}getRadiusY(){return this.get("radius")*this.get(Tt)}setRadius(e){this.radius=e,this.set({width:2*e,height:2*e})}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...oy,...e])}_toSVG(){const e=(this.endAngle-this.startAngle)%360;if(e===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
90
- `];{const{radius:t}=this,n=be(this.startAngle),s=be(this.endAngle),i=Sr(n)*t,o=br(n)*t,a=Sr(s)*t,l=br(s)*t,c=e>180?1:0,u=this.counterClockwise?0:1;return['<path d="M '.concat(i," ").concat(o," A ").concat(t," ").concat(t," 0 ").concat(c," ").concat(u," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
91
- `]}}static async fromElement(e,t,n){const s=Er(e,this.ATTRIBUTE_NAMES,n),{left:i=0,top:o=0,radius:a=0}=s;return new this(E(E({},de(s,R_)),{},{radius:a,left:i-a,top:o-a}))}static fromObject(e){return super._fromObject(e)}}_($t,"type","Circle"),_($t,"cacheProperties",[...kr,...oy]),_($t,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),_($t,"ATTRIBUTE_NAMES",["cx","cy","r",...rn]),V.setClass($t),V.setSVGClass($t);const A_=["x1","y1","x2","y2"],L_=["x1","y1","x2","y2"],Ou=["x1","x2","y1","y2"];class Yt extends Be{constructor(){let[e,t,n,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Yt.ownDefaults),this.setOptions(i),this.x1=e,this.x2=n,this.y1=t,this.y2=s,this._setWidthHeight();const{left:o,top:a}=i;typeof o=="number"&&this.set(se,o),typeof a=="number"&&this.set(rt,a)}_setWidthHeight(){const{x1:e,y1:t,x2:n,y2:s}=this;this.width=Math.abs(n-e),this.height=Math.abs(s-t);const{left:i,top:o,width:a,height:l}=pr([{x:e,y:t},{x:n,y:s}]),c=new M(i+a/2,o+l/2);this.setPositionByOrigin(c,J,J)}_set(e,t){return super._set(e,t),Ou.includes(e)&&this._setWidthHeight(),this}_render(e){e.beginPath();const t=this.calcLinePoints();e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.lineWidth=this.strokeWidth;const n=e.strokeStyle;var s;xt(this.stroke)?e.strokeStyle=this.stroke.toLive(e):e.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=n}_findCenterFromElement(){return new M((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return E(E({},super.toObject(e)),this.calcLinePoints())}_getNonTransformedDimensions(){const e=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e}calcLinePoints(){const{x1:e,x2:t,y1:n,y2:s,width:i,height:o}=this,a=e<=t?-1:1,l=n<=s?-1:1;return{x1:a*i/2,x2:a*-i/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:e,x2:t,y1:n,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(e,'" y1="').concat(n,'" x2="').concat(t,'" y2="').concat(s,`" />
92
- `)]}static async fromElement(e,t,n){const s=Er(e,this.ATTRIBUTE_NAMES,n),{x1:i=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([i,o,a,l],de(s,A_))}static fromObject(e){let{x1:t,y1:n,x2:s,y2:i}=e,o=de(e,L_);return this._fromObject(E(E({},o),{},{points:[t,n,s,i]}),{extraParam:"points"})}}_(Yt,"type","Line"),_(Yt,"cacheProperties",[...kr,...Ou]),_(Yt,"ATTRIBUTE_NAMES",rn.concat(Ou)),V.setClass(Yt),V.setSVGClass(Yt);class hn extends Be{static getDefaults(){return E(E({},super.getDefaults()),hn.ownDefaults)}constructor(e){super(),Object.assign(this,hn.ownDefaults),this.setOptions(e)}_render(e){const t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderPaintInOrder(e)}_toSVG(){const e=this.width/2,t=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-e," ").concat(t,",0 ").concat(-t,",").concat(e," ").concat(t),'" />']}}_(hn,"type","Triangle"),_(hn,"ownDefaults",{width:100,height:100}),V.setClass(hn),V.setSVGClass(hn);const ay=["rx","ry"];class ar extends Be{static getDefaults(){return E(E({},super.getDefaults()),ar.ownDefaults)}constructor(e){super(),Object.assign(this,ar.ownDefaults),this.setOptions(e)}_set(e,t){switch(super._set(e,t),e){case"rx":this.rx=t,this.set("width",2*t);break;case"ry":this.ry=t,this.set("height",2*t)}return this}getRx(){return this.get("rx")*this.get(it)}getRy(){return this.get("ry")*this.get(Tt)}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ay,...e])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
93
- `)]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,Oa,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,n){const s=Er(e,this.ATTRIBUTE_NAMES,n);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function F_(r){if(!r)return[];const e=r.replace(/,/g," ").trim().split(/\s+/),t=[];for(let n=0;n<e.length;n+=2)t.push({x:parseFloat(e[n]),y:parseFloat(e[n+1])});return t}_(ar,"type","Ellipse"),_(ar,"cacheProperties",[...kr,...ay]),_(ar,"ownDefaults",{rx:0,ry:0}),_(ar,"ATTRIBUTE_NAMES",[...rn,"cx","cy","rx","ry"]),V.setClass(ar),V.setSVGClass(ar);const N_=["left","top"],ly={exactBoundingBox:!1};class jt extends Be{static getDefaults(){return E(E({},super.getDefaults()),jt.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_(this,"strokeDiff",void 0),Object.assign(this,jt.ownDefaults),this.setOptions(t),this.points=e;const{left:n,top:s}=t;this.initialized=!0,this.setBoundingBox(!0),typeof n=="number"&&this.set(se,n),typeof s=="number"&&this.set(rt,s)}isOpen(){return!0}_projectStrokeOnPoints(e){return Tb(this.points,e,this.isOpen())}_calcDimensions(e){e=E({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},e||{});const t=this.exactBoundingBox?this._projectStrokeOnPoints(e).map(c=>c.projectedPoint):this.points;if(t.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new M,strokeOffset:new M,strokeDiff:new M};const n=pr(t),s=gl(E(E({},e),{},{scaleX:1,scaleY:1})),i=pr(this.points.map(c=>qe(c,s,!0))),o=new M(this.scaleX,this.scaleY);let a=n.left+n.width/2,l=n.top+n.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(be(this.skewX)),l-=a*Math.tan(be(this.skewY))),E(E({},n),{},{pathOffset:new M(a,l),strokeOffset:new M(i.left,i.top).subtract(new M(n.left,n.top)).multiply(o),strokeDiff:new M(n.width,n.height).subtract(new M(i.width,i.height)).multiply(o)})}_findCenterFromElement(){const e=pr(this.points);return new M(e.left+e.width/2,e.top+e.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(e){const{left:t,top:n,width:s,height:i,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:i,pathOffset:o,strokeOffset:a,strokeDiff:l}),e&&this.setPositionByOrigin(new M(t+s/2,n+i/2),J,J)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new M(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(e).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var t,n;const{width:a,height:l}=this._calcDimensions(e);o=new M((t=e.width)!==null&&t!==void 0?t:a,(n=e.height)!==null&&n!==void 0?n:l)}else{var s,i;o=new M((s=e.width)!==null&&s!==void 0?s:this.width,(i=e.height)!==null&&i!==void 0?i:this.height)}return o.multiply(new M(e.scaleX||this.scaleX,e.scaleY||this.scaleY))}return super._getTransformedDimensions(e)}_set(e,t){const n=this.initialized&&this[e]!==t,s=super._set(e,t);return this.exactBoundingBox&&n&&((e===it||e===Tt)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(e))&&this.setDimensions(),s}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return E(E({},super.toObject(e)),{},{points:this.points.map(t=>{let{x:n,y:s}=t;return{x:n,y:s}})})}_toSVG(){const e=[],t=this.pathOffset.x,n=this.pathOffset.y,s=re.NUM_FRACTION_DIGITS;for(let i=0,o=this.points.length;i<o;i++)e.push(le(this.points[i].x-t,s),",",le(this.points[i].y-n,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(e.join(""),`" />
94
- `)]}_render(e){const t=this.points.length,n=this.pathOffset.x,s=this.pathOffset.y;if(t&&!isNaN(this.points[t-1].y)){e.beginPath(),e.moveTo(this.points[0].x-n,this.points[0].y-s);for(let i=0;i<t;i++){const o=this.points[i];e.lineTo(o.x-n,o.y-s)}!this.isOpen()&&e.closePath(),this._renderPaintInOrder(e)}}complexity(){return this.points.length}static async fromElement(e,t,n){return new this(F_(e.getAttribute("points")),E(E({},de(Er(e,this.ATTRIBUTE_NAMES,n),N_)),t))}static fromObject(e){return this._fromObject(e,{extraParam:"points"})}}_(jt,"ownDefaults",ly),_(jt,"type","Polyline"),_(jt,"layoutProperties",[ys,xs,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),_(jt,"cacheProperties",[...kr,"points"]),_(jt,"ATTRIBUTE_NAMES",[...rn]),V.setClass(jt),V.setSVGClass(jt);class io extends jt{isOpen(){return!1}}_(io,"ownDefaults",ly),_(io,"type","Polygon"),V.setClass(io),V.setSVGClass(io);class cy extends Be{isEmptyStyles(e){if(!this.styles||e!==void 0&&!this.styles[e])return!0;const t=e===void 0?this.styles:{line:this.styles[e]};for(const n in t)for(const s in t[n])for(const i in t[n][s])return!1;return!0}styleHas(e,t){if(!this.styles||t!==void 0&&!this.styles[t])return!1;const n=t===void 0?this.styles:{0:this.styles[t]};for(const s in n)for(const i in n[s])if(n[s][i][e]!==void 0)return!0;return!1}cleanStyle(e){if(!this.styles)return!1;const t=this.styles;let n,s,i=0,o=!0,a=0;for(const l in t){n=0;for(const c in t[l]){const u=t[l][c]||{};i++,u[e]!==void 0?(s?u[e]!==s&&(o=!1):s=u[e],u[e]===this[e]&&delete u[e]):o=!1,Object.keys(u).length!==0?n++:delete t[l][c]}n===0&&delete t[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&i===a&&(this[e]=s,this.removeStyle(e))}removeStyle(e){if(!this.styles)return;const t=this.styles;let n,s,i;for(s in t){for(i in n=t[s],n)delete n[i][e],Object.keys(n[i]).length===0&&delete n[i];Object.keys(n).length===0&&delete t[s]}}_extendStyles(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e);this._getLineStyle(n)||this._setLineStyle(n);const i=Lh(E(E({},this._getStyleDeclaration(n,s)),t),o=>o!==void 0);this._setStyleDeclaration(n,s,i)}getSelectionStyles(e,t,n){const s=[];for(let i=e;i<(t||e);i++)s.push(this.getStyleAtPosition(i,n));return s}getStyleAtPosition(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e);return t?this.getCompleteStyleDeclaration(n,s):this._getStyleDeclaration(n,s)}setSelectionStyles(e,t,n){for(let s=t;s<(n||t);s++)this._extendStyles(s,e);this._forceClearCache=!0}_getStyleDeclaration(e,t){var n;const s=this.styles&&this.styles[e];return s&&(n=s[t])!==null&&n!==void 0?n:{}}getCompleteStyleDeclaration(e,t){return E(E({},Ss(this,this.constructor._styleProperties)),this._getStyleDeclaration(e,t))}_setStyleDeclaration(e,t,n){this.styles[e][t]=n}_deleteStyleDeclaration(e,t){delete this.styles[e][t]}_getLineStyle(e){return!!this.styles[e]}_setLineStyle(e){this.styles[e]={}}_deleteLineStyle(e){delete this.styles[e]}}_(cy,"_styleProperties",WS);const I_=/ +/g,B_=/"/g;function uc(r,e,t,n,s){return" ".concat(function(i,o){let{left:a,top:l,width:c,height:u}=o,h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:re.NUM_FRACTION_DIGITS;const d=Si(Ee,i,!1),[f,m,v,x]=[a,l,c,u].map(g=>le(g,h));return"<rect ".concat(d,' x="').concat(f,'" y="').concat(m,'" width="').concat(v,'" height="').concat(x,'"></rect>')}(r,{left:e,top:t,width:n,height:s}),`
95
- `)}const z_=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let hc;class Ve extends cy{static getDefaults(){return E(E({},super.getDefaults()),Ve.ownDefaults)}constructor(e,t){super(),_(this,"__charBounds",[]),Object.assign(this,Ve.ownDefaults),this.setOptions(t),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const e=this.path;e&&(e.segmentsInfo=Zv(e.path))}_splitText(){const e=this._splitTextIntoLines(this.text);return this.textLines=e.lines,this._textLines=e.graphemeLines,this._unwrappedTextLines=e._unwrappedLines,this._text=e.graphemeText,e}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Ut)&&this.enlargeSpaces()}enlargeSpaces(){let e,t,n,s,i,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Ut||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,i=this._textLines[l],t=this.getLineWidth(l),t<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){n=a.length,e=(this.width-t)/n;for(let u=0;u<=i.length;u++)o=this.__charBounds[l][u],this._reSpaceAndTab.test(i[u])?(o.width+=e,o.kernedWidth+=e,o.left+=s,s+=e):o.left+=s}}isEndOfWrapping(e){return e===this._textLines.length-1}missingNewlineOffset(e){return 1}get2DCursorLocation(e,t){const n=t?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<n.length;s++){if(e<=n[s].length)return{lineIndex:s,charIndex:e};e-=n[s].length+this.missingNewlineOffset(s,t)}return{lineIndex:s-1,charIndex:n[s-1].length<e?n[s-1].length:e}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const e=super._getCacheCanvasDimensions(),t=this.fontSize;return e.width+=t*e.zoomX,e.height+=t*e.zoomY,e}_render(e){const t=this.path;t&&!t.isNotVisible()&&t._render(e),this._setTextStyles(e),this._renderTextLinesBackground(e),this._renderTextDecoration(e,"underline"),this._renderText(e),this._renderTextDecoration(e,"overline"),this._renderTextDecoration(e,"linethrough")}_renderText(e){this.paintFirst===st?(this._renderTextStroke(e),this._renderTextFill(e)):(this._renderTextFill(e),this._renderTextStroke(e))}_setTextStyles(e,t,n){if(e.textBaseline="alphabetic",this.path)switch(this.pathAlign){case J:e.textBaseline="middle";break;case"ascender":e.textBaseline=rt;break;case"descender":e.textBaseline=vu}e.font=this._getFontDeclaration(t,n)}calcTextWidth(){let e=this.getLineWidth(0);for(let t=1,n=this._textLines.length;t<n;t++){const s=this.getLineWidth(t);s>e&&(e=s)}return e}_renderTextLine(e,t,n,s,i,o){this._renderChars(e,t,n,s,i,o)}_renderTextLinesBackground(e){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const t=e.fillStyle,n=this._getLeftOffset();let s=this._getTopOffset();for(let i=0,o=this._textLines.length;i<o;i++){const a=this.getHeightOfLine(i);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",i)){s+=a;continue}const l=this._textLines[i].length,c=this._getLineLeftOffset(i);let u,h,d=0,f=0,m=this.getValueOfPropertyAt(i,0,"textBackgroundColor");const v=this.getHeightOfLineImpl(i);for(let x=0;x<l;x++){const g=this.__charBounds[i][x];h=this.getValueOfPropertyAt(i,x,"textBackgroundColor"),this.path?(e.save(),e.translate(g.renderLeft,g.renderTop),e.rotate(g.angle),e.fillStyle=h,h&&e.fillRect(-g.width/2,-v*(1-this._fontSizeFraction),g.width,v),e.restore()):h!==m?(u=n+c+f,this.direction==="rtl"&&(u=this.width-u-d),e.fillStyle=m,m&&e.fillRect(u,s,d,v),f=g.left,d=g.width,m=h):d+=g.kernedWidth}h&&!this.path&&(u=n+c+f,this.direction==="rtl"&&(u=this.width-u-d),e.fillStyle=h,e.fillRect(u,s,d,v)),s+=a}e.fillStyle=t,this._removeShadow(e)}_measureChar(e,t,n,s){const i=Ks.getFontCache(t),o=this._getFontDeclaration(t),a=n?n+e:e,l=n&&o===this._getFontDeclaration(s),c=t.fontSize/this.CACHE_FONT_SIZE;let u,h,d,f;if(n&&i.has(n)&&(d=i.get(n)),i.has(e)&&(f=u=i.get(e)),l&&i.has(a)&&(h=i.get(a),f=h-d),u===void 0||d===void 0||h===void 0){const m=function(){return hc||(hc=kt({width:0,height:0}).getContext("2d")),hc}();this._setTextStyles(m,t,!0),u===void 0&&(f=u=m.measureText(e).width,i.set(e,u)),d===void 0&&l&&n&&(d=m.measureText(n).width,i.set(n,d)),l&&h===void 0&&(h=m.measureText(a).width,i.set(a,h),f=h-d)}return{width:u*c,kernedWidth:f*c}}getHeightOfChar(e,t){return this.getValueOfPropertyAt(e,t,"fontSize")}measureLine(e){const t=this._measureLine(e);return this.charSpacing!==0&&(t.width-=this._getWidthOfCharSpacing()),t.width<0&&(t.width=0),t}_measureLine(e){let t,n,s=0;const i=this.pathSide===xe,o=this.path,a=this._textLines[e],l=a.length,c=new Array(l);this.__charBounds[e]=c;for(let u=0;u<l;u++){const h=a[u];n=this._getGraphemeBox(h,e,u,t),c[u]=n,s+=n.kernedWidth,t=h}if(c[l]={left:n?n.left+n.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let u=0;const h=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case se:u=i?h-s:0;break;case J:u=(h-s)/2;break;case xe:u=i?0:h-s}u+=this.pathStartOffset*(i?-1:1);for(let d=i?l-1:0;i?d>=0:d<l;i?d--:d++)n=c[d],u>h?u%=h:u<0&&(u+=h),this._setGraphemeOnPath(u,n),u+=n.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(e,t){const n=e+t.kernedWidth/2,s=this.path,i=f_(s.path,n,s.segmentsInfo);t.renderLeft=i.x-s.pathOffset.x,t.renderTop=i.y-s.pathOffset.y,t.angle=i.angle+(this.pathSide===xe?Math.PI:0)}_getGraphemeBox(e,t,n,s,i){const o=this.getCompleteStyleDeclaration(t,n),a=s?this.getCompleteStyleDeclaration(t,n-1):{},l=this._measureChar(e,o,s,a);let c,u=l.kernedWidth,h=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),h+=c,u+=c);const d={width:h,left:0,height:o.fontSize,kernedWidth:u,deltaY:o.deltaY};if(n>0&&!i){const f=this.__charBounds[t][n-1];d.left=f.left+f.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(e){const t=this.__lineHeights;if(t[e])return t[e];let n=this.getHeightOfChar(e,0);for(let s=1,i=this._textLines[e].length;s<i;s++)n=Math.max(this.getHeightOfChar(e,s),n);return t[e]=n*this._fontSizeMult}getHeightOfLine(e){return this.getHeightOfLineImpl(e)*this.lineHeight}calcTextHeight(){let e=0;for(let t=0,n=this._textLines.length;t<n;t++)e+=t===n-1?this.getHeightOfLineImpl(t):this.getHeightOfLine(t);return e}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(e,t){e.save();let n=0;const s=this._getLeftOffset(),i=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(t,e,this._textLines[o],s+this._getLineLeftOffset(o),i+n+this.getHeightOfLineImpl(o),o),n+=this.getHeightOfLine(o);e.restore()}_renderTextFill(e){(this.fill||this.styleHas(Ee))&&this._renderTextCommon(e,"fillText")}_renderTextStroke(e){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this._setLineDash(e,this.strokeDashArray),e.beginPath(),this._renderTextCommon(e,"strokeText"),e.closePath(),e.restore())}_renderChars(e,t,n,s,i,o){const a=this.textAlign.includes(Ut),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,u=this.direction==="ltr",h=this.direction==="ltr"?1:-1,d=t.direction;let f,m,v,x,g,p="",y=0;if(t.save(),d!==this.direction&&(t.canvas.setAttribute("dir",u?"ltr":"rtl"),t.direction=u?"ltr":"rtl",t.textAlign=u?se:xe),i-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(e,t,o,0,n.join(""),s,i),void t.restore();for(let b=0,O=n.length-1;b<=O;b++)x=b===O||this.charSpacing||l,p+=n[b],v=this.__charBounds[o][b],y===0?(s+=h*(v.kernedWidth-v.width),y+=v.width):y+=v.kernedWidth,a&&!x&&this._reSpaceAndTab.test(n[b])&&(x=!0),x||(f=f||this.getCompleteStyleDeclaration(o,b),m=this.getCompleteStyleDeclaration(o,b+1),x=Hh(f,m,!1)),x&&(l?(t.save(),t.translate(v.renderLeft,v.renderTop),t.rotate(v.angle),this._renderChar(e,t,o,b,p,-y/2,0),t.restore()):(g=s,this._renderChar(e,t,o,b,p,g,i)),p="",f=m,s+=h*y,y=0);t.restore()}_applyPatternGradientTransformText(e){const t=this.width+this.strokeWidth,n=this.height+this.strokeWidth,s=kt({width:t,height:n}),i=s.getContext("2d");return s.width=t,s.height=n,i.beginPath(),i.moveTo(0,0),i.lineTo(t,0),i.lineTo(t,n),i.lineTo(0,n),i.closePath(),i.translate(t/2,n/2),i.fillStyle=e.toLive(i),this._applyPatternGradientTransform(i,e),i.fill(),i.createPattern(s,"no-repeat")}handleFiller(e,t,n){let s,i;return xt(n)?n.gradientUnits==="percentage"||n.gradientTransform||n.patternTransform?(s=-this.width/2,i=-this.height/2,e.translate(s,i),e[t]=this._applyPatternGradientTransformText(n),{offsetX:s,offsetY:i}):(e[t]=n.toLive(e),this._applyPatternGradientTransform(e,n)):(e[t]=n,{offsetX:0,offsetY:0})}_setStrokeStyles(e,t){let{stroke:n,strokeWidth:s}=t;return e.lineWidth=s,e.lineCap=this.strokeLineCap,e.lineDashOffset=this.strokeDashOffset,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,this.handleFiller(e,"strokeStyle",n)}_setFillStyles(e,t){let{fill:n}=t;return this.handleFiller(e,"fillStyle",n)}_renderChar(e,t,n,s,i,o,a){const l=this._getStyleDeclaration(n,s),c=this.getCompleteStyleDeclaration(n,s),u=e==="fillText"&&c.fill,h=e==="strokeText"&&c.stroke&&c.strokeWidth;if(h||u){if(t.save(),t.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(t),l.deltaY&&(a+=l.deltaY),u){const d=this._setFillStyles(t,c);t.fillText(i,o-d.offsetX,a-d.offsetY)}if(h){const d=this._setStrokeStyles(t,c);t.strokeText(i,o-d.offsetX,a-d.offsetY)}t.restore()}}setSuperscript(e,t){this._setScript(e,t,this.superscript)}setSubscript(e,t){this._setScript(e,t,this.subscript)}_setScript(e,t,n){const s=this.get2DCursorLocation(e,!0),i=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:i*n.size,deltaY:o+i*n.baseline};this.setSelectionStyles(a,e,t)}_getLineLeftOffset(e){const t=this.getLineWidth(e),n=this.width-t,s=this.textAlign,i=this.direction,o=this.isEndOfWrapping(e);let a=0;return s===Ut||s===Qs&&!o||s===qs&&!o||s===Fa&&!o?0:(s===J&&(a=n/2),s===xe&&(a=n),s===Qs&&(a=n/2),s===qs&&(a=n),i==="rtl"&&(s===xe||s===Ut||s===qs?a=0:s===se||s===Fa?a=-n:s!==J&&s!==Qs||(a=-n/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(e){if(this.__lineWidths[e]!==void 0)return this.__lineWidths[e];const{width:t}=this.measureLine(e);return this.__lineWidths[e]=t,t}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(e,t,n){var s;return(s=this._getStyleDeclaration(e,t)[n])!==null&&s!==void 0?s:this[n]}_renderTextDecoration(e,t){if(!this[t]&&!this.styleHas(t))return;let n=this._getTopOffset();const s=this._getLeftOffset(),i=this.path,o=this._getWidthOfCharSpacing(),a=t==="linethrough"?.5:t==="overline"?1:0,l=this.offsets[t];for(let c=0,u=this._textLines.length;c<u;c++){const h=this.getHeightOfLine(c);if(!this[t]&&!this.styleHas(t,c)){n+=h;continue}const d=this._textLines[c],f=h/this.lineHeight,m=this._getLineLeftOffset(c);let v=0,x=0,g=this.getValueOfPropertyAt(c,0,t),p=this.getValueOfPropertyAt(c,0,Ee),y=this.getValueOfPropertyAt(c,0,Tn),b=g,O=p,S=y;const T=n+f*(1-this._fontSizeFraction);let C=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let I=0,U=d.length;I<U;I++){const A=this.__charBounds[c][I];b=this.getValueOfPropertyAt(c,I,t),O=this.getValueOfPropertyAt(c,I,Ee),S=this.getValueOfPropertyAt(c,I,Tn);const G=this.getHeightOfChar(c,I),Y=this.getValueOfPropertyAt(c,I,"deltaY");if(i&&b&&O){const W=this.fontSize*S/1e3;e.save(),e.fillStyle=p,e.translate(A.renderLeft,A.renderTop),e.rotate(A.angle),e.fillRect(-A.kernedWidth/2,l*G+Y-a*W,A.kernedWidth,W),e.restore()}else if((b!==g||O!==p||G!==C||S!==y||Y!==P)&&x>0){const W=this.fontSize*y/1e3;let k=s+m+v;this.direction==="rtl"&&(k=this.width-k-x),g&&p&&y&&(e.fillStyle=p,e.fillRect(k,T+l*C+P-a*W,x,W)),v=A.left,x=A.width,g=b,y=S,p=O,C=G,P=Y}else x+=A.kernedWidth}let j=s+m+v;this.direction==="rtl"&&(j=this.width-j-x),e.fillStyle=O;const R=this.fontSize*S/1e3;b&&O&&S&&e.fillRect(j,T+l*C+P-a*R,x-o,R),n+=h}this._removeShadow(e)}_getFontDeclaration(){let{fontFamily:e=this.fontFamily,fontStyle:t=this.fontStyle,fontWeight:n=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;const o=e.includes("'")||e.includes('"')||e.includes(",")||Ve.genericFonts.includes(e.toLowerCase())?e:'"'.concat(e,'"');return[t,n,"".concat(i?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(e)))}graphemeSplit(e){return Vh(e)}_splitTextIntoLines(e){const t=e.split(this._reNewline),n=new Array(t.length),s=[`
96
- `];let i=[];for(let o=0;o<t.length;o++)n[o]=this.graphemeSplit(t[o]),i=i.concat(n[o],s);return i.pop(),{_unwrappedLines:n,lines:t,graphemeText:i,graphemeLines:n}}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return E(E({},super.toObject([...Lv,...e])),{},{styles:Db(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(e,t){const{textLayoutProperties:n}=this.constructor;super.set(e,t);let s=!1,i=!1;if(typeof e=="object")for(const o in e)o==="path"&&this.setPathInfo(),s=s||n.includes(o),i=i||o==="path";else s=n.includes(e),i=e==="path";return i&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(e,t,n){const s=Er(e,Ve.ATTRIBUTE_NAMES,n),i=E(E({},t),s),{textAnchor:o=se,textDecoration:a="",dx:l=0,dy:c=0,top:u=0,left:h=0,fontSize:d=Dh,strokeWidth:f=1}=i,m=de(i,z_),v=new this(La(e.textContent||"").trim(),E({left:h+l,top:u+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},m)),x=v.getScaledHeight()/v.height,g=((v.height+v.strokeWidth)*v.lineHeight-v.height)*x,p=v.getScaledHeight()+g;let y=0;return o===J&&(y=v.getScaledWidth()/2),o===xe&&(y=v.getScaledWidth()),v.set({left:v.left-y,top:v.top-(p-v.fontSize*(.07+v._fontSizeFraction))/v.lineHeight,strokeWidth:f}),v}static fromObject(e){return this._fromObject(E(E({},e),{},{styles:Pb(e.styles||{},e.text)}),{extraParam:"text"})}}_(Ve,"textLayoutProperties",Av),_(Ve,"cacheProperties",[...kr,...Lv]),_(Ve,"ownDefaults",VS),_(Ve,"type","Text"),_(Ve,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),_(Ve,"ATTRIBUTE_NAMES",rn.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),$v(Ve,[class extends Mv{_toSVG(){const r=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(r){const e=this._createBaseSVGMarkup(this._toSVG(),{reviver:r,noStyle:!0,withShadow:!0}),t=this.path;return t?e+t._createBaseSVGMarkup(t._toSVG(),{reviver:r,withShadow:!0,additionalTransform:wi(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(r){let{textBgRects:e,textSpans:t}=r;const n=this.getSvgTextDecoration(this);return[e.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(B_,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",n?'text-decoration="'.concat(n,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",t.join(""),`</text>
97
- `]}_getSVGTextAndBg(r,e){const t=[],n=[];let s,i=r;this.backgroundColor&&n.push(...uc(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(n,o,e+s,i),this._setSVGTextLineText(t,o,e+s,i),i+=this.getHeightOfLine(o);return{textSpans:t,textBgRects:n}}_createTextCharSpan(r,e,t,n,s){const i=re.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(e,r!==r.trim()||!!r.match(I_)),a=o?'style="'.concat(o,'"'):"",l=e.deltaY,c=l?' dy="'.concat(le(l,i),'" '):"",{angle:u,renderLeft:h,renderTop:d,width:f}=s;let m="";if(h!==void 0){const v=f/2;u&&(m=' rotate="'.concat(le(Cr(u),i),'"'));const x=ws({angle:Cr(u)});x[4]=h,x[5]=d;const g=new M(-v,0).transform(x);t=g.x,n=g.y}return'<tspan x="'.concat(le(t,i),'" y="').concat(le(n,i),'" ').concat(c).concat(m).concat(a,">").concat(kb(r),"</tspan>")}_setSVGTextLineText(r,e,t,n){const s=this.getHeightOfLine(e),i=this.textAlign.includes(Ut),o=this._textLines[e];let a,l,c,u,h,d="",f=0;n+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let m=0,v=o.length-1;m<=v;m++)h=m===v||this.charSpacing||this.path,d+=o[m],c=this.__charBounds[e][m],f===0?(t+=c.kernedWidth-c.width,f+=c.width):f+=c.kernedWidth,i&&!h&&this._reSpaceAndTab.test(o[m])&&(h=!0),h||(a=a||this.getCompleteStyleDeclaration(e,m),l=this.getCompleteStyleDeclaration(e,m+1),h=Hh(a,l,!0)),h&&(u=this._getStyleDeclaration(e,m),r.push(this._createTextCharSpan(d,u,t,n,c)),d="",a=l,this.direction==="rtl"?t-=f:t+=f,f=0)}_setSVGTextLineBg(r,e,t,n){const s=this._textLines[e],i=this.getHeightOfLine(e)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let u=0;u<s.length;u++){const{left:h,width:d,kernedWidth:f}=this.__charBounds[e][u];o=this.getValueOfPropertyAt(e,u,"textBackgroundColor"),o!==c?(c&&r.push(...uc(c,t+l,n,a,i)),l=h,a=d,c=o):a+=f}o&&r.push(...uc(c,t+l,n,a,i))}_getSVGLineTopOffset(r){let e,t=0;for(e=0;e<r;e++)t+=this.getHeightOfLine(e);const n=this.getHeightOfLine(e);return{lineTop:t,offset:(this._fontSizeMult-this._fontSizeFraction)*n/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(le(this.textDecorationThickness*this.getObjectScaling().y/10,re.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,e){const{fontFamily:t,strokeWidth:n,stroke:s,fill:i,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:u,linethrough:h,overline:d,underline:f}=r,m=this.getSvgTextDecoration({underline:f??this.underline,overline:d??this.overline,linethrough:h??this.linethrough}),v=u||this.textDecorationThickness;return[s?Si(st,s):"",n?"stroke-width: ".concat(n,"; "):"",t?"font-family: ".concat(t.includes("'")||t.includes('"')?t:"'".concat(t,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",m?"text-decoration: ".concat(m,"; text-decoration-thickness: ").concat(le(v*this.getObjectScaling().y/10,re.NUM_FRACTION_DIGITS),"%; "):"",i?Si(Ee,i):"",c?"baseline-shift: ".concat(-c,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter(e=>r[e.replace("-","")]).join(" ")}}]),V.setClass(Ve),V.setSVGClass(Ve);class W_{constructor(e){_(this,"target",void 0),_(this,"__mouseDownInPlace",!1),_(this,"__dragStartFired",!1),_(this,"__isDraggingOver",!1),_(this,"__dragStartSelection",void 0),_(this,"__dragImageDisposer",void 0),_(this,"_dispose",void 0),this.target=e;const t=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{t.forEach(n=>n()),this._dispose=void 0}}isPointerOverSelection(e){const t=this.target,n=t.getSelectionStartFromPointer(e);return t.isEditing&&n>=t.selectionStart&&n<=t.selectionEnd&&t.selectionStart<t.selectionEnd}start(e){return this.__mouseDownInPlace=this.isPointerOverSelection(e)}isActive(){return this.__mouseDownInPlace}end(e){const t=this.isActive();return t&&!this.__dragStartFired&&(this.target.setCursorByClick(e),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,t}getDragStartSelection(){return this.__dragStartSelection}setDragImage(e,t){var n;let{selectionStart:s,selectionEnd:i}=t;const o=this.target,a=o.canvas,l=new M(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),u=new M(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),h=a.getScenePoint(e).subtract(u),d=o.getCanvasRetinaScaling(),f=o.getBoundingRect(),m=u.subtract(new M(f.left,f.top)),v=a.viewportTransform,x=m.add(h).transform(v,!0),g=o.backgroundColor,p=Wh(o.styles);o.backgroundColor="";const y={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(y,0,s),o.setSelectionStyles(y,i,o.text.length),o.dirty=!0;const b=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=g,o.styles=p,o.dirty=!0,ku(b,{position:"fixed",left:"".concat(-b.width,"px"),border:nt,width:"".concat(b.width/d,"px"),height:"".concat(b.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},Lt(e.target||this.target.hiddenTextarea).body.appendChild(b),(n=e.dataTransfer)===null||n===void 0||n.setDragImage(b,x.x,x.y)}onDragStart(e){this.__dragStartFired=!0;const t=this.target,n=this.isActive();if(n&&e.dataTransfer){const s=this.__dragStartSelection={selectionStart:t.selectionStart,selectionEnd:t.selectionEnd},i=t._text.slice(s.selectionStart,s.selectionEnd).join(""),o=E({text:t.text,value:i},s);e.dataTransfer.setData("text/plain",i),e.dataTransfer.setData("application/fabric",JSON.stringify({value:i,styles:t.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),e.dataTransfer.effectAllowed="copyMove",this.setDragImage(e,o)}return t.abortCursorAnimation(),n}canDrop(e){if(this.target.editable&&!this.target.getActiveControl()&&!e.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const t=this.target.getSelectionStartFromPointer(e),n=this.__dragStartSelection;return t<n.selectionStart||t>n.selectionEnd}return!0}return!1}targetCanDrop(e){return this.target.canDrop(e)}dragEnterHandler(e){let{e:t}=e;const n=this.targetCanDrop(t);!this.__isDraggingOver&&n&&(this.__isDraggingOver=!0)}dragOverHandler(e){const{e:t}=e,n=this.targetCanDrop(t);!this.__isDraggingOver&&n?this.__isDraggingOver=!0:this.__isDraggingOver&&!n&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(t.preventDefault(),e.canDrop=!0,e.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(e){var t;const{e:n}=e,s=n.defaultPrevented;this.__isDraggingOver=!1,n.preventDefault();let i=(t=n.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain");if(i&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(n);const{styles:c}=n.dataTransfer.types.includes("application/fabric")?JSON.parse(n.dataTransfer.getData("application/fabric")):{},u=i[Math.max(0,i.length-1)],h=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,f=this.__dragStartSelection.selectionEnd;l>d&&l<=f?l=d:l>f&&(l-=f-d),o.removeChars(d,f),delete this.__dragStartSelection}o._reNewline.test(u)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(i=i.trimEnd()),e.didDrop=!0,e.dropTarget=o,o.insertChars(i,c,l),a.setActiveObject(o),o.enterEditing(n),o.selectionStart=Math.min(l+h,o._text.length),o.selectionEnd=Math.min(o.selectionStart+i.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Da,{index:l+h,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(e){let{e:t}=e;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var n;const s=this.target,i=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((n=t.dataTransfer)===null||n===void 0?void 0:n.dropEffect)||nt;l===nt?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Da,{index:o,action:"dragend"}),i.fire("text:changed",{target:s}),i.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const gg=/[ \n\.,;!\?\-]/;class V_ extends Ve{constructor(){super(...arguments),_(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(e){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(e)}_animateCursor(e){let{toValue:t,duration:n,delay:s,onComplete:i}=e;return Bv({startValue:this._currentCursorOpacity,endValue:t,duration:n,delay:s,onComplete:i,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(e){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(e||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var e;(e=this._currentTickCompleteState)===null||e===void 0||e.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(e){this.abortCursorAnimation(),this._tick(e?0:this.cursorDelay)}abortCursorAnimation(){let e=!1;[this._currentTickState,this._currentTickCompleteState].forEach(t=>{t&&!t.isDone()&&(e=!0,t.abort())}),this._currentCursorOpacity=1,e&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(e=>!e||e.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(e){let t=0,n=e-1;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n--;for(;/\S/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findWordBoundaryRight(e){let t=0,n=e;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n++;for(;/\S/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}findLineBoundaryLeft(e){let t=0,n=e-1;for(;!/\n/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findLineBoundaryRight(e){let t=0,n=e;for(;!/\n/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}searchWordBoundary(e,t){const n=this._text;let s=e>0&&this._reSpace.test(n[e])&&(t===-1||!Ph.test(n[e-1]))?e-1:e,i=n[s];for(;s>0&&s<n.length&&!gg.test(i);)s+=t,i=n[s];return t===-1&&gg.test(i)&&s++,s}selectWord(e){var t;e=(t=e)!==null&&t!==void 0?t:this.selectionStart;const n=this.searchWordBoundary(e,-1),s=Math.max(n,this.searchWordBoundary(e,1));this.selectionStart=n,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(e){var t;e=(t=e)!==null&&t!==void 0?t:this.selectionStart;const n=this.findLineBoundaryLeft(e),s=this.findLineBoundaryRight(e);this.selectionStart=n,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(e){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",e?{e}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(e){if(this.getActiveControl())return;const t=this.hiddenTextarea;Lt(t).activeElement!==t&&t.focus();const n=this.getSelectionStartFromPointer(e),s=this.selectionStart,i=this.selectionEnd;(n===this.__selectionStartOnMouseDown&&s!==i||s!==n&&i!==n)&&(n>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=n):(this.selectionStart=n,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===i||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(e,t,n){const s=n.slice(0,e),i=this.graphemeSplit(s).length;if(e===t)return{selectionStart:i,selectionEnd:i};const o=n.slice(e,t);return{selectionStart:i,selectionEnd:i+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(e,t,n){const s=n.slice(0,e).join("").length;return e===t?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+n.slice(e,t).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const e=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=e.selectionStart,this.hiddenTextarea.selectionEnd=e.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const e=this.hiddenTextarea;this.text=e.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const t=this.fromStringToGraphemeSelection(e.selectionStart,e.selectionEnd,e.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const e=this._calcTextareaPosition();this.hiddenTextarea.style.left=e.left,this.hiddenTextarea.style.top=e.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const e=this.inCompositionMode?this.compositionStart:this.selectionStart,t=this._getCursorBoundaries(e),n=this.get2DCursorLocation(e),s=n.lineIndex,i=n.charIndex,o=this.getValueOfPropertyAt(s,i,"fontSize")*this.lineHeight,a=t.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,u=c.width/l,h=c.height/l,d=u-o,f=h-o,m=new M(t.left+a,t.top+t.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new M(c.clientWidth/u,c.clientHeight/h));return m.x<0&&(m.x=0),m.x>d&&(m.x=d),m.y<0&&(m.y=0),m.y>f&&(m.y=f),m.x+=this.canvas._offset.left,m.y+=this.canvas._offset.top,{left:"".concat(m.x,"px"),top:"".concat(m.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const e=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const e=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),e&&this.fire(Pa),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),e&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const e in this.styles)this._textLines[e]||delete this.styles[e]}removeStyleFromTo(e,t){const{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e,!0),{lineIndex:i,charIndex:o}=this.get2DCursorLocation(t,!0);if(n!==i){if(this.styles[n])for(let a=s;a<this._unwrappedTextLines[n].length;a++)delete this.styles[n][a];if(this.styles[i])for(let a=o;a<this._unwrappedTextLines[i].length;a++){const l=this.styles[i][a];l&&(this.styles[n]||(this.styles[n]={}),this.styles[n][s+a-o]=l)}for(let a=n+1;a<=i;a++)delete this.styles[a];this.shiftLineStyles(i,n-i)}else if(this.styles[n]){const a=this.styles[n],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[n]){const u=parseInt(c,10);u>=o&&(a[u-l]=a[c],delete a[c])}}}shiftLineStyles(e,t){const n=Object.assign({},this.styles);for(const s in this.styles){const i=parseInt(s,10);i>e&&(this.styles[i+t]=n[i],n[i-t]||delete this.styles[i])}}insertNewlineStyleObject(e,t,n,s){const i={},o=this._unwrappedTextLines[e].length,a=o===t;let l=!1;n||(n=1),this.shiftLineStyles(e,n);const c=this.styles[e]?this.styles[e][t===0?t:t-1]:void 0;for(const h in this.styles[e]){const d=parseInt(h,10);d>=t&&(l=!0,i[d-t]=this.styles[e][h],a&&t===0||delete this.styles[e][h])}let u=!1;for(l&&!a&&(this.styles[e+n]=i,u=!0),(u||o>t)&&n--;n>0;)s&&s[n-1]?this.styles[e+n]={0:E({},s[n-1])}:c?this.styles[e+n]={0:E({},c)}:delete this.styles[e+n],n--;this._forceClearCache=!0}insertCharStyleObject(e,t,n,s){this.styles||(this.styles={});const i=this.styles[e],o=i?E({},i):{};n||(n=1);for(const l in o){const c=parseInt(l,10);c>=t&&(i[c+n]=o[c],o[c-n]||delete i[c])}if(this._forceClearCache=!0,s){for(;n--;)Object.keys(s[n]).length&&(this.styles[e]||(this.styles[e]={}),this.styles[e][t+n]=E({},s[n]));return}if(!i)return;const a=i[t?t-1:1];for(;a&&n--;)this.styles[e][t+n]=E({},a)}insertNewStyleBlock(e,t,n){const s=this.get2DCursorLocation(t,!0),i=[0];let o,a=0;for(let l=0;l<e.length;l++)e[l]===`
98
- `?(a++,i[a]=0):i[a]++;for(i[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,i[0],n),n=n&&n.slice(i[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+i[0],a),o=1;o<a;o++)i[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,i[o],n):n&&this.styles[s.lineIndex+o]&&n[0]&&(this.styles[s.lineIndex+o][0]=n[0]),n=n&&n.slice(i[o]+1);i[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,i[o],n)}removeChars(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e+1;this.removeStyleFromTo(e,t),this._text.splice(e,t-e),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(e,t,n){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:n;s>n&&this.removeStyleFromTo(n,s);const i=this.graphemeSplit(e);this.insertNewStyleBlock(i,n,t),this._text=[...this._text.slice(0,n),...i,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(e,t,n){n<=e?(t===e?this._selectionDirection=se:this._selectionDirection===xe&&(this._selectionDirection=se,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===xe?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=xe:this._selectionDirection===se&&(this._selectionDirection=xe,this.selectionStart=t),this.selectionEnd=n)}}class H_ extends V_{initHiddenTextarea(){const e=this.canvas&&Lt(this.canvas.getElement())||vs(),t=e.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(o=>{let[a,l]=o;return t.setAttribute(a,l)});const{top:n,left:s,fontSize:i}=this._calcTextareaPosition();t.style.cssText="position: absolute; top: ".concat(n,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(i,";"),(this.hiddenTextareaContainer||e.body).appendChild(t),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(o=>{let[a,l]=o;return t.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=t}blur(){this.abortCursorAnimation()}onKeyDown(e){if(!this.isEditing)return;const t=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(e.keyCode in t)this[t[e.keyCode]](e);else{if(!(e.keyCode in this.ctrlKeysMapDown)||!e.ctrlKey&&!e.metaKey)return;this[this.ctrlKeysMapDown[e.keyCode]](e)}e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(e){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey)&&(this[this.ctrlKeysMapUp[e.keyCode]](e),e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(e){const t=this.fromPaste,{value:n,selectionStart:s,selectionEnd:i}=this.hiddenTextarea;if(this.fromPaste=!1,e&&e.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Da),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(n).graphemeText,l=this._text.length,c=a.length,u=this.selectionStart,h=this.selectionEnd,d=u!==h;let f,m,v,x,g=c-l;const p=this.fromStringToGraphemeSelection(s,i,n),y=u>p.selectionStart;d?(m=this._text.slice(u,h),g+=h-u):c<l&&(m=y?this._text.slice(h+g,h):this._text.slice(u,u-g));const b=a.slice(p.selectionEnd-g,p.selectionEnd);if(m&&m.length&&(b.length&&(f=this.getSelectionStyles(u,u+1,!1),f=b.map(()=>f[0])),d?(v=u,x=h):y?(v=h-m.length,x=h):(v=h,x=h+m.length),this.removeStyleFromTo(v,x)),b.length){const{copyPasteData:O}=Zt();t&&b.join("")===O.copiedText&&!re.disableStyleCopyPaste&&(f=O.copiedTextStyle),this.insertNewStyleBlock(b,u,f)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(e){let{target:t}=e;const{selectionStart:n,selectionEnd:s}=t;this.compositionStart=n,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:e}=Zt();e.copiedText=this.getSelectedText(),re.disableStyleCopyPaste?e.copiedTextStyle=void 0:e.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(e,t){let n,s=this._getLineLeftOffset(e);return t>0&&(n=this.__charBounds[e][t-1],s+=n.left+n.width),s}getDownCursorOffset(e,t){const n=this._getSelectionForOffset(e,t),s=this.get2DCursorLocation(n),i=s.lineIndex;if(i===this._textLines.length-1||e.metaKey||e.keyCode===34)return this._text.length-n;const o=s.charIndex,a=this._getWidthBeforeCursor(i,o),l=this._getIndexOnLine(i+1,a);return this._textLines[i].slice(o).length+l+1+this.missingNewlineOffset(i)}_getSelectionForOffset(e,t){return e.shiftKey&&this.selectionStart!==this.selectionEnd&&t?this.selectionEnd:this.selectionStart}getUpCursorOffset(e,t){const n=this._getSelectionForOffset(e,t),s=this.get2DCursorLocation(n),i=s.lineIndex;if(i===0||e.metaKey||e.keyCode===33)return-n;const o=s.charIndex,a=this._getWidthBeforeCursor(i,o),l=this._getIndexOnLine(i-1,a),c=this._textLines[i].slice(0,o),u=this.missingNewlineOffset(i-1);return-this._textLines[i-1].length+l-c.length+(1-u)}_getIndexOnLine(e,t){const n=this._textLines[e];let s,i,o=this._getLineLeftOffset(e),a=0;for(let l=0,c=n.length;l<c;l++)if(s=this.__charBounds[e][l].width,o+=s,o>t){i=!0;const u=o-s,h=o,d=Math.abs(u-t);a=Math.abs(h-t)<d?l:l-1;break}return i||(a=n.length-1),a}moveCursorDown(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",e)}moveCursorUp(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",e)}_moveCursorUpOrDown(e,t){const n=this["get".concat(e,"CursorOffset")](t,this._selectionDirection===xe);if(t.shiftKey?this.moveCursorWithShift(n):this.moveCursorWithoutShift(n),n!==0){const s=this.text.length;this.selectionStart=ds(0,this.selectionStart,s),this.selectionEnd=ds(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(e){const t=this._selectionDirection===se?this.selectionStart+e:this.selectionEnd+e;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,t),e!==0}moveCursorWithoutShift(e){return e<0?(this.selectionStart+=e,this.selectionEnd=this.selectionStart):(this.selectionEnd+=e,this.selectionStart=this.selectionEnd),e!==0}moveCursorLeft(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",e)}_move(e,t,n){let s;if(e.altKey)s=this["findWordBoundary".concat(n)](this[t]);else{if(!e.metaKey&&e.keyCode!==35&&e.keyCode!==36)return this[t]+=n==="Left"?-1:1,!0;s=this["findLineBoundary".concat(n)](this[t])}return s!==void 0&&this[t]!==s&&(this[t]=s,!0)}_moveLeft(e,t){return this._move(e,t,"Left")}_moveRight(e,t){return this._move(e,t,"Right")}moveCursorLeftWithoutShift(e){let t=!0;return this._selectionDirection=se,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(t=this._moveLeft(e,"selectionStart")),this.selectionEnd=this.selectionStart,t}moveCursorLeftWithShift(e){return this._selectionDirection===xe&&this.selectionStart!==this.selectionEnd?this._moveLeft(e,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=se,this._moveLeft(e,"selectionStart")):void 0}moveCursorRight(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",e)}_moveCursorLeftOrRight(e,t){const n="moveCursor".concat(e).concat(t.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[n](t)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(e){return this._selectionDirection===se&&this.selectionStart!==this.selectionEnd?this._moveRight(e,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=xe,this._moveRight(e,"selectionEnd")):void 0}moveCursorRightWithoutShift(e){let t=!0;return this._selectionDirection=xe,this.selectionStart===this.selectionEnd?(t=this._moveRight(e,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,t}}const pg=r=>!!r.button;class $_ extends H_{constructor(){super(...arguments),_(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new W_(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(e){return this.draggableTextDelegate.onDragStart(e)}canDrop(e){return this.draggableTextDelegate.canDrop(e)}doubleClickHandler(e){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}tripleClickHandler(e){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}_mouseDownHandler(e){let{e:t,alreadySelected:n}=e;this.canvas&&this.editable&&!pg(t)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(t)||(this.canvas.textEditingManager.register(this),n&&(this.inCompositionMode=!1,this.setCursorByClick(t)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=n||this.isEditing)))}mouseUpHandler(e){let{e:t,transform:n}=e;const s=this.draggableTextDelegate.end(t);if(this.canvas){this.canvas.textEditingManager.unregister(this);const i=this.canvas._activeObject;if(i&&i!==this)return}!this.editable||this.group&&!this.group.interactive||n&&n.actionPerformed||pg(t)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(t),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(e){const t=this.getSelectionStartFromPointer(e),n=this.selectionStart,s=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(n,s,t):(this.selectionStart=t,this.selectionEnd=t),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(e){const t=this.canvas.getScenePoint(e).transform(Ft(this.calcTransformMatrix())).add(new M(-this._getLeftOffset(),-this._getTopOffset()));let n=0,s=0,i=0;for(let c=0;c<this._textLines.length&&n<=t.y;c++)n+=this.getHeightOfLine(c),i=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(i));const a=this._textLines[i].length,l=this.__charBounds[i];for(let c=0;c<a;c++){const u=o+l[c].kernedWidth;if(t.x<=u){Math.abs(t.x-u)<=Math.abs(t.x-o)&&s++;break}o=u,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const oo="moveCursorUp",ao="moveCursorDown",lo="moveCursorLeft",co="moveCursorRight",uo="exitEditing",mg=(r,e)=>{const t=e.getRetinaScaling();r.setTransform(t,0,0,t,0,0);const n=e.viewportTransform;r.transform(n[0],n[1],n[2],n[3],n[4],n[5])},X_=E({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:uo,27:uo,33:oo,34:ao,35:co,36:lo,37:lo,38:oo,39:co,40:ao},keysMapRtl:{9:uo,27:uo,33:oo,34:ao,35:lo,36:co,37:co,38:oo,39:lo,40:ao},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class dr extends $_{static getDefaults(){return E(E({},super.getDefaults()),dr.ownDefaults)}get type(){const e=super.type;return e==="itext"?"i-text":e}constructor(e,t){super(e,E(E({},dr.ownDefaults),t)),this.initBehavior()}_set(e,t){return this.isEditing&&this._savedProps&&e in this._savedProps?(this._savedProps[e]=t,this):(e==="canvas"&&(this.canvas instanceof Eu&&this.canvas.textEditingManager.remove(this),t instanceof Eu&&t.textEditingManager.add(this)),super._set(e,t))}setSelectionStart(e){e=Math.max(e,0),this._updateAndFire("selectionStart",e)}setSelectionEnd(e){e=Math.min(e,this.text.length),this._updateAndFire("selectionEnd",e)}_updateAndFire(e,t){this[e]!==t&&(this._fireSelectionChanged(),this[e]=t),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,n=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(e,t,n)}setSelectionStyles(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(e,t,n)}get2DCursorLocation(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(e,t)}render(e){super.render(e),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(e){const t=this.isEditing;this.isEditing=!1;const n=super.toCanvasElement(e);return this.isEditing=t,n}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const e=this.clearContextTop(!0);if(!e)return;const t=this._getCursorBoundaries(),n=this.findAncestorsWithClipPath(),s=n.length>0;let i,o=e;if(s){i=kt(e.canvas),o=i.getContext("2d"),mg(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,t):this.renderCursor(o,t),s)for(const a of n){const l=a.clipPath,c=kt(e.canvas),u=c.getContext("2d");if(mg(u,this.canvas),!l.absolutePositioned){const h=a.calcTransformMatrix();u.transform(h[0],h[1],h[2],h[3],h[4],h[5])}l.transform(u),l.drawObject(u,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(e.setTransform(1,0,0,1,0,0),e.drawImage(i,0,0)),this.canvas.contextTopDirty=!0,e.restore()}findAncestorsWithClipPath(){const e=[];let t=this;for(;t;)t.clipPath&&e.push(t),t=t.parent;return e}_getCursorBoundaries(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1?arguments[1]:void 0;const n=this._getLeftOffset(),s=this._getTopOffset(),i=this._getCursorBoundariesOffsets(e,t);return{left:n,top:s,leftOffset:i.left,topOffset:i.top}}_getCursorBoundariesOffsets(e,t){return t?this.__getCursorBoundariesOffsets(e):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(e)}__getCursorBoundariesOffsets(e){let t=0,n=0;const{charIndex:s,lineIndex:i}=this.get2DCursorLocation(e);for(let c=0;c<i;c++)t+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(i),a=this.__charBounds[i][s];a&&(n=a.left),this.charSpacing!==0&&s===this._textLines[i].length&&(n-=this._getWidthOfCharSpacing());const l={top:t,left:o+(n>0?n:0)};return this.direction==="rtl"&&(this.textAlign===xe||this.textAlign===Ut||this.textAlign===qs?l.left*=-1:this.textAlign===se||this.textAlign===Fa?l.left=o-(n>0?n:0):this.textAlign!==J&&this.textAlign!==Qs||(l.left=o-(n>0?n:0))),l}renderCursorAt(e){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(e,!0),e)}renderCursor(e,t){this._renderCursor(e,t,this.selectionStart)}getCursorRenderingData(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(e);const n=this.get2DCursorLocation(e),s=n.lineIndex,i=n.charIndex>0?n.charIndex-1:0,o=this.getValueOfPropertyAt(s,i,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,i,"deltaY"),u=t.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,i,"fill"),opacity:this._currentCursorOpacity,left:t.left+t.leftOffset-l/2,top:u+t.top+c,width:l,height:o}}_renderCursor(e,t,n){const{color:s,opacity:i,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(n,t);e.fillStyle=s,e.globalAlpha=i,e.fillRect(o,a,l,c)}renderSelection(e,t){const n={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(e,n,t)}renderDragSourceEffect(){const e=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,e,this._getCursorBoundaries(e.selectionStart,!0))}renderDropTargetEffect(e){const t=this.getSelectionStartFromPointer(e);this.renderCursorAt(t)}_renderSelection(e,t,n){const s=t.selectionStart,i=t.selectionEnd,o=this.textAlign.includes(Ut),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(i),c=a.lineIndex,u=l.lineIndex,h=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let f=c;f<=u;f++){const m=this._getLineLeftOffset(f)||0;let v=this.getHeightOfLine(f),x=0,g=0,p=0;if(f===c&&(g=this.__charBounds[c][h].left),f>=c&&f<u)p=o&&!this.isEndOfWrapping(f)?this.width:this.getLineWidth(f)||5;else if(f===u)if(d===0)p=this.__charBounds[u][d].left;else{const T=this._getWidthOfCharSpacing();p=this.__charBounds[u][d-1].left+this.__charBounds[u][d-1].width-T}x=v,(this.lineHeight<1||f===u&&this.lineHeight>1)&&(v/=this.lineHeight);let y=n.left+m+g,b=v,O=0;const S=p-g;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",b=1,O=v):e.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===xe||this.textAlign===Ut||this.textAlign===qs?y=this.width-y-S:this.textAlign===se||this.textAlign===Fa?y=n.left+m-p:this.textAlign!==J&&this.textAlign!==Qs||(y=n.left+m-p)),e.fillRect(y,n.top+n.topOffset+O,S,b),n.topOffset+=x}}getCurrentCharFontSize(){const e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,"fontSize")}getCurrentCharColor(){const e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,Ee)}_getCurrentCharIndex(){const e=this.get2DCursorLocation(this.selectionStart,!0),t=e.charIndex>0?e.charIndex-1:0;return{l:e.lineIndex,c:t}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}_(dr,"ownDefaults",X_),_(dr,"type","IText"),V.setClass(dr),V.setClass(dr,"i-text");class Br extends dr{static getDefaults(){return E(E({},super.getDefaults()),Br.ownDefaults)}constructor(e,t){super(e,E(E({},Br.ownDefaults),t))}static createControls(){return{controls:bb()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Ut)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(e){let t=0,n=0,s=0;const i={};for(let o=0;o<e.graphemeLines.length;o++)e.graphemeText[s]===`
99
- `&&o>0?(n=0,s++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[s])&&o>0&&(n++,s++),i[o]={line:t,offset:n},s+=e.graphemeLines[o].length,n+=e.graphemeLines[o].length;return i}styleHas(e,t){if(this._styleMap&&!this.isWrapping){const n=this._styleMap[t];n&&(t=n.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t,n=0,s=e+1,i=!1;const o=this._styleMap[e],a=this._styleMap[e+1];o&&(e=o.line,n=o.offset),a&&(s=a.line,i=s===e,t=a.offset);const l=e===void 0?this.styles:{line:this.styles[e]};for(const c in l)for(const u in l[c]){const h=parseInt(u,10);if(h>=n&&(!i||h<t))for(const d in l[c][u])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){const n=this._styleMap[e];if(!n)return{};e=n.line,t=n.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,n){const s=this._styleMap[e];super._setStyleDeclaration(s.line,s.offset+t,n)}_deleteStyleDeclaration(e,t){const n=this._styleMap[e];super._deleteStyleDeclaration(n.line,n.offset+t)}_getLineStyle(e){const t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){const t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;const n=this.getGraphemeDataForRender(e),s=[];for(let i=0;i<n.wordsData.length;i++)s.push(...this._wrapLine(i,t,n));return this.isWrapping=!1,s}getGraphemeDataForRender(e){const t=this.splitByGrapheme,n=t?"":" ";let s=0;return{wordsData:e.map((i,o)=>{let a=0;const l=t?this.graphemeSplit(i):this.wordSplit(i);return l.length===0?[{word:[],width:0}]:l.map(c=>{const u=t?[c]:this.graphemeSplit(c),h=this._measureWord(u,o,a);return s=Math.max(h,s),a+=u.length+n.length,{word:u,width:h}})}),largestWordWidth:s}}_measureWord(e,t){let n,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=0;for(let o=0,a=e.length;o<a;o++)i+=this._getGraphemeBox(e[o],t,o+s,n,!0).kernedWidth,n=e[o];return i}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,n){let{largestWordWidth:s,wordsData:i}=n,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],u=l?"":" ";let h=0,d=[],f=0,m=0,v=!0;t-=o;const x=Math.max(t,s,this.dynamicMinWidth),g=i[e];let p;for(f=0,p=0;p<g.length;p++){const{word:y,width:b}=g[p];f+=y.length,h+=m+b-a,h>x&&!v?(c.push(d),d=[],h=b,v=!0):h+=a,v||l||d.push(u),d=d.concat(y),m=l?0:this._measureWord([u],e,f),f++,v=!1}return p&&c.push(d),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?this.isEndOfWrapping(e)?1:0:1}_splitTextIntoLines(e){const t=super._splitTextIntoLines(e),n=this._wrapText(t.lines,this.width),s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=n[i].join("");return t.lines=s,t.graphemeLines=n,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const e=new Map;for(const t in this._styleMap){const n=parseInt(t,10);if(this._textLines[n]){const s=this._styleMap[t].line;e.set("".concat(s),!0)}}for(const t in this.styles)e.has(t)||delete this.styles[t]}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...e])}}_(Br,"type","Textbox"),_(Br,"textLayoutProperties",[...dr.textLayoutProperties,"width"]),_(Br,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),V.setClass(Br);class vg extends xl{shouldPerformLayout(e){return!!e.target.clipPath&&super.shouldPerformLayout(e)}shouldLayoutClipPath(){return!1}calcLayoutResult(e,t){const{target:n}=e,{clipPath:s,group:i}=n;if(!s||!this.shouldPerformLayout(e))return;const{width:o,height:a}=pr(Yv(n,s)),l=new M(o,a);if(s.absolutePositioned)return{center:rs(s.getRelativeCenterPoint(),void 0,i?i.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(n.calcOwnMatrix(),!0);if(this.shouldPerformLayout(e)){const{center:u=new M,correction:h=new M}=this.calcBoundingBox(t,e)||{};return{center:u.add(c),correction:h.subtract(c),size:l}}return{center:n.getRelativeCenterPoint().add(c),size:l}}}}_(vg,"type","clip-path"),V.setClass(vg);class yg extends xl{getInitialSize(e,t){let{target:n}=e,{size:s}=t;return new M(n.width||s.x,n.height||s.y)}}_(yg,"type","fixed"),V.setClass(yg);class U_ extends _i{subscribeTargets(e){const t=e.target;e.targets.reduce((n,s)=>(s.parent&&n.add(s.parent),n),new Set).forEach(n=>{n.layoutManager.subscribeTargets({target:n,targets:[t]})})}unsubscribeTargets(e){const t=e.target,n=t.getObjects();e.targets.reduce((s,i)=>(i.parent&&s.add(i.parent),s),new Set).forEach(s=>{!n.some(i=>i.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[t]})})}}class dn extends vn{static getDefaults(){return E(E({},super.getDefaults()),dn.ownDefaults)}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,dn.ownDefaults),this.setOptions(t);const{left:n,top:s,layoutManager:i}=t;this.groupInit(e,{left:n,top:s,layoutManager:i??new U_})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.multiSelectionStacking==="selection-order"?this.add(...t):t.forEach(s=>{const i=this._objects.findIndex(a=>a.isInFrontOf(s)),o=i===-1?this.size():i;this.insertAt(o,s)})}canEnterGroup(e){return this.getObjects().some(t=>t.isDescendantOf(e)||e.isDescendantOf(t))?(Qr("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(e)}enterGroup(e,t){e.parent&&e.parent===e.group?e.parent._exitGroup(e):e.group&&e.parent!==e.group&&e.group.remove(e),this._enterGroup(e,t)}exitGroup(e,t){this._exitGroup(e,t),e.parent&&e.parent._enterGroup(e,!0)}_onAfterObjectsChange(e,t){super._onAfterObjectsChange(e,t);const n=new Set;t.forEach(s=>{const{parent:i}=s;i&&n.add(i)}),e===Xh?n.forEach(s=>{s._onAfterObjectsChange(Na,t)}):n.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(e,t,n){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=E(E({hasControls:!1},n),{},{forActiveSelection:!0});for(let i=0;i<this._objects.length;i++)this._objects[i]._renderControls(e,s);super._renderControls(e,t),e.restore()}}_(dn,"type","ActiveSelection"),_(dn,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),V.setClass(dn),V.setClass(dn,"activeSelection");class Y_{constructor(){_(this,"resources",{})}applyFilters(e,t,n,s,i){const o=i.getContext("2d");if(!o)return;o.drawImage(t,0,0,n,s);const a={sourceWidth:n,sourceHeight:s,imageData:o.getImageData(0,0,n,s),originalEl:t,originalImageData:o.getImageData(0,0,n,s),canvasEl:i,ctx:o,filterBackend:this};e.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===n&&l.height===s||(i.width=l.width,i.height=l.height),o.putImageData(l,0,0),a}}class uy{constructor(){let{tileSize:e=re.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),_(this,"resources",{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(e,t){this.dispose(),this.createWebGLCanvas(e,t)}createWebGLCanvas(e,t){const n=kt({width:e,height:t}),s=n.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=n,this.gl=s)}applyFilters(e,t,n,s,i,o){const a=this.gl,l=i.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,t));const u={originalWidth:t.width||t.naturalWidth||0,originalHeight:t.height||t.naturalHeight||0,sourceWidth:n,sourceHeight:s,destinationWidth:n,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,n,s,c?void 0:t),targetTexture:this.createTexture(a,n,s),originalTexture:c||this.createTexture(a,n,s,c?void 0:t),passes:e.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:i},h=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,h),e.forEach(d=>{d&&d.applyTo(u)}),function(d){const f=d.targetCanvas,m=f.width,v=f.height,x=d.destinationWidth,g=d.destinationHeight;m===x&&v===g||(f.width=x,f.height=g)}(u),this.copyGLTo2D(a,u),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(u.sourceTexture),a.deleteTexture(u.targetTexture),a.deleteFramebuffer(h),l.setTransform(1,0,0,1,0,0),u}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(e,t,n,s,i){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:u,TEXTURE_MAG_FILTER:h,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:m}=e,v=e.createTexture();return e.bindTexture(a,v),e.texParameteri(a,h,i||o),e.texParameteri(a,d,i||o),e.texParameteri(a,f,u),e.texParameteri(a,m,u),s?e.texImage2D(a,0,l,l,c,s):e.texImage2D(a,0,l,t,n,0,l,c,null),v}getCachedTexture(e,t,n){const{textureCache:s}=this;if(s[e])return s[e];{const i=this.createTexture(this.gl,t.width,t.height,t,n);return i&&(s[e]=i),i}}evictCachesForKey(e){this.textureCache[e]&&(this.gl.deleteTexture(this.textureCache[e]),delete this.textureCache[e])}copyGLTo2D(e,t){const n=e.canvas,s=t.targetCanvas,i=s.getContext("2d");if(!i)return;i.translate(0,s.height),i.scale(1,-1);const o=n.height-s.height;i.drawImage(n,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(e,t){const n=t.targetCanvas.getContext("2d"),s=t.destinationWidth,i=t.destinationHeight,o=s*i*4;if(!n)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);e.readPixels(0,0,s,i,e.RGBA,e.UNSIGNED_BYTE,a);const c=new ImageData(l,s,i);n.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const e=this.gl,t={renderer:"",vendor:""};if(!e)return t;const n=e.getExtension("WEBGL_debug_renderer_info");if(n){const s=e.getParameter(n.UNMASKED_RENDERER_WEBGL),i=e.getParameter(n.UNMASKED_VENDOR_WEBGL);s&&(t.renderer=s.toLowerCase()),i&&(t.vendor=i.toLowerCase())}return this.gpuInfo=t,t}}let dc;function G_(){const{WebGLProbe:r}=Zt();return r.queryWebGL(_r()),re.enableGLFiltering&&r.isSupported(re.textureSize)?new uy({tileSize:re.textureSize}):new Y_}function fc(){return!dc&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(dc=G_()),dc}const K_=["filters","resizeFilter","src","crossOrigin","type"],hy=["cropX","cropY"];class mt extends Be{static getDefaults(){return E(E({},super.getDefaults()),mt.ownDefaults)}constructor(e,t){super(),_(this,"_lastScaleX",1),_(this,"_lastScaleY",1),_(this,"_filterScalingX",1),_(this,"_filterScalingY",1),this.filters=[],Object.assign(this,mt.ownDefaults),this.setOptions(t),this.cacheKey="texture".concat(Jr()),this.setElement(typeof e=="string"?(this.canvas&&Lt(this.canvas.getElement())||vs()).getElementById(e):e,t)}getElement(){return this._element}setElement(e){var t;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=e,this._originalElement=e,this._setWidthHeight(n),(t=e.classList)===null||t===void 0||t.add(mt.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(e){const t=fc(!1);t instanceof uy&&t.evictCachesForKey(e)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(e=>{const t=this[e];t&&Zt().dispose(t),this[e]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const e=this.getElement();return e?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}}_stroke(e){if(!this.stroke||this.strokeWidth===0)return;const t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,-n),e.lineTo(t,-n),e.lineTo(t,n),e.lineTo(-t,n),e.lineTo(-t,-n),e.closePath()}toObject(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const t=[];return this.filters.forEach(n=>{n&&t.push(n.toObject())}),E(E({},super.toObject([...hy,...e])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:t},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const e=[],t=this._element,n=-this.width/2,s=-this.height/2;let i=[],o=[],a="",l="";if(!t)return[];if(this.hasCrop()){const c=Jr();i.push('<clipPath id="imageCrop_'+c+`">
100
- `,' <rect x="'+n+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
101
- `,`</clipPath>
102
- `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),e.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(n-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(t.width||t.naturalWidth,'" height="').concat(t.height||t.naturalHeight,'"').concat(l).concat(a,`></image>
103
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(n,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
104
- `)],this.fill=c}return i=this.paintFirst!==Ee?i.concat(o,e):i.concat(e,o),i}getSrc(e){const t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute("src")||"":t.src:this.src||""}getSvgSrc(e){return this.getSrc(e)}setSrc(e){let{crossOrigin:t,signal:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Go(e,{crossOrigin:t,signal:n}).then(s=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const e=this.resizeFilter,t=this.minimumScaleTrigger,n=this.getTotalObjectScaling(),s=n.x,i=n.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!e||s>t&&i>t)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=i);const a=kt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=e.scaleX=s,this._lastScaleY=e.scaleY=i,fc().applyFilters([e],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(e=e.filter(i=>i&&!i.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),e.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const t=this._originalElement,n=t.naturalWidth||t.width,s=t.naturalHeight||t.height;if(this._element===this._originalElement){const i=kt({width:n,height:s});this._element=i,this._filteredEl=i}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,n,s),this._lastScaleX=1,this._lastScaleY=1);fc().applyFilters(e,this._originalElement,n,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){const t=this._element;if(!t)return;const n=this._filterScalingX,s=this._filterScalingY,i=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=t.naturalWidth||t.width,u=t.naturalHeight||t.height,h=a*n,d=l*s,f=Math.min(i*n,c-h),m=Math.min(o*s,u-d),v=-i/2,x=-o/2,g=Math.min(i,c/n-a),p=Math.min(o,u/s-l);t&&e.drawImage(t,h,d,f,m,v,x,g,p)}_needsResize(){const e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:e,height:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=this.getOriginalSize();this.width=e||n.width,this.height=t||n.height}parsePreserveAspectRatioAttribute(){const e=zS(this.preserveAspectRatio||""),t=this.width,n=this.height,s={width:t,height:n};let i,o=this._element.width,a=this._element.height,l=1,c=1,u=0,h=0,d=0,f=0;return!e||e.alignX===nt&&e.alignY===nt?(l=t/o,c=n/a):(e.meetOrSlice==="meet"&&(l=c=r_(this._element,s),i=(t-o*l)/2,e.alignX==="Min"&&(u=-i),e.alignX==="Max"&&(u=i),i=(n-a*c)/2,e.alignY==="Min"&&(h=-i),e.alignY==="Max"&&(h=i)),e.meetOrSlice==="slice"&&(l=c=n_(this._element,s),i=o-t/l,e.alignX==="Mid"&&(d=i/2),e.alignX==="Max"&&(d=i),i=a-n/c,e.alignY==="Mid"&&(f=i/2),e.alignY==="Max"&&(f=i),o=t/l,a=n/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:u,offsetTop:h,cropX:d,cropY:f}}static fromObject(e,t){let{filters:n,resizeFilter:s,src:i,crossOrigin:o,type:a}=e,l=de(e,K_);return Promise.all([Go(i,E(E({},t),{},{crossOrigin:o})),n&&xi(n,t),s&&xi([s],t),pl(l,t)]).then(c=>{let[u,h=[],[d]=[],f={}]=c;return new this(u,E(E({},l),{},{src:i,filters:h,resizeFilter:d},f))})}static fromURL(e){let{crossOrigin:t=null,signal:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Go(e,{crossOrigin:t,signal:n}).then(i=>new this(i,s))}static async fromElement(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const s=Er(e,this.ATTRIBUTE_NAMES,n);return this.fromURL(s["xlink:href"]||s.href,t,s).catch(i=>(Qr("log","Unable to parse Image",i),null))}}_(mt,"type","Image"),_(mt,"cacheProperties",[...kr,...hy]),_(mt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),_(mt,"CSS_CANVAS","canvas-img"),_(mt,"ATTRIBUTE_NAMES",[...rn,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),V.setClass(mt),V.setSVGClass(mt);vl(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Sl=r=>r.webgl!==void 0,Uh="precision highp float",q_=`
105
- `.concat(Uh,`;
106
- varying vec2 vTexCoord;
107
- uniform sampler2D uTexture;
108
- void main() {
109
- gl_FragColor = texture2D(uTexture, vTexCoord);
110
- }`),Q_=["type"],J_=["type"],Z_=new RegExp(Uh,"g");class Oe{get type(){return this.constructor.type}constructor(){let e=de(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Q_);Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return q_}getVertexSource(){return`
111
- attribute vec2 aPosition;
112
- varying vec2 vTexCoord;
113
- void main() {
114
- vTexCoord = aPosition;
115
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
116
- }`}createProgram(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Zt();s!=="highp"&&(t=t.replace(Z_,Uh.replace("highp",s)));const i=e.createShader(e.VERTEX_SHADER),o=e.createShader(e.FRAGMENT_SHADER),a=e.createProgram();if(!i||!o||!a)throw new Gt("Vertex, fragment shader or program creation error");if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new Gt("Vertex shader compile error for ".concat(this.type,": ").concat(e.getShaderInfoLog(i)));if(e.shaderSource(o,t),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Gt("Fragment shader compile error for ".concat(this.type,": ").concat(e.getShaderInfoLog(o)));if(e.attachShader(a,i),e.attachShader(a,o),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS))throw new Gt('Shader link error for "'.concat(this.type,'" ').concat(e.getProgramInfoLog(a)));const l=this.getUniformLocations(e,a)||{};return l.uStepW=e.getUniformLocation(a,"uStepW"),l.uStepH=e.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(e,a),uniformLocations:l}}getAttributeLocations(e,t){return{aPosition:e.getAttribLocation(t,"aPosition")}}getUniformLocations(e,t){const n=this.constructor.uniformLocations,s={};for(let i=0;i<n.length;i++)s[n[i]]=e.getUniformLocation(t,n[i]);return s}sendAttributeData(e,t,n){const s=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(s),e.vertexAttribPointer(s,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)}_setupFrameBuffer(e){const t=e.context;if(e.passes>1){const n=e.destinationWidth,s=e.destinationHeight;e.sourceWidth===n&&e.sourceHeight===s||(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,s)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)}else t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish()}_swapTextures(e){e.passes--,e.pass++;const t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t}isNeutralState(e){return!1}applyTo(e){Sl(e)?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){}getCacheKey(){return this.type}retrieveShader(e){const t=this.getCacheKey();return e.programCache[t]||(e.programCache[t]=this.createProgram(e.context)),e.programCache[t]}applyToWebGL(e){const t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)}unbindAdditionalTexture(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)}sendUniformData(e,t){}createHelpLayer(e){if(!e.helpLayer){const{sourceWidth:t,sourceHeight:n}=e,s=kt({width:t,height:n});e.helpLayer=s}}toObject(){const e=Object.keys(this.constructor.defaults||{});return E({type:this.type},e.reduce((t,n)=>(t[n]=this[n],t),{}))}toJSON(){return this.toObject()}static async fromObject(e,t){return new this(de(e,J_))}}_(Oe,"type","BaseFilter"),_(Oe,"uniformLocations",[]);const eC={multiply:`gl_FragColor.rgb *= uColor.rgb;
117
- `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
118
- `,add:`gl_FragColor.rgb += uColor.rgb;
119
- `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
120
- `,subtract:`gl_FragColor.rgb -= uColor.rgb;
121
- `,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
122
- `,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
123
- `,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
124
- `,overlay:`
125
- if (uColor.r < 0.5) {
126
- gl_FragColor.r *= 2.0 * uColor.r;
127
- } else {
128
- gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
129
- }
130
- if (uColor.g < 0.5) {
131
- gl_FragColor.g *= 2.0 * uColor.g;
132
- } else {
133
- gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
134
- }
135
- if (uColor.b < 0.5) {
136
- gl_FragColor.b *= 2.0 * uColor.b;
137
- } else {
138
- gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
139
- }
140
- `,tint:`
141
- gl_FragColor.rgb *= (1.0 - uColor.a);
142
- gl_FragColor.rgb += uColor.rgb;
143
- `};class ho extends Oe{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
144
- precision highp float;
145
- uniform sampler2D uTexture;
146
- uniform vec4 uColor;
147
- varying vec2 vTexCoord;
148
- void main() {
149
- vec4 color = texture2D(uTexture, vTexCoord);
150
- gl_FragColor = color;
151
- if (color.a > 0.0) {
152
- `.concat(eC[this.mode],`
153
- }
154
- }
155
- `)}applyTo2d(e){let{imageData:{data:t}}=e;const n=new ne(this.color).getSource(),s=this.alpha,i=n[0]*s,o=n[1]*s,a=n[2]*s,l=1-s;for(let c=0;c<t.length;c+=4){const u=t[c],h=t[c+1],d=t[c+2];let f,m,v;switch(this.mode){case"multiply":f=u*i/255,m=h*o/255,v=d*a/255;break;case"screen":f=255-(255-u)*(255-i)/255,m=255-(255-h)*(255-o)/255,v=255-(255-d)*(255-a)/255;break;case"add":f=u+i,m=h+o,v=d+a;break;case"difference":f=Math.abs(u-i),m=Math.abs(h-o),v=Math.abs(d-a);break;case"subtract":f=u-i,m=h-o,v=d-a;break;case"darken":f=Math.min(u,i),m=Math.min(h,o),v=Math.min(d,a);break;case"lighten":f=Math.max(u,i),m=Math.max(h,o),v=Math.max(d,a);break;case"overlay":f=i<128?2*u*i/255:255-2*(255-u)*(255-i)/255,m=o<128?2*h*o/255:255-2*(255-h)*(255-o)/255,v=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":f=i+u-2*i*u/255,m=o+h-2*o*h/255,v=a+d-2*a*d/255;break;case"tint":f=i+u*l,m=o+h*l,v=a+d*l}t[c]=f,t[c+1]=m,t[c+2]=v}}sendUniformData(e,t){const n=new ne(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,e.uniform4fv(t.uColor,n)}}_(ho,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),_(ho,"type","BlendColor"),_(ho,"uniformLocations",["uColor"]),V.setClass(ho);const tC={multiply:`
156
- precision highp float;
157
- uniform sampler2D uTexture;
158
- uniform sampler2D uImage;
159
- uniform vec4 uColor;
160
- varying vec2 vTexCoord;
161
- varying vec2 vTexCoord2;
162
- void main() {
163
- vec4 color = texture2D(uTexture, vTexCoord);
164
- vec4 color2 = texture2D(uImage, vTexCoord2);
165
- color.rgba *= color2.rgba;
166
- gl_FragColor = color;
167
- }
168
- `,mask:`
169
- precision highp float;
170
- uniform sampler2D uTexture;
171
- uniform sampler2D uImage;
172
- uniform vec4 uColor;
173
- varying vec2 vTexCoord;
174
- varying vec2 vTexCoord2;
175
- void main() {
176
- vec4 color = texture2D(uTexture, vTexCoord);
177
- vec4 color2 = texture2D(uImage, vTexCoord2);
178
- color.a = color2.a;
179
- gl_FragColor = color;
180
- }
181
- `},rC=["type","image"];class fo extends Oe{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return tC[this.mode]}getVertexSource(){return`
182
- attribute vec2 aPosition;
183
- varying vec2 vTexCoord;
184
- varying vec2 vTexCoord2;
185
- uniform mat3 uTransformMatrix;
186
- void main() {
187
- vTexCoord = aPosition;
188
- vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
189
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
190
- }
191
- `}applyToWebGL(e){const t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),super.applyToWebGL(e),this.unbindAdditionalTexture(t,t.TEXTURE1)}createTexture(e,t){return e.getCachedTexture(t.cacheKey,t.getElement())}calculateMatrix(){const e=this.image,{width:t,height:n}=e.getElement();return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]}applyTo2d(e){let{imageData:{data:t,width:n,height:s},filterBackend:{resources:i}}=e;const o=this.image;i.blendImage||(i.blendImage=_r());const a=i.blendImage,l=a.getContext("2d");a.width!==n||a.height!==s?(a.width=n,a.height=s):l.clearRect(0,0,n,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,n,s);const c=l.getImageData(0,0,n,s).data;for(let u=0;u<t.length;u+=4){const h=t[u],d=t[u+1],f=t[u+2],m=t[u+3],v=c[u],x=c[u+1],g=c[u+2],p=c[u+3];switch(this.mode){case"multiply":t[u]=h*v/255,t[u+1]=d*x/255,t[u+2]=f*g/255,t[u+3]=m*p/255;break;case"mask":t[u+3]=p}}}sendUniformData(e,t){const n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)}toObject(){return E(E({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(e,t){let{type:n,image:s}=e,i=de(e,rC);return mt.fromObject(s,t).then(o=>new this(E(E({},i),{},{image:o})))}}_(fo,"type","BlendImage"),_(fo,"defaults",{mode:"multiply",alpha:1}),_(fo,"uniformLocations",["uTransformMatrix","uImage"]),V.setClass(fo);class go extends Oe{getFragmentSource(){return`
192
- precision highp float;
193
- uniform sampler2D uTexture;
194
- uniform vec2 uDelta;
195
- varying vec2 vTexCoord;
196
- const float nSamples = 15.0;
197
- vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
198
- float random(vec3 scale) {
199
- /* use the fragment position for a different seed per-pixel */
200
- return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
201
- }
202
- void main() {
203
- vec4 color = vec4(0.0);
204
- float totalC = 0.0;
205
- float totalA = 0.0;
206
- float offset = random(v3offset);
207
- for (float t = -nSamples; t <= nSamples; t++) {
208
- float percent = (t + offset - 0.5) / nSamples;
209
- vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
210
- float weight = 1.0 - abs(percent);
211
- float alpha = weight * sample.a;
212
- color.rgb += sample.rgb * alpha;
213
- color.a += alpha;
214
- totalA += weight;
215
- totalC += alpha;
216
- }
217
- gl_FragColor.rgb = color.rgb / totalC;
218
- gl_FragColor.a = color.a / totalA;
219
- }
220
- `}applyTo(e){Sl(e)?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){let{imageData:{data:t,width:n,height:s}}=e;this.aspectRatio=n/s,this.horizontal=!0;let i=this.getBlurValue()*n;const o=new Uint8ClampedArray(t),a=15,l=4*n;for(let c=0;c<t.length;c+=4){let u=0,h=0,d=0,f=0,m=0;const v=c-c%l,x=v+l;for(let g=-14;g<a;g++){const p=g/a,y=4*Math.floor(i*p),b=1-Math.abs(p);let O=c+y;O<v?O=v:O>x&&(O=x);const S=t[O+3]*b;u+=t[O]*S,h+=t[O+1]*S,d+=t[O+2]*S,f+=S,m+=b}o[c]=u/f,o[c+1]=h/f,o[c+2]=d/f,o[c+3]=f/m}this.horizontal=!1,i=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let u=0,h=0,d=0,f=0,m=0;const v=c%l,x=o.length-l+v;for(let g=-14;g<a;g++){const p=g/a,y=Math.floor(i*p)*l,b=1-Math.abs(p);let O=c+y;O<v?O=v:O>x&&(O=x);const S=o[O+3]*b;u+=o[O]*S,h+=o[O+1]*S,d+=o[O+2]*S,f+=S,m+=b}t[c]=u/f,t[c+1]=h/f,t[c+2]=d/f,t[c+3]=f/m}}sendUniformData(e,t){const n=this.chooseRightDelta();e.uniform2fv(t.uDelta,n)}isNeutralState(){return this.blur===0}getBlurValue(){let e=1;const{horizontal:t,aspectRatio:n}=this;return t?n>1&&(e=1/n):n<1&&(e=n),e*this.blur*.12}chooseRightDelta(){const e=this.getBlurValue();return this.horizontal?[e,0]:[0,e]}}_(go,"type","Blur"),_(go,"defaults",{blur:0}),_(go,"uniformLocations",["uDelta"]),V.setClass(go);class po extends Oe{getFragmentSource(){return`
221
- precision highp float;
222
- uniform sampler2D uTexture;
223
- uniform float uBrightness;
224
- varying vec2 vTexCoord;
225
- void main() {
226
- vec4 color = texture2D(uTexture, vTexCoord);
227
- color.rgb += uBrightness;
228
- gl_FragColor = color;
229
- }
230
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=Math.round(255*this.brightness);for(let s=0;s<t.length;s+=4)t[s]+=n,t[s+1]+=n,t[s+2]+=n}isNeutralState(){return this.brightness===0}sendUniformData(e,t){e.uniform1f(t.uBrightness,this.brightness)}}_(po,"type","Brightness"),_(po,"defaults",{brightness:0}),_(po,"uniformLocations",["uBrightness"]),V.setClass(po);const dy={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Gn extends Oe{getFragmentSource(){return`
231
- precision highp float;
232
- uniform sampler2D uTexture;
233
- varying vec2 vTexCoord;
234
- uniform mat4 uColorMatrix;
235
- uniform vec4 uConstants;
236
- void main() {
237
- vec4 color = texture2D(uTexture, vTexCoord);
238
- color *= uColorMatrix;
239
- color += uConstants;
240
- gl_FragColor = color;
241
- }`}applyTo2d(e){const t=e.imageData.data,n=this.matrix,s=this.colorsOnly;for(let i=0;i<t.length;i+=4){const o=t[i],a=t[i+1],l=t[i+2];if(t[i]=o*n[0]+a*n[1]+l*n[2]+255*n[4],t[i+1]=o*n[5]+a*n[6]+l*n[7]+255*n[9],t[i+2]=o*n[10]+a*n[11]+l*n[12]+255*n[14],!s){const c=t[i+3];t[i]+=c*n[3],t[i+1]+=c*n[8],t[i+2]+=c*n[13],t[i+3]=o*n[15]+a*n[16]+l*n[17]+c*n[18]+255*n[19]}}}sendUniformData(e,t){const n=this.matrix,s=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,s),e.uniform4fv(t.uConstants,i)}toObject(){return E(E({},super.toObject()),{},{matrix:[...this.matrix]})}}function On(r,e){var t;const n=(_(t=class extends Gn{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",r),_(t,"defaults",{colorsOnly:!1,matrix:e}),t);return V.setClass(n,r),n}_(Gn,"type","ColorMatrix"),_(Gn,"defaults",dy),_(Gn,"uniformLocations",["uColorMatrix","uConstants"]),V.setClass(Gn);On("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);On("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);On("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);On("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);On("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);On("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);On("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class xg extends Oe{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(e),this.subFilters=e.subFilters||[]}applyTo(e){Sl(e)&&(e.passes+=this.subFilters.length-1),this.subFilters.forEach(t=>{t.applyTo(e)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(e=>e.toObject())}}isNeutralState(){return!this.subFilters.some(e=>!e.isNeutralState())}static fromObject(e,t){return Promise.all((e.subFilters||[]).map(n=>V.getClass(n.type).fromObject(n,t))).then(n=>new this({subFilters:n}))}}_(xg,"type","Composed"),V.setClass(xg);class mo extends Oe{getFragmentSource(){return`
242
- precision highp float;
243
- uniform sampler2D uTexture;
244
- uniform float uContrast;
245
- varying vec2 vTexCoord;
246
- void main() {
247
- vec4 color = texture2D(uTexture, vTexCoord);
248
- float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
249
- color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
250
- gl_FragColor = color;
251
- }`}isNeutralState(){return this.contrast===0}applyTo2d(e){let{imageData:{data:t}}=e;const n=Math.floor(255*this.contrast),s=259*(n+255)/(255*(259-n));for(let i=0;i<t.length;i+=4)t[i]=s*(t[i]-128)+128,t[i+1]=s*(t[i+1]-128)+128,t[i+2]=s*(t[i+2]-128)+128}sendUniformData(e,t){e.uniform1f(t.uContrast,this.contrast)}}_(mo,"type","Contrast"),_(mo,"defaults",{contrast:0}),_(mo,"uniformLocations",["uContrast"]),V.setClass(mo);const nC={Convolute_3_1:`
252
- precision highp float;
253
- uniform sampler2D uTexture;
254
- uniform float uMatrix[9];
255
- uniform float uStepW;
256
- uniform float uStepH;
257
- varying vec2 vTexCoord;
258
- void main() {
259
- vec4 color = vec4(0, 0, 0, 0);
260
- for (float h = 0.0; h < 3.0; h+=1.0) {
261
- for (float w = 0.0; w < 3.0; w+=1.0) {
262
- vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
263
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
264
- }
265
- }
266
- gl_FragColor = color;
267
- }
268
- `,Convolute_3_0:`
269
- precision highp float;
270
- uniform sampler2D uTexture;
271
- uniform float uMatrix[9];
272
- uniform float uStepW;
273
- uniform float uStepH;
274
- varying vec2 vTexCoord;
275
- void main() {
276
- vec4 color = vec4(0, 0, 0, 1);
277
- for (float h = 0.0; h < 3.0; h+=1.0) {
278
- for (float w = 0.0; w < 3.0; w+=1.0) {
279
- vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
280
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
281
- }
282
- }
283
- float alpha = texture2D(uTexture, vTexCoord).a;
284
- gl_FragColor = color;
285
- gl_FragColor.a = alpha;
286
- }
287
- `,Convolute_5_1:`
288
- precision highp float;
289
- uniform sampler2D uTexture;
290
- uniform float uMatrix[25];
291
- uniform float uStepW;
292
- uniform float uStepH;
293
- varying vec2 vTexCoord;
294
- void main() {
295
- vec4 color = vec4(0, 0, 0, 0);
296
- for (float h = 0.0; h < 5.0; h+=1.0) {
297
- for (float w = 0.0; w < 5.0; w+=1.0) {
298
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
299
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
300
- }
301
- }
302
- gl_FragColor = color;
303
- }
304
- `,Convolute_5_0:`
305
- precision highp float;
306
- uniform sampler2D uTexture;
307
- uniform float uMatrix[25];
308
- uniform float uStepW;
309
- uniform float uStepH;
310
- varying vec2 vTexCoord;
311
- void main() {
312
- vec4 color = vec4(0, 0, 0, 1);
313
- for (float h = 0.0; h < 5.0; h+=1.0) {
314
- for (float w = 0.0; w < 5.0; w+=1.0) {
315
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
316
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
317
- }
318
- }
319
- float alpha = texture2D(uTexture, vTexCoord).a;
320
- gl_FragColor = color;
321
- gl_FragColor.a = alpha;
322
- }
323
- `,Convolute_7_1:`
324
- precision highp float;
325
- uniform sampler2D uTexture;
326
- uniform float uMatrix[49];
327
- uniform float uStepW;
328
- uniform float uStepH;
329
- varying vec2 vTexCoord;
330
- void main() {
331
- vec4 color = vec4(0, 0, 0, 0);
332
- for (float h = 0.0; h < 7.0; h+=1.0) {
333
- for (float w = 0.0; w < 7.0; w+=1.0) {
334
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
335
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
336
- }
337
- }
338
- gl_FragColor = color;
339
- }
340
- `,Convolute_7_0:`
341
- precision highp float;
342
- uniform sampler2D uTexture;
343
- uniform float uMatrix[49];
344
- uniform float uStepW;
345
- uniform float uStepH;
346
- varying vec2 vTexCoord;
347
- void main() {
348
- vec4 color = vec4(0, 0, 0, 1);
349
- for (float h = 0.0; h < 7.0; h+=1.0) {
350
- for (float w = 0.0; w < 7.0; w+=1.0) {
351
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
352
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
353
- }
354
- }
355
- float alpha = texture2D(uTexture, vTexCoord).a;
356
- gl_FragColor = color;
357
- gl_FragColor.a = alpha;
358
- }
359
- `,Convolute_9_1:`
360
- precision highp float;
361
- uniform sampler2D uTexture;
362
- uniform float uMatrix[81];
363
- uniform float uStepW;
364
- uniform float uStepH;
365
- varying vec2 vTexCoord;
366
- void main() {
367
- vec4 color = vec4(0, 0, 0, 0);
368
- for (float h = 0.0; h < 9.0; h+=1.0) {
369
- for (float w = 0.0; w < 9.0; w+=1.0) {
370
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
371
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
372
- }
373
- }
374
- gl_FragColor = color;
375
- }
376
- `,Convolute_9_0:`
377
- precision highp float;
378
- uniform sampler2D uTexture;
379
- uniform float uMatrix[81];
380
- uniform float uStepW;
381
- uniform float uStepH;
382
- varying vec2 vTexCoord;
383
- void main() {
384
- vec4 color = vec4(0, 0, 0, 1);
385
- for (float h = 0.0; h < 9.0; h+=1.0) {
386
- for (float w = 0.0; w < 9.0; w+=1.0) {
387
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
388
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
389
- }
390
- }
391
- float alpha = texture2D(uTexture, vTexCoord).a;
392
- gl_FragColor = color;
393
- gl_FragColor.a = alpha;
394
- }
395
- `};class vo extends Oe{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return nC[this.getCacheKey()]}applyTo2d(e){const t=e.imageData,n=t.data,s=this.matrix,i=Math.round(Math.sqrt(s.length)),o=Math.floor(i/2),a=t.width,l=t.height,c=e.ctx.createImageData(a,l),u=c.data,h=this.opaque?1:0;let d,f,m,v,x,g,p,y,b,O,S,T,C;for(S=0;S<l;S++)for(O=0;O<a;O++){for(x=4*(S*a+O),d=0,f=0,m=0,v=0,C=0;C<i;C++)for(T=0;T<i;T++)p=S+C-o,g=O+T-o,p<0||p>=l||g<0||g>=a||(y=4*(p*a+g),b=s[C*i+T],d+=n[y]*b,f+=n[y+1]*b,m+=n[y+2]*b,h||(v+=n[y+3]*b));u[x]=d,u[x+1]=f,u[x+2]=m,u[x+3]=h?n[x+3]:v}e.imageData=c}sendUniformData(e,t){e.uniform1fv(t.uMatrix,this.matrix)}toObject(){return E(E({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}_(vo,"type","Convolute"),_(vo,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),_(vo,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),V.setClass(vo);const fy="Gamma";class yo extends Oe{getFragmentSource(){return`
396
- precision highp float;
397
- uniform sampler2D uTexture;
398
- uniform vec3 uGamma;
399
- varying vec2 vTexCoord;
400
- void main() {
401
- vec4 color = texture2D(uTexture, vTexCoord);
402
- vec3 correction = (1.0 / uGamma);
403
- color.r = pow(color.r, correction.r);
404
- color.g = pow(color.g, correction.g);
405
- color.b = pow(color.b, correction.b);
406
- gl_FragColor = color;
407
- gl_FragColor.rgb *= color.a;
408
- }
409
- `}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(e),this.gamma=e.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(e){let{imageData:{data:t}}=e;const n=this.gamma,s=1/n[0],i=1/n[1],o=1/n[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,i),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<t.length;l+=4)t[l]=a.r[t[l]],t[l+1]=a.g[t[l+1]],t[l+2]=a.b[t[l+2]]}sendUniformData(e,t){e.uniform3fv(t.uGamma,this.gamma)}isNeutralState(){const{gamma:e}=this;return e[0]===1&&e[1]===1&&e[2]===1}toObject(){return{type:fy,gamma:this.gamma.concat()}}}_(yo,"type",fy),_(yo,"defaults",{gamma:[1,1,1]}),_(yo,"uniformLocations",["uGamma"]),V.setClass(yo);const sC={average:`
410
- precision highp float;
411
- uniform sampler2D uTexture;
412
- varying vec2 vTexCoord;
413
- void main() {
414
- vec4 color = texture2D(uTexture, vTexCoord);
415
- float average = (color.r + color.b + color.g) / 3.0;
416
- gl_FragColor = vec4(average, average, average, color.a);
417
- }
418
- `,lightness:`
419
- precision highp float;
420
- uniform sampler2D uTexture;
421
- uniform int uMode;
422
- varying vec2 vTexCoord;
423
- void main() {
424
- vec4 col = texture2D(uTexture, vTexCoord);
425
- float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
426
- gl_FragColor = vec4(average, average, average, col.a);
427
- }
428
- `,luminosity:`
429
- precision highp float;
430
- uniform sampler2D uTexture;
431
- uniform int uMode;
432
- varying vec2 vTexCoord;
433
- void main() {
434
- vec4 col = texture2D(uTexture, vTexCoord);
435
- float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
436
- gl_FragColor = vec4(average, average, average, col.a);
437
- }
438
- `};class xo extends Oe{applyTo2d(e){let{imageData:{data:t}}=e;for(let n,s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2];switch(this.mode){case"average":n=(i+o+a)/3;break;case"lightness":n=(Math.min(i,o,a)+Math.max(i,o,a))/2;break;case"luminosity":n=.21*i+.72*o+.07*a}t[s+2]=t[s+1]=t[s]=n}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return sC[this.mode]}sendUniformData(e,t){e.uniform1i(t.uMode,1)}isNeutralState(){return!1}}_(xo,"type","Grayscale"),_(xo,"defaults",{mode:"average"}),_(xo,"uniformLocations",["uMode"]),V.setClass(xo);const iC=E(E({},dy),{},{rotation:0});class gc extends Gn{calculateMatrix(){const e=this.rotation*Math.PI,t=Sr(e),n=br(e),s=1/3,i=Math.sqrt(s)*n,o=1-t;this.matrix=[t+o/3,s*o-i,s*o+i,0,0,s*o+i,t+s*o,s*o-i,0,0,s*o-i,s*o+i,t+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(e){this.calculateMatrix(),super.applyTo(e)}toObject(){return{type:this.type,rotation:this.rotation}}}_(gc,"type","HueRotation"),_(gc,"defaults",iC),V.setClass(gc);class wo extends Oe{applyTo2d(e){let{imageData:{data:t}}=e;for(let n=0;n<t.length;n+=4)t[n]=255-t[n],t[n+1]=255-t[n+1],t[n+2]=255-t[n+2],this.alpha&&(t[n+3]=255-t[n+3])}getFragmentSource(){return`
439
- precision highp float;
440
- uniform sampler2D uTexture;
441
- uniform int uInvert;
442
- uniform int uAlpha;
443
- varying vec2 vTexCoord;
444
- void main() {
445
- vec4 color = texture2D(uTexture, vTexCoord);
446
- if (uInvert == 1) {
447
- if (uAlpha == 1) {
448
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
449
- } else {
450
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
451
- }
452
- } else {
453
- gl_FragColor = color;
454
- }
455
- }
456
- `}isNeutralState(){return!this.invert}sendUniformData(e,t){e.uniform1i(t.uInvert,Number(this.invert)),e.uniform1i(t.uAlpha,Number(this.alpha))}}_(wo,"type","Invert"),_(wo,"defaults",{alpha:!1,invert:!0}),_(wo,"uniformLocations",["uInvert","uAlpha"]),V.setClass(wo);class So extends Oe{getFragmentSource(){return`
457
- precision highp float;
458
- uniform sampler2D uTexture;
459
- uniform float uStepH;
460
- uniform float uNoise;
461
- uniform float uSeed;
462
- varying vec2 vTexCoord;
463
- float rand(vec2 co, float seed, float vScale) {
464
- return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
465
- }
466
- void main() {
467
- vec4 color = texture2D(uTexture, vTexCoord);
468
- color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
469
- gl_FragColor = color;
470
- }
471
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=this.noise;for(let s=0;s<t.length;s+=4){const i=(.5-Math.random())*n;t[s]+=i,t[s+1]+=i,t[s+2]+=i}}sendUniformData(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())}isNeutralState(){return this.noise===0}}_(So,"type","Noise"),_(So,"defaults",{noise:0}),_(So,"uniformLocations",["uNoise","uSeed"]),V.setClass(So);class bo extends Oe{applyTo2d(e){let{imageData:{data:t,width:n,height:s}}=e;for(let i=0;i<s;i+=this.blocksize)for(let o=0;o<n;o+=this.blocksize){const a=4*i*n+4*o,l=t[a],c=t[a+1],u=t[a+2],h=t[a+3];for(let d=i;d<Math.min(i+this.blocksize,s);d++)for(let f=o;f<Math.min(o+this.blocksize,n);f++){const m=4*d*n+4*f;t[m]=l,t[m+1]=c,t[m+2]=u,t[m+3]=h}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
472
- precision highp float;
473
- uniform sampler2D uTexture;
474
- uniform float uBlocksize;
475
- uniform float uStepW;
476
- uniform float uStepH;
477
- varying vec2 vTexCoord;
478
- void main() {
479
- float blockW = uBlocksize * uStepW;
480
- float blockH = uBlocksize * uStepH;
481
- int posX = int(vTexCoord.x / blockW);
482
- int posY = int(vTexCoord.y / blockH);
483
- float fposX = float(posX);
484
- float fposY = float(posY);
485
- vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
486
- vec4 color = texture2D(uTexture, squareCoords);
487
- gl_FragColor = color;
488
- }
489
- `}sendUniformData(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}}_(bo,"type","Pixelate"),_(bo,"defaults",{blocksize:4}),_(bo,"uniformLocations",["uBlocksize"]),V.setClass(bo);class _o extends Oe{getFragmentSource(){return`
490
- precision highp float;
491
- uniform sampler2D uTexture;
492
- uniform vec4 uLow;
493
- uniform vec4 uHigh;
494
- varying vec2 vTexCoord;
495
- void main() {
496
- gl_FragColor = texture2D(uTexture, vTexCoord);
497
- if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
498
- gl_FragColor.a = 0.0;
499
- }
500
- }
501
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=255*this.distance,s=new ne(this.color).getSource(),i=[s[0]-n,s[1]-n,s[2]-n],o=[s[0]+n,s[1]+n,s[2]+n];for(let a=0;a<t.length;a+=4){const l=t[a],c=t[a+1],u=t[a+2];l>i[0]&&c>i[1]&&u>i[2]&&l<o[0]&&c<o[1]&&u<o[2]&&(t[a+3]=0)}}sendUniformData(e,t){const n=new ne(this.color).getSource(),s=this.distance,i=[0+n[0]/255-s,0+n[1]/255-s,0+n[2]/255-s,1],o=[n[0]/255+s,n[1]/255+s,n[2]/255+s,1];e.uniform4fv(t.uLow,i),e.uniform4fv(t.uHigh,o)}}_(_o,"type","RemoveColor"),_(_o,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),_(_o,"uniformLocations",["uLow","uHigh"]),V.setClass(_o);class Co extends Oe{sendUniformData(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)}getFilterWindow(){const e=this.tempScale;return Math.ceil(this.lanczosLobes/e)}getCacheKey(){const e=this.getFilterWindow();return"".concat(this.type,"_").concat(e)}getFragmentSource(){const e=this.getFilterWindow();return this.generateShader(e)}getTaps(){const e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),s=new Array(n);for(let i=1;i<=n;i++)s[i-1]=e(i*t);return s}generateShader(e){const t=new Array(e);for(let n=1;n<=e;n++)t[n-1]="".concat(n,".0 * uDelta");return`
502
- precision highp float;
503
- uniform sampler2D uTexture;
504
- uniform vec2 uDelta;
505
- varying vec2 vTexCoord;
506
- uniform float uTaps[`.concat(e,`];
507
- void main() {
508
- vec4 color = texture2D(uTexture, vTexCoord);
509
- float sum = 1.0;
510
- `).concat(t.map((n,s)=>`
511
- color += texture2D(uTexture, vTexCoord + `.concat(n,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(n,") * uTaps[").concat(s,`];
512
- sum += 2.0 * uTaps[`).concat(s,`];
513
- `)).join(`
514
- `),`
515
- gl_FragColor = color / sum;
516
- }
517
- `)}applyToForWebgl(e){e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,super.applyTo(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,super.applyTo(e),e.sourceHeight=e.destinationHeight}applyTo(e){Sl(e)?this.applyToForWebgl(e):this.applyTo2d(e)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(e){return t=>{if(t>=e||t<=-e)return 0;if(t<11920929e-14&&t>-11920929e-14)return 1;const n=(t*=Math.PI)/e;return Math.sin(t)/t*Math.sin(n)/n}}applyTo2d(e){const t=e.imageData,n=this.scaleX,s=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/s;const i=t.width,o=t.height,a=Math.round(i*n),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(e,i,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(e,i,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(e,i,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(e,i,o,a,l):new ImageData(a,l),e.imageData=c}sliceByTwo(e,t,n,s,i){const o=e.imageData,a=.5;let l=!1,c=!1,u=t*a,h=n*a;const d=e.filterBackend.resources;let f=0,m=0;const v=t;let x=0;d.sliceByTwo||(d.sliceByTwo=_r());const g=d.sliceByTwo;(g.width<1.5*t||g.height<n)&&(g.width=1.5*t,g.height=n);const p=g.getContext("2d");for(p.clearRect(0,0,1.5*t,n),p.putImageData(o,0,0),s=Math.floor(s),i=Math.floor(i);!l||!c;)t=u,n=h,s<Math.floor(u*a)?u=Math.floor(u*a):(u=s,l=!0),i<Math.floor(h*a)?h=Math.floor(h*a):(h=i,c=!0),p.drawImage(g,f,m,t,n,v,x,u,h),f=v,m=x,x+=h;return p.getImageData(f,m,s,i)}lanczosResize(e,t,n,s,i){const o=e.imageData.data,a=e.ctx.createImageData(s,i),l=a.data,c=this.lanczosCreate(this.lanczosLobes),u=this.rcpScaleX,h=this.rcpScaleY,d=2/this.rcpScaleX,f=2/this.rcpScaleY,m=Math.ceil(u*this.lanczosLobes/2),v=Math.ceil(h*this.lanczosLobes/2),x={},g={x:0,y:0},p={x:0,y:0};return function y(b){let O,S,T,C,P,j,R,I,U,A,G;for(g.x=(b+.5)*u,p.x=Math.floor(g.x),O=0;O<i;O++){for(g.y=(O+.5)*h,p.y=Math.floor(g.y),P=0,j=0,R=0,I=0,U=0,S=p.x-m;S<=p.x+m;S++)if(!(S<0||S>=t)){A=Math.floor(1e3*Math.abs(S-g.x)),x[A]||(x[A]={});for(let Y=p.y-v;Y<=p.y+v;Y++)Y<0||Y>=n||(G=Math.floor(1e3*Math.abs(Y-g.y)),x[A][G]||(x[A][G]=c(Math.sqrt(Math.pow(A*d,2)+Math.pow(G*f,2))/1e3)),T=x[A][G],T>0&&(C=4*(Y*t+S),P+=T,j+=T*o[C],R+=T*o[C+1],I+=T*o[C+2],U+=T*o[C+3]))}C=4*(O*s+b),l[C]=j/P,l[C+1]=R/P,l[C+2]=I/P,l[C+3]=U/P}return++b<s?y(b):a}(0)}bilinearFiltering(e,t,n,s,i){let o,a,l,c,u,h,d,f,m,v,x,g,p,y=0;const b=this.rcpScaleX,O=this.rcpScaleY,S=4*(t-1),T=e.imageData.data,C=e.ctx.createImageData(s,i),P=C.data;for(d=0;d<i;d++)for(f=0;f<s;f++)for(u=Math.floor(b*f),h=Math.floor(O*d),m=b*f-u,v=O*d-h,p=4*(h*t+u),x=0;x<4;x++)o=T[p+x],a=T[p+4+x],l=T[p+S+x],c=T[p+S+4+x],g=o*(1-m)*(1-v)+a*m*(1-v)+l*v*(1-m)+c*m*v,P[y++]=g;return C}hermiteFastResize(e,t,n,s,i){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),u=e.imageData.data,h=e.ctx.createImageData(s,i),d=h.data;for(let f=0;f<i;f++)for(let m=0;m<s;m++){const v=4*(m+f*s);let x=0,g=0,p=0,y=0,b=0,O=0,S=0;const T=(f+.5)*a;for(let C=Math.floor(f*a);C<(f+1)*a;C++){const P=Math.abs(T-(C+.5))/c,j=(m+.5)*o,R=P*P;for(let I=Math.floor(m*o);I<(m+1)*o;I++){let U=Math.abs(j-(I+.5))/l;const A=Math.sqrt(R+U*U);A>1&&A<-1||(x=2*A*A*A-3*A*A+1,x>0&&(U=4*(I+C*t),S+=x*u[U+3],p+=x,u[U+3]<255&&(x=x*u[U+3]/250),y+=x*u[U],b+=x*u[U+1],O+=x*u[U+2],g+=x))}}d[v]=y/g,d[v+1]=b/g,d[v+2]=O/g,d[v+3]=S/p}return h}}_(Co,"type","Resize"),_(Co,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),_(Co,"uniformLocations",["uDelta","uTaps"]),V.setClass(Co);class To extends Oe{getFragmentSource(){return`
518
- precision highp float;
519
- uniform sampler2D uTexture;
520
- uniform float uSaturation;
521
- varying vec2 vTexCoord;
522
- void main() {
523
- vec4 color = texture2D(uTexture, vTexCoord);
524
- float rgMax = max(color.r, color.g);
525
- float rgbMax = max(rgMax, color.b);
526
- color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
527
- color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
528
- color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
529
- gl_FragColor = color;
530
- }
531
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=-this.saturation;for(let s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2],l=Math.max(i,o,a);t[s]+=l!==i?(l-i)*n:0,t[s+1]+=l!==o?(l-o)*n:0,t[s+2]+=l!==a?(l-a)*n:0}}sendUniformData(e,t){e.uniform1f(t.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}_(To,"type","Saturation"),_(To,"defaults",{saturation:0}),_(To,"uniformLocations",["uSaturation"]),V.setClass(To);class ko extends Oe{getFragmentSource(){return`
532
- precision highp float;
533
- uniform sampler2D uTexture;
534
- uniform float uVibrance;
535
- varying vec2 vTexCoord;
536
- void main() {
537
- vec4 color = texture2D(uTexture, vTexCoord);
538
- float max = max(color.r, max(color.g, color.b));
539
- float avg = (color.r + color.g + color.b) / 3.0;
540
- float amt = (abs(max - avg) * 2.0) * uVibrance;
541
- color.r += max != color.r ? (max - color.r) * amt : 0.00;
542
- color.g += max != color.g ? (max - color.g) * amt : 0.00;
543
- color.b += max != color.b ? (max - color.b) * amt : 0.00;
544
- gl_FragColor = color;
545
- }
546
- `}applyTo2d(e){let{imageData:{data:t}}=e;const n=-this.vibrance;for(let s=0;s<t.length;s+=4){const i=t[s],o=t[s+1],a=t[s+2],l=Math.max(i,o,a),c=(i+o+a)/3,u=2*Math.abs(l-c)/255*n;t[s]+=l!==i?(l-i)*u:0,t[s+1]+=l!==o?(l-o)*u:0,t[s+2]+=l!==a?(l-a)*u:0}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}_(ko,"type","Vibrance"),_(ko,"defaults",{vibrance:0}),_(ko,"uniformLocations",["uVibrance"]),V.setClass(ko);function oC({onSubmit:r}){const e=D.useRef(null),t=D.useRef(null),n=D.useRef(null),[s,i]=D.useState("freehand"),[o,a]=D.useState("#3B82F6"),[l,c]=D.useState("#000000"),[u,h]=D.useState([]),[d,f]=D.useState([]),m=D.useRef(null),v=D.useRef(!1);D.useEffect(()=>{if(!e.current||t.current)return;const S=new Eu(e.current,{backgroundColor:"#ffffff",selection:!0});t.current=S;const T=()=>{if(!n.current)return;const{width:P,height:j}=n.current.getBoundingClientRect();S.setDimensions({width:P,height:j})};T();const C=new ResizeObserver(T);return n.current&&C.observe(n.current),h([JSON.stringify(S.toJSON())]),()=>{C.disconnect(),S.dispose(),t.current=null}},[]);const x=D.useCallback(()=>{const S=t.current;if(!S)return;const T=JSON.stringify(S.toJSON());h(C=>[...C,T]),f([])},[]);D.useEffect(()=>{const S=t.current;if(S){if(S.isDrawingMode=!1,S.selection=!0,S.defaultCursor="default",S.getObjects().forEach(T=>{T.evented=!0,T.selectable=!0,T.hasControls=!0,T.hasBorders=!0,T.setCoords()}),S.requestRenderAll(),S.off("mouse:down"),S.off("mouse:move"),S.off("mouse:up"),s==="freehand"){S.isDrawingMode=!0;const T=new za(S);T.color=l,T.width=2,S.freeDrawingBrush=T,S.on("path:created",()=>x())}else if(s==="eraser"){S.selection=!1;const T='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23555" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4-4 9.5-9.5 5.5 5.5L7 21Z"/><path d="M22 21H7"/><path d="m11.5 12.5 5.5 5.5"/></svg>';S.defaultCursor=`url("data:image/svg+xml,${T}") 4 18, auto`,S.on("mouse:down",C=>{const P=S.findTarget(C.e);P&&(S.remove(P),x())})}else if(s!=="select"){if(s==="text")S.selection=!1,S.defaultCursor="text",S.on("mouse:down",T=>{if(v.current)return;const C=S.getScenePoint(T.e),P=new Br("Text",{left:C.x,top:C.y,fontSize:16,fill:l,width:120});S.add(P),S.setActiveObject(P),P.enterEditing(),P.selectAll(),x()});else if(["rectangle","circle","line","arrow"].includes(s)){S.selection=!1,S.defaultCursor="crosshair",S.getObjects().forEach(C=>{C.evented=!1,C.selectable=!1});let T=null;S.on("mouse:down",C=>{S.getObjects().forEach(j=>{j.evented=!1,j.selectable=!1}),v.current=!0;const P=S.getScenePoint(C.e);m.current={x:P.x,y:P.y},s==="rectangle"?(T=new At({left:P.x,top:P.y,width:0,height:0,fill:o==="transparent"?"transparent":o,stroke:l,strokeWidth:2,selectable:!1}),S.add(T)):s==="circle"?(T=new $t({left:P.x,top:P.y,radius:0,fill:o==="transparent"?"transparent":o,stroke:l,strokeWidth:2,selectable:!1}),S.add(T)):(s==="line"||s==="arrow")&&(T=new Yt([P.x,P.y,P.x,P.y],{stroke:l,strokeWidth:2,selectable:!1}),S.add(T))}),S.on("mouse:move",C=>{if(!m.current||!T)return;const P=S.getScenePoint(C.e),j=m.current;if(s==="rectangle"){const R=Math.min(j.x,P.x),I=Math.min(j.y,P.y);T.set({left:R,top:I,width:Math.abs(P.x-j.x),height:Math.abs(P.y-j.y)})}else if(s==="circle"){const R=Math.abs(P.x-j.x)/2,I=Math.abs(P.y-j.y)/2;T.set({left:Math.min(j.x,P.x),top:Math.min(j.y,P.y),radius:Math.max(R,I)})}else(s==="line"||s==="arrow")&&T.set({x2:P.x,y2:P.y});S.requestRenderAll()}),S.on("mouse:up",()=>{if(T){if(S.discardActiveObject(),s==="arrow"&&m.current){const C=T.x1,P=T.y1,j=T.x2,R=T.y2,I=Math.atan2(R-P,j-C),U=12,A=new Yt([j-U*Math.cos(I-Math.PI/6),R-U*Math.sin(I-Math.PI/6),j,R],{stroke:l,strokeWidth:2,selectable:!1}),G=new Yt([j-U*Math.cos(I+Math.PI/6),R-U*Math.sin(I+Math.PI/6),j,R],{stroke:l,strokeWidth:2,selectable:!1});S.add(A,G)}x()}T=null,m.current=null,v.current=!1})}}}},[s,o,l,x]);const g=D.useCallback(()=>{const S=t.current;if(!S||u.length<=1)return;const T=u[u.length-1],C=u[u.length-2];f(P=>[...P,T]),h(P=>P.slice(0,-1)),S.loadFromJSON(JSON.parse(C)).then(()=>S.requestRenderAll())},[u]),p=D.useCallback(()=>{const S=t.current;if(!S||d.length===0)return;const T=d[d.length-1];f(C=>C.slice(0,-1)),h(C=>[...C,T]),S.loadFromJSON(JSON.parse(T)).then(()=>S.requestRenderAll())},[d]),y=D.useCallback(()=>{const S=t.current;S&&(S.clear(),S.backgroundColor="#ffffff",S.requestRenderAll(),x())},[x]),b=D.useCallback(()=>{const S=t.current;if(!S)return;const T=S.toDataURL({format:"png",multiplier:1});r(T,S.getWidth(),S.getHeight())},[r]),O=D.useCallback(()=>{const S=t.current;if(!S)return;const T=S.getActiveObjects();if(T.length>0){for(const C of T)S.remove(C);S.discardActiveObject(),S.requestRenderAll(),x()}},[x]);return D.useEffect(()=>{const S=T=>{if(T.key==="Delete"||T.key==="Backspace"){const C=t.current;if(C){const P=C.getActiveObject();if(P&&P.type==="textbox"&&P.isEditing)return}O()}(T.metaKey||T.ctrlKey)&&T.key==="z"&&(T.preventDefault(),T.shiftKey?p():g())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[O,g,p]),{canvasElRef:e,containerRef:n,activeTool:s,setActiveTool:i,fillColor:o,setFillColor:a,strokeColor:l,setStrokeColor:c,canUndo:u.length>1,canRedo:d.length>0,handleUndo:g,handleRedo:p,handleClear:y,handleSubmit:b}}const wg=["#000000","#ffffff","#9CA3AF","#EF4444","#F97316","#EAB308","#22C55E","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#6366F1"],aC=()=>w.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("path",{d:"M5 3l14 8-6 2-4 6z"}),w.jsx("path",{d:"M13 13l6 6"})]}),lC=()=>w.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("path",{d:"m7 21-4-4 9.5-9.5 5.5 5.5L7 21Z"}),w.jsx("path",{d:"M22 21H7"}),w.jsx("path",{d:"m11.5 12.5 5.5 5.5"})]}),cC=()=>w.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("polyline",{points:"3 6 5 6 21 6"}),w.jsx("path",{d:"M19 6l-1 14H6L5 6"}),w.jsx("path",{d:"M10 11v6M14 11v6"}),w.jsx("path",{d:"M9 6V4h6v2"})]}),uC=[{id:"select",label:"Select",icon:w.jsx(aC,{})},{id:"freehand",label:"Freehand",icon:"✎"},{id:"rectangle",label:"Rectangle",icon:"□"},{id:"circle",label:"Circle",icon:"○"},{id:"line",label:"Line",icon:"╱"},{id:"arrow",label:"Arrow",icon:"→"},{id:"text",label:"Text",icon:"T"},{id:"eraser",label:"Eraser",icon:w.jsx(lC,{})}];function hC({activeTool:r,onToolChange:e,fillColor:t,onFillChange:n,strokeColor:s,onStrokeChange:i,canUndo:o,canRedo:a,onUndo:l,onRedo:c,onClear:u}){const[h,d]=D.useState(!1),[f,m]=D.useState(!1);return w.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-1 bg-bv-bg border-b border-bv-border text-[10px] shrink-0 flex-wrap",children:[uC.map(v=>w.jsx("button",{title:v.label,onClick:()=>e(v.id),className:`w-7 h-[26px] rounded border flex items-center justify-center text-[13px] cursor-pointer transition-all
547
- ${r===v.id?"bg-bv-teal/10 border-bv-teal text-bv-teal":"bg-transparent border-transparent text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text"}`,children:v.icon},v.id)),w.jsx("div",{className:"w-px h-[18px] bg-bv-border mx-1"}),w.jsx("span",{className:"text-[9px] font-mono text-bv-muted ml-0.5 mr-1",children:"Fill"}),w.jsxs("div",{className:"relative",children:[w.jsx("button",{className:"w-5 h-5 rounded border-2 border-bv-border cursor-pointer transition-all hover:border-bv-teal hover:scale-110",style:{background:t==="transparent"?"repeating-conic-gradient(#ddd 0% 25%, white 0% 50%) 50%/8px 8px":t},onClick:()=>{d(!h),m(!1)}}),h&&w.jsxs("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bv-bg border border-bv-border rounded-lg shadow-lg p-2 w-[164px]",children:[w.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted mb-1.5",children:"Fill Color"}),w.jsx("div",{className:"grid grid-cols-6 gap-1 mb-2",children:wg.map(v=>w.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer transition-all hover:scale-110
548
- ${t===v?"ring-2 ring-bv-teal ring-offset-1":"border border-black/10"}`,style:{background:v},onClick:()=>{n(v),d(!1)}},v))}),w.jsxs("div",{className:"pt-1 border-t border-bv-border flex items-center gap-1.5",children:[w.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer border border-bv-border
549
- ${t==="transparent"?"ring-2 ring-bv-teal ring-offset-1":""}`,style:{background:"repeating-conic-gradient(#ddd 0% 25%, white 0% 50%) 50%/8px 8px"},onClick:()=>{n("transparent"),d(!1)}}),w.jsx("span",{className:"text-[9px] text-bv-muted",children:"None"})]})]})]}),w.jsx("span",{className:"text-[9px] font-mono text-bv-muted ml-1.5 mr-1",children:"Stroke"}),w.jsxs("div",{className:"relative",children:[w.jsx("button",{className:"w-5 h-5 rounded border-2 border-bv-border cursor-pointer transition-all hover:border-bv-teal hover:scale-110",style:{background:s},onClick:()=>{m(!f),d(!1)}}),f&&w.jsxs("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bv-bg border border-bv-border rounded-lg shadow-lg p-2 w-[164px]",children:[w.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-bv-muted mb-1.5",children:"Stroke Color"}),w.jsx("div",{className:"grid grid-cols-6 gap-1",children:wg.map(v=>w.jsx("button",{className:`w-[22px] h-[22px] rounded cursor-pointer transition-all hover:scale-110
550
- ${s===v?"ring-2 ring-bv-teal ring-offset-1":"border border-black/10"}`,style:{background:v},onClick:()=>{i(v),m(!1)}},v))})]})]}),w.jsx("div",{className:"w-px h-[18px] bg-bv-border mx-1"}),w.jsx("button",{title:"Undo",onClick:l,disabled:!o,className:`w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer transition-all
551
- ${o?"text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text":"opacity-35 cursor-default"}`,children:"↶"}),w.jsx("button",{title:"Redo",onClick:c,disabled:!a,className:`w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer transition-all
552
- ${a?"text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text":"opacity-35 cursor-default"}`,children:"↷"}),w.jsx("button",{title:"Clear canvas",onClick:u,className:"w-7 h-[26px] rounded border border-transparent flex items-center justify-center text-[13px] cursor-pointer text-bv-text-mid hover:bg-bv-surface hover:border-bv-border hover:text-bv-text transition-all",children:w.jsx(cC,{})})]})}function dC({onSubmit:r,onClose:e}){return w.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 bg-bv-bg border-t border-bv-border text-[10px] shrink-0",children:[w.jsx("div",{className:"flex gap-1.5",children:e&&w.jsx("button",{onClick:e,className:"px-2.5 py-0.5 rounded border border-bv-border bg-bv-bg text-bv-muted text-[10px] font-medium cursor-pointer hover:bg-bv-orange/10 hover:border-bv-orange hover:text-bv-orange transition-all",children:"✕ Close"})}),w.jsx("button",{onClick:r,className:"px-2.5 py-0.5 rounded border border-bv-teal bg-bv-teal text-white text-[10px] font-medium cursor-pointer hover:bg-bv-teal/80 transition-all",children:"✓ Queue as Change"})]})}function fC({onSubmit:r,onClose:e}){const{canvasElRef:t,containerRef:n,activeTool:s,setActiveTool:i,fillColor:o,setFillColor:a,strokeColor:l,setStrokeColor:c,canUndo:u,canRedo:h,handleUndo:d,handleRedo:f,handleClear:m,handleSubmit:v}=oC({onSubmit:r});return w.jsxs("div",{className:"flex flex-col h-full","data-testid":"design-canvas",children:[w.jsx(hC,{activeTool:s,onToolChange:i,fillColor:o,onFillChange:a,strokeColor:l,onStrokeChange:c,canUndo:u,canRedo:h,onUndo:d,onRedo:f,onClear:m}),w.jsx("div",{ref:n,className:"flex-1 bg-white cursor-crosshair overflow-hidden relative",children:w.jsx("canvas",{ref:t})}),w.jsx(dC,{onSubmit:v,onClose:e})]})}function gC(){const[r,e]=D.useState(null);D.useEffect(()=>{Im(()=>{ur({type:"REGISTER",role:"design"})}),Nm(s=>{s.type==="ELEMENT_CONTEXT"&&e({componentName:s.componentName,instanceCount:s.instanceCount,target:s.target,context:s.context,insertMode:s.insertMode??"after"})}),_h()},[]);const t=(s,i,o)=>{ur({type:"DESIGN_SUBMIT",image:s,componentName:(r==null?void 0:r.componentName)??"",target:(r==null?void 0:r.target)??{tag:"",classes:"",innerText:""},context:(r==null?void 0:r.context)??"",insertMode:(r==null?void 0:r.insertMode)??"after",canvasWidth:i,canvasHeight:o})},n=()=>{ur({type:"DESIGN_CLOSE"})};return w.jsxs("div",{className:"h-screen w-screen flex flex-col",children:[r&&w.jsxs("div",{className:"px-2 py-1 bg-bv-surface border-b border-bv-border text-[10px] font-mono text-bv-muted shrink-0",children:[r.insertMode," <",r.target.tag,".",r.target.classes.split(" ")[0],">"," ","in ",r.componentName]}),w.jsx("div",{className:"flex-1 overflow-hidden",children:w.jsx(fC,{onSubmit:t,onClose:n})})]})}const pC=new URLSearchParams(window.location.search),mC=pC.get("mode"),Sg=[{id:"design",label:"Design"},{id:"message",label:"Message"},{id:"draw",label:"Draw"}];function vC(){return mC==="design"?w.jsx(gC,{}):w.jsx(yC,{})}function yC(){const[r,e]=D.useState(!1),[t,n]=D.useState(null),[s,i]=D.useState("design"),[o,a]=D.useState(!1),l=gS();D.useEffect(()=>{const R=Im(()=>{e(!0);try{const A=localStorage.getItem("tw-panel-container");A&&A!=="popover"&&Pe("overlay",{type:"SWITCH_CONTAINER",container:A})}catch{}}),I=Zx(()=>e(!1)),U=Nm(A=>{A.type==="ELEMENT_SELECTED"?(n({componentName:A.componentName,instanceCount:A.instanceCount,classes:A.classes,tailwindConfig:A.tailwindConfig}),a(!1)):A.type==="SELECT_MODE_CHANGED"?a(!!A.active):A.type==="QUEUE_UPDATE"?l.handleQueueUpdate({draftCount:A.draftCount,committedCount:A.committedCount,implementingCount:A.implementingCount,implementedCount:A.implementedCount,partialCount:A.partialCount,errorCount:A.errorCount,draft:A.draft,commits:A.commits,agentWaiting:A.agentWaiting}):A.type==="PATCH_UPDATE"&&l.handlePatchUpdate({staged:A.staged,committed:A.committed,implementing:A.implementing,implemented:A.implemented,patches:A.patches})});return _h(),e(e1()),()=>{R(),I(),U()}},[]);const{draft:c,committed:u,implementing:h,implemented:d,partial:f,error:m}=l.counts,v=u>0&&!l.agentWaiting&&h===0,x=new Map(l.patches.filter(R=>R.status==="staged").map(R=>[R.id,{id:R.id,kind:R.kind??"class-change",elementKey:R.elementKey,status:R.status,originalClass:R.originalClass,newClass:R.newClass,property:R.property,timestamp:R.timestamp,component:R.component,message:R.message,image:R.image}])),g=new Set(l.queueState.draft.map(R=>R.id)),p=[...l.queueState.draft.map(R=>x.get(R.id)??R),...l.patches.filter(R=>R.status==="staged"&&!g.has(R.id)).map(R=>x.get(R.id))],y=l.queueState.commits.filter(R=>R.status==="committed"),b=l.queueState.commits.filter(R=>R.status==="implementing"),O=l.queueState.commits.filter(R=>R.status==="implemented"),S="Please implement the next change and continue implementing changes with VyBit.";async function T(R){if(navigator.clipboard){try{if((await navigator.permissions.query({name:"clipboard-write"})).state==="denied"){C(R);return}}catch{}navigator.clipboard.writeText(R).catch(()=>C(R))}else C(R)}function C(R){const I=document.createElement("textarea");I.value=R,I.style.position="fixed",I.style.opacity="0",document.body.appendChild(I),I.select(),document.execCommand("copy"),document.body.removeChild(I)}const P=w.jsxs("div",{className:"shrink-0",children:[v&&w.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 bg-amber-50 border-t border-amber-200 text-amber-700 text-[10px] font-medium",children:[w.jsx("svg",{width:"12",height:"12",viewBox:"0 0 20 20",fill:"currentColor",className:"shrink-0 text-amber-500",children:w.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.19-1.458-1.516-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}),w.jsxs("span",{className:"flex-1 leading-tight",children:["No agent watching —"," ",w.jsx("a",{href:"https://github.com/bitovi/vybit?tab=readme-ov-file#telling-your-agent-to-start-making-features",target:"_blank",rel:"noreferrer",className:"underline hover:text-amber-900",children:"ask your agent"})," ","to start"]}),w.jsx("button",{onClick:()=>T(S),className:"shrink-0 px-1.5 py-0.5 rounded border border-amber-300 bg-amber-100 hover:bg-amber-200 text-amber-700 font-semibold text-[9px] transition-colors",title:`Copy: "${S}"`,children:"Copy prompt"})]}),w.jsxs("div",{className:"flex items-center justify-center px-3 py-1.5 border-t border-bv-border gap-2.5",children:[w.jsx(eo,{label:"draft",count:c,items:p,activeColor:"text-bv-text",onDiscard:R=>l.discard(R),onCommitAll:()=>l.commitAll(),onDiscardAll:()=>l.discardAll()}),w.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),w.jsx(eo,{label:"committed",count:u,items:y.flatMap(R=>R.patches),activeColor:"text-bv-orange"}),w.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),w.jsx(eo,{label:"implementing",count:h,items:b.flatMap(R=>R.patches),activeColor:"text-bv-orange"}),w.jsx("span",{className:"text-bv-border text-[11px]",children:"·"}),w.jsx(eo,{label:"implemented",count:d,items:O.flatMap(R=>R.patches),activeColor:"text-bv-teal"})]})]});if(!r)return w.jsxs("div",{className:"h-full flex flex-col",children:[w.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6",children:[w.jsx("div",{className:"w-2 h-2 rounded-full bg-bv-orange animate-pulse"}),w.jsx("span",{className:"text-bv-text-mid text-[12px]",children:"Waiting for connection…"})]}),P]});if(!t)return w.jsxs("div",{className:"h-full flex flex-col",children:[w.jsx("div",{className:"px-3 pt-3 pb-2 border-b border-bv-border",children:w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx(bg,{active:o,onToggle:()=>{const R=!o;a(R),Pe("overlay",{type:"TOGGLE_SELECT_MODE",active:R})}}),w.jsx("div",{className:"flex-1 min-w-0",children:o?w.jsx("span",{className:"text-[11px] text-bv-teal font-medium",children:"● Selecting… click an element on the page"}):w.jsx("span",{className:"text-[12px] text-bv-muted",children:"No element selected"})}),w.jsx(jf,{})]})}),w.jsx(Pf,{tabs:Sg,activeTab:s,onTabChange:i}),w.jsx("div",{className:"flex-1 overflow-auto",children:s==="message"?w.jsx(Mf,{draft:p,currentElementKey:"",onAddMessage:(R,I)=>l.stageMessage(R,I),onDiscard:R=>l.discard(R)}):o?w.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-8",children:[w.jsx("div",{className:"w-10 h-10 rounded-full bg-bv-teal text-white flex items-center justify-center",children:w.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M8 12l2.5 6 1.5-3 3-1.5z"})})}),w.jsx("span",{className:"text-[12px] text-bv-teal font-medium",children:"Selection mode active"}),w.jsxs("span",{className:"text-[10px] text-bv-muted text-center leading-relaxed",children:["Hover over elements on the page to preview, then click to select.",w.jsx("br",{}),"Press ",w.jsx("kbd",{className:"font-mono text-[9px] text-bv-text-mid",children:"Esc"})," to cancel."]})]}):w.jsx("div",{className:"flex flex-1 flex-col items-center justify-center p-8",children:w.jsxs("button",{onClick:()=>{a(!0),Pe("overlay",{type:"TOGGLE_SELECT_MODE",active:!0})},className:"flex flex-col items-center gap-3 px-6 py-5 rounded-lg border border-bv-border bg-bv-surface hover:border-bv-teal hover:bg-bv-teal/5 transition-all cursor-pointer",children:[w.jsx("div",{className:"w-10 h-10 rounded-full bg-bv-teal/10 text-bv-teal flex items-center justify-center",children:w.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M8 12l2.5 6 1.5-3 3-1.5z"})})}),w.jsx("span",{className:"text-[12px] text-bv-text font-medium",children:"Select an element to inspect"}),w.jsxs("span",{className:"text-[10px] text-bv-muted",children:["or press ",w.jsx("kbd",{className:"font-mono text-[9px] text-bv-text-mid font-semibold",children:"⌘⇧C"})]})]})})}),P]});const j=Qx(t.classes);return w.jsxs("div",{className:"h-full flex flex-col",children:[w.jsx("div",{className:"px-3 pt-3 pb-2 border-b border-bv-border",children:w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[w.jsx(bg,{active:o,onToggle:()=>{const R=!o;a(R),Pe("overlay",{type:"TOGGLE_SELECT_MODE",active:R})}}),w.jsxs("div",{className:"font-[family-name:var(--font-display)] font-bold text-[13px] text-bv-text leading-tight truncate",children:[t.componentName," ",w.jsxs("span",{className:"font-[family-name:var(--font-ui)] font-normal text-bv-text-mid",children:["— ",t.instanceCount," instance",t.instanceCount!==1?"s":""]})]})]}),w.jsx(jf,{})]})}),w.jsx(Pf,{tabs:Sg,activeTab:s,onTabChange:i}),w.jsxs("div",{className:"flex-1 overflow-auto",children:[s==="design"&&w.jsx(fS,{componentName:t.componentName,instanceCount:t.instanceCount,parsedClasses:j,tailwindConfig:t.tailwindConfig,patchManager:l}),s==="message"&&w.jsx(Mf,{draft:p,currentElementKey:t.componentName,onAddMessage:(R,I)=>l.stageMessage(R,I,t.componentName),onDiscard:R=>l.discard(R)}),s==="draw"&&w.jsx(mS,{componentName:t.componentName,instanceCount:t.instanceCount})]}),P]})}function bg({active:r,onToggle:e}){return w.jsx("button",{onClick:e,title:`${r?"Stop selecting":"Select an element"} (⌘⇧C)`,className:`w-7 h-7 rounded flex items-center justify-center shrink-0 border transition-all
553
- ${r?"bg-bv-teal border-bv-teal text-white":"bg-transparent border-bv-border text-bv-text-mid hover:border-bv-teal hover:text-bv-teal hover:bg-bv-teal/10"}`,children:w.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),w.jsx("path",{d:"M8 12l2.5 6 1.5-3 3-1.5z"})]})})}pc.createRoot(document.getElementById("root")).render(w.jsx(Rg.StrictMode,{children:w.jsx(vC,{})}));