@arantic/bugpin-widget 0.1.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,157 +1,112 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var Mi=typeof document<"u"?document.currentScript:null,fi,K,ho,me,Us,uo,go,fo,vs,Ni,$i,tr={},po=[],Ua=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,hr=Array.isArray;function te(n,t){for(var e in t)n[e]=t[e];return n}function bs(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function er(n,t,e){var r,i,s,o={};for(s in t)s=="key"?r=t[s]:s=="ref"?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?fi.call(arguments,2):e),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)o[s]===void 0&&(o[s]=n.defaultProps[s]);return Vr(n,o,r,i,null)}function Vr(n,t,e,r,i){var s={type:n,props:t,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ho,__i:-1,__u:0};return i==null&&K.vnode!=null&&K.vnode(s),s}function ur(n){return n.children}function Xr(n,t){this.props=n,this.context=t}function Be(n,t){if(t==null)return n.__?Be(n.__,n.__i+1):null;for(var e;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null)return e.__e;return typeof n.type=="function"?Be(n):null}function mo(n){var t,e;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null){n.__e=n.__c.base=e.__e;break}return mo(n)}}function Gs(n){(!n.__d&&(n.__d=!0)&&me.push(n)&&!Zr.__r++||Us!=K.debounceRendering)&&((Us=K.debounceRendering)||uo)(Zr)}function Zr(){for(var n,t,e,r,i,s,o,a=1;me.length;)me.length>a&&me.sort(go),n=me.shift(),a=me.length,n.__d&&(e=void 0,r=void 0,i=(r=(t=n).__v).__e,s=[],o=[],t.__P&&((e=te({},r)).__v=r.__v+1,K.vnode&&K.vnode(e),ys(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,s,i??Be(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,_o(s,e,o),r.__e=r.__=null,e.__e!=i&&mo(e)));Zr.__r=0}function vo(n,t,e,r,i,s,o,a,l,c,h){var u,d,g,f,m,b,y,w=r&&r.__k||po,O=t.length;for(l=Ga(e,t,w,l,O),u=0;u<O;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?tr:w[g.__i]||tr,g.__i=u,b=ys(n,g,d,i,s,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&_s(d.ref,null,g),h.push(g.ref,g.__c||f,g)),m==null&&f!=null&&(m=f),(y=!!(4&g.__u))||d.__k===g.__k?l=bo(g,l,n,y):typeof g.type=="function"&&b!==void 0?l=b:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=m,l}function Ga(n,t,e,r,i){var s,o,a,l,c,h=e.length,u=h,d=0;for(n.__k=new Array(i),s=0;s<i;s++)(o=t[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=n.__k[s]=Vr(null,o,null,null,null):hr(o)?o=n.__k[s]=Vr(ur,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=n.__k[s]=Vr(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):n.__k[s]=o,l=s+d,o.__=n,o.__b=n.__b+1,a=null,(c=o.__i=Na(o,e,l,u))!=-1&&(u--,(a=e[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(i>h?d--:i<h&&d++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,o.__u|=4))):n.__k[s]=null;if(u)for(s=0;s<h;s++)(a=e[s])!=null&&!(2&a.__u)&&(a.__e==r&&(r=Be(a)),wo(a,a));return r}function bo(n,t,e,r){var i,s;if(typeof n.type=="function"){for(i=n.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=n,t=bo(i[s],t,e,r));return t}n.__e!=t&&(r&&(t&&n.type&&!t.parentNode&&(t=Be(n)),e.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function yo(n,t){return t=t||[],n==null||typeof n=="boolean"||(hr(n)?n.some(function(e){yo(e,t)}):t.push(n)),t}function Na(n,t,e,r){var i,s,o,a=n.key,l=n.type,c=t[e],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return e;if(r>(h?1:0)){for(i=e-1,s=e+1;i>=0||s<t.length;)if((c=t[o=i>=0?i--:s++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function Ns(n,t,e){t[0]=="-"?n.setProperty(t,e??""):n[t]=e==null?"":typeof e!="number"||Ua.test(t)?e:e+"px"}function pr(n,t,e,r,i){var s,o;t:if(t=="style")if(typeof e=="string")n.style.cssText=e;else{if(typeof r=="string"&&(n.style.cssText=r=""),r)for(t in r)e&&t in e||Ns(n.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||Ns(n.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(fo,"$1")),o=t.toLowerCase(),t=o in n||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),n.l||(n.l={}),n.l[t+s]=e,e?r?e.u=r.u:(e.u=vs,n.addEventListener(t,s?$i:Ni,s)):n.removeEventListener(t,s?$i:Ni,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in n)try{n[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?n.removeAttribute(t):n.setAttribute(t,t=="popover"&&e==1?"":e))}}function $s(n){return function(t){if(this.l){var e=this.l[t.type+n];if(t.t==null)t.t=vs++;else if(t.t<e.u)return;return e(K.event?K.event(t):t)}}}function ys(n,t,e,r,i,s,o,a,l,c){var h,u,d,g,f,m,b,y,w,O,k,S,C,A,D,L,R,H=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),s=[a=t.__e=e.__e]),(h=K.__b)&&h(t);t:if(typeof H=="function")try{if(y=t.props,w="prototype"in H&&H.prototype.render,O=(h=H.contextType)&&r[h.__c],k=h?O?O.props.value:h.__:r,e.__c?b=(u=t.__c=e.__c).__=u.__E:(w?t.__c=u=new H(y,k):(t.__c=u=new Xr(y,k),u.constructor=H,u.render=qa),O&&O.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&H.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=te({},u.__s)),te(u.__s,H.getDerivedStateFromProps(y,u.__s))),g=u.props,f=u.state,u.__v=t,d)w&&H.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&H.getDerivedStateFromProps==null&&y!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,k),t.__v==e.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,k)===!1){for(t.__v!=e.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(I){I&&(I.__=t)}),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,k),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,f,m)})}if(u.context=k,u.props=y,u.__P=n,u.__e=!1,C=K.__r,A=0,w){for(u.state=u.__s,u.__d=!1,C&&C(t),h=u.render(u.props,u.state,u.context),D=0;D<u._sb.length;D++)u.__h.push(u._sb[D]);u._sb=[]}else do u.__d=!1,C&&C(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++A<25);u.state=u.__s,u.getChildContext!=null&&(r=te(te({},r),u.getChildContext())),w&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(g,f)),L=h,h!=null&&h.type===ur&&h.key==null&&(L=xo(h.props.children)),a=vo(n,hr(L)?L:[L],t,e,r,i,s,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),b&&(u.__E=u.__=null)}catch(I){if(t.__v=null,l||s!=null)if(I.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else{for(R=s.length;R--;)bs(s[R]);qi(t)}else t.__e=e.__e,t.__k=e.__k,I.then||qi(t);K.__e(I,t,e)}else s==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=$a(e.__e,t,e,r,i,s,o,l,c);return(h=K.diffed)&&h(t),128&t.__u?void 0:a}function qi(n){n&&n.__c&&(n.__c.__e=!0),n&&n.__k&&n.__k.forEach(qi)}function _o(n,t,e){for(var r=0;r<e.length;r++)_s(e[r],e[++r],e[++r]);K.__c&&K.__c(t,n),n.some(function(i){try{n=i.__h,i.__h=[],n.some(function(s){s.call(i)})}catch(s){K.__e(s,i.__v)}})}function xo(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:hr(n)?n.map(xo):te({},n)}function $a(n,t,e,r,i,s,o,a,l){var c,h,u,d,g,f,m,b=e.props||tr,y=t.props,w=t.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((g=s[c])&&"setAttribute"in g==!!w&&(w?g.localName==w:g.nodeType==3)){n=g,s[c]=null;break}}if(n==null){if(w==null)return document.createTextNode(y);n=document.createElementNS(i,w,y.is&&y),a&&(K.__m&&K.__m(t,s),a=!1),s=null}if(w==null)b===y||a&&n.data==y||(n.data=y);else{if(s=s&&fi.call(n.childNodes),!a&&s!=null)for(b={},c=0;c<n.attributes.length;c++)b[(g=n.attributes[c]).name]=g.value;for(c in b)if(g=b[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in y)){if(c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y)continue;pr(n,c,null,g,i)}}for(c in y)g=y[c],c=="children"?d=g:c=="dangerouslySetInnerHTML"?h=g:c=="value"?f=g:c=="checked"?m=g:a&&typeof g!="function"||b[c]===g||pr(n,c,g,b[c],i);if(h)a||u&&(h.__html==u.__html||h.__html==n.innerHTML)||(n.innerHTML=h.__html),t.__k=[];else if(u&&(n.innerHTML=""),vo(t.type=="template"?n.content:n,hr(d)?d:[d],t,e,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:e.__k&&Be(e,0),a,l),s!=null)for(c=s.length;c--;)bs(s[c]);a||(c="value",w=="progress"&&f==null?n.removeAttribute("value"):f!=null&&(f!==n[c]||w=="progress"&&!f||w=="option"&&f!=b[c])&&pr(n,c,f,b[c],i),c="checked",m!=null&&m!=n[c]&&pr(n,c,m,b[c],i))}return n}function _s(n,t,e){try{if(typeof n=="function"){var r=typeof n.__u=="function";r&&n.__u(),r&&t==null||(n.__u=n(t))}else n.current=t}catch(i){K.__e(i,e)}}function wo(n,t,e){var r,i;if(K.unmount&&K.unmount(n),(r=n.ref)&&(r.current&&r.current!=n.__e||_s(r,null,t)),(r=n.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){K.__e(s,t)}r.base=r.__P=null}if(r=n.__k)for(i=0;i<r.length;i++)r[i]&&wo(r[i],t,e||typeof n.type!="function");e||bs(n.__e),n.__c=n.__=n.__e=void 0}function qa(n,t,e){return this.constructor(n,e)}function Ka(n,t,e){var r,i,s,o;t==document&&(t=document.documentElement),K.__&&K.__(n,t),i=(r=!1)?null:t.__k,s=[],o=[],ys(t,n=t.__k=er(ur,null,[n]),i||tr,tr,t.namespaceURI,i?null:t.firstChild?fi.call(t.childNodes):null,s,i?i.__e:t.firstChild,r,o),_o(s,n,o)}fi=po.slice,K={__e:function(n,t,e,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(n)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(n,r||{}),o=i.__d),o)return i.__E=i}catch(a){n=a}throw n}},ho=0,Xr.prototype.setState=function(n,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=te({},this.state),typeof n=="function"&&(n=n(te({},e),this.props)),n&&te(e,n),n!=null&&this.__v&&(t&&this._sb.push(t),Gs(this))},Xr.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Gs(this))},Xr.prototype.render=ur,me=[],uo=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,go=function(n,t){return n.__v.__b-t.__v.__b},Zr.__r=0,fo=/(PointerCapture)$|Capture$/i,vs=0,Ni=$s(!1),$i=$s(!0);var Za=0;function _(n,t,e,r,i,s){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var c={type:n,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Za,__i:-1,__u:0,__source:i,__self:s};if(typeof n=="function"&&(o=n.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return K.vnode&&K.vnode(c),c}var rr,rt,Ei,qs,ir=0,Co=[],nt=K,Ks=nt.__b,Zs=nt.__r,Js=nt.diffed,Qs=nt.__c,tn=nt.unmount,en=nt.__;function xs(n,t){nt.__h&&nt.__h(rt,n,ir||t),ir=0;var e=rt.__H||(rt.__H={__:[],__h:[]});return n>=e.__.length&&e.__.push({}),e.__[n]}function et(n){return ir=1,Ja(ko,n)}function Ja(n,t,e){var r=xs(rr++,2);if(r.t=n,!r.__c&&(r.__=[ko(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=rt,!rt.__f)){var i=function(a,l,c){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return!!d.__c});if(h.every(function(d){return!d.__N}))return!s||s.call(this,a,l,c);var u=r.__c.props!==a;return h.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(u=!0)}}),s&&s.call(this,a,l,c)||u};rt.__f=!0;var s=rt.shouldComponentUpdate,o=rt.componentWillUpdate;rt.componentWillUpdate=function(a,l,c){if(this.__e){var h=s;s=void 0,i(a,l,c),s=h}o&&o.call(this,a,l,c)},rt.shouldComponentUpdate=i}return r.__N||r.__}function It(n,t){var e=xs(rr++,3);!nt.__s&&To(e.__H,t)&&(e.__=n,e.u=t,rt.__H.__h.push(e))}function Ot(n){return ir=5,So(function(){return{current:n}},[])}function So(n,t){var e=xs(rr++,7);return To(e.__H,t)&&(e.__=n(),e.__H=t,e.__h=n),e.__}function Y(n,t){return ir=8,So(function(){return n},t)}function Qa(){for(var n;n=Co.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(Yr),n.__H.__h.forEach(Ki),n.__H.__h=[]}catch(t){n.__H.__h=[],nt.__e(t,n.__v)}}nt.__b=function(n){rt=null,Ks&&Ks(n)},nt.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),en&&en(n,t)},nt.__r=function(n){Zs&&Zs(n),rr=0;var t=(rt=n.__c).__H;t&&(Ei===rt?(t.__h=[],rt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Yr),t.__h.forEach(Ki),t.__h=[],rr=0)),Ei=rt},nt.diffed=function(n){Js&&Js(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(Co.push(t)!==1&&qs===nt.requestAnimationFrame||((qs=nt.requestAnimationFrame)||tl)(Qa)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Ei=rt=null},nt.__c=function(n,t){t.some(function(e){try{e.__h.forEach(Yr),e.__h=e.__h.filter(function(r){return!r.__||Ki(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],nt.__e(r,e.__v)}}),Qs&&Qs(n,t)},nt.unmount=function(n){tn&&tn(n);var t,e=n.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{Yr(r)}catch(i){t=i}}),e.__H=void 0,t&&nt.__e(t,e.__v))};var rn=typeof requestAnimationFrame=="function";function tl(n){var t,e=function(){clearTimeout(r),rn&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(e,35);rn&&(t=requestAnimationFrame(e))}function Yr(n){var t=rt,e=n.__c;typeof e=="function"&&(n.__c=void 0,e()),rt=t}function Ki(n){var t=rt;n.__c=n.__(),rt=t}function To(n,t){return!n||n.length!==t.length||t.some(function(e,r){return e!==n[r]})}function ko(n,t){return typeof t=="function"?t(n):t}/**
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var ei,it,ha,je,qn,ua,da,ga,vn,Wi,Xi,qr={},fa=[],gc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ns=Array.isArray;function fe(i,t){for(var e in t)i[e]=t[e];return i}function yn(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function Kr(i,t,e){var r,s,n,o={};for(n in t)n=="key"?r=t[n]:n=="ref"?s=t[n]:o[n]=t[n];if(arguments.length>2&&(o.children=arguments.length>3?ei.call(arguments,2):e),typeof i=="function"&&i.defaultProps!=null)for(n in i.defaultProps)o[n]===void 0&&(o[n]=i.defaultProps[n]);return Os(i,o,r,s,null)}function Os(i,t,e,r,s){var n={type:i,props:t,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++ha,__i:-1,__u:0};return s==null&&it.vnode!=null&&it.vnode(n),n}function os(i){return i.children}function Ds(i,t){this.props=i,this.context=t}function nr(i,t){if(t==null)return i.__?nr(i.__,i.__i+1):null;for(var e;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null)return e.__e;return typeof i.type=="function"?nr(i):null}function pa(i){var t,e;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,t=0;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null){i.__e=i.__c.base=e.__e;break}return pa(i)}}function Kn(i){(!i.__d&&(i.__d=!0)&&je.push(i)&&!Bs.__r++||qn!=it.debounceRendering)&&((qn=it.debounceRendering)||ua)(Bs)}function Bs(){for(var i,t,e,r,s,n,o,a=1;je.length;)je.length>a&&je.sort(da),i=je.shift(),a=je.length,i.__d&&(e=void 0,r=void 0,s=(r=(t=i).__v).__e,n=[],o=[],t.__P&&((e=fe({},r)).__v=r.__v+1,it.vnode&&it.vnode(e),bn(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[s]:null,n,s??nr(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,ba(n,e,o),r.__e=r.__=null,e.__e!=s&&pa(e)));Bs.__r=0}function ma(i,t,e,r,s,n,o,a,l,c,h){var u,d,g,f,m,y,b,x=r&&r.__k||fa,T=t.length;for(l=fc(e,t,x,l,T),u=0;u<T;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?qr:x[g.__i]||qr,g.__i=u,y=bn(i,g,d,s,n,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&xn(d.ref,null,g),h.push(g.ref,g.__c||f,g)),m==null&&f!=null&&(m=f),(b=!!(4&g.__u))||d.__k===g.__k?l=va(g,l,i,b):typeof g.type=="function"&&y!==void 0?l=y:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=m,l}function fc(i,t,e,r,s){var n,o,a,l,c,h=e.length,u=h,d=0;for(i.__k=new Array(s),n=0;n<s;n++)(o=t[n])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=i.__k[n]=Os(null,o,null,null,null):ns(o)?o=i.__k[n]=Os(os,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=i.__k[n]=Os(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[n]=o,l=n+d,o.__=i,o.__b=i.__b+1,a=null,(c=o.__i=pc(o,e,l,u))!=-1&&(u--,(a=e[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>h?d--:s<h&&d++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,o.__u|=4))):i.__k[n]=null;if(u)for(n=0;n<h;n++)(a=e[n])!=null&&!(2&a.__u)&&(a.__e==r&&(r=nr(a)),wa(a,a));return r}function va(i,t,e,r){var s,n;if(typeof i.type=="function"){for(s=i.__k,n=0;s&&n<s.length;n++)s[n]&&(s[n].__=i,t=va(s[n],t,e,r));return t}i.__e!=t&&(r&&(t&&i.type&&!t.parentNode&&(t=nr(i)),e.insertBefore(i.__e,t||null)),t=i.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ya(i,t){return t=t||[],i==null||typeof i=="boolean"||(ns(i)?i.some(function(e){ya(e,t)}):t.push(i)),t}function pc(i,t,e,r){var s,n,o,a=i.key,l=i.type,c=t[e],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return e;if(r>(h?1:0)){for(s=e-1,n=e+1;s>=0||n<t.length;)if((c=t[o=s>=0?s--:n++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function Zn(i,t,e){t[0]=="-"?i.setProperty(t,e??""):i[t]=e==null?"":typeof e!="number"||gc.test(t)?e:e+"px"}function hs(i,t,e,r,s){var n,o;t:if(t=="style")if(typeof e=="string")i.style.cssText=e;else{if(typeof r=="string"&&(i.style.cssText=r=""),r)for(t in r)e&&t in e||Zn(i.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||Zn(i.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(ga,"$1")),o=t.toLowerCase(),t=o in i||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),i.l||(i.l={}),i.l[t+n]=e,e?r?e.u=r.u:(e.u=vn,i.addEventListener(t,n?Xi:Wi,n)):i.removeEventListener(t,n?Xi:Wi,n);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in i)try{i[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?i.removeAttribute(t):i.setAttribute(t,t=="popover"&&e==1?"":e))}}function Jn(i){return function(t){if(this.l){var e=this.l[t.type+i];if(t.t==null)t.t=vn++;else if(t.t<e.u)return;return e(it.event?it.event(t):t)}}}function bn(i,t,e,r,s,n,o,a,l,c){var h,u,d,g,f,m,y,b,x,T,C,S,D,A,_,M,O,V=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),n=[a=t.__e=e.__e]),(h=it.__b)&&h(t);t:if(typeof V=="function")try{if(b=t.props,x="prototype"in V&&V.prototype.render,T=(h=V.contextType)&&r[h.__c],C=h?T?T.props.value:h.__:r,e.__c?y=(u=t.__c=e.__c).__=u.__E:(x?t.__c=u=new V(b,C):(t.__c=u=new Ds(b,C),u.constructor=V,u.render=vc),T&&T.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),x&&u.__s==null&&(u.__s=u.state),x&&V.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=fe({},u.__s)),fe(u.__s,V.getDerivedStateFromProps(b,u.__s))),g=u.props,f=u.state,u.__v=t,d)x&&V.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),x&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(x&&V.getDerivedStateFromProps==null&&b!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,C),t.__v==e.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,C)===!1){for(t.__v!=e.__v&&(u.props=b,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(z){z&&(z.__=t)}),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,C),x&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,f,m)})}if(u.context=C,u.props=b,u.__P=i,u.__e=!1,D=it.__r,A=0,x){for(u.state=u.__s,u.__d=!1,D&&D(t),h=u.render(u.props,u.state,u.context),_=0;_<u._sb.length;_++)u.__h.push(u._sb[_]);u._sb=[]}else do u.__d=!1,D&&D(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++A<25);u.state=u.__s,u.getChildContext!=null&&(r=fe(fe({},r),u.getChildContext())),x&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(g,f)),M=h,h!=null&&h.type===os&&h.key==null&&(M=xa(h.props.children)),a=ma(i,ns(M)?M:[M],t,e,r,s,n,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),y&&(u.__E=u.__=null)}catch(z){if(t.__v=null,l||n!=null)if(z.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;n[n.indexOf(a)]=null,t.__e=a}else{for(O=n.length;O--;)yn(n[O]);Yi(t)}else t.__e=e.__e,t.__k=e.__k,z.then||Yi(t);it.__e(z,t,e)}else n==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=mc(e.__e,t,e,r,s,n,o,l,c);return(h=it.diffed)&&h(t),128&t.__u?void 0:a}function Yi(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(Yi)}function ba(i,t,e){for(var r=0;r<e.length;r++)xn(e[r],e[++r],e[++r]);it.__c&&it.__c(t,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(n){n.call(s)})}catch(n){it.__e(n,s.__v)}})}function xa(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:ns(i)?i.map(xa):fe({},i)}function mc(i,t,e,r,s,n,o,a,l){var c,h,u,d,g,f,m,y=e.props||qr,b=t.props,x=t.type;if(x=="svg"?s="http://www.w3.org/2000/svg":x=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),n!=null){for(c=0;c<n.length;c++)if((g=n[c])&&"setAttribute"in g==!!x&&(x?g.localName==x:g.nodeType==3)){i=g,n[c]=null;break}}if(i==null){if(x==null)return document.createTextNode(b);i=document.createElementNS(s,x,b.is&&b),a&&(it.__m&&it.__m(t,n),a=!1),n=null}if(x==null)y===b||a&&i.data==b||(i.data=b);else{if(n=n&&ei.call(i.childNodes),!a&&n!=null)for(y={},c=0;c<i.attributes.length;c++)y[(g=i.attributes[c]).name]=g.value;for(c in y)if(g=y[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;hs(i,c,null,g,s)}}for(c in b)g=b[c],c=="children"?d=g:c=="dangerouslySetInnerHTML"?h=g:c=="value"?f=g:c=="checked"?m=g:a&&typeof g!="function"||y[c]===g||hs(i,c,g,y[c],s);if(h)a||u&&(h.__html==u.__html||h.__html==i.innerHTML)||(i.innerHTML=h.__html),t.__k=[];else if(u&&(i.innerHTML=""),ma(t.type=="template"?i.content:i,ns(d)?d:[d],t,e,r,x=="foreignObject"?"http://www.w3.org/1999/xhtml":s,n,o,n?n[0]:e.__k&&nr(e,0),a,l),n!=null)for(c=n.length;c--;)yn(n[c]);a||(c="value",x=="progress"&&f==null?i.removeAttribute("value"):f!=null&&(f!==i[c]||x=="progress"&&!f||x=="option"&&f!=y[c])&&hs(i,c,f,y[c],s),c="checked",m!=null&&m!=i[c]&&hs(i,c,m,y[c],s))}return i}function xn(i,t,e){try{if(typeof i=="function"){var r=typeof i.__u=="function";r&&i.__u(),r&&t==null||(i.__u=i(t))}else i.current=t}catch(s){it.__e(s,e)}}function wa(i,t,e){var r,s;if(it.unmount&&it.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||xn(r,null,t)),(r=i.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(n){it.__e(n,t)}r.base=r.__P=null}if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&wa(r[s],t,e||typeof i.type!="function");e||yn(i.__e),i.__c=i.__=i.__e=void 0}function vc(i,t,e){return this.constructor(i,e)}function yc(i,t,e){var r,s,n,o;t==document&&(t=document.documentElement),it.__&&it.__(i,t),s=(r=!1)?null:t.__k,n=[],o=[],bn(t,i=t.__k=Kr(os,null,[i]),s||qr,qr,t.namespaceURI,s?null:t.firstChild?ei.call(t.childNodes):null,n,s?s.__e:t.firstChild,r,o),ba(n,i,o)}ei=fa.slice,it={__e:function(i,t,e,r){for(var s,n,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((n=s.constructor)&&n.getDerivedStateFromError!=null&&(s.setState(n.getDerivedStateFromError(i)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,r||{}),o=s.__d),o)return s.__E=s}catch(a){i=a}throw i}},ha=0,Ds.prototype.setState=function(i,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=fe({},this.state),typeof i=="function"&&(i=i(fe({},e),this.props)),i&&fe(e,i),i!=null&&this.__v&&(t&&this._sb.push(t),Kn(this))},Ds.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),Kn(this))},Ds.prototype.render=os,je=[],ua=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,da=function(i,t){return i.__v.__b-t.__v.__b},Bs.__r=0,ga=/(PointerCapture)$|Capture$/i,vn=0,Wi=Jn(!1),Xi=Jn(!0);var bc=0;function p(i,t,e,r,s,n){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var c={type:i,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bc,__i:-1,__u:0,__source:s,__self:n};if(typeof i=="function"&&(o=i.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return it.vnode&&it.vnode(c),c}var Zr,ft,yi,Qn,Jr=0,_a=[],vt=it,to=vt.__b,eo=vt.__r,ro=vt.diffed,so=vt.__c,io=vt.unmount,no=vt.__;function wn(i,t){vt.__h&&vt.__h(ft,i,Jr||t),Jr=0;var e=ft.__H||(ft.__H={__:[],__h:[]});return i>=e.__.length&&e.__.push({}),e.__[i]}function at(i){return Jr=1,xc(ka,i)}function xc(i,t,e){var r=wn(Zr++,2);if(r.t=i,!r.__c&&(r.__=[ka(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=ft,!ft.__f)){var s=function(a,l,c){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return!!d.__c});if(h.every(function(d){return!d.__N}))return!n||n.call(this,a,l,c);var u=r.__c.props!==a;return h.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(u=!0)}}),n&&n.call(this,a,l,c)||u};ft.__f=!0;var n=ft.shouldComponentUpdate,o=ft.componentWillUpdate;ft.componentWillUpdate=function(a,l,c){if(this.__e){var h=n;n=void 0,s(a,l,c),n=h}o&&o.call(this,a,l,c)},ft.shouldComponentUpdate=s}return r.__N||r.__}function Vt(i,t){var e=wn(Zr++,3);!vt.__s&&Sa(e.__H,t)&&(e.__=i,e.u=t,ft.__H.__h.push(e))}function Rt(i){return Jr=5,Ca(function(){return{current:i}},[])}function Ca(i,t){var e=wn(Zr++,7);return Sa(e.__H,t)&&(e.__=i(),e.__H=t,e.__h=i),e.__}function N(i,t){return Jr=8,Ca(function(){return i},t)}function wc(){for(var i;i=_a.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(Ms),i.__H.__h.forEach(Ui),i.__H.__h=[]}catch(t){i.__H.__h=[],vt.__e(t,i.__v)}}vt.__b=function(i){ft=null,to&&to(i)},vt.__=function(i,t){i&&t.__k&&t.__k.__m&&(i.__m=t.__k.__m),no&&no(i,t)},vt.__r=function(i){eo&&eo(i),Zr=0;var t=(ft=i.__c).__H;t&&(yi===ft?(t.__h=[],ft.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Ms),t.__h.forEach(Ui),t.__h=[],Zr=0)),yi=ft},vt.diffed=function(i){ro&&ro(i);var t=i.__c;t&&t.__H&&(t.__H.__h.length&&(_a.push(t)!==1&&Qn===vt.requestAnimationFrame||((Qn=vt.requestAnimationFrame)||_c)(wc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),yi=ft=null},vt.__c=function(i,t){t.some(function(e){try{e.__h.forEach(Ms),e.__h=e.__h.filter(function(r){return!r.__||Ui(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],vt.__e(r,e.__v)}}),so&&so(i,t)},vt.unmount=function(i){io&&io(i);var t,e=i.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{Ms(r)}catch(s){t=s}}),e.__H=void 0,t&&vt.__e(t,e.__v))};var oo=typeof requestAnimationFrame=="function";function _c(i){var t,e=function(){clearTimeout(r),oo&&cancelAnimationFrame(t),setTimeout(i)},r=setTimeout(e,35);oo&&(t=requestAnimationFrame(e))}function Ms(i){var t=ft,e=i.__c;typeof e=="function"&&(i.__c=void 0,e()),ft=t}function Ui(i){var t=ft;i.__c=i.__(),ft=t}function Sa(i,t){return!i||i.length!==t.length||t.some(function(e,r){return e!==i[r]})}function ka(i,t){return typeof t=="function"?t(i):t}/**
2
2
  * @license lucide-preact v0.460.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const el=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),rl=(...n)=>n.filter((t,e,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===e).join(" ").trim();/**
6
+ */const Cc=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sc=(...i)=>i.filter((t,e,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===e).join(" ").trim();/**
7
7
  * @license lucide-preact v0.460.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */var il={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};/**
11
+ */var kc={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};/**
12
12
  * @license lucide-preact v0.460.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const sl=({color:n="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:i,iconNode:s,class:o="",...a})=>er("svg",{...il,width:String(t),height:t,stroke:n,"stroke-width":r?Number(e)*24/Number(t):e,class:["lucide",o].join(" "),...a},[...s.map(([l,c])=>er(l,c)),...yo(i)]);/**
16
+ */const Tc=({color:i="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:s,iconNode:n,class:o="",...a})=>Kr("svg",{...kc,width:String(t),height:t,stroke:i,"stroke-width":r?Number(e)*24/Number(t):e,class:["lucide",o].join(" "),...a},[...n.map(([l,c])=>Kr(l,c)),...ya(s)]);/**
17
17
  * @license lucide-preact v0.460.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Lt=(n,t)=>{const e=({class:r="",children:i,...s})=>er(sl,{...s,iconNode:t,class:rl(`lucide-${el(n)}`,r)},i);return e.displayName=`${n}`,e};/**
21
+ */const _n=(i,t)=>{const e=({class:r="",children:s,...n})=>Kr(Tc,{...n,iconNode:t,class:Sc(`lucide-${Cc(i)}`,r)},s);return e.displayName=`${i}`,e};/**
22
22
  * @license lucide-preact v0.460.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const nl=Lt("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
26
+ */const Oc=_n("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
27
27
  * @license lucide-preact v0.460.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const ol=Lt("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
31
+ */const Dc=_n("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
32
32
  * @license lucide-preact v0.460.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const al=Lt("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
37
- * @license lucide-preact v0.460.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const ll=Lt("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
42
- * @license lucide-preact v0.460.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const cl=Lt("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
47
- * @license lucide-preact v0.460.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const hl=Lt("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
52
- * @license lucide-preact v0.460.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const ul=Lt("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
57
- * @license lucide-preact v0.460.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const dl=Lt("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
62
- * @license lucide-preact v0.460.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const gl=Lt("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
67
- * @license lucide-preact v0.460.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const fl=Lt("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
72
- * @license lucide-preact v0.460.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const pl=Lt("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
77
- * @license lucide-preact v0.460.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const ml=Lt("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),vl={bug:nl,"message-square":dl,"alert-circle":ol,"help-circle":al,mail:ul,send:gl,flag:ll,star:pl,zap:ml,heart:cl,info:hl,settings:fl},bl=({name:n,class:t,size:e=18,strokeWidth:r=2})=>{const i=vl[n];return i?_(i,{class:t,size:e,strokeWidth:r}):null},yl=({position:n,buttonText:t,buttonShape:e,buttonIcon:r,buttonIconSize:i,buttonIconStroke:s,theme:o,lightButtonColor:a,lightTextColor:l,lightButtonHoverColor:c,lightTextHoverColor:h,darkButtonColor:u,darkTextColor:d,darkButtonHoverColor:g,darkTextHoverColor:f,enableHoverScaleEffect:m,tooltipEnabled:b,tooltipText:y,onClick:w})=>{const[O,k]=et(!1),[S,C]=et(!1),[A,D]=et({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),L=Ot(null),R=Ot(null);It(()=>{if(o==="dark"){C(!0);return}else if(o==="light"){C(!1);return}const ct=window.matchMedia("(prefers-color-scheme: dark)");C(ct.matches);const T=F=>C(F.matches);return ct.addEventListener("change",T),()=>ct.removeEventListener("change",T)},[o]),It(()=>{if(O&&L.current&&R.current){const ct=L.current,T=R.current;requestAnimationFrame(()=>{const F=ct.getBoundingClientRect(),P=T.getBoundingClientRect(),B=window.innerWidth,$=4,q=P.left+P.width/2,gt=F.width/2;let Kt=0;const ut=q-gt;ut<$?Kt=$-ut:ut+F.width>B-$&&(Kt=B-$-(ut+F.width)),D({left:"50%",transform:`translateX(-50%) translateX(${Kt}px)`,arrowLeft:"50%"})})}},[O,y]);const H=S?O?g:u:O?c:a,I=S?O?f:d:O?h:l,M=S?u:a,j=S?d:l,z=e==="round"?"50%":"8px",V=t||"Report Bug",Q=e==="round"?`${i/2}px`:"12px 20px",U=`bugpin-launcher-button${m?" hover-scale":""}`,vt={position:"absolute",bottom:"100%",marginBottom:"8px",padding:"6px 12px",backgroundColor:M,color:j,fontSize:"12px",borderRadius:"4px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"2147483647",opacity:"0",animation:"bugpin-tooltip-fade-in 0.2s ease-in-out forwards",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)",left:A.left,transform:A.transform},St={position:"absolute",top:"100%",left:A.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderWidth:"4px",borderStyle:"solid",borderColor:`${M} transparent transparent transparent`};return _("div",{class:`bugpin-launcher-button-container ${n}`,style:{position:"fixed",zIndex:"2147483647"},children:[_("button",{ref:R,class:U,style:{position:"relative",backgroundColor:H,color:I,borderRadius:z,padding:Q,transition:"background-color 0.2s ease, color 0.2s ease"},onClick:w,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),"aria-label":V,children:[r&&_(bl,{name:r,size:i,strokeWidth:s}),t&&_("span",{children:t})]}),b&&y&&O&&_("div",{ref:L,class:"bugpin-tooltip",style:vt,children:[y,_("div",{style:St})]})]})},_l=({tabs:n,activeTab:t,onTabChange:e})=>_("div",{class:"bugpin-tabs",children:n.map(r=>_("button",{type:"button",class:`bugpin-tab ${t===r.id?"active":""}`,onClick:()=>e(r.id),children:[r.icon&&_("span",{class:"bugpin-tab-icon",children:r.icon}),r.label]},r.id))}),xl=10*1024*1024,wl=50*1024*1024,Cl=["image/png","image/jpeg","image/gif","image/webp"],Sl=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Tl=({media:n,onCapture:t,onUpload:e,onRemove:r,onAnnotate:i,isCapturing:s,enableAnnotation:o})=>{const[a,l]=et(!1),[c,h]=et(null),u=Ot(null),d=C=>C.startsWith("video/"),g=C=>C.startsWith("image/"),f=Y(C=>{if(g(C.type)){if(!Cl.includes(C.type))return`Unsupported image format: ${C.type}`;if(C.size>xl)return"Image too large. Maximum size is 10MB."}else if(d(C.type)){if(!Sl.includes(C.type))return`Unsupported video format: ${C.type}`;if(C.size>wl)return"Video too large. Maximum size is 50MB."}else return`Unsupported file type: ${C.type}`;return null},[]),m=Y(async C=>{const A=f(C);if(A){h(A);return}h(null);const D=new FileReader;D.onload=()=>{const L=D.result;if(g(C.type)){const R=new Image;R.onload=()=>{const H={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:C.type,width:R.width,height:R.height};e(H)},R.src=L}else if(d(C.type)){const R=document.createElement("video");R.onloadedmetadata=()=>{const H={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:C.type,width:R.videoWidth,height:R.videoHeight};e(H)},R.src=L}},D.readAsDataURL(C)},[f,e]),b=Y(C=>{C.preventDefault(),C.stopPropagation(),l(!0)},[]),y=Y(C=>{C.preventDefault(),C.stopPropagation(),l(!1)},[]),w=Y(async C=>{var D;C.preventDefault(),C.stopPropagation(),l(!1);const A=(D=C.dataTransfer)==null?void 0:D.files;if(A)for(let L=0;L<A.length;L++)await m(A[L])},[m]),O=Y(async C=>{const A=C.target,D=A.files;if(D)for(let L=0;L<D.length;L++)await m(D[L]);A.value=""},[m]),k=Y(()=>{var C;(C=u.current)==null||C.click()},[]),S=C=>C.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return _("div",{class:"bugpin-screenshot-manager",children:[_("div",{class:"bugpin-media-actions",children:[_("button",{type:"button",class:"bugpin-btn-action",onClick:t,disabled:s,children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 15.2c1.77 0 3.2-1.43 3.2-3.2S13.77 8.8 12 8.8 8.8 10.23 8.8 12s1.43 3.2 3.2 3.2zM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",fill:"currentColor"})}),s?"Capturing...":"Capture Screenshot"]}),_("button",{type:"button",class:"bugpin-btn-action bugpin-btn-action-secondary",onClick:k,children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z",fill:"currentColor"})}),"Upload File"]}),_("input",{ref:u,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:O})]}),c&&_("div",{class:"bugpin-upload-error",children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),c]}),_("div",{class:`bugpin-drop-zone ${a?"dragging":""} ${n.length>0?"has-media":""}`,onDragOver:b,onDragLeave:y,onDrop:w,children:n.length===0?_("div",{class:"bugpin-drop-placeholder",children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})}),_("p",{children:"Drag and drop images or videos here"}),_("span",{children:"or use the buttons above"})]}):_(ur,{children:[_("div",{class:"bugpin-media-grid",children:n.map(C=>_("div",{class:"bugpin-media-card",children:[_("div",{class:"bugpin-media-preview",children:[d(C.mimeType)?_("video",{src:C.dataUrl,muted:!0}):_("img",{src:C.dataUrl,alt:"Screenshot"}),_("div",{class:"bugpin-media-badges",children:[C.annotated&&_("span",{class:"bugpin-badge annotated",children:"Annotated"}),d(C.mimeType)&&_("span",{class:"bugpin-badge video",children:"Video"})]})]}),_("div",{class:"bugpin-media-info",children:[_("span",{class:"bugpin-media-time",children:S(C.timestamp)}),C.width&&C.height&&_("span",{class:"bugpin-media-dimensions",children:[C.width," × ",C.height]})]}),_("div",{class:"bugpin-media-item-actions",children:[o&&g(C.mimeType)&&_("button",{type:"button",class:"bugpin-btn-icon",onClick:()=>i(C.id),title:"Annotate",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",fill:"currentColor"})})}),_("button",{type:"button",class:"bugpin-btn-icon bugpin-btn-icon-danger",onClick:()=>r(C.id),title:"Remove",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]})]},C.id))}),_("div",{class:"bugpin-drop-more",children:_("span",{children:"Drop more files here"})})]})}),_("p",{class:"bugpin-helper-text",children:"Supported: PNG, JPG, GIF, WebP (max 10MB) • MP4, WebM, MOV, AVI (max 50MB)"})]})},kl=[{id:"details",label:"Details",icon:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",fill:"currentColor"})})},{id:"media",label:"Screenshots",icon:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})})}],Ol=({onClose:n,onSubmit:t,onCaptureScreenshot:e,onAnnotateMedia:r,media:i,onAddMedia:s,onRemoveMedia:o,isSubmitting:a,isCapturing:l,enableAnnotation:c,activeTab:h,onActiveTabChange:u,formData:d,onFormDataChange:g})=>{const[f,m]=et({}),b=Y((S,C)=>{g({...d,[S]:C}),f[S]&&m(A=>({...A,[S]:void 0}))},[d,g,f]),y=Y(()=>{const S={};return d.title.trim()?d.title.trim().length<4&&(S.title="Title must be at least 4 characters"):S.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(S.reporterEmail="Invalid email address"),m(S),Object.keys(S).length===0},[d]),w=Y(S=>{if(S.preventDefault(),!y()){u("details");return}t(d,i)},[d,i,y,t,u]),O=Y(S=>{S.target.classList.contains("bugpin-overlay")&&n()},[n]),k=i.length;return _("div",{class:"bugpin-overlay",onClick:O,children:_("div",{class:"bugpin-dialog bugpin-dialog-tabbed",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-title",children:[_("div",{class:"bugpin-header",children:[_("h2",{id:"bugpin-title",children:"Report a Bug"}),_("button",{class:"bugpin-close",onClick:n,"aria-label":"Close",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",fill:"currentColor"})})})]}),_("div",{class:"bugpin-tabs-container",children:_(_l,{tabs:kl.map(S=>({...S,label:S.id==="media"&&k>0?`${S.label} (${k})`:S.label})),activeTab:h,onTabChange:u})}),_("div",{class:"bugpin-body",children:[h==="details"&&_("form",{class:"bugpin-form",onSubmit:w,children:[_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label required",for:"bugpin-title-input",children:"Title"}),_("input",{id:"bugpin-title-input",class:"bugpin-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:S=>b("title",S.target.value),maxLength:200}),f.title&&_("span",{class:"bugpin-error",children:f.title})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-description",children:"Description"}),_("textarea",{id:"bugpin-description",class:"bugpin-textarea",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:S=>b("description",S.target.value)})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-priority",children:"Priority"}),_("select",{id:"bugpin-priority",class:"bugpin-select",value:d.priority,onChange:S=>b("priority",S.target.value),children:[_("option",{value:"lowest",children:"Lowest"}),_("option",{value:"low",children:"Low"}),_("option",{value:"medium",children:"Medium"}),_("option",{value:"high",children:"High"}),_("option",{value:"highest",children:"Highest"})]})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-email",children:"Email (optional)"}),_("input",{id:"bugpin-email",class:"bugpin-input",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:S=>b("reporterEmail",S.target.value)}),f.reporterEmail&&_("span",{class:"bugpin-error",children:f.reporterEmail})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-name",children:"Name (optional)"}),_("input",{id:"bugpin-name",class:"bugpin-input",type:"text",placeholder:"Your name",value:d.reporterName,onInput:S=>b("reporterName",S.target.value)})]})]}),h==="media"&&_(Tl,{media:i,onCapture:e,onUpload:s,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c})]}),_("div",{class:"bugpin-footer",children:[_("button",{type:"button",class:"bugpin-btn-cancel",onClick:n,disabled:a,children:"Cancel"}),_("button",{type:"submit",class:"bugpin-btn-submit",onClick:w,disabled:a,children:a?_("span",{class:"bugpin-spinner"}):"Submit Report"})]})]})})},Dl=({message:n,type:t,onClose:e,duration:r=5e3})=>(It(()=>{const i=setTimeout(e,r);return()=>clearTimeout(i)},[e,r]),_("div",{class:`bugpin-toast ${t}`,role:"alert",children:[t==="success"&&_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",fill:"currentColor"})}),t==="error"&&_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),_("span",{children:n})]}));function p(n,t,e){return(t=function(r){var i=function(s,o){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var l=a.call(s,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}(r,"string");return typeof i=="symbol"?i:i+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function sn(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function v(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?sn(Object(e),!0).forEach(function(r){p(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):sn(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function J(n,t){if(n==null)return{};var e,r,i=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}(n,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)e=s[r],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(i[e]=n[e])}return i}function qt(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class nn{constructor(){p(this,"browserShadowBlurConstant",1),p(this,"DPI",96),p(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),p(this,"perfLimitSizeTotal",2097152),p(this,"maxCacheSideLimit",4096),p(this,"minCacheSideLimit",256),p(this,"disableStyleCopyPaste",!1),p(this,"enableGLFiltering",!0),p(this,"textureSize",4096),p(this,"forceGLPutImageData",!1),p(this,"cachesBoundsOfCurve",!1),p(this,"fontPaths",{}),p(this,"NUM_FRACTION_DIGITS",4)}}const X=new class extends nn{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=v(v({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(n=>{delete this.fontPaths[n]})}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new nn,e=(n==null?void 0:n.reduce((r,i)=>(r[i]=t[i],r),{}))||t;this.configure(e)}},ge=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return console[n]("fabric",...e)};class Ut extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Ml extends Ut{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class El{}class Pl extends El{testPrecision(t,e){const r="precision ".concat(e,` float;
82
- void main(){}`),i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,r),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(r=>this.testPrecision(e,r)),e.getExtension("WEBGL_lose_context").loseContext(),ge("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Al={};let on;const $t=()=>on||(on={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Pl,dispose(){},copyPasteData:Al}),ze=()=>$t().document,pi=()=>$t().window,Oo=()=>{var n;return Math.max((n=X.devicePixelRatio)!==null&&n!==void 0?n:pi().devicePixelRatio,1)},Ke=new class{constructor(){p(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:r}=n;t=t.toLowerCase();const i=this.charWidthsCache;i.has(t)||i.set(t,new Map);const s=i.get(t),o="".concat(e.toLowerCase(),"_").concat((r+"").toLowerCase());return s.has(o)||s.set(o,new Map),s.get(o)}clearFontCache(n){n?this.charWidthsCache.delete((n||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(n){const{perfLimitSizeTotal:t}=X,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},Zi="6.9.1";function Ur(){}const dr=Math.PI/2,Jr=2*Math.PI,ws=Math.PI/180,mt=Object.freeze([1,0,0,1,0,0]),Cs=16,ce=.4477152502,W="center",N="left",yt="top",Ji="bottom",it="right",_t="none",Ss=/\r?\n/,Do="moving",mi="scaling",Mo="rotating",Ts="rotate",Eo="skewing",sr="resizing",jl="modifyPoly",Ll="modifyPath",Qr="changed",vi="scale",Ct="scaleX",At="scaleY",We="skewX",Ve="skewY",at="fill",xt="stroke",ti="modified",Te="json",Pi="svg",E=new class{constructor(){this[Te]=new Map,this[Pi]=new Map}has(n){return this[Te].has(n)}getClass(n){const t=this[Te].get(n);if(!t)throw new Ut("No class registered for ".concat(n));return t}setClass(n,t){t?this[Te].set(t,n):(this[Te].set(n.type,n),this[Te].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Pi].get(n)}setSVGClass(n,t){this[Pi].set(t??n.type.toLowerCase(),n)}},ei=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var r;return e.target===n||typeof e.target=="object"&&((r=e.target)===null||r===void 0?void 0:r.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class Fl{constructor(){p(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(r=>{let[i,s]=r;this.on(i,s)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if(typeof t=="object"){const r=[];return Object.entries(t).forEach(i=>{let[s,o]=i;r.push(this.once(s,o))}),()=>r.forEach(i=>i())}if(e){const r=this.on(t,function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];e.call(this,...s),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],i=r.indexOf(e);i>-1&&r.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const r in this.__eventListeners)this._removeEventListener(r);else typeof t=="object"?Object.entries(t).forEach(r=>{let[i,s]=r;this._removeEventListener(i,s)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const i=(r=this.__eventListeners[t])===null||r===void 0?void 0:r.concat();if(i)for(let s=0;s<i.length;s++)i[s].call(this,e||{})}}const Me=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},ie=n=>{if(n===0)return 1;switch(Math.abs(n)/dr){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},se=n=>{if(n===0)return 0;const t=n/dr,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ks;const r=se(t),i=ie(t),s=this.subtract(e);return new x(s.x*i-s.y*r,s.x*r+s.y*i).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const ks=new x(0,0),Gr=n=>!!n&&Array.isArray(n._objects);function Po(n){class t extends n{constructor(){super(...arguments),p(this,"_objects",[])}_onObjectAdded(r){}_onObjectRemoved(r){}_onStackOrderChanged(r){}add(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];const o=this._objects.push(...i);return i.forEach(a=>this._onObjectAdded(a)),o}insertAt(r){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return this._objects.splice(r,0,...s),s.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const r=this._objects,i=[];for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return o.forEach(l=>{const c=r.indexOf(l);c!==-1&&(r.splice(c,1),i.push(l),this._onObjectRemoved(l))}),i}forEachObject(r){this.getObjects().forEach((i,s,o)=>r(i,s,o))}getObjects(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...i))}item(r){return this._objects[r]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(r,i){return!!this._objects.includes(r)||!!i&&this._objects.some(s=>s instanceof t&&s.contains(r,!0))}complexity(){return this._objects.reduce((r,i)=>r+=i.complexity?i.complexity():0,0)}sendObjectToBack(r){return!(!r||r===this._objects[0])&&(Me(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(Me(this._objects,r),this._objects.push(r),this._onStackOrderChanged(r),!0)}sendObjectBackwards(r,i){if(!r)return!1;const s=this._objects.indexOf(r);if(s!==0){const o=this.findNewLowerIndex(r,s,i);return Me(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}bringObjectForward(r,i){if(!r)return!1;const s=this._objects.indexOf(r);if(s!==this._objects.length-1){const o=this.findNewUpperIndex(r,s,i);return Me(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,i){return r!==this._objects[i]&&(Me(this._objects,r),this._objects.splice(i,0,r),this._onStackOrderChanged(r),!0)}findNewLowerIndex(r,i,s){let o;if(s){o=i;for(let a=i-1;a>=0;--a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=i-1;return o}findNewUpperIndex(r,i,s){let o;if(s){o=i;for(let a=i+1;a<this._objects.length;++a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=i+1;return o}collectObjects(r){let{left:i,top:s,width:o,height:a}=r,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(i,s),u=h.add(new x(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class Ao extends Fl{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Nr(n){return pi().requestAnimationFrame(n)}function Rl(n){return pi().cancelAnimationFrame(n)}let Bl=0;const fe=()=>Bl++,ne=()=>{const n=ze().createElement("canvas");if(!n||n.getContext===void 0)throw new Ut("Failed to create `canvas` element");return n},Il=()=>ze().createElement("img"),jt=n=>{const t=ne();return t.width=n.width,t.height=n.height,t},jo=(n,t,e)=>n.toDataURL("image/".concat(t),e),Lo=(n,t,e)=>new Promise((r,i)=>{n.toBlob(r,"image/".concat(t),e)}),st=n=>n*ws,oe=n=>n/ws,Hl=n=>n.every((t,e)=>t===mt[e]),bt=(n,t,e)=>new x(n).transform(t,e),Wt=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:r,y:i}=new x(n[4],n[5]).transform(e,!0);return e[4]=-r,e[5]=-i,e},ht=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],Os=(n,t)=>n.reduceRight((e,r)=>r&&e?ht(r,e,t):r||e,void 0)||mt.concat(),Fo=n=>{let[t,e]=n;return Math.atan2(e,t)},ri=n=>{const t=Fo(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),r=Math.sqrt(e),i=(n[0]*n[3]-n[2]*n[1])/r,s=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:oe(t),scaleX:r,scaleY:i,skewX:oe(s),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},gr=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Xe(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=st(n),i=ie(r),s=se(r);return[i,s,-s,i,t?t-(i*t-s*e):0,e?e-(s*t+i*e):0]}const Ds=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},Ro=n=>Math.tan(st(n)),Bo=n=>[1,0,Ro(n),1,0,0],Io=n=>[1,Ro(n),0,1,0,0],bi=n=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:i=!1,skewX:s=0,skewY:o=0}=n,a=Ds(r?-t:t,i?-e:e);return s&&(a=ht(a,Bo(s),!0)),o&&(a=ht(a,Io(o),!0)),a},zl=n=>{const{translateX:t=0,translateY:e=0,angle:r=0}=n;let i=gr(t,e);r&&(i=ht(i,Xe({angle:r})));const s=bi(n);return Hl(s)||(i=ht(i,s)),i},$r=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,i){if(t&&t.aborted)return i(new Ml("loadImage"));const s=Il();let o;t&&(o=function(l){s.src="",i(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){s.onload=s.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),r(s)};n?(s.onload=a,s.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),i(new Ut("Error loading ".concat(s.src)))},e&&(s.crossOrigin=e),s.src=n):a()})},nr=function(n){let{signal:t,reviver:e=Ur}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0}),Promise.all(n.map(o=>E.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),s.push(a),a)))).then(r).catch(o=>{s.forEach(a=>{a.dispose&&a.dispose()}),i(o)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},yi=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,r)=>{const i=[];t&&t.addEventListener("abort",r,{once:!0});const s=Object.values(n).map(a=>a&&a.type&&E.has(a.type)?nr([a],{signal:t}).then(l=>{let[c]=l;return i.push(c),c}):a),o=Object.keys(n);Promise.all(s).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{i.forEach(l=>{l.dispose&&l.dispose()}),r(a)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},Ye=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},Ms=(n,t)=>Object.keys(n).reduce((e,r)=>(t(n[r],r,n)&&(e[r]=n[r]),e),{}),Z=(n,t)=>parseFloat(Number(n).toFixed(t)),or=n=>"matrix("+n.map(t=>Z(t,X.NUM_FRACTION_DIGITS)).join(" ")+")",Pt=n=>!!n&&n.toLive!==void 0,an=n=>!!n&&typeof n.toObject=="function",ln=n=>!!n&&n.offsetX!==void 0&&"source"in n,ve=n=>!!n&&"multiSelectionStacking"in n;function Ho(n){const t=n&&zt(n);let e=0,r=0;if(!n||!t)return{left:e,top:r};let i=n;const s=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(e=o.scrollLeft||s.scrollLeft||0,r=o.scrollTop||s.scrollTop||0):(e+=i.scrollLeft||0,r+=i.scrollTop||0),i.nodeType!==1||i.style.position!=="fixed"););return{left:e,top:r}}const zt=n=>n.ownerDocument||null,zo=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Wo=function(n,t,e){let{width:r,height:i}=e,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=r,n.height=i,s>1&&(n.setAttribute("width",(r*s).toString()),n.setAttribute("height",(i*s).toString()),t.scale(s,s))},Qi=(n,t)=>{let{width:e,height:r}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),r&&(n.style.height=typeof r=="number"?"".concat(r,"px"):r)};function cn(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=_t,n}class Vo{constructor(t){p(this,"_originalCanvasStyle",void 0),p(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(r=t)&&r.getContext!==void 0?t:t&&ze().getElementById(t)||ne();var r;if(e.hasAttribute("data-fabric"))throw new Ut("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:r}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(r)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:i}=this.lower;Wo(r,i,t,e)}setCSSDimensions(t){Qi(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&zt(t),i={left:0,top:0};if(!r)return i;const s=((e=zo(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(s.borderLeftWidth,10)||0,i.top+=parseInt(s.borderTopWidth,10)||0,i.left+=parseInt(s.paddingLeft,10)||0,i.top+=parseInt(s.paddingTop,10)||0;let o={left:0,top:0};const a=r.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=Ho(t);return{left:o.left+l.left-(a.clientLeft||0)+i.left,top:o.top+l.top-(a.clientTop||0)+i.top}}(this.lower.el)}dispose(){$t().dispose(this.lower.el),delete this.lower}}const Wl={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...mt]},Vl=["objects"];class fr extends Po(Ao){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return fr.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),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(t){this.elements=new Vo(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const s=super.insertAt(t,...r);return r.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),s}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(ge("warn",`Canvas is trying to add an object that belongs to a different canvas.
83
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?Oo():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:r=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const i=v({width:this.width,height:this.height},t);this.elements.setDimensions(i,this.getRetinaScaling()),this.hasLostContext=!0,this.width=i.width,this.height=i.height}r||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const r=t,i=[...this.viewportTransform],s=bt(t,Wt(i));i[0]=e,i[3]=e;const o=bt(s,i);i[4]+=r.x-o.x,i[5]+=r.y-o.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.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=Nr(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Wt(this.viewportTransform),i=bt({x:0,y:0},r),s=bt({x:t,y:e},r),o=i.min(s),a=i.max(s);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Rl(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const r=this.viewportTransform;t.save(),t.transform(...r),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let r=0,i=e.length;r<i;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this["".concat(e,"Color")],i=this["".concat(e,"Image")],s=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!r&&!i)return;const a=Pt(r);if(r){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?r.toLive(t):r,o&&t.transform(...s),a){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const l=r.gradientTransform||r.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...s),i.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return bt(this.getCenterPoint(),Wt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,W,W),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const r=this.clipPath,i=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return v(v(v({version:Zi},Ye(this,e)),{},{objects:this._objects.filter(s=>!s.excludeFromExport).map(s=>this._toObject(s,t,e))},this.__serializeBgOverlay(t,e)),i?{clipPath:i}:null)}_toObject(t,e,r){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);const s=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!i),s}__serializeBgOverlay(t,e){const r={},i=this.backgroundImage,s=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return Pt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),Pt(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),i&&!i.excludeFromExport&&(r.backgroundImage=this._toObject(i,t,e)),s&&!s.excludeFromExport&&(r.overlayImage=this._toObject(s,t,e)),r}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
84
- `)),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
36
+ */const Mc=_n("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Ec={bug:Oc,"message-square":Mc,"alert-circle":Dc},Pc=({name:i,class:t,size:e=18,strokeWidth:r=2})=>{const s=Ec[i];return s?p(s,{class:t,size:e,strokeWidth:r}):null};function Ta(i){var t,e,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(t=0;t<s;t++)i[t]&&(e=Ta(i[t]))&&(r&&(r+=" "),r+=e)}else for(e in i)i[e]&&(r&&(r+=" "),r+=e);return r}function Oa(){for(var i,t,e=0,r="",s=arguments.length;e<s;e++)(i=arguments[e])&&(t=Ta(i))&&(r&&(r+=" "),r+=t);return r}const Ac=(i,t)=>{const e=new Array(i.length+t.length);for(let r=0;r<i.length;r++)e[r]=i[r];for(let r=0;r<t.length;r++)e[i.length+r]=t[r];return e},Lc=(i,t)=>({classGroupId:i,validator:t}),Da=(i=new Map,t=null,e)=>({nextPart:i,validators:t,classGroupId:e}),Rs="-",ao=[],Fc="arbitrary..",jc=i=>{const t=Bc(i),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=i;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Ic(o);const a=o.split(Rs),l=a[0]===""&&a.length>1?1:0;return Ma(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=e[o];return l?c?Ac(c,l):l:c||ao}return e[o]||ao}}},Ma=(i,t,e)=>{if(i.length-t===0)return e.classGroupId;const s=i[t],n=e.nextPart.get(s);if(n){const c=Ma(i,t+1,n);if(c)return c}const o=e.validators;if(o===null)return;const a=t===0?i.join(Rs):i.slice(t).join(Rs),l=o.length;for(let c=0;c<l;c++){const h=o[c];if(h.validator(a))return h.classGroupId}},Ic=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=i.slice(1,-1),e=t.indexOf(":"),r=t.slice(0,e);return r?Fc+r:void 0})(),Bc=i=>{const{theme:t,classGroups:e}=i;return Rc(e,t)},Rc=(i,t)=>{const e=Da();for(const r in i){const s=i[r];Cn(s,e,r,t)}return e},Cn=(i,t,e,r)=>{const s=i.length;for(let n=0;n<s;n++){const o=i[n];$c(o,t,e,r)}},$c=(i,t,e,r)=>{if(typeof i=="string"){zc(i,t,e);return}if(typeof i=="function"){Hc(i,t,e,r);return}Vc(i,t,e,r)},zc=(i,t,e)=>{const r=i===""?t:Ea(t,i);r.classGroupId=e},Hc=(i,t,e,r)=>{if(Wc(i)){Cn(i(r),t,e,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Lc(e,i))},Vc=(i,t,e,r)=>{const s=Object.entries(i),n=s.length;for(let o=0;o<n;o++){const[a,l]=s[o];Cn(l,Ea(t,a),e,r)}},Ea=(i,t)=>{let e=i;const r=t.split(Rs),s=r.length;for(let n=0;n<s;n++){const o=r[n];let a=e.nextPart.get(o);a||(a=Da(),e.nextPart.set(o,a)),e=a}return e},Wc=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,Xc=i=>{if(i<1)return{get:()=>{},set:()=>{}};let t=0,e=Object.create(null),r=Object.create(null);const s=(n,o)=>{e[n]=o,t++,t>i&&(t=0,r=e,e=Object.create(null))};return{get(n){let o=e[n];if(o!==void 0)return o;if((o=r[n])!==void 0)return s(n,o),o},set(n,o){n in e?e[n]=o:s(n,o)}}},Gi="!",lo=":",Yc=[],co=(i,t,e,r,s)=>({modifiers:i,hasImportantModifier:t,baseClassName:e,maybePostfixModifierPosition:r,isExternal:s}),Uc=i=>{const{prefix:t,experimentalParseClassName:e}=i;let r=s=>{const n=[];let o=0,a=0,l=0,c;const h=s.length;for(let m=0;m<h;m++){const y=s[m];if(o===0&&a===0){if(y===lo){n.push(s.slice(l,m)),l=m+1;continue}if(y==="/"){c=m;continue}}y==="["?o++:y==="]"?o--:y==="("?a++:y===")"&&a--}const u=n.length===0?s:s.slice(l);let d=u,g=!1;u.endsWith(Gi)?(d=u.slice(0,-1),g=!0):u.startsWith(Gi)&&(d=u.slice(1),g=!0);const f=c&&c>l?c-l:void 0;return co(n,g,d,f)};if(t){const s=t+lo,n=r;r=o=>o.startsWith(s)?n(o.slice(s.length)):co(Yc,!1,o,void 0,!0)}if(e){const s=r;r=n=>e({className:n,parseClassName:s})}return r},Gc=i=>{const t=new Map;return i.orderSensitiveModifiers.forEach((e,r)=>{t.set(e,1e6+r)}),e=>{const r=[];let s=[];for(let n=0;n<e.length;n++){const o=e[n],a=o[0]==="[",l=t.has(o);a||l?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(o)):s.push(o)}return s.length>0&&(s.sort(),r.push(...s)),r}},Nc=i=>({cache:Xc(i.cacheSize),parseClassName:Uc(i),sortModifiers:Gc(i),...jc(i)}),qc=/\s+/,Kc=(i,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:n}=t,o=[],a=i.trim().split(qc);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:u,modifiers:d,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:m}=e(h);if(u){l=h+(l.length>0?" "+l:l);continue}let y=!!m,b=r(y?f.substring(0,m):f);if(!b){if(!y){l=h+(l.length>0?" "+l:l);continue}if(b=r(f),!b){l=h+(l.length>0?" "+l:l);continue}y=!1}const x=d.length===0?"":d.length===1?d[0]:n(d).join(":"),T=g?x+Gi:x,C=T+b;if(o.indexOf(C)>-1)continue;o.push(C);const S=s(b,y);for(let D=0;D<S.length;++D){const A=S[D];o.push(T+A)}l=h+(l.length>0?" "+l:l)}return l},Zc=(...i)=>{let t=0,e,r,s="";for(;t<i.length;)(e=i[t++])&&(r=Pa(e))&&(s&&(s+=" "),s+=r);return s},Pa=i=>{if(typeof i=="string")return i;let t,e="";for(let r=0;r<i.length;r++)i[r]&&(t=Pa(i[r]))&&(e&&(e+=" "),e+=t);return e},Jc=(i,...t)=>{let e,r,s,n;const o=l=>{const c=t.reduce((h,u)=>u(h),i());return e=Nc(c),r=e.cache.get,s=e.cache.set,n=a,a(l)},a=l=>{const c=r(l);if(c)return c;const h=Kc(l,e);return s(l,h),h};return n=o,(...l)=>n(Zc(...l))},Qc=[],wt=i=>{const t=e=>e[i]||Qc;return t.isThemeGetter=!0,t},Aa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,La=/^\((?:(\w[\w-]*):)?(.+)\)$/i,th=/^\d+\/\d+$/,eh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ih=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ne=i=>th.test(i),U=i=>!!i&&!Number.isNaN(Number(i)),Ce=i=>!!i&&Number.isInteger(Number(i)),bi=i=>i.endsWith("%")&&U(i.slice(0,-1)),he=i=>eh.test(i),oh=()=>!0,ah=i=>rh.test(i)&&!sh.test(i),Fa=()=>!1,lh=i=>ih.test(i),ch=i=>nh.test(i),hh=i=>!R(i)&&!$(i),uh=i=>ur(i,Ba,Fa),R=i=>Aa.test(i),Le=i=>ur(i,Ra,ah),xi=i=>ur(i,mh,U),ho=i=>ur(i,ja,Fa),dh=i=>ur(i,Ia,ch),us=i=>ur(i,$a,lh),$=i=>La.test(i),_r=i=>dr(i,Ra),gh=i=>dr(i,vh),uo=i=>dr(i,ja),fh=i=>dr(i,Ba),ph=i=>dr(i,Ia),ds=i=>dr(i,$a,!0),ur=(i,t,e)=>{const r=Aa.exec(i);return r?r[1]?t(r[1]):e(r[2]):!1},dr=(i,t,e=!1)=>{const r=La.exec(i);return r?r[1]?t(r[1]):e:!1},ja=i=>i==="position"||i==="percentage",Ia=i=>i==="image"||i==="url",Ba=i=>i==="length"||i==="size"||i==="bg-size",Ra=i=>i==="length",mh=i=>i==="number",vh=i=>i==="family-name",$a=i=>i==="shadow",yh=()=>{const i=wt("color"),t=wt("font"),e=wt("text"),r=wt("font-weight"),s=wt("tracking"),n=wt("leading"),o=wt("breakpoint"),a=wt("container"),l=wt("spacing"),c=wt("radius"),h=wt("shadow"),u=wt("inset-shadow"),d=wt("text-shadow"),g=wt("drop-shadow"),f=wt("blur"),m=wt("perspective"),y=wt("aspect"),b=wt("ease"),x=wt("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...C(),$,R],D=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],_=()=>[$,R,l],M=()=>[Ne,"full","auto",..._()],O=()=>[Ce,"none","subgrid",$,R],V=()=>["auto",{span:["full",Ce,$,R]},Ce,$,R],z=()=>[Ce,"auto",$,R],X=()=>["auto","min","max","fr",$,R],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],G=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",..._()],K=()=>[Ne,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],L=()=>[i,$,R],bt=()=>[...C(),uo,ho,{position:[$,R]}],gt=()=>["no-repeat",{repeat:["","x","y","space","round"]}],lt=()=>["auto","cover","contain",fh,uh,{size:[$,R]}],k=()=>[bi,_r,Le],P=()=>["","none","full",c,$,R],E=()=>["",U,_r,Le],B=()=>["solid","dashed","dotted","double"],j=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[U,bi,uo,ho],ut=()=>["","none",f,$,R],ct=()=>["none",U,$,R],st=()=>["none",U,$,R],St=()=>[U,$,R],F=()=>[Ne,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[he],breakpoint:[he],color:[oh],container:[he],"drop-shadow":[he],ease:["in","out","in-out"],font:[hh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[he],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[he],shadow:[he],spacing:["px",U],text:[he],"text-shadow":[he],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ne,R,$,y]}],container:["container"],columns:[{columns:[U,R,$,a]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{start:M()}],end:[{end:M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[Ce,"auto",$,R]}],basis:[{basis:[Ne,"full","auto",a,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[U,Ne,"auto","initial","none",R]}],grow:[{grow:["",U,$,R]}],shrink:[{shrink:["",U,$,R]}],order:[{order:[Ce,"first","last","none",$,R]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:V()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:V()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...G(),"normal"]}],"justify-self":[{"justify-self":["auto",...G()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...G(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...G(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...G(),"baseline"]}],"place-self":[{"place-self":["auto",...G()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],w:[{w:[a,"screen",...K()]}],"min-w":[{"min-w":[a,"screen","none",...K()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",e,_r,Le]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$,xi]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",bi,R]}],"font-family":[{font:[gh,R,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,$,R]}],"line-clamp":[{"line-clamp":[U,"none",$,xi]}],leading:[{leading:[n,..._()]}],"list-image":[{"list-image":["none",$,R]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$,R]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:[U,"from-font","auto",$,Le]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[U,"auto",$,R]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$,R]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",$,R]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:bt()}],"bg-repeat":[{bg:gt()}],"bg-size":[{bg:lt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ce,$,R],radial:["",$,R],conic:[Ce,$,R]},ph,dh]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:k()}],"gradient-via-pos":[{via:k()}],"gradient-to-pos":[{to:k()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...B(),"hidden","none"]}],"divide-style":[{divide:[...B(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...B(),"none","hidden"]}],"outline-offset":[{"outline-offset":[U,$,R]}],"outline-w":[{outline:["",U,_r,Le]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",h,ds,us]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",u,ds,us]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[U,Le]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",d,ds,us]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[U,$,R]}],"mix-blend":[{"mix-blend":[...j(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":j()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[U]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[$,R]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[U]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:bt()}],"mask-repeat":[{mask:gt()}],"mask-size":[{mask:lt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$,R]}],filter:[{filter:["","none",$,R]}],blur:[{blur:ut()}],brightness:[{brightness:[U,$,R]}],contrast:[{contrast:[U,$,R]}],"drop-shadow":[{"drop-shadow":["","none",g,ds,us]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",U,$,R]}],"hue-rotate":[{"hue-rotate":[U,$,R]}],invert:[{invert:["",U,$,R]}],saturate:[{saturate:[U,$,R]}],sepia:[{sepia:["",U,$,R]}],"backdrop-filter":[{"backdrop-filter":["","none",$,R]}],"backdrop-blur":[{"backdrop-blur":ut()}],"backdrop-brightness":[{"backdrop-brightness":[U,$,R]}],"backdrop-contrast":[{"backdrop-contrast":[U,$,R]}],"backdrop-grayscale":[{"backdrop-grayscale":["",U,$,R]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[U,$,R]}],"backdrop-invert":[{"backdrop-invert":["",U,$,R]}],"backdrop-opacity":[{"backdrop-opacity":[U,$,R]}],"backdrop-saturate":[{"backdrop-saturate":[U,$,R]}],"backdrop-sepia":[{"backdrop-sepia":["",U,$,R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$,R]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[U,"initial",$,R]}],ease:[{ease:["linear","initial",b,$,R]}],delay:[{delay:[U,$,R]}],animate:[{animate:["none",x,$,R]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,$,R]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:ct()}],"rotate-x":[{"rotate-x":ct()}],"rotate-y":[{"rotate-y":ct()}],"rotate-z":[{"rotate-z":ct()}],scale:[{scale:st()}],"scale-x":[{"scale-x":st()}],"scale-y":[{"scale-y":st()}],"scale-z":[{"scale-z":st()}],"scale-3d":["scale-3d"],skew:[{skew:St()}],"skew-x":[{"skew-x":St()}],"skew-y":[{"skew-y":St()}],transform:[{transform:[$,R,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:F()}],"translate-x":[{"translate-x":F()}],"translate-y":[{"translate-y":F()}],"translate-z":[{"translate-z":F()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",$,R]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",$,R]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[U,_r,Le,xi]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},bh=Jc(yh);function $t(...i){return bh(Oa(i))}const xh=["dark","theme-dark","dark-mode","dark-theme","wp-dark-mode-active","flavor-dark","is-dark","night","night-mode"],wh=["light","theme-light","light-mode","light-theme","wp-dark-mode-disabled","is-light"],za=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme","data-wp-dark-mode-active","data-dark-mode"],wi=["class","style","color-scheme",...za];function _h(i){const t=i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:Number(t[1]),g:Number(t[2]),b:Number(t[3])}:null}function Ch(i,t,e){const[r,s,n]=[i/255,t/255,e/255].map(o=>o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4));return .2126*r+.7152*s+.0722*n}function Sh(){var t;const i=document.querySelector("script[data-api-key][data-bugpin-theme]");if(i){const e=(t=i.getAttribute("data-bugpin-theme"))==null?void 0:t.toLowerCase();if(e==="dark")return"dark";if(e==="light")return"light"}return null}function kh(){var e,r,s;const i=document.documentElement,t=document.body;for(const n of[i,t])if(n){for(const o of xh)if(n.classList.contains(o))return"dark";for(const o of wh)if(n.classList.contains(o))return"light"}for(const n of za)for(const o of[i,t]){if(!o)continue;const a=(e=o.getAttribute(n))==null?void 0:e.toLowerCase();if(a){if(a==="dark"||a==="true")return"dark";if(a==="light"||a==="false")return"light"}}for(const n of[i,t]){if(!n)continue;const o=(r=n.getAttribute("color-scheme"))==null?void 0:r.toLowerCase();if(o!=null&&o.includes("dark"))return"dark";if(o!=null&&o.includes("light"))return"light"}if(typeof getComputedStyle<"u"){const o=(s=getComputedStyle(i).colorScheme)==null?void 0:s.toLowerCase();if(o){if(o==="dark"||o.startsWith("dark "))return"dark";if(o==="light"||o.startsWith("light "))return"light"}}return null}function Th(){if(typeof getComputedStyle>"u")return null;const i=document.body;if(!i)return null;const t=getComputedStyle(i).backgroundColor;if(!t||t==="rgba(0, 0, 0, 0)"||t==="transparent")return null;const e=_h(t);if(!e)return null;const r=Ch(e.r,e.g,e.b);return r<.4?"dark":r>.6?"light":null}function Oh(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function go(){return Sh()??kh()??Th()??Oh()}function Ha(i){const[t,e]=at(()=>i!=="auto"?i:go());return Vt(()=>{if(i!=="auto"){e(i);return}const r=()=>e(go());r();let s=null;if(typeof MutationObserver<"u")if(s=new MutationObserver(r),s.observe(document.documentElement,{attributes:!0,attributeFilter:wi}),document.body)s.observe(document.body,{attributes:!0,attributeFilter:wi});else{const o=new MutationObserver(()=>{document.body&&(o.disconnect(),s==null||s.observe(document.body,{attributes:!0,attributeFilter:wi}),r())});o.observe(document.documentElement,{childList:!0})}let n=null;return typeof window<"u"&&typeof window.matchMedia=="function"&&(n=window.matchMedia("(prefers-color-scheme: dark)"),n.addEventListener("change",r)),()=>{s==null||s.disconnect(),n==null||n.removeEventListener("change",r)}},[i]),t}const Dh={"bottom-right":"bottom-5 right-5","bottom-left":"bottom-5 left-5","top-right":"top-5 right-5","top-left":"top-5 left-5"},Mh=({position:i,buttonText:t,buttonShape:e,buttonIcon:r,buttonIconSize:s,buttonIconStroke:n,theme:o,lightButtonColor:a,lightTextColor:l,lightButtonHoverColor:c,lightTextHoverColor:h,darkButtonColor:u,darkTextColor:d,darkButtonHoverColor:g,darkTextHoverColor:f,enableHoverScaleEffect:m,tooltipEnabled:y,tooltipText:b,onClick:x})=>{const[T,C]=at(!1),[S,D]=at({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),A=Rt(null),_=Rt(null),O=Ha(o)==="dark";Vt(()=>{if(T&&A.current&&_.current){const L=A.current,bt=_.current;requestAnimationFrame(()=>{const gt=L.getBoundingClientRect(),lt=bt.getBoundingClientRect(),k=window.innerWidth,P=4,E=lt.left+lt.width/2,B=gt.width/2;let j=0;const H=E-B;H<P?j=P-H:H+gt.width>k-P&&(j=k-P-(H+gt.width)),D({left:"50%",transform:`translateX(-50%) translateX(${j}px)`,arrowLeft:"50%"})})}},[T,b]);const V=O?T?g:u:T?c:a,z=O?T?f:d:T?h:l,X=O?u:a,W=O?d:l,G=e==="round"?"50%":"8px",q=t||"Report Bug",K=e==="round"?`${s/2}px`:"12px 20px";return p("div",{class:$t("fixed z-[2147483647]",Dh[i]),children:[p("button",{ref:_,class:$t("relative flex items-center justify-center gap-2 border-none text-sm font-medium cursor-pointer shadow-lg transition-all duration-200",m&&"hover:scale-110 hover:shadow-xl active:scale-105"),style:{backgroundColor:V,color:z,borderRadius:G,padding:K},onClick:x,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"aria-label":q,children:[r&&p(Pc,{name:r,size:s,strokeWidth:n}),t&&p("span",{children:t})]}),y&&b&&T&&p("div",{ref:A,class:"absolute bottom-full mb-2 px-3 py-1.5 text-xs rounded whitespace-nowrap pointer-events-none z-[2147483647] animate-[bugpin-tooltip-fade-in_0.2s_ease-in-out_forwards] shadow-md",style:{backgroundColor:X,color:W,opacity:0,left:S.left,transform:S.transform},children:[b,p("div",{class:"absolute top-full border-4 border-solid border-transparent",style:{left:S.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderTopColor:X}})]})]})},fo=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,po=Oa,Eh=(i,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return po(i,e==null?void 0:e.class,e==null?void 0:e.className);const{variants:s,defaultVariants:n}=t,o=Object.keys(s).map(c=>{const h=e==null?void 0:e[c],u=n==null?void 0:n[c];if(h===null)return null;const d=fo(h)||fo(u);return s[c][d]}),a=e&&Object.entries(e).reduce((c,h)=>{let[u,d]=h;return d===void 0||(c[u]=d),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,h)=>{let{class:u,className:d,...g}=h;return Object.entries(g).every(f=>{let[m,y]=f;return Array.isArray(y)?y.includes({...n,...a}[m]):{...n,...a}[m]===y})?[...c,u,d]:c},[]);return po(i,o,l,e==null?void 0:e.class,e==null?void 0:e.className)},Ph=Eh("inline-flex items-center justify-center gap-2 font-medium font-sans cursor-pointer transition-colors border-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover hover:text-primary-hover-foreground",outline:"border border-solid border-input bg-background text-foreground hover:bg-muted",ghost:"bg-transparent hover:bg-muted text-foreground",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90"},size:{default:"h-10 px-4 text-sm rounded-sm",sm:"h-8 px-3 text-xs rounded-sm",lg:"h-12 px-6 text-base rounded",icon:"h-8 w-8 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),oe=({class:i,variant:t,size:e,children:r,type:s="button",...n})=>p("button",{type:s,class:$t(Ph({variant:t,size:e}),i),...n,children:r}),_i=({class:i,error:t,type:e="text",...r})=>p("input",{type:e,class:$t("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r}),Ah=({class:i,error:t,...e})=>p("textarea",{class:$t("min-h-20 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] resize-y transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...e}),Lh=({class:i,error:t,children:e,...r})=>p("select",{class:$t("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] cursor-pointer transition-colors","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r,children:e}),Cr=({class:i,required:t,children:e,for:r,...s})=>p("label",{for:r,class:$t("text-sm font-medium text-foreground",i),...s,children:[e,t&&p("span",{class:"text-destructive ml-0.5",children:"*"})]}),Fh=({tabs:i,activeTab:t,onTabChange:e})=>p("div",{class:"inline-flex p-1 bg-muted rounded gap-1",role:"tablist","aria-orientation":"horizontal",children:i.map(r=>{const s=r.id===t;return p("button",{type:"button",role:"tab",id:`tab-${r.id}`,"aria-selected":s,"aria-controls":`tabpanel-${r.id}`,tabIndex:s?0:-1,class:$t("flex items-center gap-2 px-3 py-1.5 border-none rounded-md bg-transparent text-muted-foreground text-sm font-medium font-sans cursor-pointer transition-colors","hover:text-foreground",s&&"bg-background text-foreground shadow-sm"),onClick:()=>e(r.id),children:[r.icon&&p("span",{class:"flex items-center justify-center [&_svg]:w-4 [&_svg]:h-4",children:r.icon}),r.label]},r.id)})}),jh={success:"bg-green-50 border-green-200 text-green-600",error:"bg-red-50 border-red-200 text-red-600",info:"bg-blue-50 border-blue-200 text-blue-600"},Ih=({message:i,type:t,onClose:e,duration:r=5e3})=>(Vt(()=>{const s=setTimeout(e,r);return()=>clearTimeout(s)},[e,r]),p("div",{class:$t("fixed bottom-20 right-5 z-[2147483647] flex items-center gap-3 px-5 py-4 border border-solid rounded text-sm shadow-lg animate-[slideIn_0.3s_ease-out]",jh[t]),role:"alert","aria-live":"polite",children:[t==="success"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",fill:"currentColor"})}),t==="error"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),t==="info"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z",fill:"currentColor"})}),p("span",{children:i})]})),Bh=10*1024*1024,Rh=50*1024*1024,$h=["image/png","image/jpeg","image/gif","image/webp"],zh=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Hh=({media:i,onCapture:t,onUpload:e,onRemove:r,onAnnotate:s,isCapturing:n,enableAnnotation:o,maxImageSize:a=Bh,maxVideoSize:l=Rh})=>{const[c,h]=at(!1),[u,d]=at(null),g=Rt(null),f=O=>O.startsWith("video/"),m=O=>O.startsWith("image/"),y=Math.round(a/(1024*1024)),b=Math.round(l/(1024*1024)),x=N(O=>{if(m(O.type)){if(!$h.includes(O.type))return`Unsupported image format: ${O.type}`;if(O.size>a)return`Image too large. Maximum size is ${y}MB.`}else if(f(O.type)){if(!zh.includes(O.type))return`Unsupported video format: ${O.type}`;if(O.size>l)return`Video too large. Maximum size is ${b}MB.`}else return`Unsupported file type: ${O.type}`;return null},[a,y,l,b]),T=N(async O=>{const V=x(O);if(V){d(V);return}d(null);const z=new FileReader;z.onload=()=>{const X=z.result;if(m(O.type)){const W=new Image;W.onload=()=>{const G={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:X,timestamp:new Date,annotated:!1,mimeType:O.type,width:W.width,height:W.height};e(G)},W.src=X}else if(f(O.type)){const W=document.createElement("video");W.onloadedmetadata=()=>{const G={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:X,timestamp:new Date,annotated:!1,mimeType:O.type,width:W.videoWidth,height:W.videoHeight};e(G)},W.src=X}},z.readAsDataURL(O)},[x,e]),C=N(O=>{O.preventDefault(),O.stopPropagation(),h(!0)},[]),S=N(O=>{O.preventDefault(),O.stopPropagation(),h(!1)},[]),D=N(async O=>{var z;O.preventDefault(),O.stopPropagation(),h(!1);const V=(z=O.dataTransfer)==null?void 0:z.files;if(V)for(let X=0;X<V.length;X++)await T(V[X])},[T]),A=N(async O=>{const V=O.target,z=V.files;if(z)for(let X=0;X<z.length;X++)await T(z[X]);V.value=""},[T]),_=N(()=>{var O;(O=g.current)==null||O.click()},[]),M=O=>O.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return p("div",{class:"flex flex-col gap-4",children:[p("p",{class:"text-xs text-muted-foreground",children:"Tip: Use the annotation tool to hide any sensitive data before submitting."}),p("div",{class:"flex gap-2",children:[p(oe,{class:"flex-1",onClick:t,disabled:n,children:[p("svg",{class:"w-4.5 h-4.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 15.2c1.77 0 3.2-1.43 3.2-3.2S13.77 8.8 12 8.8 8.8 10.23 8.8 12s1.43 3.2 3.2 3.2zM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",fill:"currentColor"})}),n?"Capturing...":"Capture Screenshot"]}),p("input",{ref:g,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:A})]}),u&&p("div",{class:"flex items-center gap-2 px-3 py-2.5 bg-red-50 dark:bg-red-950/50 border border-solid border-red-200 dark:border-red-800 rounded text-red-600 dark:text-red-400 text-sm",children:[p("svg",{class:"w-4.5 h-4.5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),u]}),p("div",{class:$t("min-h-40 border-2 border-dashed border-border rounded bg-muted transition-colors",c&&"border-primary bg-primary/5",i.length>0&&"border-solid bg-background min-h-0"),onDragOver:C,onDragLeave:S,onDrop:D,children:i.length===0?p("div",{class:"flex flex-col items-center justify-center py-8 px-4 text-muted-foreground text-center cursor-pointer transition-colors hover:text-primary [&_svg]:hover:text-primary",onClick:_,children:[p("svg",{class:"w-12 h-12 mb-3 text-muted-foreground transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z",fill:"currentColor"})}),p("p",{class:"text-sm font-medium mb-1",children:"Drag and drop files here"}),p("span",{class:"text-xs text-muted-foreground",children:"or click to browse"})]}):p("div",{class:"grid grid-cols-2 gap-3 p-3",children:[i.map(O=>p("div",{class:"relative rounded overflow-hidden bg-background border border-solid border-border",children:[p("div",{class:"relative aspect-video bg-gray-800",children:[f(O.mimeType)?p("video",{class:"w-full h-full object-contain",src:O.dataUrl,muted:!0}):p("img",{class:"w-full h-full object-contain",src:O.dataUrl,alt:"Screenshot"}),p("div",{class:"absolute top-1.5 left-1.5 flex gap-1",children:[O.annotated&&p("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-blue-100 dark:bg-blue-900/70 text-blue-700 dark:text-blue-300",children:"Annotated"}),f(O.mimeType)&&p("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Video"})]})]}),p("div",{class:"flex justify-between px-2 py-1.5 text-xs text-muted-foreground border-t border-solid border-border",children:[p("span",{children:M(O.timestamp)}),O.width&&O.height&&p("span",{children:[O.width," x ",O.height]})]}),p("div",{class:"flex gap-1 px-2 py-1.5 border-t border-solid border-border bg-muted",children:[o&&m(O.mimeType)&&p(oe,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-background hover:bg-muted text-foreground",onClick:()=>s(O.id),title:"Annotate",children:p("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",fill:"currentColor"})})}),p(oe,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-background hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950 text-foreground",onClick:()=>r(O.id),title:"Remove",children:p("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]})]},O.id)),p("div",{class:"flex flex-col items-center justify-center gap-2 min-h-28 border-2 border-dashed border-border rounded bg-muted cursor-pointer transition-colors hover:border-primary hover:bg-primary/5 [&_svg]:hover:text-primary [&_span]:hover:text-primary",onClick:_,children:[p("svg",{class:"w-8 h-8 text-muted-foreground transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})}),p("span",{class:"text-xs text-muted-foreground transition-colors",children:"Add more"})]})]})}),p("p",{class:"text-xs text-muted-foreground text-center",children:["Supported: PNG, JPG, GIF, WebP (max ",y,"MB) - MP4, WebM, MOV, AVI (max ",b,"MB)"]})]})},Vh="bugpin-skip-screen-capture-consent",Wh=({onConfirm:i,onCancel:t})=>{const[e,r]=at(!1);return p("div",{class:"flex-1 flex flex-col items-center justify-center p-6 gap-5 text-center",children:[p("div",{class:"space-y-2 max-w-sm",children:[p("h1",{children:"Browser permission required"}),p("p",{class:"text-sm text-muted-foreground",children:"Your browser will ask for permission to share your screen. Follow the steps shown."})]}),p("div",{class:"grid grid-cols-2 pb-4 gap-3 w-full max-w-xl",children:[p("div",{class:"flex flex-col items-center gap-1.5",children:[p("div",{class:"w-full rounded-lg overflow-hidden border border-solid border-border shadow-sm",children:p("svg",{viewBox:"0 0 200 148",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[p("defs",{children:p("filter",{id:"ff-shadow",x:"-4%",y:"-4%",width:"108%",height:"108%",children:p("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2","flood-opacity":"0.08"})})}),p("rect",{width:"200",height:"180",rx:"10",fill:"#ffffff",filter:"url(#ff-shadow)"}),p("text",{x:"16",y:"24","font-family":"system-ui, -apple-system, sans-serif","font-size":"10","font-weight":"700",fill:"#111",children:"Allow this site to see your screen?"}),p("rect",{x:"14",y:"42",width:"172",height:"26",rx:"6",fill:"#f5f5f5",stroke:"#ddd","stroke-width":"1"}),p("rect",{x:"23",y:"50",width:"11",height:"10",rx:"2",fill:"#d0d0d0"}),p("rect",{x:"25",y:"48",width:"3",height:"3",rx:"1",fill:"#bbb"}),p("rect",{x:"30",y:"48",width:"3",height:"3",rx:"1",fill:"#bbb"}),p("text",{x:"42",y:"55","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"9",fill:"#444",children:"Use operating system settings"}),p("rect",{x:"16",y:"74",width:"11",height:"11",rx:"3",fill:"white",stroke:"#c8c8c8","stroke-width":"1.2"}),p("text",{x:"34",y:"79.5","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#777",children:"Mute website notifications while sharing"}),p("line",{x1:"0",y1:"112",x2:"200",y2:"112",stroke:"#eaeaea","stroke-width":"1"}),p("rect",{x:"82",y:"119",width:"50",height:"22",rx:"6",fill:"white",stroke:"#ddd","stroke-width":"1"}),p("text",{x:"107",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#444","text-anchor":"middle",children:"Block"}),p("rect",{x:"136",y:"117",width:"56",height:"26",rx:"13",fill:"#aaa",opacity:"0.45"}),p("rect",{x:"138",y:"119",width:"52",height:"22",rx:"11",fill:"#9ca3af"}),p("text",{x:"164",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"white","font-weight":"600","text-anchor":"middle",children:"Allow"})]})}),p("p",{class:"text-xs font-medium text-muted-foreground",children:"Firefox"})]}),p("div",{class:"flex flex-col items-center gap-1.5",children:[p("div",{class:"w-full rounded-lg overflow-hidden border border-solid border-border shadow-sm",children:p("svg",{viewBox:"0 0 200 148",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[p("defs",{children:[p("filter",{id:"ce-shadow",x:"-4%",y:"-4%",width:"108%",height:"108%",children:p("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2","flood-opacity":"0.08"})}),p("clipPath",{id:"tab-preview-clip",children:p("rect",{x:"14",y:"48",width:"172",height:"56",rx:"6"})})]}),p("rect",{width:"200",height:"180",rx:"10",fill:"#ffffff",filter:"url(#ce-shadow)"}),p("text",{x:"16",y:"24","font-family":"system-ui, -apple-system, sans-serif","font-size":"10","font-weight":"700",fill:"#111",children:"Allow this site to see this tab?"}),p("text",{x:"16",y:"43","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#777",children:"The site will see this tab's contents."}),p("rect",{x:"14",y:"48",width:"172",height:"56",rx:"6",fill:"white",stroke:"#d4d4d8","stroke-width":"1"}),p("g",{"clip-path":"url(#tab-preview-clip)",children:[p("rect",{x:"14",y:"48",width:"172",height:"13",fill:"#ececec"}),p("circle",{cx:"26",cy:"54",r:"4",fill:"#ccc"}),p("rect",{x:"38",y:"51",width:"100",height:"7",rx:"3.5",fill:"#ddd"}),p("rect",{x:"22",y:"67",width:"72",height:"5",rx:"2.5",fill:"#ddd"}),p("rect",{x:"22",y:"76",width:"140",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"83",width:"120",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"89",width:"130",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"95",width:"100",height:"3.5",rx:"1.75",fill:"#e8e8e8"})]}),p("line",{x1:"0",y1:"112",x2:"200",y2:"112",stroke:"#eaeaea","stroke-width":"1"}),p("rect",{x:"86",y:"119",width:"48",height:"22",rx:"11",fill:"white",stroke:"#ddd","stroke-width":"1"}),p("text",{x:"110",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#444","text-anchor":"middle",children:"Cancel"}),p("rect",{x:"137",y:"117",width:"56",height:"26",rx:"13",fill:"#aaa",opacity:"0.45"}),p("rect",{x:"139",y:"119",width:"52",height:"22",rx:"11",fill:"#9ca3af"}),p("text",{x:"165",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"white","font-weight":"600","text-anchor":"middle",children:"Allow"})]})}),p("p",{class:"text-xs font-medium text-muted-foreground",children:"Chrome · Edge"})]})]}),p("label",{class:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[p("input",{type:"checkbox",checked:e,onChange:n=>r(n.target.checked),class:"w-3.5 h-3.5 accent-primary cursor-pointer"}),"Don't show this again"]}),p("div",{class:"flex gap-3 w-full max-w-xs",children:[p(oe,{variant:"outline",class:"flex-1",onClick:t,children:"Back"}),p(oe,{class:"flex-1",onClick:()=>{e&&localStorage.setItem(Vh,"true"),i()},children:"Take Screenshot"})]})]})},Xh=[{id:"details",label:"Details",icon:p("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",fill:"currentColor"})})},{id:"media",label:"Screenshots",icon:p("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})})}],Yh=({onClose:i,onSubmit:t,onCaptureScreenshot:e,onAnnotateMedia:r,media:s,onAddMedia:n,onRemoveMedia:o,isSubmitting:a,isCapturing:l,enableAnnotation:c,activeTab:h,onActiveTabChange:u,formData:d,onFormDataChange:g,showScreenCaptureConsent:f,onConsentConfirm:m,onConsentCancel:y,maxImageSize:b,maxVideoSize:x})=>{const[T,C]=at({}),S=N((M,O)=>{g({...d,[M]:O}),T[M]&&C(V=>({...V,[M]:void 0}))},[d,g,T]),D=N(()=>{const M={};return d.title.trim()?d.title.trim().length<4&&(M.title="Title must be at least 4 characters"):M.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(M.reporterEmail="Invalid email address"),C(M),Object.keys(M).length===0},[d]),A=N(M=>{if(M.preventDefault(),!D()){u("details");return}t(d,s)},[d,s,D,t,u]),_=s.length;return p("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative w-full max-w-3xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-title",children:[p("div",{class:"flex items-center justify-between p-6 border-b border-solid border-border",children:[p("h1",{id:"bugpin-title",children:"Report a Bug"}),p(oe,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close",children:p("svg",{class:"w-5 h-5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",fill:"currentColor"})})})]}),f?p(Wh,{onConfirm:m,onCancel:y}):p(os,{children:[p("div",{class:"p-4 pb-0 bg-transparent",children:p(Fh,{tabs:Xh.map(M=>({...M,label:M.id==="media"&&_>0?`${M.label} (${_})`:M.label})),activeTab:h,onTabChange:u})}),p("div",{class:"flex-1 overflow-y-auto p-6",children:[h==="details"&&p("form",{class:"flex flex-col gap-4",onSubmit:A,children:[p("div",{class:"flex flex-col gap-1.5",children:[p(Cr,{for:"bugpin-title-input",required:!0,children:"Title"}),p(_i,{id:"bugpin-title-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:M=>S("title",M.target.value),maxLength:200,error:!!T.title,"aria-describedby":T.title?"bugpin-title-error":void 0}),T.title&&p("span",{id:"bugpin-title-error",class:"text-destructive text-xs mt-0.5",children:T.title})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Cr,{for:"bugpin-description",children:"Description"}),p(Ah,{id:"bugpin-description",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:M=>S("description",M.target.value)})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Cr,{for:"bugpin-priority",children:"Priority"}),p(Lh,{id:"bugpin-priority",value:d.priority,onChange:M=>S("priority",M.target.value),children:[p("option",{value:"highest",children:"Highest"}),p("option",{value:"high",children:"High"}),p("option",{value:"medium",children:"Medium"}),p("option",{value:"low",children:"Low"}),p("option",{value:"lowest",children:"Lowest"})]})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Cr,{for:"bugpin-name",children:"Name (optional)"}),p(_i,{id:"bugpin-name",type:"text",placeholder:"Your name",value:d.reporterName,onInput:M=>S("reporterName",M.target.value)})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Cr,{for:"bugpin-email",children:"Email (optional)"}),p(_i,{id:"bugpin-email",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:M=>S("reporterEmail",M.target.value),error:!!T.reporterEmail,"aria-describedby":T.reporterEmail?"bugpin-email-error":void 0}),T.reporterEmail&&p("span",{id:"bugpin-email-error",class:"text-destructive text-xs mt-0.5",children:T.reporterEmail})]})]}),h==="media"&&p(Hh,{media:s,onCapture:e,onUpload:n,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c,maxImageSize:b,maxVideoSize:x})]}),p("div",{class:"flex gap-3 p-6 border-t border-solid border-border bg-muted",children:[p(oe,{variant:"outline",class:"flex-1",onClick:i,disabled:a,children:"Cancel"}),p(oe,{class:"flex-1",onClick:A,disabled:a,children:a?p("span",{class:"w-4 h-4 border-2 border-solid border-white/30 border-t-white rounded-full animate-[spin_0.8s_linear_infinite]"}):"Submit Report"})]})]}),p("div",{class:"py-3 px-6 text-center text-xs text-muted-foreground border-t border-solid border-border bg-background",children:["Powered by"," ",p("a",{href:"https://bugpin.io",target:"_blank",rel:"noopener noreferrer",class:"text-primary no-underline font-medium hover:underline hover:text-primary-hover",children:"BugPin"})]})]})})};function v(i,t,e){return(t=function(r){var s=function(n,o){if(typeof n!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var l=a.call(n,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(n)}(r,"string");return typeof s=="symbol"?s:s+""}(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class mo{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const et=new class extends mo{constructor(i){super(),this.configure(i)}configure(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,i)}addFonts(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths={...this.fontPaths,...i}}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(i=>{delete this.fontPaths[i]})}clearFonts(){this.fontPaths={}}restoreDefaults(i){const t=new mo,e=(i==null?void 0:i.reduce((r,s)=>(r[s]=t[s],r),{}))||t;this.configure(e)}},Me=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return console[i]("fabric",...e)};class se extends Error{constructor(t,e){super(`fabric: ${t}`,e)}}class Uh extends se{constructor(t){super(`${t} 'options.signal' is in 'aborted' state`)}}class Gh{}class Nh extends Gh{testPrecision(t,e){const r=`precision ${e} float;
37
+ void main(){}`,s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,r),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(r=>this.testPrecision(e,r)),e.getExtension("WEBGL_lose_context").loseContext(),Me("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const qh={};let vo;const le=()=>vo||(vo={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Nh,dispose(){},copyPasteData:qh}),gr=()=>le().document,ri=()=>le().window,Va=()=>{var i;return Math.max((i=et.devicePixelRatio)!==null&&i!==void 0?i:ri().devicePixelRatio,1)},Wr=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(i){let{fontFamily:t,fontStyle:e,fontWeight:r}=i;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const n=s.get(t),o=`${e.toLowerCase()}_${(r+"").toLowerCase()}`;return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(i){i?this.charWidthsCache.delete((i||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(i){const{perfLimitSizeTotal:t}=et,e=Math.sqrt(t*i);return[Math.floor(e),Math.floor(t/e)]}},Ni="7.2.0";function Es(){}const as=Math.PI/2,Kh=Math.PI/4,or=2*Math.PI,Sn=Math.PI/180,Mt=Object.freeze([1,0,0,1,0,0]),kn=16,Se=.4477152502,Y="center",Q="left",At="top",qi="bottom",pt="right",Lt="none",Tn=/\r?\n/,Wa="moving",si="scaling",Xa="rotating",On="rotate",Ya="skewing",Qr="resizing",Zh="modifyPoly",Jh="modifyPath",$s="changed",ii="scale",jt="scaleX",Xt="scaleY",fr="skewX",pr="skewY",_t="fill",zt="stroke",zs="modified",Ie="ltr",de="rtl",Ki="normal",qe="json",Ci="svg",I=new class{constructor(){this[qe]=new Map,this[Ci]=new Map}has(i){return this[qe].has(i)}getClass(i){const t=this[qe].get(i);if(!t)throw new se(`No class registered for ${i}`);return t}setClass(i,t){t?this[qe].set(t,i):(this[qe].set(i.type,i),this[qe].set(i.type.toLowerCase(),i))}getSVGClass(i){return this[Ci].get(i)}setSVGClass(i,t){this[Ci].set(t??i.type.toLowerCase(),i)}},Hs=new class extends Array{remove(i){const t=this.indexOf(i);t>-1&&this.splice(t,1)}cancelAll(){const i=this.splice(0);return i.forEach(t=>t.abort()),i}cancelByCanvas(i){if(!i)return[];const t=this.filter(e=>{var r;return e.target===i||typeof e.target=="object"&&((r=e.target)===null||r===void 0?void 0:r.canvas)===i});return t.forEach(e=>e.abort()),t}cancelByTarget(i){if(!i)return[];const t=this.filter(e=>e.target===i);return t.forEach(e=>e.abort()),t}};class Qh{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(r=>{let[s,n]=r;this.on(s,n)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if(typeof t=="object"){const r=[];return Object.entries(t).forEach(s=>{let[n,o]=s;r.push(this.once(n,o))}),()=>r.forEach(s=>s())}if(e){const r=this.on(t,function(){for(var s=arguments.length,n=new Array(s),o=0;o<s;o++)n[o]=arguments[o];e.call(this,...n),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],s=r.indexOf(e);s>-1&&r.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const r in this.__eventListeners)this._removeEventListener(r);else typeof t=="object"?Object.entries(t).forEach(r=>{let[s,n]=r;this._removeEventListener(s,n)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const s=(r=this.__eventListeners[t])===null||r===void 0?void 0:r.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const Qe=(i,t)=>{const e=i.indexOf(t);return e!==-1&&i.splice(e,1),i},ve=i=>{if(i===0)return 1;switch(Math.abs(i)/as){case 1:case 3:return 0;case 2:return-1}return Math.cos(i)},ye=i=>{if(i===0)return 0;const t=i/as,e=Math.sign(i);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(i)};class w{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new w(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Dn;const r=ye(t),s=ve(t),n=this.subtract(e);return new w(n.x*s-n.y*r,n.x*r+n.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Dn=new w(0,0),Ps=i=>!!i&&Array.isArray(i._objects);function Ua(i){class t extends i{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(r){}_onObjectRemoved(r){}_onStackOrderChanged(r){}add(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(r){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];return this._objects.splice(r,0,...n),n.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const r=this._objects,s=[];for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.forEach(l=>{const c=r.indexOf(l);c!==-1&&(r.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(r){this.getObjects().forEach((s,n,o)=>r(s,n,o))}getObjects(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(r){return this._objects[r]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(r,s){return!!this._objects.includes(r)||!!s&&this._objects.some(n=>n instanceof t&&n.contains(r,!0))}complexity(){return this._objects.reduce((r,s)=>r+=s.complexity?s.complexity():0,0)}sendObjectToBack(r){return!(!r||r===this._objects[0])&&(Qe(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(Qe(this._objects,r),this._objects.push(r),this._onStackOrderChanged(r),!0)}sendObjectBackwards(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==0){const o=this.findNewLowerIndex(r,n,s);return Qe(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}bringObjectForward(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(r,n,s);return Qe(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,s){return r!==this._objects[s]&&(Qe(this._objects,r),this._objects.splice(s,0,r),this._onStackOrderChanged(r),!0)}findNewLowerIndex(r,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(r,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(r){let{left:s,top:n,width:o,height:a}=r,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(s,n),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class Ga extends Qh{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function As(i){return ri().requestAnimationFrame(i)}function tu(i){return ri().cancelAnimationFrame(i)}let eu=0;const Ee=()=>eu++,be=()=>{const i=gr().createElement("canvas");if(!i||i.getContext===void 0)throw new se("Failed to create `canvas` element");return i},ru=()=>gr().createElement("img"),Yt=i=>{const t=be();return t.width=i.width,t.height=i.height,t},Na=(i,t,e)=>i.toDataURL(`image/${t}`,e),qa=(i,t,e)=>new Promise((r,s)=>{i.toBlob(r,`image/${t}`,e)}),mt=i=>i*Sn,Pe=i=>i/Sn,su=i=>i.every((t,e)=>t===Mt[e]),Et=(i,t,e)=>new w(i).transform(t,e),Qt=i=>{const t=1/(i[0]*i[3]-i[1]*i[2]),e=[t*i[3],-t*i[1],-t*i[2],t*i[0],0,0],{x:r,y:s}=new w(i[4],i[5]).transform(e,!0);return e[4]=-r,e[5]=-s,e},Ct=(i,t,e)=>[i[0]*t[0]+i[2]*t[1],i[1]*t[0]+i[3]*t[1],i[0]*t[2]+i[2]*t[3],i[1]*t[2]+i[3]*t[3],e?0:i[0]*t[4]+i[2]*t[5]+i[4],e?0:i[1]*t[4]+i[3]*t[5]+i[5]],Mn=(i,t)=>i.reduceRight((e,r)=>r&&e?Ct(r,e,t):r||e,void 0)||Mt.concat(),Ka=i=>{let[t,e]=i;return Math.atan2(e,t)},Vs=i=>{const t=Ka(i),e=Math.pow(i[0],2)+Math.pow(i[1],2),r=Math.sqrt(e),s=(i[0]*i[3]-i[2]*i[1])/r,n=Math.atan2(i[0]*i[2]+i[1]*i[3],e);return{angle:Pe(t),scaleX:r,scaleY:s,skewX:Pe(n),skewY:0,translateX:i[4]||0,translateY:i[5]||0}},ls=function(i){return[1,0,0,1,i,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function mr(){let{angle:i=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=mt(i),s=ve(r),n=ye(r);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const En=function(i){return[i,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:i,0,0]},Za=i=>Math.tan(mt(i)),Ja=i=>[1,0,Za(i),1,0,0],Qa=i=>[1,Za(i),0,1,0,0],ni=i=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=i,a=En(r?-t:t,s?-e:e);return n&&(a=Ct(a,Ja(n),!0)),o&&(a=Ct(a,Qa(o),!0)),a},iu=i=>{const{translateX:t=0,translateY:e=0,angle:r=0}=i;let s=ls(t,e);r&&(s=Ct(s,mr({angle:r})));const n=ni(i);return su(n)||(s=Ct(s,n)),s},Ls=function(i){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,s){if(t&&t.aborted)return s(new Uh("loadImage"));const n=ru();let o;t&&(o=function(l){n.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),r(n)};i?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new se(`Error loading ${n.src}`))},e&&(n.crossOrigin=e),n.src=i):a()})},ts=function(i){let{signal:t,reviver:e=Es}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(i.map(o=>I.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),n.push(a),a)))).then(r).catch(o=>{n.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},oi=function(i){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0});const n=Object.values(i).map(a=>a&&a.type&&I.has(a.type)?ts([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(i);Promise.all(n).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),r(a)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},vr=function(i){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in i&&(t[e]=i[e]),t),{})},Pn=(i,t)=>Object.keys(i).reduce((e,r)=>(t(i[r],r,i)&&(e[r]=i[r]),e),{}),ot=(i,t)=>parseFloat(Number(i).toFixed(t)),es=i=>"matrix("+i.map(t=>ot(t,et.NUM_FRACTION_DIGITS)).join(" ")+")",Wt=i=>!!i&&i.toLive!==void 0,yo=i=>!!i&&typeof i.toObject=="function",bo=i=>!!i&&i.offsetX!==void 0&&"source"in i,Be=i=>!!i&&"multiSelectionStacking"in i;function tl(i){const t=i&&Zt(i);let e=0,r=0;if(!i||!t)return{left:e,top:r};let s=i;const n=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||n.scrollLeft||0,r=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,r+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:r}}const Zt=i=>i.ownerDocument||null,el=i=>{var t;return((t=i.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},rl=function(i,t,e){let{width:r,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;i.width=r,i.height=s,n>1&&(i.setAttribute("width",(r*n).toString()),i.setAttribute("height",(s*n).toString()),t.scale(n,n))},Zi=(i,t)=>{let{width:e,height:r}=t;e&&(i.style.width=typeof e=="number"?`${e}px`:e),r&&(i.style.height=typeof r=="number"?`${r}px`:r)};function xo(i){return i.onselectstart!==void 0&&(i.onselectstart=()=>!1),i.style.userSelect=Lt,i}class sl{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(r=t)&&r.getContext!==void 0?t:t&&gr().getElementById(t)||be();var r;if(e.hasAttribute("data-fabric"))throw new se("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:r}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width",`${e}`),s.setAttribute("height",`${r}`),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:s}=this.lower;rl(r,s,t,e)}setCSSDimensions(t){Zi(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&Zt(t),s={left:0,top:0};if(!r)return s;const n=((e=el(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(n.borderLeftWidth,10)||0,s.top+=parseInt(n.borderTopWidth,10)||0,s.left+=parseInt(n.paddingLeft,10)||0,s.top+=parseInt(n.paddingTop,10)||0;let o={left:0,top:0};const a=r.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=tl(t);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(){le().dispose(this.lower.el),delete this.lower}}const nu={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Mt],patternQuality:"best"},Z=i=>i.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Sr;const An=i=>{if(Sr||Sr||(Sr="Intl"in ri()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Sr){const t=Sr.segment(i);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return ou(i)},ou=i=>{const t=[];for(let e,r=0;r<i.length;r++)(e=au(i,r))!==!1&&t.push(e);return t},au=(i,t)=>{const e=i.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return i.charAt(t);if(55296<=e&&e<=56319){if(i.length<=t+1)throw"High surrogate without following low surrogate";const s=i.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return i.charAt(t)+i.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const r=i.charCodeAt(t-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1};class cs extends Ua(Ga){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return cs.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),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(t){this.elements=new sl(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=super.insertAt(t,...r);return r.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(Me("warn",`Canvas is trying to add an object that belongs to a different canvas.
38
+ Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?Va():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:r=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s={width:this.width,height:this.height,...t};this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}r||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const r=t,s=[...this.viewportTransform],n=Et(t,Qt(s));s[0]=e,s[3]=e;const o=Et(n,s);s[4]+=r.x-o.x,s[5]+=r.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new w(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new w(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.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=As(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Qt(this.viewportTransform),s=Et({x:0,y:0},r),n=Et({x:t,y:e},r),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(tu(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality=this.patternQuality,this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const r=this.viewportTransform;t.save(),t.transform(...r),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let r=0,s=e.length;r<s;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this[`${e}Color`],s=this[`${e}Image`],n=this.viewportTransform,o=this[`${e}Vpt`];if(!r&&!s)return;const a=Wt(r);if(r){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?r.toLive(t):r,o&&t.transform(...n),a){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const l=r.gradientTransform||r.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...n),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenterPoint(){return new w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Et(this.getCenterPoint(),Qt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,Y,Y),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const r=this.clipPath,s=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return{version:Ni,...vr(this,e),objects:this._objects.filter(n=>!n.excludeFromExport).map(n=>this._toObject(n,t,e)),...this.__serializeBgOverlay(t,e),...s?{clipPath:s}:null}}_toObject(t,e,r){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const r={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return Wt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),Wt(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),s&&!s.excludeFromExport&&(r.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(r.overlayImage=this._toObject(n,t,e)),r}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];var s;return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push(`<g clip-path="url(#${Z((s=this.clipPath.clipPathId)!==null&&s!==void 0?s:"")})" >
39
+ `),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
85
40
  `),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
86
41
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
87
- `)}_setSVGHeader(t,e){const r=e.width||"".concat(this.width),i=e.height||"".concat(this.height),s=X.NUM_FRACTION_DIGITS,o=e.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(Z(-l[4]/l[0],s)," ").concat(Z(-l[5]/l[3],s)," ").concat(Z(this.width/l[0],s)," ").concat(Z(this.height/l[3],s),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',i,'" ',a,`xml:space="preserve">
88
- `,"<desc>Created with Fabric.js ",Zi,`</desc>
42
+ `)}_setSVGHeader(t,e){const r=e.width||`${this.width}`,s=e.height||`${this.height}`,n=et.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a=`viewBox="${o.x} ${o.y} ${o.width} ${o.height}" `;else if(this.svgViewportTransformation){const l=this.viewportTransform;a=`viewBox="${ot(-l[4]/l[0],n)} ${ot(-l[5]/l[3],n)} ${ot(this.width/l[0],n)} ${ot(this.height/l[3],n)}" `}else a=`viewBox="0 0 ${this.width} ${this.height}" `;t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',s,'" ',a,`xml:space="preserve">
43
+ `,"<desc>Created with Fabric.js ",Ni,`</desc>
89
44
  `,`<defs>
90
45
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
91
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(fe()),'<clipPath id="'.concat(e.clipPathId,`" >
92
- `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
93
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(Pt(e)){const r=this["".concat(t,"Vpt")],i=this.viewportTransform,s={isType:()=>!1,width:this.width/(r?i[0]:1),height:this.height/(r?i[3]:1)};return e.toSVG(s,{additionalTransform:r?or(i):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=X.fontPaths;this._objects.forEach(function s(o){t.push(o),Gr(o)&&o._objects.forEach(s)}),t.forEach(s=>{if(!(o=s)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=s;!e[l]&&r[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&r[u]&&(e[u]=!0)})}))});const i=Object.keys(e).map(s=>` @font-face {
94
- font-family: '`.concat(s,`';
95
- src: url('`).concat(r[s],`');
46
+ `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId=`CLIPPATH_${Ee()}`,`<clipPath id="${e.clipPathId}" >
47
+ ${e.toClipPathSVG(t.reviver)}</clipPath>
48
+ `):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this[`${t}Color`];if(Wt(e)){const r=this[`${t}Vpt`],s=this.viewportTransform,n={isType:()=>!1,width:this.width/(r?s[0]:1),height:this.height/(r?s[3]:1)};return e.toSVG(n,{additionalTransform:r?es(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=et.fontPaths;this._objects.forEach(function n(o){t.push(o),Ps(o)&&o._objects.forEach(n)}),t.forEach(n=>{if(!(o=n)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=n;!e[l]&&r[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&r[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(n=>` @font-face {
49
+ font-family: '${n}';
50
+ src: url('${r[n]}');
96
51
  }
97
- `)).join("");return i?` <style type="text/css"><![CDATA[
98
- `.concat(i,`]]></style>
99
- `):""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){const i=this[e];i&&!i.excludeFromExport&&i.toSVG&&t.push(i.toSVG(r))}_setSVGBgOverlayColor(t,e){const r=this["".concat(e,"Color")];if(r)if(Pt(r)){const i=r.repeat||"",s=this.width,o=this.height,a=this["".concat(e,"Vpt")]?or(Wt(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(s/2,",").concat(o/2,')" x="').concat(r.offsetX-s/2,'" y="').concat(r.offsetY-o/2,'" width="').concat(i!=="repeat-y"&&i!=="no-repeat"||!ln(r)?s:r.source.width,'" height="').concat(i!=="repeat-x"&&i!=="no-repeat"||!ln(r)?o:r.source.height,'" fill="url(#SVGID_').concat(r.id,`)"></rect>
100
- `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',`></rect>
101
- `)}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new Ut("`json` is undefined"));const i=typeof t=="string"?JSON.parse(t):t,{objects:s=[]}=i,o=J(i,Vl),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:u}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([nr(s,{reviver:e,signal:r}),yi({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:u},{signal:r})]).then(g=>{let[f,m]=g;return this.clear(),this.add(...f),this.set(o),this.set(m),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=jt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:s=!1}=t,o=i*(s?this.getRetinaScaling():1);return jo(this.toCanvasElement(o,t),e,r)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:s=!1}=t,o=i*(s?this.getRetinaScaling():1);return Lo(this.toCanvasElement(o,t),e,r)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:r,left:i,top:s,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(r||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,g=c*t,f=this.viewportTransform,m=[g,0,0,g,(f[4]-(i||0))*t,(f[5]-(s||0))*t],b=this.enableRetinaScaling,y=jt({width:a,height:l}),w=o?this._objects.filter(O=>o(O)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(y.getContext("2d"),w),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=d,y}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),ei.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.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," }>")}}p(fr,"ownDefaults",Wl);const Xl=["touchstart","touchmove","touchend"],Yl=n=>{const t=Ho(n.target),e=function(r){const i=r.changedTouches;return i&&i[0]?i[0]:r}(n);return new x(e.clientX+t.left,e.clientY+t.top)},ts=n=>Xl.includes(n.type)||n.pointerType==="touch",hn=n=>{n.preventDefault(),n.stopPropagation()},re=n=>{let t=0,e=0,r=0,i=0;for(let s=0,o=n.length;s<o;s++){const{x:a,y:l}=n[s];(a>r||!s)&&(r=a),(a<t||!s)&&(t=a),(l>i||!s)&&(i=l),(l<e||!s)&&(e=l)}return{left:t,top:e,width:r-t,height:i-e}},Ul=["translateX","translateY","scaleX","scaleY"],Gl=(n,t)=>ii(n,ht(t,n.calcOwnMatrix())),ii=(n,t)=>{const e=ri(t),{translateX:r,translateY:i,scaleX:s,scaleY:o}=e,a=J(e,Ul),l=new x(r,i);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:s,scaleY:o}),n.setPositionByOrigin(l,W,W)},Nl=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Xo=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),Es=(n,t,e)=>{const r=n/2,i=t/2,s=[new x(-r,-i),new x(r,-i),new x(-r,i),new x(r,i)].map(a=>a.transform(e)),o=re(s);return new x(o.width,o.height)},_i=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mt;return ht(Wt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:mt),n)},Le=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;return n.transform(_i(t,e))},$l=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;return n.transform(_i(t,e),!0)},ql=(n,t,e)=>{const r=_i(t,e);return ii(n,ht(r,n.calcOwnMatrix())),r},Yo=(n,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire("object:".concat(n),v(v({},t),{},{target:r})),r.fire(n,t)},Kl={left:-.5,top:-.5,center:0,bottom:.5,right:.5},ot=n=>typeof n=="string"?Kl[n]:n-.5,si="not-allowed";function Uo(n){return ot(n.originX)===ot(W)&&ot(n.originY)===ot(W)}function un(n){return .5-ot(n)}const Xt=(n,t)=>n[t],Go=(n,t,e,r)=>({e:n,transform:t,pointer:new x(e,r)});function No(n,t){const e=n.getTotalAngle()+oe(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Ps(n,t,e,r,i){var s;let{target:o,corner:a}=n;const l=o.controls[a],c=((s=o.canvas)===null||s===void 0?void 0:s.getZoom())||1,h=o.padding/c,u=function(d,g,f,m){const b=d.getRelativeCenterPoint(),y=f!==void 0&&m!==void 0?d.translateToGivenOrigin(b,W,W,f,m):new x(d.left,d.top);return(d.angle?g.rotate(-st(d.angle),b):g).subtract(y)}(o,new x(r,i),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Zl=(n,t,e,r)=>{const{target:i,offsetX:s,offsetY:o}=t,a=e-s,l=r-o,c=!Xt(i,"lockMovementX")&&i.left!==a,h=!Xt(i,"lockMovementY")&&i.top!==l;return c&&i.set(N,a),h&&i.set(yt,l),(c||h)&&Yo(Do,Go(n,t,e,r)),c||h},ni=n=>n.replace(/\s+/g," "),dn={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"},Ai=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),gn=(n,t,e,r)=>{n/=255,t/=255,e/=255;const i=Math.max(n,t,e),s=Math.min(n,t,e);let o,a;const l=(i+s)/2;if(i===s)o=a=0;else{const c=i-s;switch(a=l>.5?c/(2-i-s):c/(i+s),i){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},fn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},mr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),pn=n=>{let[t,e,r,i=1]=n;const s=Math.round(.3*t+.59*e+.11*r);return[s,s,s,i]};class G{constructor(t){if(p(this,"isUnrecognised",!1),t)if(t instanceof G)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,r,i,s=1]=t;this.setSource([e,r,i,s])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in dn&&(t=dn[t]),t==="transparent"?[255,255,255,0]:G.sourceFromHex(t)||G.sourceFromRgb(t)||G.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(r,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,r]=gn(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){const[t,e,r,i]=gn(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(r,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,i]=this.getSource();return"".concat(mr(t)).concat(mr(e)).concat(mr(r)).concat(mr(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(pn(this.getSource())),this}toBlackWhite(t){const[e,,,r]=pn(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,r]),this}overlayWith(t){t instanceof G||(t=new G(t));const e=this.getSource(),r=t.getSource(),[i,s,o]=e.map((a,l)=>Math.round(.5*a+.5*r[l]));return this.setSource([i,s,o,e[3]]),this}static fromRgb(t){return G.fromRgba(t)}static fromRgba(t){return new G(G.sourceFromRgb(t))}static sourceFromRgb(t){const e=ni(t).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(e){const[r,i,s]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[r,i,s,fn(e[4])]}}static fromHsl(t){return G.fromHsla(t)}static fromHsla(t){return new G(G.sourceFromHsl(t))}static sourceFromHsl(t){const e=ni(t).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(!e)return;const r=(G.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,s=parseFloat(e[3])/100;let o,a,l;if(i===0)o=a=l=s;else{const c=s<=.5?s*(i+1):s+i-s*i,h=2*s-c;o=Ai(h,c,r+1/3),a=Ai(h,c,r),l=Ai(h,c,r-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),fn(e[4])]}static fromHex(t){return new G(G.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let r;r=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[i,s,o,a=255]=r.map(l=>parseInt(l,16));return[i,s,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?oe(r):e.includes("turn")?360*r:r}}const Fe=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Cs;const e=/\D{0,2}$/.exec(n),r=parseFloat(n),i=X.DPI;switch(e==null?void 0:e[0]){case"mm":return r*i/25.4;case"cm":return r*i/2.54;case"in":return r*i;case"pt":return r*i/72;case"pc":return r*i/72*12;case"em":return r*t;default:return r}},Jl=n=>{const[t,e]=n.trim().split(" "),[r,i]=(s=t)&&s!==_t?[s.slice(1,4),s.slice(5,8)]:s===_t?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:e||"meet",alignX:r,alignY:i}},ar=function(n,t){let e,r,i=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const s=new G(t),o=s.getAlpha();e=s.toRgb(),o!==1&&(r=o.toString())}else e="none";return i?"".concat(n,": ").concat(e,"; ").concat(r?"".concat(n,"-opacity: ").concat(r,"; "):""):"".concat(n,'="').concat(e,'" ').concat(r?"".concat(n,'-opacity="').concat(r,'" '):"")};class $o{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):_t,s=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",h=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),d=ar(at,this.fill);return[ar(xt,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",s,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].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(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t?this.calcTransformMatrix():this.calcOwnMatrix(),i='transform="'.concat(or(r));return"".concat(i).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,withShadow:i,additionalTransform:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=i?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,g=this.shadow,f=[],m=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(fe()),b='<clipPath id="'.concat(l.clipPathId,`" >
102
- `).concat(l.toClipPathSVG(r),`</clipPath>
103
- `)),h&&f.push("<g ",a,this.getSvgCommons(),` >
52
+ `).join("");return s?` <style type="text/css"><![CDATA[
53
+ ${s}]]></style>
54
+ `:""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(r))}_setSVGBgOverlayColor(t,e){const r=this[`${e}Color`];if(r)if(Wt(r)){const s=r.repeat||"",n=this.width,o=this.height,a=this[`${e}Vpt`]?es(Qt(this.viewportTransform)):"";t.push(`<rect transform="${a} translate(${n/2},${o/2})" x="${r.offsetX-n/2}" y="${r.offsetY-o/2}" width="${s!=="repeat-y"&&s!=="no-repeat"||!bo(r)?n:r.source.width}" height="${s!=="repeat-x"&&s!=="no-repeat"||!bo(r)?o:r.source.height}" fill="url(#SVGID_${r.id})"></rect>
55
+ `)}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',`></rect>
56
+ `)}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new se("`json` is undefined"));const{objects:s=[],...n}=typeof t=="string"?JSON.parse(t):t,{backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=n,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([ts(s,{reviver:e,signal:r}),oi({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:r})]).then(d=>{let[g,f]=d;return this.clear(),this.add(...g),this.set(n),this.set(f),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Yt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return Na(this.toCanvasElement(o,t),e,r)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return qa(this.toCanvasElement(o,t),e,r)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:r,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(r||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,g=c*t,f=this.viewportTransform,m=[g,0,0,g,(f[4]-(s||0))*t,(f[5]-(n||0))*t],y=this.enableRetinaScaling,b=Yt({width:a,height:l}),x=o?this._objects.filter(T=>o(T)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),x),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=y,this.skipControlsDrawing=d,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hs.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.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 (${this.complexity()}): { objects: ${this._objects.length} }>`}}v(cs,"ownDefaults",nu);const lu=["touchstart","touchmove","touchend"],cu=i=>{const t=tl(i.target),e=function(r){const s=r.changedTouches;return s&&s[0]?s[0]:r}(i);return new w(e.clientX+t.left,e.clientY+t.top)},Ji=i=>lu.includes(i.type)||i.pointerType==="touch",wo=i=>{i.preventDefault(),i.stopPropagation()},me=i=>{let t=0,e=0,r=0,s=0;for(let n=0,o=i.length;n<o;n++){const{x:a,y:l}=i[n];(a>r||!n)&&(r=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:r-t,height:s-e}},hu=(i,t)=>Ws(i,Ct(t,i.calcOwnMatrix())),Ws=(i,t)=>{const{translateX:e,translateY:r,scaleX:s,scaleY:n,...o}=Vs(t),a=new w(e,r);i.flipX=!1,i.flipY=!1,Object.assign(i,o),i.set({scaleX:s,scaleY:n}),i.setPositionByOrigin(a,Y,Y)},uu=i=>{i.scaleX=1,i.scaleY=1,i.skewX=0,i.skewY=0,i.flipX=!1,i.flipY=!1,i.rotate(0)},il=i=>({scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,angle:i.angle,left:i.left,flipX:i.flipX,flipY:i.flipY,top:i.top}),Ln=(i,t,e)=>{const r=i/2,s=t/2,n=[new w(-r,-s),new w(r,-s),new w(-r,s),new w(r,s)].map(a=>a.transform(e)),o=me(n);return new w(o.width,o.height)},ai=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Mt;return Ct(Qt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Mt),i)},ar=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Mt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;return i.transform(ai(t,e))},du=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Mt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;return i.transform(ai(t,e),!0)},gu=(i,t,e)=>{const r=ai(t,e);return Ws(i,Ct(r,i.calcOwnMatrix())),r},fu={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Ot=i=>typeof i=="string"?fu[i]:i-.5,pu=new w(1,0),nl=new w,ol=(i,t)=>i.rotate(t),Xs=(i,t)=>new w(t).subtract(i),Qi=i=>i.distanceFrom(nl),tn=(i,t)=>Math.atan2(Xr(i,t),mu(i,t)),al=i=>tn(pu,i),Fn=i=>i.eq(nl)?i:i.scalarDivide(Qi(i)),ll=function(i){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Fn(new w(-i.y,i.x).scalarMultiply(t?1:-1))},Xr=(i,t)=>i.x*t.y-i.y*t.x,mu=(i,t)=>i.x*t.x+i.y*t.y,_o=(i,t,e)=>{if(i.eq(t)||i.eq(e))return!0;const r=Xr(t,e),s=Xr(t,i),n=Xr(e,i);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},Ys="not-allowed";function cl(i){return Ot(i.originX)===Ot(Y)&&Ot(i.originY)===Ot(Y)}function Co(i){return .5-Ot(i)}const te=(i,t)=>i[t],hl=(i,t,e,r)=>({e:i,transform:t,pointer:new w(e,r)});function ul(i,t,e){const r=e,s=ar(i.getCenterPoint(),i.canvas.viewportTransform,void 0),n=al(Xs(s,r))+or;return Math.round(n%or/Kh)}function jn(i,t,e,r,s){var n;let{target:o,corner:a}=i;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,u=function(d,g,f,m){const y=d.getRelativeCenterPoint(),b=f!==void 0&&m!==void 0?d.translateToGivenOrigin(y,Y,Y,f,m):new w(d.left,d.top);return(d.angle?g.rotate(-mt(d.angle),y):g).subtract(b)}(o,new w(r,s),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Us=i=>i.replace(/\s+/g," "),So={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"},Si=(i,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+6*(t-i)*e:e<.5?t:e<2/3?i+(t-i)*(2/3-e)*6:i),ko=(i,t,e,r)=>{i/=255,t/=255,e/=255;const s=Math.max(i,t,e),n=Math.min(i,t,e);let o,a;const l=(s+n)/2;if(s===n)o=a=0;else{const c=s-n;switch(a=l>.5?c/(2-s-n):c/(s+n),s){case i:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-i)/c+2;break;case e:o=(i-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},To=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(i)/(i.endsWith("%")?100:1)},gs=i=>Math.min(Math.round(i),255).toString(16).toUpperCase().padStart(2,"0"),Oo=i=>{let[t,e,r,s=1]=i;const n=Math.round(.3*t+.59*e+.11*r);return[n,n,n,s]};class rt{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,r,s,n=1]=t;this.setSource([e,r,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in So&&(t=So[t]),t==="transparent"?[255,255,255,0]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return`rgb(${t},${e},${r})`}toRgba(){return`rgba(${this.getSource().join(",")})`}toHsl(){const[t,e,r]=ko(...this.getSource());return`hsl(${t},${e}%,${r}%)`}toHsla(){const[t,e,r,s]=ko(...this.getSource());return`hsla(${t},${e}%,${r}%,${s})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,s]=this.getSource();return`${gs(t)}${gs(e)}${gs(r)}${gs(Math.round(255*s))}`}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Oo(this.getSource())),this}toBlackWhite(t){const[e,,,r]=Oo(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,r]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),r=t.getSource(),[s,n,o]=e.map((a,l)=>Math.round(.5*a+.5*r[l]));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.sourceFromRgb(t))}static sourceFromRgb(t){const e=Us(t).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(e){const[r,s,n]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[r,s,n,To(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.sourceFromHsl(t))}static sourceFromHsl(t){const e=Us(t).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(!e)return;const r=(rt.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=n;else{const c=n<=.5?n*(s+1):n+s-n*s,h=2*n-c;o=Si(h,c,r+1/3),a=Si(h,c,r),l=Si(h,c,r-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),To(e[4])]}static fromHex(t){return new rt(rt.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let r;r=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[s,n,o,a=255]=r.map(l=>parseInt(l,16));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?Pe(r):e.includes("turn")?360*r:r}}const sr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:kn;const e=/\D{0,2}$/.exec(i),r=parseFloat(i),s=et.DPI;switch(e==null?void 0:e[0]){case"mm":return r*s/25.4;case"cm":return r*s/2.54;case"in":return r*s;case"pt":return r*s/72;case"pc":return r*s/72*12;case"em":return r*t;default:return r}},vu=i=>{const[t,e]=i.trim().split(" "),[r,s]=(n=t)&&n!==Lt?[n.slice(1,4),n.slice(5,8)]:n===Lt?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:r,alignY:s}},rs=function(i,t){let e,r,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e=`url(#SVGID_${Z(t.id)})`;else{const n=new rt(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(r=o.toString())}else e="none";return s?`${i}: ${e}; ${r?`${i}-opacity: ${r}; `:""}`:`${i}="${e}" ${r?`${i}-opacity="${r}" `:""}`};class dl{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Lt,n=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",h=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),d=rs(_t,this.fill);return[rs(zt,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].map(g=>Z(g)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${Z(this.shadow.id)});`:""}getSvgCommons(){return[this.id?`id="${Z(String(this.id))}" `:"",this.clipPath?`clip-path="url(#${this.clipPath.clipPathId})" `:""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t?this.calcTransformMatrix():this.calcOwnMatrix();return`${`transform="${es(r)}`}${e}" `}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":`style="${this.getSvgStyles()}" `,a=s?`style="${this.getSvgFilter()}" `:"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,g=this.shadow,f=[],m=t.indexOf("COMMON_PARTS");let y;l&&(l.clipPathId=`CLIPPATH_${Ee()}`,y=`<clipPath id="${l.clipPathId}" >
57
+ ${l.toClipPathSVG(r)}</clipPath>
58
+ `),h&&f.push("<g ",a,this.getSvgCommons(),` >
104
59
  `),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
105
- `);const y=[o,c,e?"":this.addPaintOrder()," ",s?'transform="'.concat(s,'" '):""].join("");return t[m]=y,Pt(d)&&f.push(d.toSVG(this)),Pt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(b),f.push(t.join("")),f.push(`</g>
60
+ `);const b=[o,c,e?"":this.addPaintOrder()," ",n?`transform="${n}" `:""].join("");return t[m]=b,Wt(d)&&f.push(d.toSVG(this)),Wt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(y),f.push(t.join("")),f.push(`</g>
106
61
  `),h&&f.push(`</g>
107
- `),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==at?' paint-order="'.concat(this.paintFirst,'" '):""}}function xi(n){return new RegExp("^("+n.join("|")+")\\b","i")}const Ce="textDecorationThickness",qo=["fontSize","fontWeight","fontFamily","fontStyle"],Ko=["underline","overline","linethrough"],Zo=[...qo,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Jo=[...Zo,...Ko,"textBackgroundColor","direction",Ce],Ql=[...qo,...Ko,xt,"strokeWidth",at,"deltaY","textBackgroundColor",Ce],tc={_reNewline:Ss,_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:N,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:N,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,[Ce]:66.667},Yt="justify",oi="justify-left",Ze="justify-right",Je="justify-center";var mn,vn,bn;const Vt=String.raw(mn||(mn=qt(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),ji=String.raw(vn||(vn=qt(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),ec=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Vt+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Vt+"))?\\s+(.*)"),rc={cx:N,x:N,r:"radius",cy:yt,y:yt,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":Ce},Li="font-size",Fi="clip-path";xi(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);xi(["symbol","image","marker","pattern","view","svg"]);const yn=xi(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(bn||(bn=qt(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Vt,ji,Vt,ji,Vt,ji,Vt));const ic=new x(1,0),Qo=new x,ta=(n,t)=>n.rotate(t),es=(n,t)=>new x(t).subtract(n),rs=n=>n.distanceFrom(Qo),is=(n,t)=>Math.atan2(Qe(n,t),nc(n,t)),sc=n=>is(ic,n),As=n=>n.eq(Qo)?n:n.scalarDivide(rs(n)),ea=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return As(new x(-n.y,n.x).scalarMultiply(t?1:-1))},Qe=(n,t)=>n.x*t.y-n.y*t.x,nc=(n,t)=>n.x*t.x+n.y*t.y,_n=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const r=Qe(t,e),i=Qe(t,n),s=Qe(e,n);return r>=0?i>=0&&s<=0:!(i<=0&&s>=0)},xn="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",wn=new RegExp("(?:\\s|^)"+xn+xn+"("+Vt+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Nt{constructor(t){const e=typeof t=="string"?Nt.parseShadow(t):t;Object.assign(this,Nt.ownDefaults,e),this.id=fe()}static parseShadow(t){const e=t.trim(),[,r=0,i=0,s=0]=(wn.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(wn,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:i,blur:s}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=ta(new x(this.offsetX,this.offsetY),st(-t.angle)),r=new G(this.color);let i=40,s=40;return t.width&&t.height&&(i=100*Z((Math.abs(e.x)+this.blur)/t.width,X.NUM_FRACTION_DIGITS)+20,s=100*Z((Math.abs(e.y)+this.blur)/t.height,X.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(s,'%" height="').concat(100+2*s,'%" x="-').concat(i,'%" width="').concat(100+2*i,`%" >
108
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(Z(this.blur?this.blur/2:0,X.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
109
- <feOffset dx="`).concat(Z(e.x,X.NUM_FRACTION_DIGITS),'" dy="').concat(Z(e.y,X.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
110
- <feFlood flood-color="`).concat(r.toRgb(),'" flood-opacity="').concat(r.getAlpha(),`"/>
62
+ `),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==_t?` paint-order="${Z(this.paintFirst)}" `:""}}function li(i){return new RegExp("^("+i.join("|")+")\\b","i")}const We="textDecorationThickness",gl=["fontSize","fontWeight","fontFamily","fontStyle"],fl=["underline","overline","linethrough"],pl=[...gl,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],ml=[...pl,...fl,"textBackgroundColor","direction",We],yu=[...gl,...fl,zt,"strokeWidth",_t,"deltaY","textBackgroundColor",We],bu={_reNewline:Tn,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:Ki,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Q,fontStyle:Ki,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Q,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:Ie,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,[We]:66.667},ie="justify",Gs="justify-left",Yr="justify-right",Ur="justify-center",Xe=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,xu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Xe+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Xe+"))?\\s+(.*)"),wu={cx:Q,x:Q,r:"radius",cy:At,y:At,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":We},ki="font-size",Ti="clip-path";li(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);li(["symbol","image","marker","pattern","view","svg"]);const Do=li(["symbol","g","a","svg","clipPath","defs"]),Mo="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Eo=new RegExp("(?:\\s|^)"+Mo+Mo+"("+Xe+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ae{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=typeof t=="string"?ae.parseShadow(t):t;Object.assign(this,ae.ownDefaults,e),this.id=Ee()}static parseShadow(t){const e=t.trim(),[,r=0,s=0,n=0]=(Eo.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Eo,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:s,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=ol(new w(this.offsetX,this.offsetY),mt(-t.angle)),r=et.NUM_FRACTION_DIGITS,s=new rt(this.color);let n=40,o=40;return t.width&&t.height&&(n=100*ot((Math.abs(e.x)+this.blur)/t.width,r)+20,o=100*ot((Math.abs(e.y)+this.blur)/t.height,r)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),`<filter id="SVGID_${Z(this.id)}" y="-${o}%" height="${100+2*o}%" x="-${n}%" width="${100+2*n}%" >
63
+ <feGaussianBlur in="SourceAlpha" stdDeviation="${ot(this.blur?this.blur/2:0,r)}"></feGaussianBlur>
64
+ <feOffset dx="${ot(e.x,r)}" dy="${ot(e.y,r)}" result="oBlur" ></feOffset>
65
+ <feFlood flood-color="${s.toRgb()}" flood-opacity="${s.getAlpha()}"/>
111
66
  <feComposite in2="oBlur" operator="in" />
112
67
  <feMerge>
113
68
  <feMergeNode></feMergeNode>
114
69
  <feMergeNode in="SourceGraphic"></feMergeNode>
115
70
  </feMerge>
116
71
  </filter>
117
- `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=Nt.ownDefaults;return this.includeDefaultValues?t:Ms(t,(r,i)=>r!==e[i])}static async fromObject(t){return new this(t)}}p(Nt,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),p(Nt,"type","shadow"),E.setClass(Nt,"shadow");const Ie=(n,t,e)=>Math.max(n,Math.min(t,e)),oc=[yt,N,Ct,At,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",We,Ve],ae=[at,xt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ac={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:N,originY:yt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:at,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},lc=(n,t,e,r)=>-e*Math.cos(n/r*dr)+e+t,cc=()=>!1;class js{constructor(t){let{startValue:e,byValue:r,duration:i=500,delay:s=0,easing:o=lc,onStart:a=Ur,onChange:l=Ur,onComplete:c=Ur,abort:h=cc,target:u}=t;p(this,"_state","pending"),p(this,"durationProgress",0),p(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=s,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,this.startValue=e,this.byValue=r,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 t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Nr(t),this.delay):Nr(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:i,valueProgress:s}=this.calculate(r);this.value=Object.freeze(i),this.valueProgress=s,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=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),Nr(this.tick)))}register(){ei.push(this)}unregister(){ei.remove(this)}abort(){this._state="aborted",this.unregister()}}const hc=["startValue","endValue"];class uc extends js{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(v(v({},J(t,hc)),{},{startValue:e,byValue:r-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const dc=["startValue","endValue"];class gc extends js{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(v(v({},J(t,dc)),{},{startValue:e,byValue:r.map((i,s)=>i-e[s])}))}calculate(t){const e=this.startValue.map((r,i)=>this.easing(t,r,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const fc=["startValue","endValue","easing","onChange","onComplete","abort"],pc=(n,t,e,r)=>t+e*(1-Math.cos(n/r*dr)),Ri=n=>n&&((t,e,r)=>n(new G(t).toRgba(),e,r));class mc extends js{constructor(t){let{startValue:e,endValue:r,easing:i=pc,onChange:s,onComplete:o,abort:a}=t,l=J(t,fc);const c=new G(e).getSource(),h=new G(r).getSource();super(v(v({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:i,onChange:Ri(s),onComplete:Ri(o),abort:Ri(a)}))}calculate(t){const[e,r,i,s]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,r,i].map(Math.round),Ie(0,s,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 ra(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new gc(n):new uc(n);return t.start(),t}function vc(n){const t=new mc(n);return t.start(),t}class tt{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(i=>!this.includes(i))),this}static isPointContained(t,e,r){let i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const s=es(e,r),o=es(e,t).divide(s);return i?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const r=new x(t).setX(Math.min(t.x-1,...e.map(s=>s.x)));let i=0;for(let s=0;s<e.length;s++){const o=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,r);if(o.includes(t))return!0;i+=+(o.status==="Intersection")}return i%2==1}static intersectLineLine(t,e,r,i){let s=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=i.x-r.x,h=i.y-r.y,u=t.x-r.x,d=t.y-r.y,g=c*d-h*u,f=a*d-l*u,m=h*a-c*l;if(m!==0){const b=g/m,y=f/m;return(s||0<=b&&b<=1)&&(o||0<=y&&y<=1)?new tt("Intersection").append(new x(t.x+b*a,t.y+b*l)):new tt}if(g===0||f===0){const b=s||o||tt.isPointContained(t,r,i)||tt.isPointContained(e,r,i)||tt.isPointContained(r,t,e)||tt.isPointContained(i,t,e);return new tt(b?"Coincident":void 0)}return new tt("Parallel")}static intersectSegmentLine(t,e,r,i){return tt.intersectLineLine(t,e,r,i,!1,!0)}static intersectSegmentSegment(t,e,r,i){return tt.intersectLineLine(t,e,r,i,!1,!1)}static intersectLinePolygon(t,e,r){let i=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const s=new tt,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=tt.intersectLineLine(t,e,a,l,i,!1),c.status==="Coincident")return c;s.append(...c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectSegmentPolygon(t,e,r){return tt.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new tt,i=t.length,s=[];for(let o=0;o<i;o++){const a=t[o],l=t[(o+1)%i],c=tt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(s.push(c),r.append(a,l)):r.append(...c.points)}return s.length>0&&s.length===t.length?new tt("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const i=e.min(r),s=e.max(r),o=new x(s.x,i.y),a=new x(i.x,s.y);return tt.intersectPolygonPolygon(t,[i,o,s,a])}}class bc extends Ao{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?bt(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=bt(t,Wt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,r,i];if(this.group){const o=this.group.calcTransformMatrix();return s.map(a=>bt(a,o))}return s}intersectsWithRect(t,e){return tt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=tt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:r,top:i,width:s,height:o}=this.getBoundingRect();return r>=t.x&&r+s<=e.x&&i>=t.y&&i+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return tt.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return re(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Ct,t),this._set(At,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?oe(Fo(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||mt.concat()}calcACoords(){const t=Xe({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),i=gr(e,r),s=ht(i,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:bt({x:-a,y:-l},s),tr:bt({x:a,y:-l},s),bl:bt({x:-a,y:l},s),br:bt({x:a,y:l},s)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.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,ot(this.originX),ot(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const r=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((s,o)=>s===r[o])?i.value:(this.group&&(e=ht(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const r=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},s=zl(i);return this.ownMatrixCache={key:t,value:s},s}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=v({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),r=e.strokeWidth;let i=r,s=0;this.strokeUniform&&(i=0,s=r);const o=e.width+i,a=e.height+i;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):Es(o,a,bi(e)),l.scalarAdd(s)}translateToGivenOrigin(t,e,r,i,s){let o=t.x,a=t.y;const l=ot(i)-ot(e),c=ot(s)-ot(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,r){if(e===W&&r===W)return t;const i=this.translateToGivenOrigin(t,e,r,W,W);return this.angle?i.rotate(st(this.angle),t):i}translateToOriginPoint(t,e,r){const i=this.translateToGivenOrigin(t,W,W,e,r);return this.angle?i.rotate(st(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?bt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const i=this.translateToCenterPoint(t,e,r),s=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),N,yt)}}const yc=["type"],_c=["extraParam"];let Zt=class qr extends bc{static getDefaults(){return qr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){ge("warn","Setting type has no effect",t)}constructor(t){super(),p(this,"_cacheContext",null),Object.assign(this,qr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ne(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,i=X.maxCacheSideLimit,s=X.minCacheSideLimit;if(e<=i&&r<=i&&e*r<=X.perfLimitSizeTotal)return e<s&&(t.width=s),r<s&&(t.height=s),t;const o=e/r,[a,l]=Ke.limitDimsByArea(o),c=Ie(s,a,i),h=Ie(s,l,i);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:r,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:i,zoomX:s,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=r!==t.width||i!==t.height,h=this.zoomX!==s||this.zoomY!==o;if(!t||!e)return!1;if(c||h){r!==t.width||i!==t.height?(t.width=r,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(s,o),this.zoomX=s,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=ri(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==Ct&&t!==At||(e=this._constrainScale(e)),t===Ct&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof Nt||(e=new Nt(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:s}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:s,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===xt&&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(t,e,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){const i=this.fill,s=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=i,this.stroke=s}createClipPathLayer(t,e){const r=jt(e),i=r.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(s=>{s.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const s=Wt(this.calcTransformMatrix());i.transform(s[0],s[1],s[2],s[3],s[4],s[5])}return t.transform(i),t.drawObject(i,!0,e),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,r);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Pt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(Pt(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,r=this.canvas,i=this.getCanvasRetinaScaling(),[s,,,o]=(r==null?void 0:r.viewportTransform)||mt,a=s*i,l=o*i,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*X.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!Pt(e))return{offsetX:0,offsetY:0};const r=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,i,s):t.transform(1,0,0,1,i,s),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:i,offsetY:s}}_renderPaintInOrder(t){this.paintFirst===xt?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var r;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),o=i.x/this.scaleX/s,a=i.y/this.scaleY/s,l=jt({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(i.zoomX/this.scaleX/s,i.zoomY/this.scaleY/s),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(s*this.scaleX/i.zoomX,s*this.scaleY/i.zoomY),t.strokeStyle=(r=c.createPattern(l,"no-repeat"))!==null&&r!==void 0?r:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(E.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Xo(this),r=this.group,i=this.shadow,s=Math.abs,o=t.enableRetinaScaling?Oo():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(w=>new fr(w,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Nl(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&ql(this,this.getViewportTransform()),this.setCoords();const c=ne(),h=this.getBoundingRect(),u=this.shadow,d=new x;if(u){const w=u.blur,O=u.nonScaling?new x(1,1):this.getObjectScaling();d.x=2*Math.round(s(u.offsetX)+w)*s(O.x),d.y=2*Math.round(s(u.offsetY)+w)*s(O.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const m=l(c);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new x(m.width/2,m.height/2),W,W);const b=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const y=m.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=i,r&&(this.group=r),this.set(e),this.setCoords(),m._objects=[],m.destroy(),y}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return jo(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Lo(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:i}=this;if(e){const{x:s,y:o}=this.getRelativeCenterPoint();this.originX=W,this.originY=W,this.left=s,this.top=o}if(this.set("angle",t),e){const{x:s,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),r,i);this.left=s,this.top=o,this.originX=r,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){ei.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&$t().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((r,i)=>{let[s,o]=i;return r[s]=this._animate(s,o,e),r},{})}_animate(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=t.split("."),s=this.constructor.colorProperties.includes(i[i.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=r,h=v(v({},r),{},{target:this,startValue:a??i.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,g)=>{i.reduce((f,m,b)=>(b===i.length-1&&(f[m]=u),f[m]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}});return s?vc(h):ra(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let i,s=0;s<e.length;s++){if(i=e[s],i===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let o=0;o<r.length;o++){if(this===r[o])return{fork:[],otherFork:[t,...r.slice(0,o)],common:[this,...e]};if(i===r[o])return{fork:[this,...e.slice(0,s)],otherFork:[t,...r.slice(0,o)],common:e.slice(s)}}}return{fork:[this,...e],otherFork:[t,...r],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const r=e.common[0]||this.canvas;if(!r)return;const i=e.fork.pop(),s=e.otherFork.pop(),o=r._objects.indexOf(i),a=r._objects.indexOf(s);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(qr.customProperties,this.constructor.customProperties||[]);let e;const r=X.NUM_FRACTION_DIGITS,{clipPath:i,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:g,height:f,strokeWidth:m,strokeLineCap:b,strokeDashOffset:y,strokeLineJoin:w,strokeUniform:O,strokeMiterLimit:k,scaleX:S,scaleY:C,angle:A,flipX:D,flipY:L,opacity:R,visible:H,backgroundColor:I,fillRule:M,paintFirst:j,globalCompositeOperation:z,skewX:V,skewY:Q}=this;i&&!i.excludeFromExport&&(e=i.toObject(t.concat("inverted","absolutePositioned")));const U=St=>Z(St,r),vt=v(v({},Ye(this,t)),{},{type:this.constructor.type,version:Zi,originX:u,originY:d,left:U(c),top:U(h),width:U(g),height:U(f),fill:an(s)?s.toObject():s,stroke:an(o)?o.toObject():o,strokeWidth:U(m),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:y,strokeLineJoin:w,strokeUniform:O,strokeMiterLimit:U(k),scaleX:U(S),scaleY:U(C),angle:U(A),flipX:D,flipY:L,opacity:U(R),shadow:a&&a.toObject(),visible:H,backgroundColor:I,fillRule:M,paintFirst:j,globalCompositeOperation:z,skewX:U(V),skewY:U(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?vt:this._removeDefaultValues(vt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Ms(t,(i,s)=>{if(s===N||s===yt||s==="type")return!0;const o=r[s];return i!==o&&!(Array.isArray(i)&&Array.isArray(o)&&i.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=J(t,yc),r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:i}=r,s=J(r,_c);return yi(e,s).then(o=>i?(delete o[i],new this(e[i],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};p(Zt,"stateProperties",oc),p(Zt,"cacheProperties",ae),p(Zt,"ownDefaults",ac),p(Zt,"type","FabricObject"),p(Zt,"colorProperties",[at,xt,"backgroundColor"]),p(Zt,"customProperties",[]),E.setClass(Zt),E.setClass(Zt,"object");const Ue=(n,t,e)=>(r,i,s,o)=>{const a=t(r,i,s,o);return a&&Yo(n,v(v({},Go(r,i,s,o)),e)),a};function Ge(n){return(t,e,r,i)=>{const{target:s,originX:o,originY:a}=e,l=s.getRelativeCenterPoint(),c=s.translateToOriginPoint(l,o,a),h=n(t,e,r,i);return s.setPositionByOrigin(c,e.originX,e.originY),h}}const Cn=Ue(sr,Ge((n,t,e,r)=>{const i=Ps(t,t.originX,t.originY,e,r);if(ot(t.originX)===ot(W)||ot(t.originX)===ot(it)&&i.x<0||ot(t.originX)===ot(N)&&i.x>0){const{target:s}=t,o=s.strokeWidth/(s.strokeUniform?s.scaleX:1),a=Uo(t)?2:1,l=s.width,c=Math.abs(i.x*a/s.scaleX)-o;return s.set("width",Math.max(c,1)),l!==s.width}return!1}));function xc(n,t,e,r,i){r=r||{};const s=this.sizeX||r.cornerSize||i.cornerSize,o=this.sizeY||r.cornerSize||i.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:i.transparentCorners,l=a?xt:at,c=!a&&(r.cornerStrokeColor||i.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=r.cornerColor||i.cornerColor||"",n.strokeStyle=r.cornerStrokeColor||i.cornerStrokeColor||"",s>o?(h=s,n.scale(1,o/s),d=e*s/o):o>s?(h=o,n.scale(s/o,1),u=t*o/s):h=s,n.beginPath(),n.arc(u,d,h/2,0,Jr,!1),n[l](),c&&n.stroke(),n.restore()}function wc(n,t,e,r,i){r=r||{};const s=this.sizeX||r.cornerSize||i.cornerSize,o=this.sizeY||r.cornerSize||i.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:i.transparentCorners,l=a?xt:at,c=!a&&(r.cornerStrokeColor||i.cornerStrokeColor),h=s/2,u=o/2;n.save(),n.fillStyle=r.cornerColor||i.cornerColor||"",n.strokeStyle=r.cornerStrokeColor||i.cornerStrokeColor||"",n.translate(t,e);const d=i.getTotalAngle();n.rotate(st(d)),n["".concat(l,"Rect")](-h,-u,s,o),c&&n.strokeRect(-h,-u,s,o),n.restore()}class Rt{constructor(t){p(this,"visible",!0),p(this,"actionName",vi),p(this,"angle",0),p(this,"x",0),p(this,"y",0),p(this,"offsetX",0),p(this,"offsetY",0),p(this,"sizeX",0),p(this,"sizeY",0),p(this,"touchSizeX",0),p(this,"touchSizeY",0),p(this,"cursorStyle","crosshair"),p(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,r,i){var s;let{tl:o,tr:a,br:l,bl:c}=i;return((s=e.canvas)===null||s===void 0?void 0:s.getActiveObject())===e&&e.isControlVisible(t)&&tt.isPointInPolygon(r,[o,a,l,c])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,i;return(r=(i=t._controlsVisibility)===null||i===void 0?void 0:i[e])!==null&&r!==void 0?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,i){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,i,s,o){const a=Os([gr(r,i),Xe({angle:t}),Ds((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,r,i,s){((i=i||{}).cornerStyle||s.cornerStyle)==="circle"?xc.call(this,t,e,r,i,s):wc.call(this,t,e,r,i,s)}}const Cc=(n,t,e)=>e.lockRotation?si:t.cursorStyle,Sc=Ue(Mo,Ge((n,t,e,r)=>{let{target:i,ex:s,ey:o,theta:a,originX:l,originY:c}=t;const h=i.translateToOriginPoint(i.getRelativeCenterPoint(),l,c);if(Xt(i,"lockRotation"))return!1;const u=Math.atan2(o-h.y,s-h.x),d=Math.atan2(r-h.y,e-h.x);let g=oe(d-u+a);if(i.snapAngle&&i.snapAngle>0){const m=i.snapAngle,b=i.snapThreshold||m,y=Math.ceil(g/m)*m,w=Math.floor(g/m)*m;Math.abs(g-w)<b?g=w:Math.abs(g-y)<b&&(g=y)}g<0&&(g=360+g),g%=360;const f=i.angle!==g;return i.angle=g,f}));function ia(n,t){const e=t.canvas,r=n[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function sa(n,t,e){const r=Xt(n,"lockScalingX"),i=Xt(n,"lockScalingY");if(r&&i||!t&&(r||i)&&e||r&&t==="x"||i&&t==="y")return!0;const{width:s,height:o,strokeWidth:a}=n;return s===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const Tc=["e","se","s","sw","w","nw","n","ne","e"],qe=(n,t,e)=>{const r=ia(n,e);if(sa(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",r))return si;const i=No(e,t);return"".concat(Tc[i],"-resize")};function Ls(n,t,e,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const s=t.target,o=i.by,a=ia(n,s);let l,c,h,u,d,g;if(sa(s,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Ps(t,t.originX,t.originY,e,r),d=o!=="y"?Math.sign(l.x||t.signX||1):1,g=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=g),Xt(s,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=s._getTransformedDimensions(),a&&!o){const b=Math.abs(l.x)+Math.abs(l.y),{original:y}=t,w=b/(Math.abs(u.x*y.scaleX/s.scaleX)+Math.abs(u.y*y.scaleY/s.scaleY));c=y.scaleX*w,h=y.scaleY*w}else c=Math.abs(l.x*s.scaleX/u.x),h=Math.abs(l.y*s.scaleY/u.y);Uo(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=un(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=un(t.originY),h*=-1,t.signY=g)}const f=s.scaleX,m=s.scaleY;return o?(o==="x"&&s.set(Ct,c),o==="y"&&s.set(At,h)):(!Xt(s,"lockScalingX")&&s.set(Ct,c),!Xt(s,"lockScalingY")&&s.set(At,h)),f!==s.scaleX||m!==s.scaleY}const vr=Ue(mi,Ge((n,t,e,r)=>Ls(n,t,e,r))),kc=Ue(mi,Ge((n,t,e,r)=>Ls(n,t,e,r,{by:"x"}))),Oc=Ue(mi,Ge((n,t,e,r)=>Ls(n,t,e,r,{by:"y"}))),Dc=["target","ex","ey","skewingSide"],Bi={x:{counterAxis:"y",scale:Ct,skew:We,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:At,skew:Ve,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Mc=["ns","nesw","ew","nwse"],Ec=(n,t,e)=>{if(t.x!==0&&Xt(e,"lockSkewingY")||t.y!==0&&Xt(e,"lockSkewingX"))return si;const r=No(e,t)%4;return"".concat(Mc[r],"-resize")};function na(n,t,e,r,i){const{target:s}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Bi[n];if(Xt(s,l))return!1;const{origin:u,flip:d}=Bi[o],g=ot(e[u])*(s[d]?-1:1),f=-Math.sign(g)*(s[h]?-1:1),m=.5*-((s[c]===0&&Ps(e,W,W,r,i)[n]>0||s[c]>0?1:-1)*f)+.5;return Ue(Eo,Ge((y,w,O,k)=>function(S,C,A){let{target:D,ex:L,ey:R,skewingSide:H}=C,I=J(C,Dc);const{skew:M}=Bi[S],j=A.subtract(new x(L,R)).divide(new x(D.scaleX,D.scaleY))[S],z=D[M],V=I[M],Q=Math.tan(st(V)),U=S==="y"?D._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:D._getTransformedDimensions({scaleX:1,scaleY:1}).y,vt=2*j*H/Math.max(U,1)+Q,St=oe(Math.atan(vt));D.set(M,St);const ct=z!==D[M];if(ct&&S==="y"){const{skewX:T,scaleX:F}=D,P=D._getTransformedDimensions({skewY:z}),B=D._getTransformedDimensions(),$=T!==0?P.x/B.x:1;$!==1&&D.set(Ct,$*F)}return ct}(n,w,new x(O,k))))(t,v(v({},e),{},{[a]:m,skewingSide:f}),r,i)}const Pc=(n,t,e,r)=>na("x",n,t,e,r),Ac=(n,t,e,r)=>na("y",n,t,e,r);function wi(n,t){return n[t.canvas.altActionKey]}const br=(n,t,e)=>{const r=wi(n,e);return t.x===0?r?We:At:t.y===0?r?Ve:Ct:""},Ee=(n,t,e)=>wi(n,e)?Ec(0,t,e):qe(n,t,e),Sn=(n,t,e,r)=>wi(n,t.target)?Ac(n,t,e,r):kc(n,t,e,r),Tn=(n,t,e,r)=>wi(n,t.target)?Pc(n,t,e,r):Oc(n,t,e,r),oa=()=>({ml:new Rt({x:-.5,y:0,cursorStyleHandler:Ee,actionHandler:Sn,getActionName:br}),mr:new Rt({x:.5,y:0,cursorStyleHandler:Ee,actionHandler:Sn,getActionName:br}),mb:new Rt({x:0,y:.5,cursorStyleHandler:Ee,actionHandler:Tn,getActionName:br}),mt:new Rt({x:0,y:-.5,cursorStyleHandler:Ee,actionHandler:Tn,getActionName:br}),tl:new Rt({x:-.5,y:-.5,cursorStyleHandler:qe,actionHandler:vr}),tr:new Rt({x:.5,y:-.5,cursorStyleHandler:qe,actionHandler:vr}),bl:new Rt({x:-.5,y:.5,cursorStyleHandler:qe,actionHandler:vr}),br:new Rt({x:.5,y:.5,cursorStyleHandler:qe,actionHandler:vr}),mtr:new Rt({x:0,y:-.5,actionHandler:Sc,cursorStyleHandler:Cc,offsetY:-40,withConnection:!0,actionName:Ts})}),jc=()=>({mr:new Rt({x:.5,y:0,actionHandler:Cn,cursorStyleHandler:Ee,actionName:sr}),ml:new Rt({x:-.5,y:0,actionHandler:Cn,cursorStyleHandler:Ee,actionName:sr})}),Lc=()=>v(v({},oa()),jc());class lr extends Zt{static getDefaults(){return v(v({},super.getDefaults()),lr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),lr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:oa()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,i=e.action;if(this===r&&i&&i.startsWith(vi))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const r=Object.entries(this.oCoords);for(let i=r.length-1;i>=0;i--){const[s,o]=r[i],a=this.controls[s];if(a.shouldActivate(s,this,t,e?o.touchCorner:o.corner))return this.__corner=s,{key:s,control:a,coord:this.oCoords[s]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),r=gr(e.x,e.y),i=Xe({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),s=ht(r,i),o=ht(t,s),a=ht(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?ri(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((u,d)=>{const g=u.positionHandler(c,a,this,u);h[d]=Object.assign(g,this._calcCornerCoords(u,g))}),h}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),r=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(st(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=v({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},r);t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:r,hasControls:i}=this,s=v({hasBorders:r,hasControls:i},e),o=this.getViewportTransform(),a=s.hasBorders,l=s.hasControls,c=ht(o,this.calcTransformMatrix()),h=ri(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(st(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let i;if(r&&r.forActiveSelection||this.group){const s=Es(this.width,this.height,bi(e)),o=this.isStrokeAccountedForInDimensions()?ks:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=s.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((i,s)=>{i.withConnection&&i.getVisibility(this,s)&&(r=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:s,cornerColor:o}=this,a=v({cornerStrokeColor:i,cornerDashArray:s,cornerColor:o},e);t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[r,i]=e;return this.setControlVisible(r,i)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transform(e);const i=this.width+4,s=this.height+4;return e.clearRect(-i/2,-s/2,i,s),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function aa(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),n}p(lr,"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 dt extends lr{}aa(dt,[$o]),E.setClass(dt),E.setClass(dt,"object");const Fc=(n,t,e,r)=>{const i=2*(r=Math.round(r))+1,{data:s}=n.getImageData(t-r,e-r,i,i);for(let o=3;o<s.length;o+=4)if(s[o]>0)return!1;return!0};class la{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const r=es(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(st(this.options.skewY)),e.x+=e.y*Math.tan(st(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Rc=new x;class Re extends la{static getOrthogonalRotationFactor(t,e){const r=e?is(t,e):sc(t);return Math.abs(r)<dr?-1:1}constructor(t,e,r,i){super(i),p(this,"AB",void 0),p(this,"AC",void 0),p(this,"alpha",void 0),p(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=is(this.AB,this.AC),this.bisector=As(ta(this.AB.eq(Rc)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),s=ea(i),o=Re.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,r*o)}projectBevel(){const t=[];return(this.alpha%Jr==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),r=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),s=this.options.strokeUniform?rs(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return rs(i)/this.strokeProjectionMagnitude<=s&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],i=new x(Re.getOrthogonalRotationFactor(this.bisector),Re.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(s=>{_n(s,t,e)&&r.push(this.A.add(s))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:i,skewY:s,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(st(i)),Math.tan(st(s))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new x(Math.sqrt(Math.max(h**2-u**2,0)),u),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(m=>this.applySkew(l?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{_n(m,t,e)&&r.push(this.applySkew(this.A).add(m))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Jr==0,r=this.applySkew(this.A),i=t[e?0:2].subtract(r),s=t[e?1:0].subtract(r),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Qe(i,o)>0,l=a?i:s,c=a?s:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class kn extends la{constructor(t,e,r){super(r),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(ea(i),r)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Re(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(As(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(r);t.push(i.add(e),i.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const Bc=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const r=[];if(n.length===0)return r;const i=n.reduce((s,o)=>(s[s.length-1].eq(o)||s.push(new x(o)),s),[new x(n[0])]);if(i.length===1)e=!0;else if(!e){const s=i[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(i,a=>!a.eq(s));i.splice(o+1)}return i.forEach((s,o,a)=>{let l,c;o===0?(c=a[1],l=e?s:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?s:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?r.push(...new kn(s,s,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new Re(s,l,c,t).project()):r.push(...new kn(s,o===0?c:l,t).project())}),r},Fs=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(r=>{t[e][r]=v({},n[e][r])})}),t},Ic=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Ne;const Rs=n=>{if(Ne||Ne||(Ne="Intl"in pi()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ne){const t=Ne.segment(n);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return Hc(n)},Hc=n=>{const t=[];for(let e,r=0;r<n.length;r++)(e=zc(n,r))!==!1&&t.push(e);return t},zc=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const i=n.charCodeAt(t+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const r=n.charCodeAt(t-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1},Bs=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textDecorationThickness!==t.textDecorationThickness||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Wc=(n,t)=>{const e=t.split(`
118
- `),r=[];let i=-1,s={};n=Fs(n);for(let o=0;o<e.length;o++){const a=Rs(e[o]);if(n[o])for(let l=0;l<a.length;l++){i++;const c=n[o][l];c&&Object.keys(c).length>0&&(Bs(s,c,!0)?r.push({start:i,end:i+1,style:c}):r[r.length-1].end++),s=c||{}}else i+=a.length,s={}}return r},Vc=(n,t)=>{if(!Array.isArray(n))return Fs(n);const e=t.split(Ss),r={};let i=-1,s=0;for(let o=0;o<e.length;o++){const a=Rs(e[o]);for(let l=0;l<a.length;l++)i++,n[s]&&n[s].start<=i&&i<n[s].end&&(r[o]=r[o]||{},r[o][l]=v({},n[s].style),i===n[s].end-1&&s++)}return r},pe=["display","transform",at,"fill-opacity","fill-rule","opacity",xt,"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 On(n,t){const e=n.nodeName,r=n.getAttribute("class"),i=n.getAttribute("id"),s="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),i&&t.length&&(o=new RegExp("#"+i+s,"i"),t=t.replace(o,"")),r&&t.length){const a=r.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+s,"i"),t=t.replace(o,"")}return t.length===0}function Xc(n,t){let e=!0;const r=On(n,t.pop());return r&&t.length&&(e=function(i,s){let o,a=!0;for(;i.parentElement&&i.parentElement.nodeType===1&&s.length;)a&&(o=s.pop()),a=On(i=i.parentElement,o);return s.length===0}(n,t)),r&&e&&t.length===0}const Yc=n=>{var t;return(t=rc[n])!==null&&t!==void 0?t:n},Uc=new RegExp("(".concat(Vt,")"),"gi"),Gc=n=>ni(n.replace(Uc," $1 ").replace(/,/gi," "));var Dn,Mn,En,Pn,An,jn,Ln;const pt="(".concat(Vt,")"),Nc=String.raw(Dn||(Dn=qt(["(skewX)(",")"],["(skewX)\\(","\\)"])),pt),$c=String.raw(Mn||(Mn=qt(["(skewY)(",")"],["(skewY)\\(","\\)"])),pt),qc=String.raw(En||(En=qt(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),pt,pt,pt),Kc=String.raw(Pn||(Pn=qt(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),pt,pt),Zc=String.raw(An||(An=qt(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),pt,pt),Jc=String.raw(jn||(jn=qt(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),pt,pt,pt,pt,pt,pt),Is="(?:".concat(Jc,"|").concat(Zc,"|").concat(qc,"|").concat(Kc,"|").concat(Nc,"|").concat($c,")"),Qc="(?:".concat(Is,"*)"),th=String.raw(Ln||(Ln=qt(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Qc),eh=new RegExp(th),rh=new RegExp(Is),ih=new RegExp(Is,"g");function ss(n){const t=[];if(!(n=Gc(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!eh.test(n))return[...mt];for(const e of n.matchAll(ih)){const r=rh.exec(e[0]);if(!r)continue;let i=mt;const s=r.filter(f=>!!f),[,o,...a]=s,[l,c,h,u,d,g]=a.map(f=>parseFloat(f));switch(o){case"translate":i=gr(l,c);break;case Ts:i=Xe({angle:l},{x:c,y:h});break;case vi:i=Ds(l,c);break;case We:i=Bo(l);break;case Ve:i=Io(l);break;case"matrix":i=[l,c,h,u,d,g]}t.push(i)}return Os(t)}function sh(n,t,e,r){const i=Array.isArray(t);let s,o=t;if(n!==at&&n!==xt||t!==_t){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===_t?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?ht(e.transformMatrix,ss(t)):ss(t);else if(n==="visible")o=t!==_t&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?N:t==="end"?it:W;else if(n==="charSpacing"||n===Ce)s=Fe(t,r)/r*1e3;else if(n==="paintFirst"){const a=t.indexOf(at),l=t.indexOf(xt);o=at,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=xt)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";s=i?t.map(Fe):Fe(t,r)}}else o="";return!i&&isNaN(s)?o:s}function nh(n,t){const e=n.match(ec);if(!e)return;const r=e[1],i=e[3],s=e[4],o=e[5],a=e[6];r&&(t.fontStyle=r),i&&(t.fontWeight=isNaN(parseFloat(i))?i:parseFloat(i)),s&&(t.fontSize=Fe(s)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function oh(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,i]=e.split(":");t[r.trim().toLowerCase()]=i.trim()})}function ah(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?oh(e,t):function(r,i){Object.entries(r).forEach(s=>{let[o,a]=s;a!==void 0&&(i[o.toLowerCase()]=a)})}(e,t)),t}const lh={stroke:"strokeOpacity",fill:"fillOpacity"};function le(n,t,e){if(!n)return{};let r,i={},s=Cs;n.parentNode&&yn.test(n.parentNode.nodeName)&&(i=le(n.parentElement,t,e),i.fontSize&&(r=s=Fe(i.fontSize)));const o=v(v(v({},t.reduce((c,h)=>{const u=n.getAttribute(h);return u&&(c[h]=u),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const d in h)Xc(c,d.split(" "))&&(u=v(v({},u),h[d]));return u}(n,e)),ah(n));o[Fi]&&n.setAttribute(Fi,o[Fi]),o[Li]&&(r=Fe(o[Li],s),o[Li]="".concat(r));const a={};for(const c in o){const h=Yc(c),u=sh(h,o[c],i,r);a[h]=u}a&&a.font&&nh(a.font,a);const l=v(v({},i),a);return yn.test(n.nodeName)?l:function(c){const h=dt.getDefaults();return Object.entries(lh).forEach(u=>{let[d,g]=u;if(c[g]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const f=new G(c[d]);c[d]=f.setAlpha(Z(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const ch=["left","top","width","height","visible"],ca=["rx","ry"];class Mt extends dt{static getDefaults(){return v(v({},super.getDefaults()),Mt.ownDefaults)}constructor(t){super(),Object.assign(this,Mt.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:r}=this,i=-e/2,s=-r/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,r/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(i+o,s),t.lineTo(i+e-o,s),l&&t.bezierCurveTo(i+e-ce*o,s,i+e,s+ce*a,i+e,s+a),t.lineTo(i+e,s+r-a),l&&t.bezierCurveTo(i+e,s+r-ce*a,i+e-ce*o,s+r,i+e-o,s+r),t.lineTo(i+o,s+r),l&&t.bezierCurveTo(i+ce*o,s+r,i,s+r-ce*a,i,s+r-a),t.lineTo(i,s+a),l&&t.bezierCurveTo(i,s+ce*a,i+ce*o,s,i+o,s),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ca,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:i}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(r,'" ry="').concat(i,'" width="').concat(t,'" height="').concat(e,`" />
119
- `)]}static async fromElement(t,e,r){const i=le(t,this.ATTRIBUTE_NAMES,r),{left:s=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=i,h=J(i,ch);return new this(v(v(v({},e),h),{},{left:s,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}p(Mt,"type","Rect"),p(Mt,"cacheProperties",[...ae,...ca]),p(Mt,"ownDefaults",{rx:0,ry:0}),p(Mt,"ATTRIBUTE_NAMES",[...pe,"x","y","rx","ry","width","height"]),E.setClass(Mt),E.setSVGClass(Mt);const ee="initialization",ai="added",Hs="removed",li="imperative",ha=(n,t)=>{const{strokeUniform:e,strokeWidth:r,width:i,height:s,group:o}=t,a=o&&o!==n?_i(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?$l(new x(r,r),void 0,n.calcTransformMatrix()):ks,u=!e&&c?r:0,d=Es(i+u,s+u,Os([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Ci{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:i}=t;return e===ee||e===li||!!r&&i!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==ee&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:i}=e;if(r===li&&e.overrides)return e.overrides;if(t.length===0)return;const{left:s,top:o,width:a,height:l}=re(t.map(u=>ha(i,u)).reduce((u,d)=>u.concat(d),[])),c=new x(a,l),h=new x(s,o).add(c.scalarDivide(2));if(r===ee){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:u}}return{center:h.transform(i.calcOwnMatrix()),size:c}}}p(Ci,"type","strategy");class ns extends Ci{shouldPerformLayout(t){return!0}}p(ns,"type","fit-content"),E.setClass(ns);const hh=["strategy"],uh=["target","strategy","bubbles","prevStrategy"],ua="layoutManager";class cr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new ns;p(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=v(v({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[ti,Do,sr,Mo,mi,Eo,Qr,jl,Ll].map(i=>t.on(i,s=>this.performLayout(i===ti?{type:"object_modified",trigger:i,e:s,target:r}:{type:"object_modifying",trigger:i,e:s,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(r=>r()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:r}=t,{canvas:i}=e;if(r===ee||r===ai?this.subscribeTargets(t):r===Hs&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),r===li&&t.deep){const s=J(t,hh);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(v(v({},s),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:r,type:i}=t,s=r.calcLayoutResult(t,e.getObjects());if(!s)return;const o=i===ee?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=s,h=o.subtract(a).add(l).transform(i===ee?mt:Wt(e.calcOwnMatrix()),!0).add(c);return{result:s,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:r}=t,{result:{size:i},nextCenter:s}=e;var o,a;r.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===ee?r.set({left:(o=t.x)!==null&&o!==void 0?o:s.x+i.x*ot(r.originX),top:(a=t.y)!==null&&a!==void 0?a:s.y+i.y*ot(r.originY)}):(r.setPositionByOrigin(s,W,W),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(i=>{i.group===r&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:i}=e;r.set({left:r.left+i.x,top:r.top+i.y})}onAfterLayout(t,e){const{target:r,strategy:i,bubbles:s,prevStrategy:o}=t,a=J(t,uh),{canvas:l}=r;r.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:r});const c=r.parent;s&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(r),c.layoutManager.performLayout(v(v({},a),{},{target:c}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:ua,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}E.setClass(cr,ua);const dh=["type","objects","layoutManager"];class gh extends cr{performLayout(){}}class xe extends Po(dt){static getDefaults(){return v(v({},super.getDefaults()),xe.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),p(this,"_activeObjects",[]),p(this,"__objectSelectionTracker",void 0),p(this,"__objectSelectionDisposer",void 0),Object.assign(this,xe.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var r;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(i=>{this.enterGroup(i,!1)}),this.layoutManager=(r=e.layoutManager)!==null&&r!==void 0?r:new cr,this.layoutManager.performLayout({type:ee,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(ge("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(ge("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,r,i)=>this.canEnterGroup(e)&&i.indexOf(e)===r)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const i=this._filterObjectsBeforeEnteringGroup(e),s=super.add(...i);return this._onAfterObjectsChange(ai,i),s}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(r),o=super.insertAt(t,...s);return this._onAfterObjectsChange(ai,s),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Hs,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const r=this[t];return super._set(t,e),t==="canvas"&&r!==e&&(this._objects||[]).forEach(i=>{i._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:r}=e;const i=this._activeObjects;if(t)i.push(r),this._set("dirty",!0);else if(i.length>0){const s=i.indexOf(r);s>-1&&(i.splice(s,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&ii(t,ht(Wt(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(ii(t,ht(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=dt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,r){this._renderBackground(t);for(let s=0;s<this._objects.length;s++){var i;const o=this._objects[s];(i=this.canvas)!==null&&i!==void 0&&i.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Wt(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,r)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(v({target:this,type:li},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(i){return!i.excludeFromExport}).map(function(i){const s=i.includeDefaultValues;i.includeDefaultValues=r;const o=i[t||"toObject"](e);return i.includeDefaultValues=s,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return v(v(v({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=Mt.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const i=e.join("");return t?t(i):i}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
120
- `],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let i=0;i<this._objects.length;i++)e.push(" ",this._objects[i].toSVG(t));return e.push(`</g>
121
- `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let i=0;i<this._objects.length;i++)e.push(" ",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:r,objects:i=[],layoutManager:s}=t,o=J(t,dh);return Promise.all([nr(i,e),yi(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,v(v(v({},o),c),{},{layoutManager:new gh}));if(s){const u=E.getClass(s.type),d=E.getClass(s.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new cr;return h.layoutManager.subscribeTargets({type:ee,target:h,targets:h.getObjects()}),h.setCoords(),h})}}p(xe,"type","Group"),p(xe,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),E.setClass(xe);const fh=(n,t)=>Math.min(t.width/n.width,t.height/n.height),ph=(n,t)=>Math.max(t.width/n.width,t.height/n.height),os="\\s*,?\\s*",$e="".concat(os,"(").concat(Vt,")"),mh="".concat($e).concat($e).concat($e).concat(os,"([01])").concat(os,"([01])").concat($e).concat($e),vh={m:"l",M:"L"},bh=(n,t,e,r,i,s,o,a,l,c,h)=>{const u=ie(n),d=se(n),g=ie(t),f=se(t),m=e*i*g-r*s*f+o,b=r*i*g+e*s*f+a;return["C",c+l*(-e*i*d-r*s*u),h+l*(-r*i*d+e*s*u),m+l*(e*i*f+r*s*g),b+l*(r*i*f-e*s*g),m,b]},Fn=(n,t,e,r)=>{const i=Math.atan2(t,n),s=Math.atan2(r,e);return s>=i?s-i:2*Math.PI-(i-s)};function Rn(n,t,e,r,i,s,o,a){let l;if(X.cachesBoundsOfCurve&&(l=[...arguments].join(),Ke.boundsOfCurveCache[l]))return Ke.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*n-12*e+6*i,f=-3*n+9*e-9*i+3*o,m=3*e-3*n;for(let k=0;k<2;++k){if(k>0&&(g=6*t-12*r+6*s,f=-3*t+9*r-9*s+3*a,m=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const L=-m/g;0<L&&L<1&&u.push(L);continue}const S=g*g-4*m*f;if(S<0)continue;const C=c(S),A=(-g+C)/(2*f);0<A&&A<1&&u.push(A);const D=(-g-C)/(2*f);0<D&&D<1&&u.push(D)}let b=u.length;const y=b,w=da(n,t,e,r,i,s,o,a);for(;b--;){const{x:k,y:S}=w(u[b]);d[0][b]=k,d[1][b]=S}d[0][y]=n,d[1][y]=t,d[0][y+1]=o,d[1][y+1]=a;const O=[new x(Math.min(...d[0]),Math.min(...d[1])),new x(Math.max(...d[0]),Math.max(...d[1]))];return X.cachesBoundsOfCurve&&(Ke.boundsOfCurveCache[l]=O),O}const yh=(n,t,e)=>{let[r,i,s,o,a,l,c,h]=e;const u=((d,g,f,m,b,y,w)=>{if(f===0||m===0)return[];let O=0,k=0,S=0;const C=Math.PI,A=w*ws,D=se(A),L=ie(A),R=.5*(-L*d-D*g),H=.5*(-L*g+D*d),I=f**2,M=m**2,j=H**2,z=R**2,V=I*M-I*j-M*z;let Q=Math.abs(f),U=Math.abs(m);if(V<0){const ut=Math.sqrt(1-V/(I*M));Q*=ut,U*=ut}else S=(b===y?-1:1)*Math.sqrt(V/(I*j+M*z));const vt=S*Q*H/U,St=-S*U*R/Q,ct=L*vt-D*St+.5*d,T=D*vt+L*St+.5*g;let F=Fn(1,0,(R-vt)/Q,(H-St)/U),P=Fn((R-vt)/Q,(H-St)/U,(-R-vt)/Q,(-H-St)/U);y===0&&P>0?P-=2*C:y===1&&P<0&&(P+=2*C);const B=Math.ceil(Math.abs(P/C*2)),$=[],q=P/B,gt=8/3*Math.sin(q/4)*Math.sin(q/4)/Math.sin(q/2);let Kt=F+q;for(let ut=0;ut<B;ut++)$[ut]=bh(F,Kt,L,D,Q,U,ct,T,gt,O,k),O=$[ut][5],k=$[ut][6],F=Kt,Kt+=q;return $})(c-n,h-t,i,s,a,l,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},_h=n=>{let t=0,e=0,r=0,i=0;const s=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],r=h[1],i=h[2],u=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],u=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],u=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":yh(t,e,h).forEach(d=>s.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=r,e=i,u=["Z"]}u?(s.push(u),o=u[0]):o=""}return s},ci=(n,t,e,r)=>Math.sqrt((e-n)**2+(r-t)**2),da=(n,t,e,r,i,s,o,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),u=(g=>3*g*(1-g)**2)(l),d=(g=>(1-g)**3)(l);return new x(o*c+i*h+e*u+n*d,a*c+s*h+r*u+t*d)},ga=n=>n**2,fa=n=>2*n*(1-n),pa=n=>(1-n)**2,xh=(n,t,e,r,i,s,o,a)=>l=>{const c=ga(l),h=fa(l),u=pa(l),d=3*(u*(e-n)+h*(i-e)+c*(o-i)),g=3*(u*(r-t)+h*(s-r)+c*(a-s));return Math.atan2(g,d)},wh=(n,t,e,r,i,s)=>o=>{const a=ga(o),l=fa(o),c=pa(o);return new x(i*a+e*l+n*c,s*a+r*l+t*c)},Ch=(n,t,e,r,i,s)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(i-e)),c=2*(a*(r-t)+o*(s-r));return Math.atan2(c,l)},Bn=(n,t,e)=>{let r=new x(t,e),i=0;for(let s=1;s<=100;s+=1){const o=n(s/100);i+=ci(r.x,r.y,o.x,o.y),r=o}return i},Sh=(n,t)=>{let e,r=0,i=0,s={x:n.x,y:n.y},o=v({},s),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;i<t&&a>1e-4;)o=c(r),l=r,e=ci(s.x,s.y,o.x,o.y),e+i>t?(r-=a,a/=2):(s=o,r+=a,i+=e);return v(v({},o),{},{angle:h(l)})},ma=n=>{let t,e,r=0,i=0,s=0,o=0,a=0;const l=[];for(const c of n){const h={x:i,y:s,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=i=c[1],e.y=a=s=c[2];break;case"L":e=h,e.length=ci(i,s,c[1],c[2]),i=c[1],s=c[2];break;case"C":t=da(i,s,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=xh(i,s,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Bn(t,i,s),i=c[5],s=c[6];break;case"Q":t=wh(i,s,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ch(i,s,c[1],c[2],c[3],c[4]),e.length=Bn(t,i,s),i=c[3],s=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=ci(i,s,o,a),i=o,s=a}r+=e.length,l.push(e)}return l.push({length:r,x:i,y:s}),l},Th=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ma(n),r=0;for(;t-e[r].length>0&&r<e.length-2;)t-=e[r].length,r++;const i=e[r],s=t/i.length,o=n[r];switch(i.command){case"M":return{x:i.x,y:i.y,angle:0};case"Z":return v(v({},new x(i.x,i.y).lerp(new x(i.destX,i.destY),s)),{},{angle:Math.atan2(i.destY-i.y,i.destX-i.x)});case"L":return v(v({},new x(i.x,i.y).lerp(new x(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-i.y,o[1]-i.x)});case"C":case"Q":return Sh(i,t)}},kh=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),In=new RegExp(mh,"g"),Oh=new RegExp(Vt,"gi"),Dh={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Mh=n=>{var t;const e=[],r=(t=n.match(kh))!==null&&t!==void 0?t:[];for(const i of r){const s=i[0];if(s==="z"||s==="Z"){e.push([s]);continue}const o=Dh[s.toLowerCase()];let a=[];if(s==="a"||s==="A"){In.lastIndex=0;for(let l=null;l=In.exec(i);)a.push(...l.slice(1))}else a=i.match(Oh)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=vh[s];c[0]=l>0&&h?h:s;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},Eh=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new x(n[0]),r=new x(n[1]),i=1,s=0;const o=[],a=n.length,l=a>2;let c;for(l&&(i=n[2].x<r.x?-1:n[2].x===r.x?0:1,s=n[2].y<r.y?-1:n[2].y===r.y?0:1),o.push(["M",e.x-i*t,e.y-s*t]),c=1;c<a;c++){if(!e.eq(r)){const h=e.midPointFrom(r);o.push(["Q",e.x,e.y,h.x,h.y])}e=n[c],c+1<n.length&&(r=n[c+1])}return l&&(i=e.x>n[c-2].x?1:e.x===n[c-2].x?0:-1,s=e.y>n[c-2].y?1:e.y===n[c-2].y?0:-1),o.push(["L",e.x+i*t,e.y+s*t]),o},va=(n,t)=>n.map(e=>e.map((r,i)=>i===0||t===void 0?r:Z(r,t)).join(" ")).join(" ");function as(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(r=>{let[i,s]=r;return e.setProperty(i,s)}))}class Ph extends Vo{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),p(this,"upper",void 0),p(this,"container",void 0);const{el:i}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(r),i.parentNode&&i.parentNode.replaceChild(o,i),o.append(i,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ne();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ze().createElement("div");return t.setAttribute("data-fabric","wrapper"),as(t,{position:"relative"}),cn(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:i}=e;as(t,v(v({},r),{},{"touch-action":i?"manipulation":_t})),cn(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:i}=this.upper;Wo(r,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Qi(this.upper.el,t),Qi(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),$t().dispose(this.upper.el),delete this.upper,delete this.container}}class Si extends fr{constructor(){super(...arguments),p(this,"targets",[]),p(this,"_hoveredTargets",[]),p(this,"_currentTransform",null),p(this,"_groupSelector",null),p(this,"contextTopDirty",!1)}static getDefaults(){return v(v({},super.getDefaults()),Si.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Ph(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):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(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const i=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+i,-r+i),s.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=o,s.restore();const a=Math.round(i*this.getRetinaScaling());return Fc(s,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(r=>!!r&&t[r]===!0):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&r.length>1&&r.indexOf(e)===-1&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let i;return e===vi||e===Ct||e===At||e===sr?i=this.centeredScaling||t.centeredScaling:e===Ts&&(i=this.centeredRotation||t.centeredRotation),i?!r:r}_getOriginFromCorner(t,e){const r={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=it:["mr","tr","br"].includes(e)&&(r.x=N),["tl","mt","tr"].includes(e)?r.y=Ji:["bl","mb","br"].includes(e)&&(r.y=yt)),r}_setupCurrentTransform(t,e,r){var i;const s=e.group?Le(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=r&&a?(i=a.getActionHandler(t,e,a))===null||i===void 0?void 0:i.bind(a):Zl,c=((g,f,m,b)=>{if(!f||!g)return"drag";const y=b.controls[f];return y.getActionName(m,y,b)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:W,y:W}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:s.x-e.left,offsetY:s.y-e.top,originX:u.x,originY:u.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:st(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:v(v({},Xo(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:i,deltaY:s}=this._groupSelector,o=new x(e,r).transform(this.viewportTransform),a=new x(e+i,r+s).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,dt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),r=this._activeObject,i=this.getActiveObjects();if(this.targets=[],r&&i.length>=1){if(r.findControl(e,ts(t))||i.length>1&&this.searchPossibleTargets([r],e))return r;if(r===this.searchPossibleTargets([r],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==r?(this.targets=s,r):o}return r}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const i=this.getZoom(),s=t.padding/i;if(s){const[o,a,l,c]=r,h=Math.atan2(a.y-o.y,a.x-o.x),u=ie(h)*s,d=se(h)*s,g=u+d,f=u-d;r=[new x(o.x-f,o.y-g),new x(a.x+g,a.y-f),new x(l.x+f,l.y+g),new x(c.x-g,c.y+f)]}return tt.isPointInPolygon(e,r)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Le(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let r=t.length;for(;r--;){const i=t[r];if(this._checkTarget(i,e)){if(Gr(i)&&i.subTargetCheck){const s=this._searchPossibleTargets(i._objects,e);s&&this.targets.push(s)}return i}}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e);if(r&&Gr(r)&&r.interactive&&this.targets[0]){const i=this.targets;for(let s=i.length-1;s>0;s--){const o=i[s];if(!Gr(o)||!o.interactive)return o}return i[0]}return r}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,i=r.getBoundingClientRect();let s=Yl(t),o=i.width||0,a=i.height||0;o&&a||(yt in i&&Ji in i&&(a=Math.abs(i.top-i.bottom)),it in i&&N in i&&(o=Math.abs(i.right-i.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,e||(s=Le(s,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(s.x/=l,s.y/=l);const c=o===0||a===0?new x(1,1):new x(r.width/o,r.height/a);return s.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ne(),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 t=this._activeObject;return ve(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,i=!1;const s=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{s.includes(l)||(r=!0,l.fire("deselected",{e,target:l}),a.push(l))}),s.forEach(l=>{t.includes(l)||(r=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&s.length>0?(i=!0,r&&this.fire("selection:updated",{e,selected:o,deselected:a})):s.length>0?(i=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(i=!0,this.fire("selection:cleared",{e,deselected:a})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){const r=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),i}_setActiveObject(t,e){const r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,ve(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),ve(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});const i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,r=e.target,i={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),r.fire(ti,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ve(t)&&(t.removeAll(),t.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(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,r){const i=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,r);return t.set(i),s}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&ve(e)&&this._activeObject===e){const r=Ye(t,["angle","flipX","flipY",N,Ct,At,We,Ve,yt]);return Gl(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(i)}}p(Si,"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 Ah{constructor(t){p(this,"targets",[]),p(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:i}=t.getActiveObject()||{};i&&i.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),Me(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const jh=["target","oldTarget","fireCanvas","e"],Tt={passive:!1},ke=(n,t)=>{const e=n.getViewportPoint(t),r=n.getScenePoint(t);return{viewportPoint:e,scenePoint:r,pointer:e,absolutePointer:r}},he=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return n.addEventListener(...e)},Et=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return n.removeEventListener(...e)},Lh={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 ls extends Si{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),p(this,"_isClick",void 0),p(this,"textEditingManager",new Ah(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(he,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const r=this.upperCanvasEl,i=this._getEventPrefix();t(zo(r),"resize",this._onResize),t(r,i+"down",this._onMouseDown),t(r,"".concat(i,"move"),this._onMouseMove,Tt),t(r,"".concat(i,"out"),this._onMouseOut),t(r,"".concat(i,"enter"),this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),t(r,"click",this._onClick),t(r,"dblclick",this._onClick),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,Tt)}removeListeners(){this.addOrRemove(Et,"remove");const t=this._getEventPrefix(),e=zt(this.upperCanvasEl);Et(e,"".concat(t,"up"),this._onMouseUp),Et(e,"touchend",this._onTouchEnd,Tt),Et(e,"".concat(t,"move"),this._onMouseMove,Tt),Et(e,"touchmove",this._onMouseMove,Tt),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,r=v({e:t},ke(this,t));this.fire("mouse:out",v(v({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",v({},r)),this._hoveredTargets.forEach(i=>{this.fire("mouse:out",v(v({},r),{},{target:i})),i&&i.fire("mouseout",v({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",v({e:t},ke(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void he(this.upperCanvasEl,"drag",this._onDragProgress)}hn(t)}_renderDragEffects(t,e,r){let i=!1;const s=this._dropTarget;s&&s!==e&&s!==r&&(s.clearContextTop(),i=!0),e==null||e.clearContextTop(),r!==e&&(r==null||r.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),i=!0),r&&(o.save(),r.transform(o),r.renderDropTargetEffect(t),o.restore(),i=!0),o.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==_t,r=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};Et(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",i),this._dragSource&&this._dragSource.fire("dragend",i),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:r,targets:i}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:r,subTargets:i,dragSource:s,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(r,o),r&&(r.canDrop(t)&&(a=r),r.fire(e,o));for(let l=0;l<i.length;l++){const c=i[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,s,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:r}=this.findDragTargets(t),i={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(e,i)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:r}=this.findDragTargets(t),i=this._basicEventHandler("drop:before",v({e:t,target:e,subTargets:r,dragSource:this._dragSource},ke(this,t)));i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){const e=this.findTarget(t),r=this.targets||[],i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&hn(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const r=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||r&&this._target===r)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const i=this.upperCanvasEl,s=this._getEventPrefix(),o=zt(i);he(o,"touchend",this._onTouchEnd,Tt),e&&he(o,"touchmove",this._onMouseMove,Tt),Et(i,"".concat(s,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();Et(e,"".concat(r,"move"),this._onMouseMove,Tt);const i=zt(e);he(i,"".concat(r,"up"),this._onMouseUp),he(i,"".concat(r,"move"),this._onMouseMove,Tt)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=zt(this.upperCanvasEl);Et(r,"touchend",this._onTouchEnd,Tt),Et(r,"touchmove",this._onMouseMove,Tt),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{he(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const i=zt(this.upperCanvasEl);Et(i,"".concat(r,"up"),this._onMouseUp),Et(i,"".concat(r,"move"),this._onMouseMove,Tt),he(e,"".concat(r,"move"),this._onMouseMove,Tt)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const r=this._currentTransform,i=this._isClick,s=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(r&&(this._finalizeCurrentTransform(t),c=r.actionPerformed),!i){const h=s===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){const h=s.findControl(this.getViewportPoint(t),ts(t)),{key:u,control:d}=h||{};if(l=u,s.selectable&&s!==this._activeObject&&s.activeOn==="up")this.setActiveObject(s,t),c=!0;else if(d){const g=d.getMouseUpHandler(t,s,d);g&&(a=this.getScenePoint(t),g.call(d,t,r,a.x,a.y))}s.isMoving=!1}if(r&&(r.target!==s||r.corner!==l)){const h=r.target&&r.target.controls[r.corner],u=h&&h.getMouseUpHandler(t,r.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,r,a.x,a.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),c?this.requestRenderAll():i||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:r,subTargets:i=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let s=0;s<i.length;s++)i[s]!==r&&i[s].fire(t,e);return e}_handleEvent(t,e,r){const i=this._target,s=this.targets||[],o=v(v(v({e:t,target:i,subTargets:s},ke(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?r:{});this.fire("mouse:".concat(e),o),i&&i.fire("mouse".concat(e),o);for(let a=0;a<s.length;a++)s[a]!==i&&s[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,r=!!e&&e===this._activeObject;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down",{alreadySelected:r}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let s=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(r=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),ts(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,r);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:r}),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Le(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const r=this.findTarget(t);this._setCursorFromEvent(t,r),this._fireOverOutEvents(t,r)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const r=this._hoveredTarget,i=this._hoveredTargets,s=this.targets,o=Math.max(i.length,s.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let a=0;a<o;a++)s[a]===e||i[a]&&i[a]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:s[a],oldTarget:i[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const r=this._draggedoverTarget,i=this._hoveredTargets,s=this.targets,o=Math.max(i.length,s.length);this.fireSyntheticInOutEvents("drag",v(v({},e),{},{target:t,oldTarget:r,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",v(v({},e),{},{target:s[a],oldTarget:i[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:i,fireCanvas:s,e:o}=e,a=J(e,jh);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Lh[t],d=i!==r;if(i&&d){const g=v(v({},a),{},{e:o,target:i,nextTarget:r},ke(this,o));s&&this.fire(u,g),i.fire(c,g)}if(r&&d){const g=v(v({},a),{},{e:o,target:r,previousTarget:i},ke(this,o));s&&this.fire(h,g),r.fire(l,g)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,i=r.target,s=i.group?Le(e,void 0,i.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,s),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:i,actionHandler:s,target:o}=e,a=!!s&&s(t,e,r.x,r.y);a&&o.setCoords(),i==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let r=e.hoverCursor||this.hoverCursor;const i=ve(this._activeObject)?this._activeObject:null,s=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(s){const o=s.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(o=>{r=o.hoverCursor||r}),this.setCursor(r)}handleMultiSelection(t,e){const r=this._activeObject,i=ve(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||i)&&(i||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(i){const s=r.getObjects();if(e===r){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],r.size()===1&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(s,t)}else{r.isEditing&&r.exitEditing();const s=new(E.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(r,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:i,deltaY:s}=this._groupSelector,o=new x(e,r),a=o.add(new x(i,s)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=E.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:r}=this.elements;r.ctx=void 0;const i=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),i}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const ba={x1:0,y1:0,x2:0,y2:0},Fh=v(v({},ba),{},{r1:0,r2:0}),Pe=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function ya(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function _a(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(ya(n)?100:1):NaN;return Ie(0,Pe(e,t),1)}const Rh=/\s*;\s*/,Bh=/\s*:\s*/;function Ih(n,t){let e,r;const i=n.getAttribute("style");if(i){const o=i.split(Rh);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Bh).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}const s=new G(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:_a(n.getAttribute("offset"),0),color:s.toRgb(),opacity:Pe(parseFloat(r||n.getAttribute("stop-opacity")||""),1)*s.getAlpha()*t}}function Hh(n,t){const e=[],r=n.getElementsByTagName("stop"),i=_a(t,1);for(let s=r.length;s--;)e.push(Ih(r[s],i));return e}function xa(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function wa(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ft(n,t){return n.getAttribute(t)}function zh(n,t){return function(e,r){let i,{width:s,height:o,gradientUnits:a}=r;return Object.entries(e).reduce((l,c)=>{let[h,u]=c;if(u==="Infinity")i=1;else if(u==="-Infinity")i=0;else{const d=typeof u=="string";i=d?parseFloat(u):u,d&&ya(u)&&(i*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(i*=s),h!=="y1"&&h!=="y2"||(i*=o)))}return l[h]=i,l},{})}(xa(n)==="linear"?function(e){return{x1:Ft(e,"x1")||0,y1:Ft(e,"y1")||0,x2:Ft(e,"x2")||"100%",y2:Ft(e,"y2")||0}}(n):function(e){return{x1:Ft(e,"fx")||Ft(e,"cx")||"50%",y1:Ft(e,"fy")||Ft(e,"cy")||"50%",r1:0,x2:Ft(e,"cx")||"50%",y2:Ft(e,"cy")||"50%",r2:Ft(e,"r")||"50%"}}(n),v(v({},t),{},{gradientUnits:wa(n)}))}class yr{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:i={},colorStops:s=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:v(v({},e==="radial"?Fh:ba),i),colorStops:s,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(fe()):fe()})}addColorStop(t){for(const e in t){const r=new G(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return v(v({},Ye(this,t)),{},{type:this.type,coords:v({},this.coords),colorStops:this.colorStops.map(e=>v({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=[],i=this.gradientTransform?this.gradientTransform.concat():mt.concat(),s=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>v({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;s==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),i[4]-=a,i[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(s,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(or(i),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:g,y2:f}=this.coords;r.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',g,'" y2="',f,`">
122
- `)}else if(this.type==="radial"){const{x1:u,y1:d,x2:g,y2:f,r1:m,r2:b}=this.coords,y=m>b;r.push("<radialGradient ",h,' cx="',y?u:g,'" cy="',y?d:f,'" r="',y?m:b,'" fx="',y?g:u,'" fy="',y?f:d,`">
123
- `),y&&(o.reverse(),o.forEach(O=>{O.offset=1-O.offset}));const w=Math.min(m,b);if(w>0){const O=w/Math.max(m,b);o.forEach(k=>{k.offset+=O*(1-k.offset)})}}return o.forEach(u=>{let{color:d,offset:g,opacity:f}=u;r.push("<stop ",'offset="',100*g+"%",'" style="stop-color:',d,f!==void 0?";stop-opacity: "+f:";",`"/>
72
+ `}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=ae.ownDefaults;return this.includeDefaultValues?t:Pn(t,(r,s)=>r!==e[s])}static async fromObject(t){return new this(t)}}v(ae,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ae,"type","shadow"),I.setClass(ae,"shadow");const lr=(i,t,e)=>Math.max(i,Math.min(t,e)),_u=[At,Q,jt,Xt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",fr,pr],xe=[_t,zt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Cu={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:Y,originY:Y,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:_t,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},Su=(i,t,e,r)=>-e*Math.cos(i/r*as)+e+t,ku=()=>!1;class In{constructor(t){let{startValue:e,byValue:r,duration:s=500,delay:n=0,easing:o=Su,onStart:a=Es,onChange:l=Es,onComplete:c=Es,abort:h=ku,target:u}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=n,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,this.startValue=e,this.byValue=r,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 t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>As(t),this.delay):As(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:s,valueProgress:n}=this.calculate(r);this.value=Object.freeze(s),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=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),As(this.tick)))}register(){Hs.push(this)}unregister(){Hs.remove(this)}abort(){this._state="aborted",this.unregister()}}class Tu extends In{constructor(t){let{startValue:e=0,endValue:r=100,...s}=t;super({...s,startValue:e,byValue:r-e})}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}class Ou extends In{constructor(t){let{startValue:e=[0],endValue:r=[100],...s}=t;super({...s,startValue:e,byValue:r.map((n,o)=>n-e[o])})}calculate(t){const e=this.startValue.map((r,s)=>this.easing(t,r,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Du=(i,t,e,r)=>t+e*(1-Math.cos(i/r*as)),Oi=i=>i&&((t,e,r)=>i(new rt(t).toRgba(),e,r));class Mu extends In{constructor(t){let{startValue:e,endValue:r,easing:s=Du,onChange:n,onComplete:o,abort:a,...l}=t;const c=new rt(e).getSource(),h=new rt(r).getSource();super({...l,startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:Oi(n),onComplete:Oi(o),abort:Oi(a)})}calculate(t){const[e,r,s,n]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,r,s].map(Math.round),lr(0,n,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 vl(i){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(i)?new Ou(i):new Tu(i);return t.start(),t}function Eu(i){const t=new Mu(i);return t.start(),t}class ht{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(s=>!this.includes(s))),this}static isPointContained(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const n=Xs(e,r),o=Xs(e,t).divide(n);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const r=new w(t).setX(Math.min(t.x-1,...e.map(n=>n.x)));let s=0;for(let n=0;n<e.length;n++){const o=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,r);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,r,s){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-r.x,h=s.y-r.y,u=t.x-r.x,d=t.y-r.y,g=c*d-h*u,f=a*d-l*u,m=h*a-c*l;if(m!==0){const y=g/m,b=f/m;return(n||0<=y&&y<=1)&&(o||0<=b&&b<=1)?new ht("Intersection").append(new w(t.x+y*a,t.y+y*l)):new ht}if(g===0||f===0){const y=n||o||ht.isPointContained(t,r,s)||ht.isPointContained(e,r,s)||ht.isPointContained(r,t,e)||ht.isPointContained(s,t,e);return new ht(y?"Coincident":void 0)}return new ht("Parallel")}static intersectSegmentLine(t,e,r,s){return ht.intersectLineLine(t,e,r,s,!1,!0)}static intersectSegmentSegment(t,e,r,s){return ht.intersectLineLine(t,e,r,s,!1,!1)}static intersectLinePolygon(t,e,r){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new ht,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=ht.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;n.append(...c.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,r){return ht.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new ht,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ht.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),r.append(a,l)):r.append(...c.points)}return n.length>0&&n.length===t.length?new ht("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const s=e.min(r),n=e.max(r),o=new w(n.x,s.y),a=new w(s.x,n.y);return ht.intersectPolygonPolygon(t,[s,o,n,a])}}class Pu extends Ga{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Et(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=Et(t,Qt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new w(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map(a=>Et(a,o))}return n}intersectsWithRect(t,e){return ht.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ht.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:r,top:s,width:n,height:o}=this.getBoundingRect();return r>=t.x&&r+n<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ht.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return me(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(jt,t),this._set(Xt,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?Pe(Ka(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Mt.concat()}calcACoords(){const t=mr({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),s=ls(e,r),n=Ct(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Et({x:-a,y:-l},n),tr:Et({x:a,y:-l},n),bl:Et({x:-a,y:l},n),br:Et({x:a,y:l},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.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,Ot(this.originX),Ot(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const r=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((n,o)=>n===r[o])?s.value:(this.group&&(e=Ct(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key.every((o,a)=>o===t[a]))return e.value;const r=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=iu(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new w(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...t},r=e.strokeWidth;let s=r,n=0;this.strokeUniform&&(s=0,n=r);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):Ln(o,a,ni(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,r,s,n){let o=t.x,a=t.y;const l=Ot(s)-Ot(e),c=Ot(n)-Ot(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,r){if(e===Y&&r===Y)return t;const s=this.translateToGivenOrigin(t,e,r,Y,Y);return this.angle?s.rotate(mt(this.angle),t):s}translateToOriginPoint(t,e,r){const s=this.translateToGivenOrigin(t,Y,Y,e,r);return this.angle?s.rotate(mt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Et(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.getPositionByOrigin(t,e)}getPositionByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const s=this.translateToCenterPoint(t,e,r),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.getPositionByOrigin(Q,At)}positionByLeftTop(t){return this.setPositionByOrigin(t,Q,At)}}let ue=class Fs extends Pu{static getDefaults(){return Fs.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Me("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Fs.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=be(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,s=et.maxCacheSideLimit,n=et.minCacheSideLimit;if(e<=s&&r<=s&&e*r<=et.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;const o=e/r,[a,l]=Wr.limitDimsByArea(o),c=lr(n,a,s),h=lr(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:r,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=r!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){r!==t.width||s!==t.height?(t.width=r,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,o),this.zoomX=n,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vs(this.calcTransformMatrix());return new w(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==jt&&t!==Xt||(e=this._constrainScale(e)),t===jt&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ae||(e=new ae(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:r,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:s,cacheTranslationY:n,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===zt&&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(t,e,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this.fire("before:render",{ctx:t}),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const r=Yt(e),s=r.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(n=>{n.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const n=Qt(this.calcTransformMatrix());s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(s),t.drawObject(s,!0,e),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,r);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Wt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(Wt(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,r=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(r==null?void 0:r.viewportTransform)||Mt,a=n*s,l=o*s,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*et.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!Wt(e))return{offsetX:0,offsetY:0};const r=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,n):t.transform(1,0,0,1,s,n),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===zt?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var r;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=Yt({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/n,s.zoomY/this.scaleY/n),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/s.zoomX,n*this.scaleY/s.zoomY),t.strokeStyle=(r=c.createPattern(l,"no-repeat"))!==null&&r!==void 0?r:"")}_findCenterFromElement(){return new w(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(I.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=il(this),r=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?Va():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(x=>new cs(x,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&uu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&gu(this,this.getViewportTransform()),this.setCoords();const c=be(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const x=u.blur,T=u.nonScaling?new w(1,1):this.getObjectScaling();d.x=2*Math.round(n(u.offsetX)+x)*n(T.x),d.y=2*Math.round(n(u.offsetY)+x)*n(T.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const m=l(c);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new w(m.width/2,m.height/2),Y,Y);const y=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const b=m.toCanvasElement(a||1,t);return this.set("canvas",y),this.shadow=s,r&&(this.group=r),this.set(e),this.setCoords(),m._objects=[],m.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Na(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return qa(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=Y,this.originY=Y,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.getPositionByOrigin(r,s);this.left=n,this.top=o,this.originX=r,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hs.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&le().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((r,s)=>{let[n,o]=s;return r[n]=this._animate(n,o,e),r},{})}_animate(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),n=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=r,h={...r,target:this,startValue:a??s.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,g)=>{s.reduce((f,m,y)=>(y===s.length-1&&(f[m]=u),f[m]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}};return n?Eu(h):vl(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let s,n=0;n<e.length;n++){if(s=e[n],s===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let o=0;o<r.length;o++){if(this===r[o])return{fork:[],otherFork:[t,...r.slice(0,o)],common:[this,...e]};if(s===r[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...r.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...r],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const r=e.common[0]||this.canvas;if(!r)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=r._objects.indexOf(s),a=r._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Fs.customProperties,this.constructor.customProperties||[]);let e;const r=et.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:g,height:f,strokeWidth:m,strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:T,strokeMiterLimit:C,scaleX:S,scaleY:D,angle:A,flipX:_,flipY:M,opacity:O,visible:V,backgroundColor:z,fillRule:X,paintFirst:W,globalCompositeOperation:G,skewX:q,skewY:K}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const L=gt=>ot(gt,r),bt={...vr(this,t),type:this.constructor.type,version:Ni,originX:u,originY:d,left:L(c),top:L(h),width:L(g),height:L(f),fill:yo(n)?n.toObject():n,stroke:yo(o)?o.toObject():o,strokeWidth:L(m),strokeDashArray:l&&l.concat(),strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:T,strokeMiterLimit:L(C),scaleX:L(S),scaleY:L(D),angle:L(A),flipX:_,flipY:M,opacity:L(O),shadow:a&&a.toObject(),visible:V,backgroundColor:z,fillRule:X,paintFirst:W,globalCompositeOperation:G,skewX:L(q),skewY:L(K),...e?{clipPath:e}:null};return this.includeDefaultValues?bt:this._removeDefaultValues(bt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Pn(t,(s,n)=>{if(n===Q||n===At||n==="type")return!0;const o=r[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)})}toString(){return`#<${this.constructor.type}>`}static _fromObject(t){let{type:e,...r}=t,{extraParam:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return oi(r,n).then(o=>s?(delete o[s],new this(r[s],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};v(ue,"stateProperties",_u),v(ue,"cacheProperties",xe),v(ue,"ownDefaults",Cu),v(ue,"type","FabricObject"),v(ue,"colorProperties",[_t,zt,"backgroundColor"]),v(ue,"customProperties",[]),I.setClass(ue),I.setClass(ue,"object");const yl=(i,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire(`object:${i}`,{...t,target:r}),r.fire(i,t)},yr=(i,t,e)=>(r,s,n,o)=>{const a=t(r,s,n,o);return a&&yl(i,{...hl(r,s,n,o),...e}),a};function br(i){return(t,e,r,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getPositionByOrigin(o,a),c=i(t,e,r,s);return n.setPositionByOrigin(l,e.originX,e.originY),c}}const Au=(i,t,e,r)=>(s,n,o,a)=>{const l=jn(n,n.originX,n.originY,o,a)[e],c=Ot(n[t]);if(c===0||c>0&&l<0||c<0&&l>0){const{target:h}=n,u=h.strokeWidth/(h.strokeUniform?h[r]:1),d=cl(n)?2:1,g=h[i],f=Math.abs(l*d/h[r])-u;return h.set(i,Math.max(f,1)),g!==h[i]}return!1},Lu=Au("width","originX","x","scaleX"),Po=yr(Qr,br(Lu));function Fu(i,t,e,r,s){i.save();const{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(i,t,e,s,r);let c=o;o>a?i.scale(1,a/o):a>o&&(c=a,i.scale(o/a,1)),i.beginPath(),i.arc(0,0,c/2,0,or,!1),i[l](),n&&i.stroke(),i.restore()}function ju(i,t,e,r,s){i.save();const{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(i,t,e,s,r),c=o/2,h=a/2;i[`${l}Rect`](-c,-h,o,a),n&&i.strokeRect(-c,-h,o,a),i.restore()}class Nt{constructor(t){v(this,"visible",!0),v(this,"actionName",ii),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}getTransformAnchorPoint(){var t;return(t=this.transformAnchorPoint)!==null&&t!==void 0?t:new w(.5-this.x,.5-this.y)}shouldActivate(t,e,r,s){var n;let{tl:o,tr:a,br:l,bl:c}=s;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&ht.isPointInPolygon(r,[o,a,l,c])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r,s){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,s;return(r=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&r!==void 0?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,s){return new w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,s,n,o){const a=Mn([ls(r,s),mr({angle:t}),En((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}commonRenderProps(t,e,r,s){let n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const{cornerSize:o,cornerColor:a,transparentCorners:l,cornerStrokeColor:c}=n,h=o||s.cornerSize,u=this.sizeX||h,d=this.sizeY||h,g=l!==void 0?l:s.transparentCorners,f=g?zt:_t,m=c||s.cornerStrokeColor,y=!g&&!!m;return t.fillStyle=a||s.cornerColor||"",t.strokeStyle=m||"",t.translate(e,r),t.rotate(mt(s.getTotalAngle())),{stroke:y,xSize:u,ySize:d,transparentCorners:g,opName:f}}render(t,e,r,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Fu.call(this,t,e,r,s,n):ju.call(this,t,e,r,s,n)}}const Iu=(i,t,e)=>e.lockRotation?Ys:t.cursorStyle,Bu=yr(Xa,br((i,t,e,r)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.getPositionByOrigin(l,c);if(te(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,n-h.x),d=Math.atan2(r-h.y,e-h.x);let g=Pe(d-u+a);if(s.snapAngle&&s.snapAngle>0){const m=s.snapAngle,y=s.snapThreshold||m,b=Math.ceil(g/m)*m,x=Math.floor(g/m)*m;Math.abs(g-x)<y?g=x:Math.abs(g-b)<y&&(g=b)}g<0&&(g=360+g),g%=360;const f=s.angle!==g;return s.angle=g,f}));function bl(i,t){const e=t.canvas,r=i[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function xl(i,t,e){const r=te(i,"lockScalingX"),s=te(i,"lockScalingY");if(r&&s||!t&&(r||s)&&e||r&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=i;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const Ru=["e","se","s","sw","w","nw","n","ne","e"],Tr=(i,t,e,r)=>{const s=bl(i,e);if(xl(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return Ys;const n=ul(e,0,r);return`${Ru[n]}-resize`};function Bn(i,t,e,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=bl(i,n);let l,c,h,u,d,g;if(xl(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=jn(t,t.originX,t.originY,e,r),d=o!=="y"?Math.sign(l.x||t.signX||1):1,g=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=g),te(n,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){const y=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,x=y/(Math.abs(u.x*b.scaleX/n.scaleX)+Math.abs(u.y*b.scaleY/n.scaleY));c=b.scaleX*x,h=b.scaleY*x}else c=Math.abs(l.x*n.scaleX/u.x),h=Math.abs(l.y*n.scaleY/u.y);cl(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Co(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=Co(t.originY),h*=-1,t.signY=g)}const f=n.scaleX,m=n.scaleY;return o?(o==="x"&&n.set(jt,c),o==="y"&&n.set(Xt,h)):(!te(n,"lockScalingX")&&n.set(jt,c),!te(n,"lockScalingY")&&n.set(Xt,h)),f!==n.scaleX||m!==n.scaleY}const fs=yr(si,br((i,t,e,r)=>Bn(i,t,e,r))),$u=yr(si,br((i,t,e,r)=>Bn(i,t,e,r,{by:"x"}))),zu=yr(si,br((i,t,e,r)=>Bn(i,t,e,r,{by:"y"}))),Di={x:{counterAxis:"y",scale:jt,skew:fr,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Xt,skew:pr,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Hu=["ns","nesw","ew","nwse"],Vu=(i,t,e,r)=>{if(t.x!==0&&te(e,"lockSkewingY")||t.y!==0&&te(e,"lockSkewingX"))return Ys;const s=ul(e,0,r)%4;return`${Hu[s]}-resize`};function wl(i,t,e,r,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Di[i];if(te(n,l))return!1;const{origin:u,flip:d}=Di[o],g=Ot(e[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[h]?-1:1),m=.5*-((n[c]===0&&jn(e,Y,Y,r,s)[i]>0||n[c]>0?1:-1)*f)+.5;return yr(Ya,br((b,x,T,C)=>function(S,D,A){let{target:_,ex:M,ey:O,skewingSide:V,...z}=D;const{skew:X}=Di[S],W=A.subtract(new w(M,O)).divide(new w(_.scaleX,_.scaleY))[S],G=_[X],q=z[X],K=Math.tan(mt(q)),L=S==="y"?_._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:_._getTransformedDimensions({scaleX:1,scaleY:1}).y,bt=2*W*V/Math.max(L,1)+K,gt=Pe(Math.atan(bt));_.set(X,gt);const lt=G!==_[X];if(lt&&S==="y"){const{skewX:k,scaleX:P}=_,E=_._getTransformedDimensions({skewY:G}),B=_._getTransformedDimensions(),j=k!==0?E.x/B.x:1;j!==1&&_.set(jt,j*P)}return lt}(i,x,new w(T,C))))(t,{...e,[a]:m,skewingSide:f},r,s)}const Wu=(i,t,e,r)=>wl("x",i,t,e,r),Xu=(i,t,e,r)=>wl("y",i,t,e,r);function ci(i,t){return i[t.canvas.altActionKey]}const ps=(i,t,e)=>{const r=ci(i,e);return t.x===0?r?fr:Xt:t.y===0?r?pr:jt:""},tr=(i,t,e,r)=>ci(i,e)?Vu(0,t,e,r):Tr(i,t,e,r),Ao=(i,t,e,r)=>ci(i,t.target)?Xu(i,t,e,r):$u(i,t,e,r),Lo=(i,t,e,r)=>ci(i,t.target)?Wu(i,t,e,r):zu(i,t,e,r),_l=()=>({ml:new Nt({x:-.5,y:0,cursorStyleHandler:tr,actionHandler:Ao,getActionName:ps}),mr:new Nt({x:.5,y:0,cursorStyleHandler:tr,actionHandler:Ao,getActionName:ps}),mb:new Nt({x:0,y:.5,cursorStyleHandler:tr,actionHandler:Lo,getActionName:ps}),mt:new Nt({x:0,y:-.5,cursorStyleHandler:tr,actionHandler:Lo,getActionName:ps}),tl:new Nt({x:-.5,y:-.5,cursorStyleHandler:Tr,actionHandler:fs}),tr:new Nt({x:.5,y:-.5,cursorStyleHandler:Tr,actionHandler:fs}),bl:new Nt({x:-.5,y:.5,cursorStyleHandler:Tr,actionHandler:fs}),br:new Nt({x:.5,y:.5,cursorStyleHandler:Tr,actionHandler:fs}),mtr:new Nt({x:0,y:-.5,actionHandler:Bu,cursorStyleHandler:Iu,offsetY:-40,withConnection:!0,actionName:On})}),Yu=()=>({mr:new Nt({x:.5,y:0,actionHandler:Po,cursorStyleHandler:tr,actionName:Qr}),ml:new Nt({x:-.5,y:0,actionHandler:Po,cursorStyleHandler:tr,actionName:Qr})}),Uu=()=>({..._l(),...Yu()});class ss extends ue{static getDefaults(){return{...super.getDefaults(),...ss.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),ss.ownDefaults),this.setOptions(t)}static createControls(){return{controls:_l()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,s=e.action;if(this===r&&s&&s.startsWith(ii))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const r=Object.entries(this.oCoords);for(let s=r.length-1;s>=0;s--){const[n,o]=r[s],a=this.controls[n];if(a.shouldActivate(n,this,t,e?o.touchCorner:o.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),r=ls(e.x,e.y),s=mr({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Ct(r,s),o=Ct(t,n),a=Ct(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Vs(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((u,d)=>{const g=u.positionHandler(c,a,this,u);h[d]=Object.assign(g,this._calcCornerCoords(u,g))}),h}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),r=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(mt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...r};t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:r,hasControls:s}=this,n={hasBorders:r,hasControls:s,...e},o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Ct(o,this.calcTransformMatrix()),h=Vs(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(mt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let s;if(r&&r.forActiveSelection||this.group){const n=Ln(this.width,this.height,ni(e)),o=this.isStrokeAccountedForInDimensions()?Dn:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=n.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(r=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a={cornerStrokeColor:s,cornerDashArray:n,cornerColor:o,...e};t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[r,s]=e;return this.setControlVisible(r,s)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transform(e);const s=this.width+4,n=this.height+4;return e.clearRect(-s/2,-n/2,s,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Cl(i,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),i}v(ss,"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 dt extends ss{}Cl(dt,[dl]),I.setClass(dt),I.setClass(dt,"object");const Gu=(i,t,e,r)=>{const s=2*(r=Math.round(r))+1,{data:n}=i.getImageData(t-r,e-r,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Sl{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const r=Xs(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new w(t);return e.y+=e.x*Math.tan(mt(this.options.skewY)),e.x+=e.y*Math.tan(mt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Nu=new w;class ir extends Sl{static getOrthogonalRotationFactor(t,e){const r=e?tn(t,e):al(t);return Math.abs(r)<as?-1:1}constructor(t,e,r,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=tn(this.AB,this.AC),this.bisector=Fn(ol(this.AB.eq(Nu)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=ll(s),o=ir.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*o)}projectBevel(){const t=[];return(this.alpha%or===0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),r=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),n=this.options.strokeUniform?Qi(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Qi(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],s=new w(ir.getOrthogonalRotationFactor(this.bisector),ir.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(n=>{_o(n,t,e)&&r.push(this.A.add(n))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(mt(s)),Math.tan(mt(n))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new w(Math.sqrt(Math.max(h**2-u**2,0)),u),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new w(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(m=>this.applySkew(l?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{_o(m,t,e)&&r.push(this.applySkew(this.A).add(m))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%or===0,r=this.applySkew(this.A),s=t[e?0:2].subtract(r),n=t[e?1:0].subtract(r),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Xr(s,o)>0,l=a?s:n,c=a?n:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class Fo extends Sl{constructor(t,e,r){super(r),this.A=new w(t),this.T=new w(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(ll(s),r)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new ir(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(Fn(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(r);t.push(s.add(e),s.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const qu=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const r=[];if(i.length===0)return r;const s=i.reduce((n,o)=>(n[n.length-1].eq(o)||n.push(new w(o)),n),[new w(i[0])]);if(s.length===1)e=!0;else if(!e){const n=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(n));s.splice(o+1)}return s.forEach((n,o,a)=>{let l,c;o===0?(c=a[1],l=e?n:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?n:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?r.push(...new Fo(n,n,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new ir(n,l,c,t).project()):r.push(...new Fo(n,o===0?c:l,t).project())}),r},Rn=i=>{const t={};return Object.keys(i).forEach(e=>{t[e]={},Object.keys(i[e]).forEach(r=>{t[e][r]={...i[e][r]}})}),t},$n=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return i.fill!==t.fill||i.stroke!==t.stroke||i.strokeWidth!==t.strokeWidth||i.fontSize!==t.fontSize||i.fontFamily!==t.fontFamily||i.fontWeight!==t.fontWeight||i.fontStyle!==t.fontStyle||i.textDecorationThickness!==t.textDecorationThickness||i.textBackgroundColor!==t.textBackgroundColor||i.deltaY!==t.deltaY||e&&(i.overline!==t.overline||i.underline!==t.underline||i.linethrough!==t.linethrough)},Ku=(i,t)=>{const e=t.split(`
73
+ `),r=[];let s=-1,n={};i=Rn(i);for(let o=0;o<e.length;o++){const a=An(e[o]);if(i[o])for(let l=0;l<a.length;l++){s++;const c=i[o][l];c&&Object.keys(c).length>0&&($n(n,c,!0)?r.push({start:s,end:s+1,style:c}):r[r.length-1].end++),n=c||{}}else s+=a.length,n={}}return r},Zu=(i,t)=>{if(!Array.isArray(i))return Rn(i);const e=t.split(Tn),r={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=An(e[o]);for(let l=0;l<a.length;l++)s++,i[n]&&i[n].start<=s&&s<i[n].end&&(r[o]=r[o]||{},r[o][l]={...i[n].style},s===i[n].end-1&&n++)}return r},Ae=["display","transform",_t,"fill-opacity","fill-rule","opacity",zt,"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 jo(i,t){const e=i.nodeName,r=i.getAttribute("class"),s=i.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+n,"i"),t=t.replace(o,"")),r&&t.length){const a=r.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function Ju(i,t){let e=!0;const r=jo(i,t.pop());return r&&t.length&&(e=function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=jo(s=s.parentElement,o);return n.length===0}(i,t)),r&&e&&t.length===0}function Qu(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e={};for(const r in t)Ju(i,r.split(" "))&&(e={...e,...t[r]});return e}const td=i=>{var t;return(t=wu[i])!==null&&t!==void 0?t:i},ed=new RegExp(`(${Xe})`,"gi"),Dt=`(${Xe})`,rd=String.raw`(skewX)\(${Dt}\)`,sd=String.raw`(skewY)\(${Dt}\)`,id=String.raw`(rotate)\(${Dt}(?: ${Dt} ${Dt})?\)`,nd=String.raw`(scale)\(${Dt}(?: ${Dt})?\)`,od=String.raw`(translate)\(${Dt}(?: ${Dt})?\)`,zn=`(?:${String.raw`(matrix)\(${Dt} ${Dt} ${Dt} ${Dt} ${Dt} ${Dt}\)`}|${od}|${id}|${nd}|${rd}|${sd})`,ad=`(?:${zn}*)`,ld=String.raw`^\s*(?:${ad}?)\s*$`,cd=new RegExp(ld),hd=new RegExp(zn),ud=new RegExp(zn,"g");function en(i){const t=[];if(!(i=(e=>Us(e.replace(ed," $1 ").replace(/,/gi," ")))(i).replace(/\s*([()])\s*/gi,"$1"))||i&&!cd.test(i))return[...Mt];for(const e of i.matchAll(ud)){const r=hd.exec(e[0]);if(!r)continue;let s=Mt;const n=r.filter(f=>!!f),[,o,...a]=n,[l,c,h,u,d,g]=a.map(f=>parseFloat(f));switch(o){case"translate":s=ls(l,c);break;case On:s=mr({angle:l},{x:c,y:h});break;case ii:s=En(l,c);break;case fr:s=Ja(l);break;case pr:s=Qa(l);break;case"matrix":s=[l,c,h,u,d,g]}t.push(s)}return Mn(t)}function dd(i,t,e,r){const s=Array.isArray(t);let n,o=t;if(i!==_t&&i!==zt||t!==Lt){if(i==="strokeUniform")return t==="non-scaling-stroke";if(i==="strokeDashArray")o=t===Lt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(i==="transformMatrix")o=e&&e.transformMatrix?Ct(e.transformMatrix,en(t)):en(t);else if(i==="visible")o=t!==Lt&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(i==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(i==="textAnchor")o=t==="start"?Q:t==="end"?pt:Y;else if(i==="charSpacing"||i===We)n=sr(t,r)/r*1e3;else if(i==="paintFirst"){const a=t.indexOf(_t),l=t.indexOf(zt);o=_t,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=zt)}else{if(i==="href"||i==="xlink:href"||i==="font"||i==="id")return t;if(i==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(sr):sr(t,r)}}else o="";return!s&&isNaN(n)?o:n}function gd(i,t){i.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,s]=e.split(":");t[r.trim().toLowerCase()]=s.trim()})}function fd(i){const t={},e=i.getAttribute("style");return e&&(typeof e=="string"?gd(e,t):function(r,s){Object.entries(r).forEach(n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)})}(e,t)),t}const pd={stroke:"strokeOpacity",fill:"fillOpacity"};function we(i,t,e){if(!i)return{};let r,s={},n=kn;i.parentNode&&Do.test(i.parentNode.nodeName)&&(s=we(i.parentElement,t,e),s.fontSize&&(r=n=sr(s.fontSize)));const o={...t.reduce((c,h)=>{const u=i.getAttribute(h);return u&&(c[h]=u),c},{}),...Qu(i,e),...fd(i)};o[Ti]&&i.setAttribute(Ti,o[Ti]),o[ki]&&(r=sr(o[ki],n),o[ki]=`${r}`);const a={};for(const c in o){const h=td(c),u=dd(h,o[c],s,r);a[h]=u}a&&a.font&&function(c,h){const u=c.match(xu);if(!u)return;const d=u[1],g=u[3],f=u[4],m=u[5],y=u[6];d&&(h.fontStyle=d),g&&(h.fontWeight=isNaN(parseFloat(g))?g:parseFloat(g)),f&&(h.fontSize=sr(f)),y&&(h.fontFamily=y),m&&(h.lineHeight=m===Ki?1:m)}(a.font,a);const l={...s,...a};return Do.test(i.nodeName)?l:function(c){const h=dt.getDefaults();return Object.entries(pd).forEach(u=>{let[d,g]=u;if(c[g]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const f=new rt(c[d]);c[d]=f.setAlpha(ot(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const kl=["rx","ry"];class Pt extends dt{static getDefaults(){return{...super.getDefaults(),...Pt.ownDefaults}}constructor(t){super(),Object.assign(this,Pt.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:r}=this,s=-e/2,n=-r/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,r/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,n),t.lineTo(s+e-o,n),l&&t.bezierCurveTo(s+e-Se*o,n,s+e,n+Se*a,s+e,n+a),t.lineTo(s+e,n+r-a),l&&t.bezierCurveTo(s+e,n+r-Se*a,s+e-Se*o,n+r,s+e-o,n+r),t.lineTo(s+o,n+r),l&&t.bezierCurveTo(s+Se*o,n+r,s,n+r-Se*a,s,n+r-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+Se*a,s+Se*o,n,s+o,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...kl,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:s}=this;return["<rect ","COMMON_PARTS",`x="${-t/2}" y="${-e/2}" rx="${Z(r)}" ry="${Z(s)}" width="${Z(t)}" height="${Z(e)}" />
74
+ `]}static async fromElement(t,e,r){const{left:s=0,top:n=0,width:o=0,height:a=0,visible:l=!0,...c}=we(t,this.ATTRIBUTE_NAMES,r);return new this({...e,...c,left:s,top:n,width:o,height:a,visible:!!(l&&o&&a)})}}v(Pt,"type","Rect"),v(Pt,"cacheProperties",[...xe,...kl]),v(Pt,"ownDefaults",{rx:0,ry:0}),v(Pt,"ATTRIBUTE_NAMES",[...Ae,"x","y","rx","ry","width","height"]),I.setClass(Pt),I.setSVGClass(Pt);const pe="initialization",Ns="added",Hn="removed",qs="imperative",Tl=(i,t)=>{const{strokeUniform:e,strokeWidth:r,width:s,height:n,group:o}=t,a=o&&o!==i?ai(o.calcTransformMatrix(),i.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?du(new w(r,r),void 0,i.calcTransformMatrix()):Dn,u=!e&&c?r:0,d=Ln(s+u,n+u,Mn([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class hi{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:s}=t;return e===pe||e===qs||!!r&&s!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==pe&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:s}=e;if(r===qs&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=me(t.map(u=>Tl(s,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(n,o).add(c.scalarDivide(2));if(r===pe){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(hi,"type","strategy");class rn extends hi{shouldPerformLayout(t){return!0}}v(rn,"type","fit-content"),I.setClass(rn);const Ol="layoutManager";class is{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new rn;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e={bubbles:!0,strategy:this.strategy,...t,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(e);const r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[zs,Wa,Qr,Xa,si,Ya,$s,Zh,Jh].map(s=>t.on(s,n=>this.performLayout(s===zs?{type:"object_modified",trigger:s,e:n,target:r}:{type:"object_modifying",trigger:s,e:n,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(r=>r()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:r}=t,{canvas:s}=e;if(r===pe||r===Ns?this.subscribeTargets(t):r===Hn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),r===qs&&t.deep){const{strategy:n,...o}=t;e.forEachObject(a=>a.layoutManager&&a.layoutManager.performLayout({...o,bubbles:!1,target:a}))}}getLayoutResult(t){const{target:e,strategy:r,type:s}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===pe?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=n,h=o.subtract(a).add(l).transform(s===pe?Mt:Qt(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:r}=t,{result:{size:s},nextCenter:n}=e;var o,a;r.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===pe?r.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*Ot(r.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*Ot(r.originY)}):(r.setPositionByOrigin(n,Y,Y),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(s=>{s.group===r&&this.layoutObject(t,e,s)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:s}=e;r.set({left:r.left+s.x,top:r.top+s.y})}onAfterLayout(t,e){const{target:r,strategy:s,bubbles:n,prevStrategy:o,...a}=t,{canvas:l}=r;r.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:r});const c=r.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(r),c.layoutManager.performLayout({...a,target:c})),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:Ol,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}I.setClass(is,Ol);class md extends is{performLayout(){}}class Oe extends Ua(dt){static getDefaults(){return{...super.getDefaults(),...Oe.ownDefaults}}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,Oe.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var r;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(s=>{this.enterGroup(s,!1)}),this.layoutManager=(r=e.layoutManager)!==null&&r!==void 0?r:new is,this.layoutManager.performLayout({type:pe,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Me("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Me("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,r,s)=>this.canEnterGroup(e)&&s.indexOf(e)===r)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Ns,s),n}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(r),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Ns,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Hn,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const r=this[t];return super._set(t,e),t==="canvas"&&r!==e&&(this._objects||[]).forEach(s=>{s._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:r}=e;const s=this._activeObjects;if(t)s.push(r),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(r);n>-1&&(s.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Ws(t,Ct(Qt(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Ws(t,Ct(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=dt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,r){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var s;const o=this._objects[n];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Qt(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,r)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout({target:this,type:qs,...t})}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const n=s.includeDefaultValues;s.includeDefaultValues=r;const o=s[t||"toObject"](e);return s.includeDefaultValues=n,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return{...super.toObject(["subTargetCheck","interactive",...t]),...e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{},objects:this.__serializeObjects("toObject",t)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=Pt.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
75
+ `],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
76
+ `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?`opacity: ${Z(this.opacity)};`:"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:r,objects:s=[],layoutManager:n,...o}=t;return Promise.all([ts(s,e),oi(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,{...o,...c,layoutManager:new md});if(n){const u=I.getClass(n.type),d=I.getClass(n.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new is;return h.layoutManager.subscribeTargets({type:pe,target:h,targets:h.getObjects()}),h.setCoords(),h})}}v(Oe,"type","Group"),v(Oe,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),I.setClass(Oe);const vd=(i,t)=>Math.min(t.width/i.width,t.height/i.height),yd=(i,t)=>Math.max(t.width/i.width,t.height/i.height),sn="\\s*,?\\s*",kr=`${sn}(${Xe})`,bd=`${kr}${kr}${kr}${sn}([01])${sn}([01])${kr}${kr}`,xd={m:"l",M:"L"},wd=(i,t,e,r,s,n,o,a,l,c,h)=>{const u=ve(i),d=ye(i),g=ve(t),f=ye(t),m=e*s*g-r*n*f+o,y=r*s*g+e*n*f+a;return["C",c+l*(-e*s*d-r*n*u),h+l*(-r*s*d+e*n*u),m+l*(e*s*f+r*n*g),y+l*(r*s*f-e*n*g),m,y]},Io=(i,t,e,r)=>{const s=Math.atan2(t,i),n=Math.atan2(r,e);return n>=s?n-s:2*Math.PI-(s-n)};function Bo(i,t,e,r,s,n,o,a){let l;if(et.cachesBoundsOfCurve&&(l=[...arguments].join(),Wr.boundsOfCurveCache[l]))return Wr.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*i-12*e+6*s,f=-3*i+9*e-9*s+3*o,m=3*e-3*i;for(let C=0;C<2;++C){if(C>0&&(g=6*t-12*r+6*n,f=-3*t+9*r-9*n+3*a,m=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const M=-m/g;0<M&&M<1&&u.push(M);continue}const S=g*g-4*m*f;if(S<0)continue;const D=c(S),A=(-g+D)/(2*f);0<A&&A<1&&u.push(A);const _=(-g-D)/(2*f);0<_&&_<1&&u.push(_)}let y=u.length;const b=y,x=Dl(i,t,e,r,s,n,o,a);for(;y--;){const{x:C,y:S}=x(u[y]);d[0][y]=C,d[1][y]=S}d[0][b]=i,d[1][b]=t,d[0][b+1]=o,d[1][b+1]=a;const T=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return et.cachesBoundsOfCurve&&(Wr.boundsOfCurveCache[l]=T),T}const _d=(i,t,e)=>{let[r,s,n,o,a,l,c,h]=e;const u=((d,g,f,m,y,b,x)=>{if(f===0||m===0)return[];let T=0,C=0,S=0;const D=Math.PI,A=x*Sn,_=ye(A),M=ve(A),O=.5*(-M*d-_*g),V=.5*(-M*g+_*d),z=f**2,X=m**2,W=V**2,G=O**2,q=z*X-z*W-X*G;let K=Math.abs(f),L=Math.abs(m);if(q<0){const st=Math.sqrt(1-q/(z*X));K*=st,L*=st}else S=(y===b?-1:1)*Math.sqrt(q/(z*W+X*G));const bt=S*K*V/L,gt=-S*L*O/K,lt=M*bt-_*gt+.5*d,k=_*bt+M*gt+.5*g;let P=Io(1,0,(O-bt)/K,(V-gt)/L),E=Io((O-bt)/K,(V-gt)/L,(-O-bt)/K,(-V-gt)/L);b===0&&E>0?E-=2*D:b===1&&E<0&&(E+=2*D);const B=Math.ceil(Math.abs(E/D*2)),j=[],H=E/B,ut=8/3*Math.sin(H/4)*Math.sin(H/4)/Math.sin(H/2);let ct=P+H;for(let st=0;st<B;st++)j[st]=wd(P,ct,M,_,K,L,lt,k,ut,T,C),T=j[st][5],C=j[st][6],P=ct,ct+=H;return j})(c-i,h-t,s,n,a,l,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=i,u[d][2]+=t,u[d][3]+=i,u[d][4]+=t,u[d][5]+=i,u[d][6]+=t;return u},Cd=i=>{let t=0,e=0,r=0,s=0;const n=[];let o,a=0,l=0;for(const c of i){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],r=h[1],s=h[2],u=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],u=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],u=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":_d(t,e,h).forEach(d=>n.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=r,e=s,u=["Z"]}u?(n.push(u),o=u[0]):o=""}return n},Ks=(i,t,e,r)=>Math.sqrt((e-i)**2+(r-t)**2),Dl=(i,t,e,r,s,n,o,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),u=(g=>3*g*(1-g)**2)(l),d=(g=>(1-g)**3)(l);return new w(o*c+s*h+e*u+i*d,a*c+n*h+r*u+t*d)},Ml=i=>i**2,El=i=>2*i*(1-i),Pl=i=>(1-i)**2,Sd=(i,t,e,r,s,n,o,a)=>l=>{const c=Ml(l),h=El(l),u=Pl(l),d=3*(u*(e-i)+h*(s-e)+c*(o-s)),g=3*(u*(r-t)+h*(n-r)+c*(a-n));return Math.atan2(g,d)},kd=(i,t,e,r,s,n)=>o=>{const a=Ml(o),l=El(o),c=Pl(o);return new w(s*a+e*l+i*c,n*a+r*l+t*c)},Td=(i,t,e,r,s,n)=>o=>{const a=1-o,l=2*(a*(e-i)+o*(s-e)),c=2*(a*(r-t)+o*(n-r));return Math.atan2(c,l)},Ro=(i,t,e)=>{let r=new w(t,e),s=0;for(let n=1;n<=100;n+=1){const o=i(n/100);s+=Ks(r.x,r.y,o.x,o.y),r=o}return s},Od=(i,t)=>{let e,r=0,s=0,n={x:i.x,y:i.y},o={...n},a=.01,l=0;const c=i.iterator,h=i.angleFinder;for(;s<t&&a>1e-4;)o=c(r),l=r,e=Ks(n.x,n.y,o.x,o.y),e+s>t?(r-=a,a/=2):(n=o,r+=a,s+=e);return{...o,angle:h(l)}},Al=i=>{let t,e,r=0,s=0,n=0,o=0,a=0;const l=[];for(const c of i){const h={x:s,y:n,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=n=c[2];break;case"L":e=h,e.length=Ks(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Dl(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=Sd(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Ro(t,s,n),s=c[5],n=c[6];break;case"Q":t=kd(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Td(s,n,c[1],c[2],c[3],c[4]),e.length=Ro(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Ks(s,n,o,a),s=o,n=a}r+=e.length,l.push(e)}return l.push({length:r,x:s,y:n}),l},Dd=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Al(i),r=0;for(;t-e[r].length>0&&r<e.length-2;)t-=e[r].length,r++;const s=e[r],n=t/s.length,o=i[r];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return{...new w(s.x,s.y).lerp(new w(s.destX,s.destY),n),angle:Math.atan2(s.destY-s.y,s.destX-s.x)};case"L":return{...new w(s.x,s.y).lerp(new w(o[1],o[2]),n),angle:Math.atan2(o[2]-s.y,o[1]-s.x)};case"C":case"Q":return Od(s,t)}},Md=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),$o=new RegExp(bd,"g"),Ed=new RegExp(Xe,"gi"),Pd={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Ad=i=>{var t;const e=[],r=(t=i.match(Md))!==null&&t!==void 0?t:[];for(const s of r){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=Pd[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){$o.lastIndex=0;for(let l=null;l=$o.exec(s);)a.push(...l.slice(1))}else a=s.match(Ed)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=xd[n];c[0]=l>0&&h?h:n;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},Ld=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new w(i[0]),r=new w(i[1]),s=1,n=0;const o=[],a=i.length,l=a>2;let c;for(l&&(s=i[2].x<r.x?-1:i[2].x===r.x?0:1,n=i[2].y<r.y?-1:i[2].y===r.y?0:1),o.push(["M",e.x-s*t,e.y-n*t]),c=1;c<a;c++){if(!e.eq(r)){const h=e.midPointFrom(r);o.push(["Q",e.x,e.y,h.x,h.y])}e=i[c],c+1<i.length&&(r=i[c+1])}return l&&(s=e.x>i[c-2].x?1:e.x===i[c-2].x?0:-1,n=e.y>i[c-2].y?1:e.y===i[c-2].y?0:-1),o.push(["L",e.x+s*t,e.y+n*t]),o},Ll=(i,t)=>i.map(e=>e.map((r,s)=>s===0||t===void 0?r:ot(r,t)).join(" ")).join(" ");function nn(i,t){const e=i.style;e&&Object.entries(t).forEach(r=>{let[s,n]=r;return e.setProperty(s,n)})}class Fd extends sl{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(r),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=be();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=gr().createElement("div");return t.setAttribute("data-fabric","wrapper"),nn(t,{position:"relative"}),xo(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:s}=e;nn(t,{...r,"touch-action":s?"manipulation":Lt}),xo(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:s}=this.upper;rl(r,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Zi(this.upper.el,t),Zi(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),le().dispose(this.upper.el),delete this.upper,delete this.container}}const jd=(i,t,e,r)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=r-o,c=!te(s,"lockMovementX")&&s.left!==a,h=!te(s,"lockMovementY")&&s.top!==l;return c&&s.set(Q,a),h&&s.set(At,l),(c||h)&&yl(Wa,hl(i,t,e,r)),c||h};class ui extends cs{constructor(){super(...arguments),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...ui.ownDefaults}}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Fd(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):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(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-r+s),n.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=o,n.restore();const a=Math.round(s*this.getRetinaScaling());return Gu(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(r=>!!r&&t[r]===!0):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&r.length>1&&r.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let s;return e===ii||e===jt||e===Xt||e===Qr?s=this.centeredScaling||t.centeredScaling:e===On&&(s=this.centeredRotation||t.centeredRotation),s?!r:r}_getOriginFromCorner(t,e){const r=e?t.controls[e].getTransformAnchorPoint():{x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=pt:["mr","tr","br"].includes(e)&&(r.x=Q),["tl","mt","tr"].includes(e)?r.y=qi:["bl","mb","br"].includes(e)&&(r.y=At)),r}_setupCurrentTransform(t,e,r){var s;const n=e.group?ar(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=r&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):jd,c=((_,M,O,V)=>{if(!M||!_)return"drag";const z=V.controls[M];return z.getActionName(O,z,V)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:Y,y:Y}:this._getOriginFromCorner(e,o),{scaleX:d,scaleY:g,skewX:f,skewY:m,left:y,top:b,angle:x,width:T,height:C,cropX:S,cropY:D}=e,A={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:d,scaleY:g,skewX:f,skewY:m,offsetX:n.x-y,offsetY:n.y-b,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:mt(x),width:T,height:C,shiftKey:t.shiftKey,altKey:h,original:{...il(e),originX:u.x,originY:u.y,cropX:S,cropY:D}};this._currentTransform=A,this.fire("before:transform",{e:t,transform:A})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new w(e,r).transform(this.viewportTransform),a=new w(e+s,r+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,dt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};const e=this.getScenePoint(t),r=this._activeObject,s=this.getActiveObjects(),n=this.searchPossibleTargets(this._objects,e),{subTargets:o,container:a,target:l}=n,c={...n,currentSubTargets:o,currentContainer:a,currentTarget:l};if(!r)return c;const h={...this.searchPossibleTargets([r],e),currentSubTargets:o,currentContainer:a,currentTarget:l};return r.findControl(this.getViewportPoint(t),Ji(t))?{...h,target:r}:h.target&&(s.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&t[this.altSelectionKey])?h:c}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=r,h=Math.atan2(a.y-o.y,a.x-o.x),u=ve(h)*n,d=ye(h)*n,g=u+d,f=u-d;r=[new w(o.x-f,o.y-g),new w(a.x+g,a.y-f),new w(l.x+f,l.y+g),new w(c.x-g,c.y+f)]}return ht.isPointInPolygon(e,r)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,e)){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;{const r=e.transform(this.viewportTransform);if(!this.isTargetTransparent(t,r.x,r.y))return!0}}return!1}_searchPossibleTargets(t,e,r){let s=t.length;for(;s--;){const n=t[s];if(this._checkTarget(n,e)){if(Ps(n)&&n.subTargetCheck){const{target:o}=this._searchPossibleTargets(n._objects,e,r);o&&r.push(o)}return{target:n,subTargets:r}}}return{subTargets:[]}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e,[]);r.container=r.target;const{container:s,subTargets:n}=r;if(s&&Ps(s)&&s.interactive&&n[0]){for(let o=n.length-1;o>0;o--){const a=n[o];if(!Ps(a)||!a.interactive)return r.target=a,r}return r.target=n[0],r}return r}getViewportPoint(t){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(t,!0)}getScenePoint(t){return this._scenePoint?this._scenePoint:this._getPointerImpl(t)}_getPointerImpl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,s=r.getBoundingClientRect();let n=cu(t),o=s.width||0,a=s.height||0;o&&a||(At in s&&qi in s&&(a=Math.abs(s.top-s.bottom)),pt in s&&Q in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=ar(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new w(1,1):new w(r.width/o,r.height/a);return n.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=be(),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 t=this._activeObject;return Be(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{n.includes(l)||(r=!0,l.fire("deselected",{e,target:l}),a.push(l))}),n.forEach(l=>{t.includes(l)||(r=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&n.length>0?(s=!0,r&&this.fire("selection:updated",{e,selected:o,deselected:a})):n.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const r=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),s}_setActiveObject(t,e){const r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Be(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),Be(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,r=e.target,s={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),r.fire(zs,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Be(t)&&(t.removeAll(),t.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(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,r){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,r);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Be(e)&&this._activeObject===e){const r=vr(t,["angle","flipX","flipY",Q,jt,Xt,fr,pr,At]);return hu(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(s)}}v(ui,"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:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!0});class Id{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),Qe(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const It={passive:!1},Fe=(i,t)=>({viewportPoint:i.getViewportPoint(t),scenePoint:i.getScenePoint(t)}),ke=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.addEventListener(...e)},Ht=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.removeEventListener(...e)},Bd={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 on extends ui{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Id(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(ke)}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,s=this._getEventPrefix();t(el(r),"resize",this._onResize),t(r,s+"down",this._onMouseDown),t(r,`${s}move`,this._onMouseMove,It),t(r,`${s}out`,this._onMouseOut),t(r,`${s}enter`,this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),e||(t(r,"click",this._onClick),t(r,"dblclick",this._onClick)),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,It)}removeListeners(){this.addOrRemove(Ht);const t=this._getEventPrefix(),e=Zt(this.upperCanvasEl);Ht(e,`${t}up`,this._onMouseUp),Ht(e,"touchend",this._onTouchEnd,It),Ht(e,`${t}move`,this._onMouseMove,It),Ht(e,"touchmove",this._onMouseMove,It),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_onMouseOut(t){const e=this._hoveredTarget,r={e:t,...Fe(this,t)};this.fire("mouse:out",{...r,target:e}),this._hoveredTarget=void 0,e&&e.fire("mouseout",{...r}),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",{...r,target:s}),s&&s.fire("mouseout",{...r})}),this._hoveredTargets=[]}_onMouseEnter(t){const{target:e}=this.findTarget(t);this._currentTransform||e||(this.fire("mouse:over",{e:t,...Fe(this,t)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void ke(this.upperCanvasEl,"drag",this._onDragProgress)}wo(t)}_renderDragEffects(t,e,r){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==r&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),r!==e&&(r==null||r.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),r&&(o.save(),r.transform(o),r.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const{currentSubTargets:e}=this.findTarget(t),r=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Lt,s=r?this._activeObject:void 0,n={e:t,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:r,dropTarget:s};Ht(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",n),this._dragSource&&this._dragSource.fire("dragend",n),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}_onDragOver(t){const e="dragover",{currentContainer:r,currentSubTargets:s}=this.findTarget(t),n=this._dragSource,o={e:t,target:r,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(t,r,o),r&&(r.canDrop(t)&&(a=r),r.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,n,a),this._dropTarget=a}_onDragEnter(t){const{currentContainer:e,currentSubTargets:r}=this.findTarget(t),s={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(t,e,s)}_onDragLeave(t){const{currentSubTargets:e}=this.findTarget(t),r={e:t,target:this._draggedoverTarget,subTargets:e,dragSource:this._dragSource};this.fire("dragleave",r),this._fireEnterLeaveEvents(t,void 0,r),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(t){const{currentContainer:e,currentSubTargets:r}=this.findTarget(t),s=this._basicEventHandler("drop:before",{e:t,target:e,subTargets:r,dragSource:this._dragSource,...Fe(this,t)});s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const{target:e,subTargets:r}=this.findTarget(t),s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&wo(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}fireEventFromPointerEvent(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};this._cacheTransformEventData(t);const{target:n,subTargets:o}=this.findTarget(t),a={e:t,target:n,subTargets:o,...Fe(this,t),transform:this._currentTransform,...s};this.fire(e,a),n&&n.fire(r,a);for(let l=0;l<o.length;l++)o[l]!==n&&o[l].fire(r,a);this._resetTransformEventData()}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){this._cacheTransformEventData(t);let e=!this.allowTouchScrolling;const r=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t);const{target:s}=this.findTarget(t);(this.isDrawingMode||r&&s===r)&&(e=!0),e&&t.preventDefault();const n=this.upperCanvasEl,o=this._getEventPrefix(),a=Zt(n);ke(a,"touchend",this._onTouchEnd,It),e&&ke(a,"touchmove",this._onMouseMove,It),Ht(n,`${o}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(t){this._cacheTransformEventData(t),this.__onMouseDown(t);const e=this.upperCanvasEl,r=this._getEventPrefix();Ht(e,`${r}move`,this._onMouseMove,It);const s=Zt(e);ke(s,`${r}up`,this._onMouseUp),ke(s,`${r}move`,this._onMouseMove,It),this._resetTransformEventData()}_onTouchEnd(t){if(t.touches.length>0)return;this._cacheTransformEventData(t),this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=Zt(this.upperCanvasEl);Ht(r,"touchend",this._onTouchEnd,It),Ht(r,"touchmove",this._onMouseMove,It),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ke(this.upperCanvasEl,`${e}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this._cacheTransformEventData(t),this.__onMouseUp(t);const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const s=Zt(this.upperCanvasEl);Ht(s,`${r}up`,this._onMouseUp),Ht(s,`${r}move`,this._onMouseMove,It),ke(e,`${r}move`,this._onMouseMove,It)}this._resetTransformEventData()}_onMouseMove(t){this._cacheTransformEventData(t);const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._handleEvent(t,"up:before");const r=this._currentTransform,s=this._isClick,{target:n}=this.findTarget(t),{button:o}=t;if(o)return void((this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(r&&(this._finalizeCurrentTransform(t),c=r.actionPerformed),!s){const h=n===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(n)||!h&&n===this._activeObject)}if(n){const h=n.findControl(this.getViewportPoint(t),Ji(t)),{key:u,control:d}=h||{};if(l=u,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(d){const g=d.getMouseUpHandler(t,n,d);g&&(a=this.getScenePoint(t),g.call(d,t,r,a.x,a.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==l)){const h=r.target&&r.target.controls[r.corner],u=h&&h.getMouseUpHandler(t,r.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,r,a.x,a.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:r,subTargets:s=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==r&&s[n].fire(t,e);return e}_handleEvent(t,e,r){const{target:s,subTargets:n}=this.findTarget(t),o={e:t,target:s,subTargets:n,...Fe(this,t),transform:this._currentTransform,...e==="down:before"||e==="down"?r:{}};e!=="up:before"&&e!=="up"||(o.isClick=this._isClick),this.fire(`mouse:${e}`,o),s&&s.fire(`mouse${e}`,o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire(`mouse${e}`,o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._handleEvent(t,"down:before");let{target:e}=this.findTarget(t),r=!!e&&e===this._activeObject;const{button:s}=t;if(s)return void((this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:r}));if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(r=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),Ji(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,r);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:r}),n&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(t),this._scenePoint=ar(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(t),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(t){if(this._isClick=!1,this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const{target:r}=this.findTarget(t);this._setCursorFromEvent(t,r),this._fireOverOutEvents(t,r)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move")}_fireOverOutEvents(t,e){const{_hoveredTarget:r,_hoveredTargets:s}=this,{subTargets:n}=this.findTarget(t),o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=n}_fireEnterLeaveEvents(t,e,r){const s=this._draggedoverTarget,n=this._hoveredTargets,{subTargets:o}=this.findTarget(t),a=Math.max(n.length,o.length);this.fireSyntheticInOutEvents("drag",{...r,target:e,oldTarget:s,fireCanvas:!0});for(let l=0;l<a;l++)this.fireSyntheticInOutEvents("drag",{...r,target:o[l],oldTarget:n[l]});this._draggedoverTarget=e}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:s,fireCanvas:n,e:o,...a}=e;const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Bd[t],d=s!==r;if(s&&d){const g={...a,e:o,target:s,nextTarget:r,...Fe(this,o)};n&&this.fire(u,g),s.fire(c,g)}if(r&&d){const g={...a,e:o,target:r,previousTarget:s,...Fe(this,o)};n&&this.fire(h,g),r.fire(l,g)}}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,s=r.target,n=s.group?ar(e,void 0,s.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,n),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,r.x,r.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let r=e.hoverCursor||this.hoverCursor;const s=Be(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const{control:o,coord:a}=n;this.setCursor(o.cursorStyleHandler(t,o,e,a))}else{if(e.subTargetCheck){const{subTargets:o}=this.findTarget(t);o.concat().reverse().forEach(a=>{r=a.hoverCursor||r})}this.setCursor(r)}}handleMultiSelection(t,e){const r=this._activeObject,s=Be(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||s)&&(s||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(s){const n=r.getObjects();let o=[];if(e===r){const a=this.getScenePoint(t);let l=this.searchPossibleTargets(n,a);if(l.target?(e=l.target,o=l.subTargets):(l=this.searchPossibleTargets(this._objects,a),e=l.target,o=l.subTargets),!e||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=o,r.size()===1&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=o),this._fireSelectionEvents(n,t)}else{r.isEditing&&r.exitEditing();const n=new(I.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(r,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new w(e,r),a=o.add(new w(s,n)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=I.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:r}=this.elements;r.ctx=void 0;const s=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Fl={x1:0,y1:0,x2:0,y2:0},Rd={...Fl,r1:0,r2:0},er=(i,t)=>isNaN(i)&&typeof t=="number"?t:i;function jl(i){return i&&/%$/.test(i)&&Number.isFinite(parseFloat(i))}function Il(i,t){const e=typeof i=="number"?i:typeof i=="string"?parseFloat(i)/(jl(i)?100:1):NaN;return lr(0,er(e,t),1)}const $d=/\s*;\s*/,zd=/\s*:\s*/;function Hd(i,t){let e,r;const s=i.getAttribute("style");if(s){const o=s.split($d);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(zd).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}e=e||i.getAttribute("stop-color")||"rgb(0,0,0)",r=er(parseFloat(r||i.getAttribute("stop-opacity")||""),1);const n=new rt(e);return n.setAlpha(n.getAlpha()*r*t),{offset:Il(i.getAttribute("offset"),0),color:n.toRgba()}}function Vd(i,t){const e=[],r=i.getElementsByTagName("stop"),s=Il(t,1);for(let n=r.length;n--;)e.push(Hd(r[n],s));return e}function Bl(i){return i.nodeName==="linearGradient"||i.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Rl(i){return i.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Gt(i,t){return i.getAttribute(t)}function Wd(i,t){return function(e,r){let s,{width:n,height:o,gradientUnits:a}=r;return Object.entries(e).reduce((l,c)=>{let[h,u]=c;if(u==="Infinity")s=1;else if(u==="-Infinity")s=0;else{const d=typeof u=="string";s=d?parseFloat(u):u,d&&jl(u)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l},{})}(Bl(i)==="linear"?function(e){return{x1:Gt(e,"x1")||0,y1:Gt(e,"y1")||0,x2:Gt(e,"x2")||"100%",y2:Gt(e,"y2")||0}}(i):function(e){return{x1:Gt(e,"fx")||Gt(e,"cx")||"50%",y1:Gt(e,"fy")||Gt(e,"cy")||"50%",r1:0,x2:Gt(e,"cx")||"50%",y2:Gt(e,"cy")||"50%",r2:Gt(e,"r")||"50%"}}(i),{...t,gradientUnits:Rl(i)})}class ms{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:{...e==="radial"?Rd:Fl,...s},colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?`${c}_${Ee()}`:Ee()})}addColorStop(t){for(const e in t)this.colorStops.push({offset:parseFloat(e),color:t[e]});return this}toObject(t){return{...vr(this,t),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(e=>({...e})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=[],s=this.gradientTransform?this.gradientTransform.concat():Mt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(d=>({...d})).sort((d,g)=>d.offset-g.offset);let a=-this.offsetX,l=-this.offsetY;var c;n==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=[`id="SVGID_${Z(String(this.id))}"`,`gradientUnits="${n}"`,`gradientTransform="${e?e+" ":""}${es(s)}"`,""].join(" "),u=d=>parseFloat(String(d));if(this.type==="linear"){const{x1:d,y1:g,x2:f,y2:m}=this.coords,y=u(d),b=u(g),x=u(f),T=u(m);r.push("<linearGradient ",h,' x1="',y,'" y1="',b,'" x2="',x,'" y2="',T,`">
77
+ `)}else if(this.type==="radial"){const{x1:d,y1:g,x2:f,y2:m,r1:y,r2:b}=this.coords,x=u(d),T=u(g),C=u(f),S=u(m),D=u(y),A=u(b),_=D>A;r.push("<radialGradient ",h,' cx="',_?x:C,'" cy="',_?T:S,'" r="',_?D:A,'" fx="',_?C:x,'" fy="',_?S:T,`">
78
+ `),_&&(o.reverse(),o.forEach(O=>{O.offset=1-O.offset}));const M=Math.min(D,A);if(M>0){const O=M/Math.max(D,A);o.forEach(V=>{V.offset+=O*(1-V.offset)})}}return o.forEach(d=>{let{color:g,offset:f}=d;r.push(`<stop offset="${100*f}%" style="stop-color:${g};"/>
124
79
  `)}),r.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
125
- `),r.join("")}toLive(t){const{x1:e,y1:r,x2:i,y2:s,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,r,i,s):t.createRadialGradient(e,r,o,i,s,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new G(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this(v(v({},t),{},{colorStops:e?e.map(i=>v({},i)):void 0,gradientTransform:r?[...r]:void 0}))}static fromElement(t,e,r){const i=wa(t),s=e._findCenterFromElement();return new this(v({id:t.getAttribute("id")||void 0,type:xa(t),coords:zh(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:Hh(t,r.opacity),gradientUnits:i,gradientTransform:ss(t.getAttribute("gradientTransform")||"")},i==="pixels"?{offsetX:e.width/2-s.x,offsetY:e.height/2-s.y}:{offsetX:0,offsetY:0}))}}p(yr,"type","Gradient"),E.setClass(yr,"gradient"),E.setClass(yr,"linear"),E.setClass(yr,"radial");const Wh=["type","source","patternTransform"];class Ii{get type(){return"pattern"}set type(t){ge("warn","Setting type has no effect",t)}constructor(t){p(this,"repeat","repeat"),p(this,"offsetX",0),p(this,"offsetY",0),p(this,"crossOrigin",""),this.id=fe(),Object.assign(this,t)}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(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:r}=this;return v(v({},Ye(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:Z(this.offsetX,X.NUM_FRACTION_DIGITS),offsetY:Z(this.offsetY,X.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:r}=t;const{source:i,repeat:s,id:o}=this,a=Pe(this.offsetX/e,0),l=Pe(this.offsetY/r,0),c=s==="repeat-y"||s==="no-repeat"?1+Math.abs(a||0):Pe(i.width/e,0),h=s==="repeat-x"||s==="no-repeat"?1+Math.abs(l||0):Pe(i.height/r,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(i.width,'" height="').concat(i.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
126
- `)}static async fromObject(t,e){let{type:r,source:i,patternTransform:s}=t,o=J(t,Wh);const a=await $r(i,v(v({},e),{},{crossOrigin:o.crossOrigin}));return new this(v(v({},o),{},{patternTransform:s&&s.slice(0),source:a}))}}p(Ii,"type","Pattern"),E.setClass(Ii),E.setClass(Ii,"pattern");class Vh{constructor(t){p(this,"color","rgb(0, 0, 0)"),p(this,"width",1),p(this,"shadow",null),p(this,"strokeLineCap","round"),p(this,"strokeLineJoin","round"),p(this,"strokeMiterLimit",10),p(this,"strokeDashArray",null),p(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new G(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,r=t.contextTop,i=t.getZoom()*t.getRetinaScaling();r.shadowColor=e.color,r.shadowBlur=e.blur*i,r.shadowOffsetX=e.offsetX*i,r.shadowOffsetY=e.offsetY*i}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Xh=["path","left","top"],Yh=["d"];class ue extends dt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:r,left:i,top:s}=e,o=J(e,Xh);super(),Object.assign(this,ue.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof i=="number"&&this.set(N,i),typeof s=="number"&&this.set(yt,s)}_setPath(t,e){this.path=_h(Array.isArray(t)?t:Mh(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,r=-this.pathOffset.y;t.beginPath();for(const i of this.path)switch(i[0]){case"L":t.lineTo(i[1]+e,i[2]+r);break;case"M":t.moveTo(i[1]+e,i[2]+r);break;case"C":t.bezierCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r,i[5]+e,i[6]+r);break;case"Q":t.quadraticCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v(v({},super.toObject(t)),{},{path:this.path.map(e=>e.slice())})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=va(this.path,X.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
127
- `)]}_getOffsetTransform(){const t=X.NUM_FRACTION_DIGITS;return" translate(".concat(Z(-this.pathOffset.x,t),", ").concat(Z(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:r,pathOffset:i}=this._calcDimensions();this.set({width:e,height:r,pathOffset:i}),t&&this.setPositionByOrigin(i,W,W)}_calcBoundsFromPath(){const t=[];let e=0,r=0,i=0,s=0;for(const o of this.path)switch(o[0]){case"L":i=o[1],s=o[2],t.push({x:e,y:r},{x:i,y:s});break;case"M":i=o[1],s=o[2],e=i,r=s;break;case"C":t.push(...Rn(i,s,o[1],o[2],o[3],o[4],o[5],o[6])),i=o[5],s=o[6];break;case"Q":t.push(...Rn(i,s,o[1],o[2],o[1],o[2],o[3],o[4])),i=o[3],s=o[4];break;case"Z":i=e,s=r}return re(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return v(v({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const i=le(t,this.ATTRIBUTE_NAMES,r),{d:s}=i;return new this(s,v(v(v({},J(i,Yh)),e),{},{left:void 0,top:void 0}))}}p(ue,"type","Path"),p(ue,"cacheProperties",[...ae,"path","fillRule"]),p(ue,"ATTRIBUTE_NAMES",[...pe,"d"]),E.setClass(ue),E.setSVGClass(ue);class hi extends Vh{constructor(t){super(t),p(this,"decimate",.4),p(this,"drawStraightLine",!1),p(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,r){const i=e.midPointFrom(r);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:r}=e;this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:r}=e;if(this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const i=this._points,s=i.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=hi.drawSegment(o,i[s-2],i[s-1]),o.stroke(),o.restore()}}onMouseUp(t){let{e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,e=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&e.x===r.x&&e.y===r.y){const i=this.width/1e3;e.x-=i,r.x+=i}t.moveTo(e.x,e.y);for(let i=1;i<this._points.length;i++)hi.drawSegment(t,e,r),e=this._points[i],r=this._points[i+1];t.lineTo(e.x,e.y),t.stroke(),t.restore()}convertPointsToSVGPath(t){const e=this.width/1e3;return Eh(t,e)}createPath(t){const e=new ue(t,{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,e.shadow=new Nt(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let r,i=t[0];const s=this.canvas.getZoom(),o=Math.pow(e/s,2),a=t.length-1,l=[i];for(let c=1;c<a-1;c++)r=Math.pow(i.x-t[c].x,2)+Math.pow(i.y-t[c].y,2),r>=o&&(i=t[c],l.push(i));return l.push(t[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(r){return va(r)==="M 0 0 Q 0 0 0 0 L 0 0"}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const Uh=["left","top","radius"],Ca=["radius","startAngle","endAngle","counterClockwise"];class Jt extends dt{static getDefaults(){return v(v({},super.getDefaults()),Jt.ownDefaults)}constructor(t){super(),Object.assign(this,Jt.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,st(this.startAngle),st(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(Ct)}getRadiusY(){return this.get("radius")*this.get(At)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Ca,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
128
- `];{const{radius:e}=this,r=st(this.startAngle),i=st(this.endAngle),s=ie(r)*e,o=se(r)*e,a=ie(i)*e,l=se(i)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(s," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
129
- `]}}static async fromElement(t,e,r){const i=le(t,this.ATTRIBUTE_NAMES,r),{left:s=0,top:o=0,radius:a=0}=i;return new this(v(v({},J(i,Uh)),{},{radius:a,left:s-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}p(Jt,"type","Circle"),p(Jt,"cacheProperties",[...ae,...Ca]),p(Jt,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),p(Jt,"ATTRIBUTE_NAMES",["cx","cy","r",...pe]),E.setClass(Jt),E.setSVGClass(Jt);const Gh=["x1","y1","x2","y2"],Nh=["x1","y1","x2","y2"],cs=["x1","x2","y1","y2"];class Qt extends dt{constructor(){let[t,e,r,i]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Qt.ownDefaults),this.setOptions(s),this.x1=t,this.x2=r,this.y1=e,this.y2=i,this._setWidthHeight();const{left:o,top:a}=s;typeof o=="number"&&this.set(N,o),typeof a=="number"&&this.set(yt,a)}_setWidthHeight(){const{x1:t,y1:e,x2:r,y2:i}=this;this.width=Math.abs(r-t),this.height=Math.abs(i-e);const{left:s,top:o,width:a,height:l}=re([{x:t,y:e},{x:r,y:i}]),c=new x(s+a/2,o+l/2);this.setPositionByOrigin(c,W,W)}_set(t,e){return super._set(t,e),cs.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const r=t.strokeStyle;var i;Pt(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(i=this.stroke)!==null&&i!==void 0?i:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=r}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v(v({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:r,y2:i,width:s,height:o}=this,a=t<=e?-1:1,l=r<=i?-1:1;return{x1:a*s/2,x2:a*-s/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:r,y2:i}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(r,'" x2="').concat(e,'" y2="').concat(i,`" />
130
- `)]}static async fromElement(t,e,r){const i=le(t,this.ATTRIBUTE_NAMES,r),{x1:s=0,y1:o=0,x2:a=0,y2:l=0}=i;return new this([s,o,a,l],J(i,Gh))}static fromObject(t){let{x1:e,y1:r,x2:i,y2:s}=t,o=J(t,Nh);return this._fromObject(v(v({},o),{},{points:[e,r,i,s]}),{extraParam:"points"})}}p(Qt,"type","Line"),p(Qt,"cacheProperties",[...ae,...cs]),p(Qt,"ATTRIBUTE_NAMES",pe.concat(cs)),E.setClass(Qt),E.setSVGClass(Qt);class be extends dt{static getDefaults(){return v(v({},super.getDefaults()),be.ownDefaults)}constructor(t){super(),Object.assign(this,be.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}p(be,"type","Triangle"),p(be,"ownDefaults",{width:100,height:100}),E.setClass(be),E.setSVGClass(be);const Sa=["rx","ry"];class Ht extends dt{static getDefaults(){return v(v({},super.getDefaults()),Ht.ownDefaults)}constructor(t){super(),Object.assign(this,Ht.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(Ct)}getRy(){return this.get("ry")*this.get(At)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Sa,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
131
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Jr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const i=le(t,this.ATTRIBUTE_NAMES,r);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function $h(n){if(!n)return[];const t=n.replace(/,/g," ").trim().split(/\s+/),e=[];for(let r=0;r<t.length;r+=2)e.push({x:parseFloat(t[r]),y:parseFloat(t[r+1])});return e}p(Ht,"type","Ellipse"),p(Ht,"cacheProperties",[...ae,...Sa]),p(Ht,"ownDefaults",{rx:0,ry:0}),p(Ht,"ATTRIBUTE_NAMES",[...pe,"cx","cy","rx","ry"]),E.setClass(Ht),E.setSVGClass(Ht);const qh=["left","top"],Ta={exactBoundingBox:!1};class Bt extends dt{static getDefaults(){return v(v({},super.getDefaults()),Bt.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),p(this,"strokeDiff",void 0),Object.assign(this,Bt.ownDefaults),this.setOptions(e),this.points=t;const{left:r,top:i}=e;this.initialized=!0,this.setBoundingBox(!0),typeof r=="number"&&this.set(N,r),typeof i=="number"&&this.set(yt,i)}isOpen(){return!0}_projectStrokeOnPoints(t){return Bc(this.points,t,this.isOpen())}_calcDimensions(t){t=v({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},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const r=re(e),i=bi(v(v({},t),{},{scaleX:1,scaleY:1})),s=re(this.points.map(c=>bt(c,i,!0))),o=new x(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(st(this.skewX)),l-=a*Math.tan(st(this.skewY))),v(v({},r),{},{pathOffset:new x(a,l),strokeOffset:new x(s.left,s.top).subtract(new x(r.left,r.top)).multiply(o),strokeDiff:new x(r.width,r.height).subtract(new x(s.width,s.height)).multiply(o)})}_findCenterFromElement(){const t=re(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,width:i,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:i,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+i/2,r+s/2),W,W)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,r;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r:l)}else{var i,s;o=new x((i=t.width)!==null&&i!==void 0?i:this.width,(s=t.height)!==null&&s!==void 0?s:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const r=this.initialized&&this[t]!==e,i=super._set(t,e);return this.exactBoundingBox&&r&&((t===Ct||t===At)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),i}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v(v({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:r,y:i}=e;return{x:r,y:i}})})}_toSVG(){const t=[],e=this.pathOffset.x,r=this.pathOffset.y,i=X.NUM_FRACTION_DIGITS;for(let s=0,o=this.points.length;s<o;s++)t.push(Z(this.points[s].x-e,i),",",Z(this.points[s].y-r,i)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
132
- `)]}_render(t){const e=this.points.length,r=this.pathOffset.x,i=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-i);for(let s=0;s<e;s++){const o=this.points[s];t.lineTo(o.x-r,o.y-i)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){return new this($h(t.getAttribute("points")),v(v({},J(le(t,this.ATTRIBUTE_NAMES,r),qh)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}p(Bt,"ownDefaults",Ta),p(Bt,"type","Polyline"),p(Bt,"layoutProperties",[We,Ve,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),p(Bt,"cacheProperties",[...ae,"points"]),p(Bt,"ATTRIBUTE_NAMES",[...pe]),E.setClass(Bt),E.setSVGClass(Bt);class _r extends Bt{isOpen(){return!1}}p(_r,"ownDefaults",Ta),p(_r,"type","Polygon"),E.setClass(_r),E.setSVGClass(_r);class ka extends dt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const r in e)for(const i in e[r])for(const s in e[r][i])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const r=e===void 0?this.styles:{0:this.styles[e]};for(const i in r)for(const s in r[i])if(r[i][s][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let r,i,s=0,o=!0,a=0;for(const l in e){r=0;for(const c in e[l]){const h=e[l][c]||{};s++,h[t]!==void 0?(i?h[t]!==i&&(o=!1):i=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?r++:delete e[l][c]}r===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&s===a&&(this[t]=i,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let r,i,s;for(i in e){for(s in r=e[i],r)delete r[s][t],Object.keys(r[s]).length===0&&delete r[s];Object.keys(r).length===0&&delete e[i]}}_extendStyles(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);const s=Ms(v(v({},this._getStyleDeclaration(r,i)),e),o=>o!==void 0);this._setStyleDeclaration(r,i,s)}getSelectionStyles(t,e,r){const i=[];for(let s=t;s<(e||t);s++)i.push(this.getStyleAtPosition(s,r));return i}getStyleAtPosition(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,i):this._getStyleDeclaration(r,i)}setSelectionStyles(t,e,r){for(let i=e;i<(r||e);i++)this._extendStyles(i,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;const i=this.styles&&this.styles[t];return i&&(r=i[e])!==null&&r!==void 0?r:{}}getCompleteStyleDeclaration(t,e){return v(v({},Ye(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}p(ka,"_styleProperties",Ql);const Kh=/ +/g,Zh=/"/g;function Hi(n,t,e,r,i){return" ".concat(function(s,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:X.NUM_FRACTION_DIGITS;const d=ar(at,s,!1),[g,f,m,b]=[a,l,c,h].map(y=>Z(y,u));return"<rect ".concat(d,' x="').concat(g,'" y="').concat(f,'" width="').concat(m,'" height="').concat(b,'"></rect>')}(n,{left:t,top:e,width:r,height:i}),`
133
- `)}const Jh=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let zi;class ft extends ka{static getDefaults(){return v(v({},super.getDefaults()),ft.ownDefaults)}constructor(t,e){super(),p(this,"__charBounds",[]),Object.assign(this,ft.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=ma(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}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(Yt)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,i,s,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Yt||l!==c-1&&!this.isEndOfWrapping(l))&&(i=0,s=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){r=a.length,t=(this.width-e)/r;for(let h=0;h<=s.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(s[h])?(o.width+=t,o.kernedWidth+=t,o.left+=i,i+=t):o.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const r=e?this._unwrappedTextLines:this._textLines;let i;for(i=0;i<r.length;i++){if(t<=r[i].length)return{lineIndex:i,charIndex:t};t-=r[i].length+this.missingNewlineOffset(i,e)}return{lineIndex:i-1,charIndex:r[i-1].length<t?r[i-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===xt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case W:t.textBaseline="middle";break;case"ascender":t.textBaseline=yt;break;case"descender":t.textBaseline=Ji}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,r,i,s,o){this._renderChars(t,e,r,i,s,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=this._getLeftOffset();let i=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){const a=this.getHeightOfLine(s);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",s)){i+=a;continue}const l=this._textLines[s].length,c=this._getLineLeftOffset(s);let h,u,d=0,g=0,f=this.getValueOfPropertyAt(s,0,"textBackgroundColor");const m=this.getHeightOfLineImpl(s);for(let b=0;b<l;b++){const y=this.__charBounds[s][b];u=this.getValueOfPropertyAt(s,b,"textBackgroundColor"),this.path?(t.save(),t.translate(y.renderLeft,y.renderTop),t.rotate(y.angle),t.fillStyle=u,u&&t.fillRect(-y.width/2,-m*(1-this._fontSizeFraction),y.width,m),t.restore()):u!==f?(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,i,d,m),g=y.left,d=y.width,f=u):d+=y.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,i,d,m)),i+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,i){const s=Ke.getFontCache(e),o=this._getFontDeclaration(e),a=r?r+t:t,l=r&&o===this._getFontDeclaration(i),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,g;if(r&&s.has(r)&&(d=s.get(r)),s.has(t)&&(g=h=s.get(t)),l&&s.has(a)&&(u=s.get(a),g=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return zi||(zi=jt({width:0,height:0}).getContext("2d")),zi}();this._setTextStyles(f,e,!0),h===void 0&&(g=h=f.measureText(t).width,s.set(t,h)),d===void 0&&l&&r&&(d=f.measureText(r).width,s.set(r,d)),l&&u===void 0&&(u=f.measureText(a).width,s.set(a,u),g=u-d)}return{width:h*c,kernedWidth:g*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,r,i=0;const s=this.pathSide===it,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const u=a[h];r=this._getGraphemeBox(u,t,h,e),c[h]=r,i+=r.kernedWidth,e=u}if(c[l]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case N:h=s?u-i:0;break;case W:h=(u-i)/2;break;case it:h=s?0:u-i}h+=this.pathStartOffset*(s?-1:1);for(let d=s?l-1:0;s?d>=0:d<l;s?d--:d++)r=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,r),h+=r.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,i=this.path,s=Th(i.path,r,i.segmentsInfo);e.renderLeft=s.x-i.pathOffset.x,e.renderTop=s.y-i.pathOffset.y,e.angle=s.angle+(this.pathSide===it?Math.PI:0)}_getGraphemeBox(t,e,r,i,s){const o=this.getCompleteStyleDeclaration(e,r),a=i?this.getCompleteStyleDeclaration(e,r-1):{},l=this._measureChar(t,o,i,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(r>0&&!s){const g=this.__charBounds[e][r-1];d.left=g.left+g.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)r=Math.max(this.getHeightOfChar(t,i),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=0;const i=this._getLeftOffset(),s=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],i+this._getLineLeftOffset(o),s+r+this.getHeightOfLineImpl(o),o),r+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(at))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,r,i,s,o){const a=this.textAlign.includes(Yt),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",u=this.direction==="ltr"?1:-1,d=e.direction;let g,f,m,b,y,w="",O=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?N:it),s-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,r.join(""),i,s),void e.restore();for(let k=0,S=r.length-1;k<=S;k++)b=k===S||this.charSpacing||l,w+=r[k],m=this.__charBounds[o][k],O===0?(i+=u*(m.kernedWidth-m.width),O+=m.width):O+=m.kernedWidth,a&&!b&&this._reSpaceAndTab.test(r[k])&&(b=!0),b||(g=g||this.getCompleteStyleDeclaration(o,k),f=this.getCompleteStyleDeclaration(o,k+1),b=Bs(g,f,!1)),b&&(l?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,k,w,-O/2,0),e.restore()):(y=i,this._renderChar(t,e,o,k,w,y,s)),w="",g=f,i+=u*O,O=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,i=jt({width:e,height:r}),s=i.getContext("2d");return i.width=e,i.height=r,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,r),s.lineTo(0,r),s.closePath(),s.translate(e/2,r/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(i,"no-repeat")}handleFiller(t,e,r){let i,s;return Pt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?(i=-this.width/2,s=-this.height/2,t.translate(i,s),t[e]=this._applyPatternGradientTransformText(r),{offsetX:i,offsetY:s}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,strokeWidth:i}=e;return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,i,s,o,a){const l=this._getStyleDeclaration(r,i),c=this.getCompleteStyleDeclaration(r,i),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(s,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(s,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){const i=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),o=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),a={fontSize:s*r.size,deltaY:o+s*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,i=this.textAlign,s=this.direction,o=this.isEndOfWrapping(t);let a=0;return i===Yt||i===Je&&!o||i===Ze&&!o||i===oi&&!o?0:(i===W&&(a=r/2),i===it&&(a=r),i===Je&&(a=r/2),i===Ze&&(a=r),s==="rtl"&&(i===it||i===Yt||i===Ze?a=0:i===N||i===oi?a=-r:i!==W&&i!==Je||(a=-r/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,r){var i;return(i=this._getStyleDeclaration(t,e)[r])!==null&&i!==void 0?i:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=this._getTopOffset();const i=this._getLeftOffset(),s=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){r+=u;continue}const d=this._textLines[c],g=u/this.lineHeight,f=this._getLineLeftOffset(c);let m=0,b=0,y=this.getValueOfPropertyAt(c,0,e),w=this.getValueOfPropertyAt(c,0,at),O=this.getValueOfPropertyAt(c,0,Ce),k=y,S=w,C=O;const A=r+g*(1-this._fontSizeFraction);let D=this.getHeightOfChar(c,0),L=this.getValueOfPropertyAt(c,0,"deltaY");for(let I=0,M=d.length;I<M;I++){const j=this.__charBounds[c][I];k=this.getValueOfPropertyAt(c,I,e),S=this.getValueOfPropertyAt(c,I,at),C=this.getValueOfPropertyAt(c,I,Ce);const z=this.getHeightOfChar(c,I),V=this.getValueOfPropertyAt(c,I,"deltaY");if(s&&k&&S){const Q=this.fontSize*C/1e3;t.save(),t.fillStyle=w,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,l*z+V-a*Q,j.kernedWidth,Q),t.restore()}else if((k!==y||S!==w||z!==D||C!==O||V!==L)&&b>0){const Q=this.fontSize*O/1e3;let U=i+f+m;this.direction==="rtl"&&(U=this.width-U-b),y&&w&&O&&(t.fillStyle=w,t.fillRect(U,A+l*D+L-a*Q,b,Q)),m=j.left,b=j.width,y=k,O=C,w=S,D=z,L=V}else b+=j.kernedWidth}let R=i+f+m;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=S;const H=this.fontSize*C/1e3;k&&S&&C&&t.fillRect(R,A+l*D+L-a*H,b-o,H),r+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||ft.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,r,"".concat(s?this.CACHE_FONT_SIZE:i,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Rs(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),i=[`
134
- `];let s=[];for(let o=0;o<e.length;o++)r[o]=this.graphemeSplit(e[o]),s=s.concat(r[o],i);return s.pop(),{_unwrappedLines:r,lines:e,graphemeText:s,graphemeLines:r}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v(v({},super.toObject([...Jo,...t])),{},{styles:Wc(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:r}=this.constructor;super.set(t,e);let i=!1,s=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),i=i||r.includes(o),s=s||o==="path";else i=r.includes(t),s=t==="path";return s&&this.setPathInfo(),i&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,r){const i=le(t,ft.ATTRIBUTE_NAMES,r),s=v(v({},e),i),{textAnchor:o=N,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=Cs,strokeWidth:g=1}=s,f=J(s,Jh),m=new this(ni(t.textContent||"").trim(),v({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),b=m.getScaledHeight()/m.height,y=((m.height+m.strokeWidth)*m.lineHeight-m.height)*b,w=m.getScaledHeight()+y;let O=0;return o===W&&(O=m.getScaledWidth()/2),o===it&&(O=m.getScaledWidth()),m.set({left:m.left-O,top:m.top-(w-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:g}),m}static fromObject(t){return this._fromObject(v(v({},t),{},{styles:Vc(t.styles||{},t.text)}),{extraParam:"text"})}}p(ft,"textLayoutProperties",Zo),p(ft,"cacheProperties",[...ae,...Jo]),p(ft,"ownDefaults",tc),p(ft,"type","Text"),p(ft,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),p(ft,"ATTRIBUTE_NAMES",pe.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),aa(ft,[class extends $o{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:n,withShadow:!0,additionalTransform:or(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const r=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(Zh,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",r?'text-decoration="'.concat(r,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
135
- `]}_getSVGTextAndBg(n,t){const e=[],r=[];let i,s=n;this.backgroundColor&&r.push(...Hi(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)i=this._getLineLeftOffset(o),this.direction==="rtl"&&(i+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(r,o,t+i,s),this._setSVGTextLineText(e,o,t+i,s),s+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:r}}_createTextCharSpan(n,t,e,r,i){const s=X.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Kh)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(Z(l,s),'" '):"",{angle:h,renderLeft:u,renderTop:d,width:g}=i;let f="";if(u!==void 0){const m=g/2;h&&(f=' rotate="'.concat(Z(oe(h),s),'"'));const b=Xe({angle:oe(h)});b[4]=u,b[5]=d;const y=new x(-m,0).transform(b);e=y.x,r=y.y}return'<tspan x="'.concat(Z(e,s),'" y="').concat(Z(r,s),'" ').concat(c).concat(f).concat(a,">").concat(Ic(n),"</tspan>")}_setSVGTextLineText(n,t,e,r){const i=this.getHeightOfLine(t),s=this.textAlign.includes(Yt),o=this._textLines[t];let a,l,c,h,u,d="",g=0;r+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,m=o.length-1;f<=m;f++)u=f===m||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[t][f],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=Bs(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),n.push(this._createTextCharSpan(d,h,e,r,c)),d="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(n,t,e,r){const i=this._textLines[t],s=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<i.length;h++){const{left:u,width:d,kernedWidth:g}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Hi(c,e+l,r,a,s)),l=u,a=d,c=o):a+=g}o&&n.push(...Hi(c,e+l,r,a,s))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const r=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*r/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," text-decoration-thickness: ").concat(Z(this.textDecorationThickness*this.getObjectScaling().y/10,X.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:r,stroke:i,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:u,overline:d,underline:g}=n,f=this.getSvgTextDecoration({underline:g??this.underline,overline:d??this.overline,linethrough:u??this.linethrough}),m=h||this.textDecorationThickness;return[i?ar(xt,i):"",r?"stroke-width: ".concat(r,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",f?"text-decoration: ".concat(f,"; text-decoration-thickness: ").concat(Z(m*this.getObjectScaling().y/10,X.NUM_FRACTION_DIGITS),"%; "):"",s?ar(at,s):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),E.setClass(ft),E.setSVGClass(ft);class Qh{constructor(t){p(this,"target",void 0),p(this,"__mouseDownInPlace",!1),p(this,"__dragStartFired",!1),p(this,"__isDraggingOver",!1),p(this,"__dragStartSelection",void 0),p(this,"__dragImageDisposer",void 0),p(this,"_dispose",void 0),this.target=t;const e=[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=()=>{e.forEach(r=>r()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var r;let{selectionStart:i,selectionEnd:s}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(i),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new x(g.left,g.top)),m=a.viewportTransform,b=f.add(u).transform(m,!0),y=o.backgroundColor,w=Fs(o.styles);o.backgroundColor="";const O={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(O,0,i),o.setSelectionStyles(O,s,o.text.length),o.dirty=!0;const k=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=y,o.styles=w,o.dirty=!0,as(k,{position:"fixed",left:"".concat(-k.width,"px"),border:_t,width:"".concat(k.width/d,"px"),height:"".concat(k.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{k.remove()},zt(t.target||this.target.hiddenTextarea).body.appendChild(k),(r=t.dataTransfer)===null||r===void 0||r.setDragImage(k,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(i.selectionStart,i.selectionEnd).join(""),o=v({text:e.text,value:s},i);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:r}=t,i=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let s=(e=r.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(s&&!i){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(r);const{styles:c}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},h=s[Math.max(0,s.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>d&&l<=g?l=d:l>g&&(l-=g-d),o.removeChars(d,g),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(s,c,l),a.setActiveObject(o),o.enterEditing(r),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+s.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Qr,{index:l+u,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var r;const i=this.target,s=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((r=e.dataTransfer)===null||r===void 0?void 0:r.dropEffect)||_t;l===_t?(i.selectionStart=o,i.selectionEnd=a,i._updateTextarea(),i.hiddenTextarea.focus()):(i.clearContextTop(),l==="move"&&(i.removeChars(o,a),i.selectionStart=i.selectionEnd=o,i.hiddenTextarea&&(i.hiddenTextarea.value=i.text),i._updateTextarea(),i.fire(Qr,{index:o,action:"dragend"}),s.fire("text:changed",{target:i}),s.requestRenderAll()),i.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Hn=/[ \n\.,;!\?\-]/;class tu extends ft{constructor(){super(...arguments),p(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:r,delay:i,onComplete:s}=t;return ra({startValue:this._currentCursorOpacity,endValue:e,duration:r,delay:i,onComplete:s,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.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(t){let e=0,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let i=t>0&&this._reSpace.test(r[t])&&(e===-1||!Ss.test(r[t-1]))?t-1:t,s=r[i];for(;i>0&&i<r.length&&!Hn.test(s);)i+=e,s=r[i];return e===-1&&Hn.test(s)&&i++,i}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.searchWordBoundary(t,-1),i=Math.max(r,this.searchWordBoundary(t,1));this.selectionStart=r,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=r,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),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(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;zt(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&i!==s||i!==r&&s!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===s||(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(t,e,r){const i=r.slice(0,t),s=this.graphemeSplit(i).length;if(t===e)return{selectionStart:s,selectionEnd:s};const o=r.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,r){const i=r.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+r.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),i=r.lineIndex,s=r.charIndex,o=this.getValueOfPropertyAt(i,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,g=u-o,f=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.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 t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),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 t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(ti),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:o}=this.get2DCursorLocation(e,!0);if(r!==s){if(this.styles[r])for(let a=i;a<this._unwrappedTextLines[r].length;a++)delete this.styles[r][a];if(this.styles[s])for(let a=o;a<this._unwrappedTextLines[s].length;a++){const l=this.styles[s][a];l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][i+a-o]=l)}for(let a=r+1;a<=s;a++)delete this.styles[a];this.shiftLineStyles(s,r-s)}else if(this.styles[r]){const a=this.styles[r],l=o-i;for(let c=i;c<o;c++)delete a[c];for(const c in this.styles[r]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const i in this.styles){const s=parseInt(i,10);s>t&&(this.styles[s+e]=r[s],r[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,r,i){const s={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;r||(r=1),this.shiftLineStyles(t,r);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,s[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+r]=s,h=!0),(h||o>e)&&r--;r>0;)i&&i[r-1]?this.styles[t+r]={0:v({},i[r-1])}:c?this.styles[t+r]={0:v({},c)}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,i){this.styles||(this.styles={});const s=this.styles[t],o=s?v({},s):{};r||(r=1);for(const l in o){const c=parseInt(l,10);c>=e&&(s[c+r]=o[c],o[c-r]||delete s[c])}if(this._forceClearCache=!0,i){for(;r--;)Object.keys(i[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]=v({},i[r]));return}if(!s)return;const a=s[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]=v({},a)}insertNewStyleBlock(t,e,r){const i=this.get2DCursorLocation(e,!0),s=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
136
- `?(a++,s[a]=0):s[a]++;for(s[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,s[0],r),r=r&&r.slice(s[0]+1)),a&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+s[0],a),o=1;o<a;o++)s[o]>0?this.insertCharStyleObject(i.lineIndex+o,0,s[o],r):r&&this.styles[i.lineIndex+o]&&r[0]&&(this.styles[i.lineIndex+o][0]=r[0]),r=r&&r.slice(s[o]+1);s[o]>0&&this.insertCharStyleObject(i.lineIndex+o,0,s[o],r)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;i>r&&this.removeStyleFromTo(r,i);const s=this.graphemeSplit(t);this.insertNewStyleBlock(s,r,e),this._text=[...this._text.slice(0,r),...s,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=N:this._selectionDirection===it&&(this._selectionDirection=N,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===it?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=it:this._selectionDirection===N&&(this._selectionDirection=it,this.selectionStart=e),this.selectionEnd=r)}}class eu extends tu{initHiddenTextarea(){const t=this.canvas&&zt(this.canvas.getElement())||ze(),e=t.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 e.setAttribute(a,l)});const{top:r,left:i,fontSize:s}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(r,"; left: ").concat(i,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(s,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),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 e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:r,selectionStart:i,selectionEnd:s}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Qr),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(r).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,u=this.selectionEnd,d=h!==u;let g,f,m,b,y=c-l;const w=this.fromStringToGraphemeSelection(i,s,r),O=h>w.selectionStart;d?(f=this._text.slice(h,u),y+=u-h):c<l&&(f=O?this._text.slice(u+y,u):this._text.slice(h,h-y));const k=a.slice(w.selectionEnd-y,w.selectionEnd);if(f&&f.length&&(k.length&&(g=this.getSelectionStyles(h,h+1,!1),g=k.map(()=>g[0])),d?(m=h,b=u):O?(m=u-f.length,b=u):(m=u,b=u+f.length),this.removeStyleFromTo(m,b)),k.length){const{copyPasteData:S}=$t();e&&k.join("")===S.copiedText&&!X.disableStyleCopyPaste&&(g=S.copiedTextStyle),this.insertNewStyleBlock(k,h,g)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:i}=e;this.compositionStart=r,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=$t();t.copiedText=this.getSelectedText(),X.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let r,i=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],i+=r.left+r.width),i}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),s=i.lineIndex;if(s===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-r;const o=i.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s+1,a);return this._textLines[s].slice(o).length+l+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),s=i.lineIndex;if(s===0||t.metaKey||t.keyCode===33)return-r;const o=i.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s-1,a),c=this._textLines[s].slice(0,o),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const r=this._textLines[t];let i,s,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=r.length;l<c;l++)if(i=this.__charBounds[t][l].width,o+=i,o>e){s=!0;const h=o-i,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return s||(a=r.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const r=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===it);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const i=this.text.length;this.selectionStart=Ie(0,this.selectionStart,i),this.selectionEnd=Ie(0,this.selectionEnd,i),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===N?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,r){let i;if(t.altKey)i=this["findWordBoundary".concat(r)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;i=this["findLineBoundary".concat(r)](this[e])}return i!==void 0&&this[e]!==i&&(this[e]=i,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=N,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===it&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=N,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const r="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===N&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=it,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=it,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const zn=n=>!!n.button;class ru extends eu{constructor(){super(...arguments),p(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 Qh(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:r}=t;this.canvas&&this.editable&&!zn(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=t;const i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const s=this.canvas._activeObject;if(s&&s!==this)return}!this.editable||this.group&&!this.group.interactive||r&&r.actionPerformed||zn(e)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),r=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Wt(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let r=0,i=0,s=0;for(let c=0;c<this._textLines.length&&r<=e.y;c++)r+=this.getHeightOfLine(c),s=c,c>0&&(i+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(s));const a=this._textLines[s].length,l=this.__charBounds[s];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&i++;break}o=h,i++}return Math.min(this.flipX?a-i:i,this._text.length)}}const xr="moveCursorUp",wr="moveCursorDown",Cr="moveCursorLeft",Sr="moveCursorRight",Tr="exitEditing",Wn=(n,t)=>{const e=t.getRetinaScaling();n.setTransform(e,0,0,e,0,0);const r=t.viewportTransform;n.transform(r[0],r[1],r[2],r[3],r[4],r[5])},iu=v({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:Tr,27:Tr,33:xr,34:wr,35:Sr,36:Cr,37:Cr,38:xr,39:Sr,40:wr},keysMapRtl:{9:Tr,27:Tr,33:xr,34:wr,35:Cr,36:Sr,37:Sr,38:xr,39:Cr,40:wr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Gt extends ru{static getDefaults(){return v(v({},super.getDefaults()),Gt.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,v(v({},Gt.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof ls&&this.canvas.textEditingManager.remove(this),e instanceof ls&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),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 t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),i=r.length>0;let s,o=t;if(i){s=jt(t.canvas),o=s.getContext("2d"),Wn(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,e):this.renderCursor(o,e),i)for(const a of r){const l=a.clipPath,c=jt(t.canvas),h=c.getContext("2d");if(Wn(h,this.canvas),!l.absolutePositioned){const u=a.calcTransformMatrix();h.transform(u[0],u[1],u[2],u[3],u[4],u[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const r=this._getLeftOffset(),i=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:r,top:i,leftOffset:s.left,topOffset:s.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,r=0;const{charIndex:i,lineIndex:s}=this.get2DCursorLocation(t);for(let c=0;c<s;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(s),a=this.__charBounds[s][i];a&&(r=a.left),this.charSpacing!==0&&i===this._textLines[s].length&&(r-=this._getWidthOfCharSpacing());const l={top:e,left:o+(r>0?r:0)};return this.direction==="rtl"&&(this.textAlign===it||this.textAlign===Yt||this.textAlign===Ze?l.left*=-1:this.textAlign===N||this.textAlign===oi?l.left=o-(r>0?r:0):this.textAlign!==W&&this.textAlign!==Je||(l.left=o-(r>0?r:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const r=this.get2DCursorLocation(t),i=r.lineIndex,s=r.charIndex>0?r.charIndex-1:0,o=this.getValueOfPropertyAt(i,s,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(i,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,s,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,r){const{color:i,opacity:s,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(r,e);t.fillStyle=i,t.globalAlpha=s,t.fillRect(o,a,l,c)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,r){const i=e.selectionStart,s=e.selectionEnd,o=this.textAlign.includes(Yt),a=this.get2DCursorLocation(i),l=this.get2DCursorLocation(s),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let g=c;g<=h;g++){const f=this._getLineLeftOffset(g)||0;let m=this.getHeightOfLine(g),b=0,y=0,w=0;if(g===c&&(y=this.__charBounds[c][u].left),g>=c&&g<h)w=o&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(d===0)w=this.__charBounds[h][d].left;else{const A=this._getWidthOfCharSpacing();w=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-A}b=m,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(m/=this.lineHeight);let O=r.left+f+y,k=m,S=0;const C=w-y;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",k=1,S=m):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===it||this.textAlign===Yt||this.textAlign===Ze?O=this.width-O-C:this.textAlign===N||this.textAlign===oi?O=r.left+f-w:this.textAlign!==W&&this.textAlign!==Je||(O=r.left+f-w)),t.fillRect(O,r.top+r.topOffset+S,C,k),r.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,at)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}p(Gt,"ownDefaults",iu),p(Gt,"type","IText"),E.setClass(Gt),E.setClass(Gt,"i-text");class ye extends Gt{static getDefaults(){return v(v({},super.getDefaults()),ye.ownDefaults)}constructor(t,e){super(t,v(v({},ye.ownDefaults),e))}static createControls(){return{controls:Lc()}}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(Yt)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,i=0;const s={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[i]===`
137
- `&&o>0?(r=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&o>0&&(r++,i++),s[o]={line:e,offset:r},i+=t.graphemeLines[o].length,r+=t.graphemeLines[o].length;return s}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[e];r&&(e=r.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,i=t+1,s=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,r=o.offset),a&&(i=a.line,s=i===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const u=parseInt(h,10);if(u>=r&&(!s||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const r=this.getGraphemeDataForRender(t),i=[];for(let s=0;s<r.wordsData.length;s++)i.push(...this._wrapLine(s,e,r));return this.isWrapping=!1,i}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=e?"":" ";let i=0;return{wordsData:t.map((s,o)=>{let a=0;const l=e?this.graphemeSplit(s):this.wordSplit(s);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return i=Math.max(u,i),a+=h.length+r.length,{word:h,width:u}})}),largestWordWidth:i}}_measureWord(t,e){let r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=0;for(let o=0,a=t.length;o<a;o++)s+=this._getGraphemeBox(t[o],e,o+i,r,!0).kernedWidth,r=t[o];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:i,wordsData:s}=r,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],g=0,f=0,m=!0;e-=o;const b=Math.max(e,i,this.dynamicMinWidth),y=s[t];let w;for(g=0,w=0;w<y.length;w++){const{word:O,width:k}=y[w];g+=O.length,u+=f+k-a,u>b&&!m?(c.push(d),d=[],u=k,m=!0):u+=a,m||l||d.push(h),d=d.concat(O),f=l?0:this._measureWord([h],t,g),g++,m=!1}return w&&c.push(d),i+o>this.dynamicMinWidth&&(this.dynamicMinWidth=i-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),r=this._wrapText(e.lines,this.width),i=new Array(r.length);for(let s=0;s<r.length;s++)i[s]=r[s].join("");return e.lines=i,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){const i=this._styleMap[e].line;t.set("".concat(i),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}p(ye,"type","Textbox"),p(ye,"textLayoutProperties",[...Gt.textLayoutProperties,"width"]),p(ye,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),E.setClass(ye);class Vn extends Ci{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:i,group:s}=r;if(!i||!this.shouldPerformLayout(t))return;const{width:o,height:a}=re(ha(r,i)),l=new x(o,a);if(i.absolutePositioned)return{center:Le(i.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:l};{const c=i.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:u=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}p(Vn,"type","clip-path"),E.setClass(Vn);class Xn extends Ci{getInitialSize(t,e){let{target:r}=t,{size:i}=e;return new x(r.width||i.x,r.height||i.y)}}p(Xn,"type","fixed"),E.setClass(Xn);class su extends cr{subscribeTargets(t){const e=t.target;t.targets.reduce((r,i)=>(i.parent&&r.add(i.parent),r),new Set).forEach(r=>{r.layoutManager.subscribeTargets({target:r,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((i,s)=>(s.parent&&i.add(s.parent),i),new Set).forEach(i=>{!r.some(s=>s.parent===i)&&i.layoutManager.unsubscribeTargets({target:i,targets:[e]})})}}class _e extends xe{static getDefaults(){return v(v({},super.getDefaults()),_e.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,_e.ownDefaults),this.setOptions(e);const{left:r,top:i,layoutManager:s}=e;this.groupInit(t,{left:r,top:i,layoutManager:s??new su})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(i=>{const s=this._objects.findIndex(a=>a.isInFrontOf(i)),o=s===-1?this.size():s;this.insertAt(o,i)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(ge("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const r=new Set;e.forEach(i=>{const{parent:s}=i;s&&r.add(s)}),t===Hs?r.forEach(i=>{i._onAfterObjectsChange(ai,e)}):r.forEach(i=>{i._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const i=v(v({hasControls:!1},r),{},{forActiveSelection:!0});for(let s=0;s<this._objects.length;s++)this._objects[s]._renderControls(t,i);super._renderControls(t,e),t.restore()}}p(_e,"type","ActiveSelection"),p(_e,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),E.setClass(_e),E.setClass(_e,"activeSelection");class nu{constructor(){p(this,"resources",{})}applyFilters(t,e,r,i,s){const o=s.getContext("2d");if(!o)return;o.drawImage(e,0,0,r,i);const a={sourceWidth:r,sourceHeight:i,imageData:o.getImageData(0,0,r,i),originalEl:e,originalImageData:o.getImageData(0,0,r,i),canvasEl:s,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===r&&l.height===i||(s.width=l.width,s.height=l.height),o.putImageData(l,0,0),a}}class Oa{constructor(){let{tileSize:t=X.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};p(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),p(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const r=jt({width:t,height:e}),i=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=r,this.gl=i)}applyFilters(t,e,r,i,s,o){const a=this.gl,l=s.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:r,sourceHeight:i,destinationWidth:r,destinationHeight:i,context:a,sourceTexture:this.createTexture(a,r,i,c?void 0:e),targetTexture:this.createTexture(a,r,i),originalTexture:c||this.createTexture(a,r,i,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const g=d.targetCanvas,f=g.width,m=g.height,b=d.destinationWidth,y=d.destinationHeight;f===b&&m===y||(g.width=b,g.height=y)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,r,i,s){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:f}=t,m=t.createTexture();return t.bindTexture(a,m),t.texParameteri(a,u,s||o),t.texParameteri(a,d,s||o),t.texParameteri(a,g,h),t.texParameteri(a,f,h),i?t.texImage2D(a,0,l,l,c,i):t.texImage2D(a,0,l,e,r,0,l,c,null),m}getCachedTexture(t,e,r){const{textureCache:i}=this;if(i[t])return i[t];{const s=this.createTexture(this.gl,e.width,e.height,e,r);return s&&(i[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const r=t.canvas,i=e.targetCanvas,s=i.getContext("2d");if(!s)return;s.translate(0,i.height),s.scale(1,-1);const o=r.height-i.height;s.drawImage(r,0,o,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),i=e.destinationWidth,s=e.destinationHeight,o=i*s*4;if(!r)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,i,s,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,i,s);r.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const i=t.getParameter(r.UNMASKED_RENDERER_WEBGL),s=t.getParameter(r.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}}let Wi;function ou(){const{WebGLProbe:n}=$t();return n.queryWebGL(ne()),X.enableGLFiltering&&n.isSupported(X.textureSize)?new Oa({tileSize:X.textureSize}):new nu}function Vi(){return!Wi&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Wi=ou()),Wi}const au=["filters","resizeFilter","src","crossOrigin","type"],Da=["cropX","cropY"];class Dt extends dt{static getDefaults(){return v(v({},super.getDefaults()),Dt.ownDefaults)}constructor(t,e){super(),p(this,"_lastScaleX",1),p(this,"_lastScaleY",1),p(this,"_filterScalingX",1),p(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Dt.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(fe()),this.setElement(typeof t=="string"?(this.canvas&&zt(this.canvas.getElement())||ze()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(r),(e=t.classList)===null||e===void 0||e.add(Dt.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Vi(!1);e instanceof Oa&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&$t().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(r=>{r&&e.push(r.toObject())}),v(v({},super.toObject([...Da,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,r=-this.width/2,i=-this.height/2;let s=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=fe();s.push('<clipPath id="imageCrop_'+c+`">
138
- `,' <rect x="'+r+'" y="'+i+'" width="'+this.width+'" height="'+this.height+`" />
80
+ `),r.join("")}toLive(t){const{x1:e,y1:r,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,r,s,n):t.createRadialGradient(e,r,o,s,n,a);return this.colorStops.forEach(c=>{let{color:h,offset:u}=c;l.addColorStop(u,h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this({...t,colorStops:e?e.map(s=>({...s})):void 0,gradientTransform:r?[...r]:void 0})}static fromElement(t,e,r){const s=Rl(t),n=e._findCenterFromElement();return new this({id:t.getAttribute("id")||void 0,type:Bl(t),coords:Wd(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:Vd(t,r.opacity),gradientUnits:s,gradientTransform:en(t.getAttribute("gradientTransform")||""),...s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}}v(ms,"type","Gradient"),I.setClass(ms,"gradient"),I.setClass(ms,"linear"),I.setClass(ms,"radial");class Mi{get type(){return"pattern"}set type(t){Me("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=Ee(),Object.assign(this,t)}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(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:r}=this;return{...vr(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:ot(this.offsetX,et.NUM_FRACTION_DIGITS),offsetY:ot(this.offsetY,et.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG(t){let{width:e,height:r}=t;const{source:s,repeat:n,id:o}=this,a=er(this.offsetX/e,0),l=er(this.offsetY/r,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):er(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):er(s.height/r,0);return[`<pattern id="SVGID_${Z(o)}" x="${a}" y="${l}" width="${c}" height="${h}">`,`<image x="0" y="0" width="${s.width}" height="${s.height}" xlink:href="${Z(this.sourceToString())}"></image>`,"</pattern>",""].join(`
81
+ `)}static async fromObject(t,e){let{type:r,source:s,patternTransform:n,...o}=t;const a=await Ls(s,{...e,crossOrigin:o.crossOrigin});return new this({...o,patternTransform:n&&n.slice(0),source:a})}}v(Mi,"type","Pattern"),I.setClass(Mi),I.setClass(Mi,"pattern");class Xd{constructor(t){v(this,"color","rgb(0, 0, 0)"),v(this,"width",1),v(this,"shadow",null),v(this,"strokeLineCap","round"),v(this,"strokeLineJoin","round"),v(this,"strokeMiterLimit",10),v(this,"strokeDashArray",null),v(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new rt(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,r=t.contextTop,s=t.getZoom()*t.getRetinaScaling();r.shadowColor=e.color,r.shadowBlur=e.blur*s,r.shadowOffsetX=e.offsetX*s,r.shadowOffsetY=e.offsetY*s}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}class Te extends dt{constructor(t){let{path:e,left:r,top:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Te.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof r=="number"&&this.set(Q,r),typeof s=="number"&&this.set(At,s)}_setPath(t,e){this.path=Cd(Array.isArray(t)?t:Ad(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,r=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+r);break;case"M":t.moveTo(s[1]+e,s[2]+r);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r,s[5]+e,s[6]+r);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{...super.toObject(t),path:this.path.map(e=>e.slice())}}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){return["<path ","COMMON_PARTS",`d="${Ll(this.path,et.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />
82
+ `]}_getOffsetTransform(){const t=et.NUM_FRACTION_DIGITS;return` translate(${ot(-this.pathOffset.x,t)}, ${ot(-this.pathOffset.y,t)})`}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:r,pathOffset:s}=this._calcDimensions();this.set({width:e,height:r,pathOffset:s}),t&&this.setPositionByOrigin(s,Y,Y)}_calcBoundsFromPath(){const t=[];let e=0,r=0,s=0,n=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],n=o[2],t.push({x:e,y:r},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,r=n;break;case"C":t.push(...Bo(s,n,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],n=o[6];break;case"Q":t.push(...Bo(s,n,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],n=o[4];break;case"Z":s=e,n=r}return me(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return{...t,pathOffset:new w(t.left+t.width/2,t.top+t.height/2)}}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const{d:s,...n}=we(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...n,...e,left:void 0,top:void 0})}}v(Te,"type","Path"),v(Te,"cacheProperties",[...xe,"path","fillRule"]),v(Te,"ATTRIBUTE_NAMES",[...Ae,"d"]),I.setClass(Te),I.setSVGClass(Te);class Zs extends Xd{constructor(t){super(t),v(this,"decimate",.4),v(this,"drawStraightLine",!1),v(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,r){const s=e.midPointFrom(r);return t.quadraticCurveTo(e.x,e.y,s.x,s.y),s}onMouseDown(t,e){let{e:r}=e;this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:r}=e;if(this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const s=this._points,n=s.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=Zs.drawSegment(o,s[n-2],s[n-1]),o.stroke(),o.restore()}}onMouseUp(t){let{e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,e=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&e.x===r.x&&e.y===r.y){const s=this.width/1e3;e.x-=s,r.x+=s}t.moveTo(e.x,e.y);for(let s=1;s<this._points.length;s++)Zs.drawSegment(t,e,r),e=this._points[s],r=this._points[s+1];t.lineTo(e.x,e.y),t.stroke(),t.restore()}convertPointsToSVGPath(t){const e=this.width/1e3;return Ld(t,e)}createPath(t){const e=new Te(t,{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,e.shadow=new ae(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let r,s=t[0];const n=this.canvas.getZoom(),o=Math.pow(e/n,2),a=t.length-1,l=[s];for(let c=1;c<a-1;c++)r=Math.pow(s.x-t[c].x,2)+Math.pow(s.y-t[c].y,2),r>=o&&(s=t[c],l.push(s));return l.push(t[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(r){return Ll(r)==="M 0 0 Q 0 0 0 0 L 0 0"}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const $l=["radius","startAngle","endAngle","counterClockwise"];class ge extends dt{static getDefaults(){return{...super.getDefaults(),...ge.ownDefaults}}constructor(t){super(),Object.assign(this,ge.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,mt(this.startAngle),mt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(jt)}getRadiusY(){return this.get("radius")*this.get(Xt)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...$l,...t])}_toSVG(){const{radius:t,startAngle:e,endAngle:r}=this,s=(r-e)%360;if(s===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${Z(t)}`,`" />
83
+ `];{const n=mt(e),o=mt(r),a=ve(n)*t,l=ye(n)*t,c=ve(o)*t,h=ye(o)*t;return[`<path d="M ${a} ${l} A ${t} ${t} 0 ${s>180?1:0} ${this.counterClockwise?0:1} ${c} ${h}" `,"COMMON_PARTS",` />
84
+ `]}}static async fromElement(t,e,r){const{left:s=0,top:n=0,radius:o=0,...a}=we(t,this.ATTRIBUTE_NAMES,r);return new this({...a,radius:o,left:s-o,top:n-o})}static fromObject(t){return super._fromObject(t)}}v(ge,"type","Circle"),v(ge,"cacheProperties",[...xe,...$l]),v(ge,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(ge,"ATTRIBUTE_NAMES",["cx","cy","r",...Ae]),I.setClass(ge),I.setSVGClass(ge);const an=["x1","x2","y1","y2"];class Jt extends dt{constructor(){let[t,e,r,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Jt.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(Q,o),typeof a=="number"&&this.set(At,a)}_setWidthHeight(){const{x1:t,y1:e,x2:r,y2:s}=this;this.width=Math.abs(r-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=me([{x:t,y:e},{x:r,y:s}]),c=new w(n+a/2,o+l/2);this.setPositionByOrigin(c,Y,Y)}_set(t,e){return super._set(t,e),an.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const r=t.strokeStyle;var s;Wt(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=r}_findCenterFromElement(){return new w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{...super.toObject(t),...this.calcLinePoints()}}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:r,y2:s,width:n,height:o}=this,a=t<=e?-.5:.5,l=r<=s?-.5:.5;return{x1:a*n,x2:a*-n,y1:l*o,y2:l*-o}}_toSVG(){const{x1:t,x2:e,y1:r,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",`x1="${t}" y1="${r}" x2="${e}" y2="${s}" />
85
+ `]}static async fromElement(t,e,r){const{x1:s=0,y1:n=0,x2:o=0,y2:a=0,...l}=we(t,this.ATTRIBUTE_NAMES,r);return new this([s,n,o,a],l)}static fromObject(t){let{x1:e,y1:r,x2:s,y2:n,...o}=t;return this._fromObject({...o,points:[e,r,s,n]},{extraParam:"points"})}}v(Jt,"type","Line"),v(Jt,"cacheProperties",[...xe,...an]),v(Jt,"ATTRIBUTE_NAMES",Ae.concat(an)),I.setClass(Jt),I.setSVGClass(Jt);class Re extends dt{static getDefaults(){return{...super.getDefaults(),...Re.ownDefaults}}constructor(t){super(),Object.assign(this,Re.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',`${-t} ${e},0 ${-e},${t} ${e}`,'" />']}}v(Re,"type","Triangle"),v(Re,"ownDefaults",{width:100,height:100}),I.setClass(Re),I.setSVGClass(Re);const zl=["rx","ry"];class Kt extends dt{static getDefaults(){return{...super.getDefaults(),...Kt.ownDefaults}}constructor(t){super(),Object.assign(this,Kt.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(jt)}getRy(){return this.get("ry")*this.get(Xt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...zl,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${Z(this.rx)}" ry="${Z(this.ry)}" />
86
+ `]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,or,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const s=we(t,this.ATTRIBUTE_NAMES,r);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}v(Kt,"type","Ellipse"),v(Kt,"cacheProperties",[...xe,...zl]),v(Kt,"ownDefaults",{rx:0,ry:0}),v(Kt,"ATTRIBUTE_NAMES",[...Ae,"cx","cy","rx","ry"]),I.setClass(Kt),I.setSVGClass(Kt);const Hl={exactBoundingBox:!1};class qt extends dt{static getDefaults(){return{...super.getDefaults(),...qt.ownDefaults}}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,qt.ownDefaults),this.setOptions(e),this.points=t;const{left:r,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof r=="number"&&this.set(Q,r),typeof s=="number"&&this.set(At,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return qu(this.points,t,this.isOpen())}_calcDimensions(t){t={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,...t||{}};const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new w,strokeOffset:new w,strokeDiff:new w};const r=me(e),s=ni({...t,scaleX:1,scaleY:1}),n=me(this.points.map(c=>Et(c,s,!0))),o=new w(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(mt(this.skewX)),l-=a*Math.tan(mt(this.skewY))),{...r,pathOffset:new w(a,l),strokeOffset:new w(n.left,n.top).subtract(new w(r.left,r.top)).multiply(o),strokeDiff:new w(r.width,r.height).subtract(new w(n.width,n.height)).multiply(o)}}_findCenterFromElement(){const t=me(this.points);return new w(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new w(e+s/2,r+n/2),Y,Y)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,r;const{width:a,height:l}=this._calcDimensions(t);o=new w((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r:l)}else{var s,n;o=new w((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new w(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const r=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&r&&((t===jt||t===Xt)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{...super.toObject(t),points:this.points.map(e=>{let{x:r,y:s}=e;return{x:r,y:s}})}}_toSVG(){const t=this.pathOffset.x,e=this.pathOffset.y,r=et.NUM_FRACTION_DIGITS,s=this.points.map(n=>{let{x:o,y:a}=n;return`${ot(o-t,r)},${ot(a-e,r)}`}).join(" ");return[`<${Z(this.constructor.type).toLowerCase()} `,"COMMON_PARTS",`points="${s}" />
87
+ `]}_render(t){const e=this.points.length,r=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-r,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){const s=function(l){if(!l)return[];const c=l.replace(/,/g," ").trim().split(/\s+/),h=[];for(let u=0;u<c.length;u+=2)h.push({x:parseFloat(c[u]),y:parseFloat(c[u+1])});return h}(t.getAttribute("points")),{left:n,top:o,...a}=we(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...a,...e})}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(qt,"ownDefaults",Hl),v(qt,"type","Polyline"),v(qt,"layoutProperties",[fr,pr,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(qt,"cacheProperties",[...xe,"points"]),v(qt,"ATTRIBUTE_NAMES",[...Ae]),I.setClass(qt),I.setSVGClass(qt);class Or extends qt{isOpen(){return!1}}v(Or,"ownDefaults",Hl),v(Or,"type","Polygon"),I.setClass(Or),I.setSVGClass(Or);class Vl extends dt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const r in e)for(const s in e[r])for(const n in e[r][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const r=e===void 0?this.styles:{0:this.styles[e]};for(const s in r)for(const n in r[s])if(r[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let r,s,n=0,o=!0,a=0;for(const l in e){r=0;for(const c in e[l]){const h=e[l][c]||{};n++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?r++:delete e[l][c]}r===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&n===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let r,s,n;for(s in e){for(n in r=e[s],r)delete r[n][t],Object.keys(r[n]).length===0&&delete r[n];Object.keys(r).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);const n=Pn({...this._getStyleDeclaration(r,s),...e},o=>o!==void 0);this._setStyleDeclaration(r,s,n)}getSelectionStyles(t,e,r){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,r));return s}getStyleAtPosition(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,s):this._getStyleDeclaration(r,s)}setSelectionStyles(t,e,r){for(let s=e;s<(r||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;const s=this.styles&&this.styles[t];return s&&(r=s[e])!==null&&r!==void 0?r:{}}getCompleteStyleDeclaration(t,e){return{...vr(this,this.constructor._styleProperties),...this._getStyleDeclaration(t,e)}}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(Vl,"_styleProperties",yu);const Yd=/ +/g,Ud=/"/g;function Ei(i,t,e,r,s){return` ${function(n,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:et.NUM_FRACTION_DIGITS;const d=rs(_t,n,!1),[g,f,m,y]=[a,l,c,h].map(b=>ot(b,u));return`<rect ${d} x="${g}" y="${f}" width="${m}" height="${y}"></rect>`}(i,{left:t,top:e,width:r,height:s})}
88
+ `}let Pi;class Tt extends Vl{static getDefaults(){return{...super.getDefaults(),...Tt.ownDefaults}}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Tt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Al(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}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(ie)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===ie||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,n=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){r=a.length,t=(this.width-e)/r;for(let h=0;h<=n.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(n[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const r=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<r.length;s++){if(t<=r[s].length)return{lineIndex:s,charIndex:t};t-=r[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:r[s-1].length<t?r[s-1].length:t}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===zt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case Y:t.textBaseline="middle";break;case"ascender":t.textBaseline=At;break;case"descender":t.textBaseline=qi}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,r,s,n,o){this._renderChars(t,e,r,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=this._getLeftOffset();let s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const a=this.getHeightOfLine(n);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",n)){s+=a;continue}const l=this._textLines[n].length,c=this._getLineLeftOffset(n);let h,u,d=0,g=0,f=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const m=this.getHeightOfLineImpl(n);for(let y=0;y<l;y++){const b=this.__charBounds[n][y];u=this.getValueOfPropertyAt(n,y,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=u,u&&t.fillRect(-b.width/2,-m*(1-this._fontSizeFraction),b.width,m),t.restore()):u!==f?(h=r+c+g,this.direction===de&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,s,d,m),g=b.left,d=b.width,f=u):d+=b.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction===de&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,m)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,s){const n=Wr.getFontCache(e),o=this._getFontDeclaration(e),a=r?r+t:t,l=r&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,g;if(r&&n.has(r)&&(d=n.get(r)),n.has(t)&&(g=h=n.get(t)),l&&n.has(a)&&(u=n.get(a),g=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return Pi||(Pi=Yt({width:0,height:0}).getContext("2d")),Pi}();this._setTextStyles(f,e,!0),h===void 0&&(g=h=f.measureText(t).width,n.set(t,h)),d===void 0&&l&&r&&(d=f.measureText(r).width,n.set(r,d)),l&&u===void 0&&(u=f.measureText(a).width,n.set(a,u),g=u-d)}return{width:h*c,kernedWidth:g*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,r,s=0;const n=this.pathSide===pt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const u=a[h];r=this._getGraphemeBox(u,t,h,e),c[h]=r,s+=r.kernedWidth,e=u}if(c[l]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Q:h=n?u-s:0;break;case Y:h=(u-s)/2;break;case pt:h=n?0:u-s}h+=this.pathStartOffset*(n?-1:1);for(let d=n?l-1:0;n?d>=0:d<l;n?d--:d++)r=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,r),h+=r.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,s=this.path,n=Dd(s.path,r,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===pt?Math.PI:0)}_getGraphemeBox(t,e,r,s,n){const o=this.getCompleteStyleDeclaration(e,r),a=s?this.getCompleteStyleDeclaration(e,r-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(r>0&&!n){const g=this.__charBounds[e][r-1];d.left=g.left+g.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)r=Math.max(this.getHeightOfChar(t,s),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction===Ie?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=0;const s=this._getLeftOffset(),n=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),n+r+this.getHeightOfLineImpl(o),o),r+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(_t))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,r,s,n,o){const a=this.textAlign.includes(ie),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction===Ie,u=this.direction===Ie?1:-1,d=e.direction;let g,f,m,y,b,x="",T=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?Ie:de),e.direction=h?Ie:de,e.textAlign=h?Q:pt),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,r.join(""),s,n),void e.restore();for(let C=0,S=r.length-1;C<=S;C++)y=C===S||this.charSpacing||l,x+=r[C],m=this.__charBounds[o][C],T===0?(s+=u*(m.kernedWidth-m.width),T+=m.width):T+=m.kernedWidth,a&&!y&&this._reSpaceAndTab.test(r[C])&&(y=!0),y||(g=g||this.getCompleteStyleDeclaration(o,C),f=this.getCompleteStyleDeclaration(o,C+1),y=$n(g,f,!1)),y&&(l?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,C,x,-T/2,0),e.restore()):(b=s,this._renderChar(t,e,o,C,x,b,n)),x="",g=f,s+=u*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,s=Yt({width:e,height:r}),n=s.getContext("2d");return s.width=e,s.height=r,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,r),n.lineTo(0,r),n.closePath(),n.translate(e/2,r/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,r){let s,n;return Wt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(r),{offsetX:s,offsetY:n}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,s,n,o,a){const l=this._getStyleDeclaration(r,s),c=this.getCompleteStyleDeclaration(r,s),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(n,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(n,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){const s=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:n*r.size,deltaY:o+n*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===ie||s===Ur&&!o||s===Yr&&!o||s===Gs&&!o?0:(s===Y&&(a=r/2),s===pt&&(a=r),s===Ur&&(a=r/2),s===Yr&&(a=r),n===de&&(s===pt||s===Yr?a=0:s===Q||s===Gs?a=-r:s!==Y&&s!==Ur||(a=-r/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,r){var s;return(s=this._getStyleDeclaration(t,e)[r])!==null&&s!==void 0?s:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=this._getTopOffset();const s=this._getLeftOffset(),n=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){r+=u;continue}const d=this._textLines[c],g=u/this.lineHeight,f=this._getLineLeftOffset(c);let m=0,y=0,b=this.getValueOfPropertyAt(c,0,e),x=this.getValueOfPropertyAt(c,0,_t),T=this.getValueOfPropertyAt(c,0,We),C=b,S=x,D=T;const A=r+g*(1-this._fontSizeFraction);let _=this.getHeightOfChar(c,0),M=this.getValueOfPropertyAt(c,0,"deltaY");for(let z=0,X=d.length;z<X;z++){const W=this.__charBounds[c][z];C=this.getValueOfPropertyAt(c,z,e),S=this.getValueOfPropertyAt(c,z,_t),D=this.getValueOfPropertyAt(c,z,We);const G=this.getHeightOfChar(c,z),q=this.getValueOfPropertyAt(c,z,"deltaY");if(n&&C&&S){const K=this.fontSize*D/1e3;t.save(),t.fillStyle=x,t.translate(W.renderLeft,W.renderTop),t.rotate(W.angle),t.fillRect(-W.kernedWidth/2,l*G+q-a*K,W.kernedWidth,K),t.restore()}else if((C!==b||S!==x||G!==_||D!==T||q!==M)&&y>0){const K=this.fontSize*T/1e3;let L=s+f+m;this.direction===de&&(L=this.width-L-y),b&&x&&T&&(t.fillStyle=x,t.fillRect(L,A+l*_+M-a*K,y,K)),m=W.left,y=W.width,b=C,T=D,x=S,_=G,M=q}else y+=W.kernedWidth}let O=s+f+m;this.direction===de&&(O=this.width-O-y),t.fillStyle=S;const V=this.fontSize*D/1e3;C&&S&&D&&t.fillRect(O,A+l*_+M-a*V,y-o,V),r+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Tt.genericFonts.includes(t.toLowerCase())?t:`"${t}"`;return[e,r,`${n?this.CACHE_FONT_SIZE:s}px`,o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return An(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),s=[`
89
+ `];let n=[];for(let o=0;o<e.length;o++)r[o]=this.graphemeSplit(e[o]),n=n.concat(r[o],s);return n.pop(),{_unwrappedLines:r,lines:e,graphemeText:n,graphemeLines:r}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{...super.toObject([...ml,...t]),styles:Ku(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(t,e){const{textLayoutProperties:r}=this.constructor;super.set(t,e);let s=!1,n=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||r.includes(o),n=n||o==="path";else s=r.includes(t),n=t==="path";return n&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,r){const s=we(t,Tt.ATTRIBUTE_NAMES,r),{textAnchor:n=Q,textDecoration:o="",dx:a=0,dy:l=0,top:c=0,left:h=0,fontSize:u=kn,strokeWidth:d=1,...g}={...e,...s},f=new this(Us(t.textContent||"").trim(),{left:h+a,top:c+l,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:u,...g}),m=f.getScaledHeight()/f.height,y=((f.height+f.strokeWidth)*f.lineHeight-f.height)*m,b=f.getScaledHeight()+y;let x=0;return n===Y&&(x=f.getScaledWidth()/2),n===pt&&(x=f.getScaledWidth()),f.set({left:f.left-x,top:f.top-(b-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:d}),f}static fromObject(t){return this._fromObject({...t,styles:Zu(t.styles||{},t.text)},{extraParam:"text"})}}v(Tt,"textLayoutProperties",pl),v(Tt,"cacheProperties",[...xe,...ml]),v(Tt,"ownDefaults",bu),v(Tt,"type","Text"),v(Tt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Tt,"ATTRIBUTE_NAMES",Ae.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Cl(Tt,[class extends dl{_toSVG(){const i=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(i.textTop,i.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(i){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:i,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:i,withShadow:!0,additionalTransform:es(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(i){let{textBgRects:t,textSpans:e}=i;const r=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',`font-family="${Z(this.fontFamily.replace(Ud,"'"))}" `,`font-size="${Z(this.fontSize)}" `,this.fontStyle?`font-style="${Z(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${Z(this.fontWeight)}" `:"",r?`text-decoration="${r}" `:"",this.direction==="rtl"?'direction="rtl" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
90
+ `]}_getSVGTextAndBg(i,t){const e=[],r=[];let s,n=i;this.backgroundColor&&r.push(Ei(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(r,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:r}}_createTextCharSpan(i,t,e,r,s){const n=et.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,i!==i.trim()||!!i.match(Yd)),a=o?`style="${o}"`:"",l=t.deltaY,c=l?` dy="${ot(l,n)}" `:"",{angle:h,renderLeft:u,renderTop:d,width:g}=s;let f="";if(u!==void 0){const m=g/2;h&&(f=` rotate="${ot(Pe(h),n)}"`);const y=mr({angle:Pe(h)});y[4]=u,y[5]=d;const b=new w(-m,0).transform(y);e=b.x,r=b.y}return`<tspan x="${ot(e,n)}" y="${ot(r,n)}" ${c}${f}${a}>${Z(i)}</tspan>`}_setSVGTextLineText(i,t,e,r){const s=this.getHeightOfLine(t),n=this.textAlign.includes(ie),o=this._textLines[t];let a,l,c,h,u,d="",g=0;r+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,m=o.length-1;f<=m;f++)u=f===m||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[t][f],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=$n(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),i.push(this._createTextCharSpan(d,h,e,r,c)),d="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(i,t,e,r){const s=this._textLines[t],n=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:u,width:d,kernedWidth:g}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&i.push(Ei(c,e+l,r,a,n)),l=u,a=d,c=o):a+=g}o&&i.push(Ei(c,e+l,r,a,n))}getSvgStyles(i){return`${super.getSvgStyles(i)} text-decoration-thickness: ${ot(this.textDecorationThickness*this.getObjectScaling().y/10,et.NUM_FRACTION_DIGITS)}%; white-space: pre;`}getSvgSpanStyles(i,t){const{fontFamily:e,strokeWidth:r,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,textDecorationThickness:c,linethrough:h,overline:u,underline:d}=i,g=this.getSvgTextDecoration({underline:d??this.underline,overline:u??this.overline,linethrough:h??this.linethrough}),f=c||this.textDecorationThickness;return[s?rs(zt,s):"",r?`stroke-width: ${Z(r)}; `:"",e?`font-family: ${e.includes("'")||e.includes('"')?Z(e):`'${Z(e)}'`}; `:"",o?`font-size: ${Z(o)}px; `:"",a?`font-style: ${Z(a)}; `:"",l?`font-weight: ${Z(l)}; `:"",g?`text-decoration: ${g}; text-decoration-thickness: ${ot(f*this.getObjectScaling().y/10,et.NUM_FRACTION_DIGITS)}%; `:"",n?rs(_t,n):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(i){return["overline","underline","line-through"].filter(t=>i[t.replace("-","")]).join(" ")}}]),I.setClass(Tt),I.setSVGClass(Tt);class Gd{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[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=()=>{e.forEach(r=>r()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var r;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new w(g.left,g.top)),m=a.viewportTransform,y=f.add(u).transform(m,!0),b=o.backgroundColor,x=Rn(o.styles);o.backgroundColor="";const T={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(T,0,s),o.setSelectionStyles(T,n,o.text.length),o.dirty=!0;const C=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=x,o.dirty=!0,nn(C,{position:"fixed",left:-C.width+"px",border:Lt,width:C.width/d+"px",height:C.height/d+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{C.remove()},Zt(t.target||this.target.hiddenTextarea).body.appendChild(C),(r=t.dataTransfer)===null||r===void 0||r.setDragImage(C,y.x,y.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o={text:e.text,value:n,...s};t.dataTransfer.setData("text/plain",n),t.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:r}=t,s=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let n=(e=r.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(n&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(r);const{styles:c}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>d&&l<=g?l=d:l>g&&(l-=g-d),o.removeChars(d,g),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(n,c,l),a.setActiveObject(o),o.enterEditing(r),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+n.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire($s,{index:l+u,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var r;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((r=e.dataTransfer)===null||r===void 0?void 0:r.dropEffect)||Lt;l===Lt?(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($s,{index:o,action:"dragend"}),n.fire("text:changed",{target:s}),n.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const zo=/[ \n\.,;!\?\-]/;class Nd extends Tt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:r,delay:s,onComplete:n}=t;return vl({startValue:this._currentCursorOpacity,endValue:e,duration:r,delay:s,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.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(t){let e=0,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let s=t>0&&this._reSpace.test(r[t])&&(e===-1||!Tn.test(r[t-1]))?t-1:t,n=r[s];for(;s>0&&s<r.length&&!zo.test(n);)s+=e,n=r[s];return e===-1&&zo.test(n)&&s++,s}selectWord(t){t=t??this.selectionStart;const e=this.searchWordBoundary(t,-1),r=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t??this.selectionStart;const e=this.findLineBoundaryLeft(t),r=this.findLineBoundaryRight(t);this.selectionStart=e,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),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(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;Zt(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&s!==n||s!==r&&n!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===n||(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(t,e,r){const s=r.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=r.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,r){const s=r.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+r.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){const{hiddenTextarea:t,direction:e,textAlign:r,inCompositionMode:s}=this;if(!t)return;const n=r!==ie?r.replace("justify-",""):e===Ie?Q:pt,o=this.getPositionByOrigin(n,"top");this.cursorOffsetCache={},this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setPositionByOrigin(o,n,"top"),this.setCoords();const a=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=a.selectionEnd,s||(this.selectionStart=a.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,g=u-o,f=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:`${f.x}px`,top:`${f.y}px`,fontSize:`${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)}exitEditingImpl(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(zs),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(r!==n){if(this.styles[r])for(let a=s;a<this._unwrappedTextLines[r].length;a++)delete this.styles[r][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][s+a-o]=l)}for(let a=r+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,r-n)}else if(this.styles[r]){const a=this.styles[r],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[r]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=r[n],r[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,r,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;r||(r=1),this.shiftLineStyles(t,r);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,n[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+r]=n,h=!0),(h||o>e)&&r--;r>0;)s&&s[r-1]?this.styles[t+r]={0:{...s[r-1]}}:c?this.styles[t+r]={0:{...c}}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,s){this.styles||(this.styles={});const n=this.styles[t],o=n?{...n}:{};r||(r=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+r]=o[c],o[c-r]||delete n[c])}if(this._forceClearCache=!0,s){for(;r--;)Object.keys(s[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]={...s[r]});return}if(!n)return;const a=n[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]={...a}}insertNewStyleBlock(t,e,r){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
91
+ `?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],r),r=r&&r.slice(n[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+n[0],a),o=1;o<a;o++)n[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,n[o],r):r&&this.styles[s.lineIndex+o]&&r[0]&&(this.styles[s.lineIndex+o][0]=r[0]),r=r&&r.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],r)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;s>r&&this.removeStyleFromTo(r,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,r,e),this._text=[...this._text.slice(0,r),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=Q:this._selectionDirection===pt&&(this._selectionDirection=Q,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===pt?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=pt:this._selectionDirection===Q&&(this._selectionDirection=pt,this.selectionStart=e),this.selectionEnd=r)}}class qd extends Nd{initHiddenTextarea(){const t=this.canvas&&Zt(this.canvas.getElement())||gr(),e=t.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 e.setAttribute(a,l)});const{top:r,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText=`position: absolute; top: ${r}; left: ${s}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${n};`,(this.hiddenTextareaContainer||t.body).appendChild(e),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 e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:r,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire($s),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(r).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,u=this.selectionEnd,d=h!==u;let g,f,m,y,b=c-l;const x=this.fromStringToGraphemeSelection(s,n,r),T=h>x.selectionStart;d?(f=this._text.slice(h,u),b+=u-h):c<l&&(f=T?this._text.slice(u+b,u):this._text.slice(h,h-b));const C=a.slice(x.selectionEnd-b,x.selectionEnd);if(f&&f.length&&(C.length&&(g=this.getSelectionStyles(h,h+1,!1),g=C.map(()=>g[0])),d?(m=h,y=u):T?(m=u-f.length,y=u):(m=u,y=u+f.length),this.removeStyleFromTo(m,y)),C.length){const{copyPasteData:S}=le();e&&C.join("")===S.copiedText&&!et.disableStyleCopyPaste&&(g=S.copiedTextStyle),this.insertNewStyleBlock(C,h,g)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:s}=e;this.compositionStart=r,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=le();t.copiedText=this.getSelectedText(),et.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let r,s=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],s+=r.left+r.width),s}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-r;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(o).length+l+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-r;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n-1,a),c=this._textLines[n].slice(0,o),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const r=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=r.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return n||(a=r.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const r=this[`get${t}CursorOffset`](e,this._selectionDirection===pt);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const s=this.text.length;this.selectionStart=lr(0,this.selectionStart,s),this.selectionEnd=lr(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Q?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,r){let s;if(t.altKey)s=this[`findWordBoundary${r}`](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;s=this[`findLineBoundary${r}`](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Q,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===pt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Q,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const r=`moveCursor${t}${e.shiftKey?"WithShift":"WithoutShift"}`;this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Q&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=pt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=pt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ho=i=>!!i.button;class Kd extends qd{constructor(){super(...arguments),v(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 Gd(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:r}=t;this.canvas&&this.editable&&!Ho(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const n=this.canvas._activeObject;if(n&&n!==this)return}!this.editable||this.group&&!this.group.interactive||r&&r.actionPerformed||Ho(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),r=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Qt(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let r=0,s=0,n=0;for(let c=0;c<this._textLines.length&&r<=e.y;c++)r+=this.getHeightOfLine(c),n=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(n));const a=this._textLines[n].length,l=this.__charBounds[n];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const vs="moveCursorUp",ys="moveCursorDown",bs="moveCursorLeft",xs="moveCursorRight",ws="exitEditing",Vo=(i,t)=>{const e=t.getRetinaScaling();i.setTransform(e,0,0,e,0,0);const r=t.viewportTransform;i.transform(r[0],r[1],r[2],r[3],r[4],r[5])},Zd={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:ws,27:ws,33:vs,34:ys,35:xs,36:bs,37:bs,38:vs,39:xs,40:ys},keysMapRtl:{9:ws,27:ws,33:vs,34:ys,35:bs,36:xs,37:xs,38:vs,39:bs,40:ys},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};class ne extends Kd{static getDefaults(){return{...super.getDefaults(),...ne.ownDefaults}}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,{...ne.ownDefaults,...e}),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof on&&this.canvas.textEditingManager.remove(this),e instanceof on&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),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 t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),s=r.length>0;let n,o=t;if(s){n=Yt(t.canvas),o=n.getContext("2d"),Vo(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,e):this.renderCursor(o,e),s)for(const a of r){const l=a.clipPath,c=Yt(t.canvas),h=c.getContext("2d");if(Vo(h,this.canvas),!l.absolutePositioned){const u=a.calcTransformMatrix();h.transform(u[0],u[1],u[2],u[3],u[4],u[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const r=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:r,top:s,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,r=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t),{textAlign:o,direction:a}=this;for(let u=0;u<n;u++)e+=this.getHeightOfLine(u);const l=this._getLineLeftOffset(n),c=this.__charBounds[n][s];c&&(r=c.left),this.charSpacing!==0&&s===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());let h=l+(r>0?r:0);return a===de&&(o===pt||o===ie||o===Yr?h*=-1:o===Q||o===Gs?h=l-(r>0?r:0):o!==Y&&o!==Ur||(h=l-(r>0?r:0))),{top:e,left:h}}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex>0?r.charIndex-1:0,o=this.getValueOfPropertyAt(s,n,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,r){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(r,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,r){const{textAlign:s,direction:n}=this,o=e.selectionStart,a=e.selectionEnd,l=s.includes(ie),c=this.get2DCursorLocation(o),h=this.get2DCursorLocation(a),u=c.lineIndex,d=h.lineIndex,g=c.charIndex<0?0:c.charIndex,f=h.charIndex<0?0:h.charIndex;for(let m=u;m<=d;m++){const y=this._getLineLeftOffset(m)||0;let b=this.getHeightOfLine(m),x=0,T=0,C=0;if(m===u&&(T=this.__charBounds[u][g].left),m>=u&&m<d)C=l&&!this.isEndOfWrapping(m)?this.width:this.getLineWidth(m)||5;else if(m===d)if(f===0)C=this.__charBounds[d][f].left;else{const M=this._getWidthOfCharSpacing();C=this.__charBounds[d][f-1].left+this.__charBounds[d][f-1].width-M}x=b,(this.lineHeight<1||m===d&&this.lineHeight>1)&&(b/=this.lineHeight);let S=r.left+y+T,D=b,A=0;const _=C-T;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",D=1,A=b):t.fillStyle=this.selectionColor,n===de&&(s===pt||s===ie||s===Yr?S=this.width-S-_:s===Q||s===Gs?S=r.left+y-C:s!==Y&&s!==Ur||(S=r.left+y-C)),t.fillRect(S,r.top+r.topOffset+A,_,D),r.topOffset+=x}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,_t)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(ne,"ownDefaults",Zd),v(ne,"type","IText"),I.setClass(ne),I.setClass(ne,"i-text");class $e extends ne{static getDefaults(){return{...super.getDefaults(),...$e.ownDefaults}}constructor(t,e){super(t,{...$e.ownDefaults,...e})}static createControls(){return{controls:Uu()}}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(ie)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
92
+ `&&o>0?(r=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(r++,s++),n[o]={line:e,offset:r},s+=t.graphemeLines[o].length,r+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[e];r&&(e=r.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,r=o.offset),a&&(s=a.line,n=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const u=parseInt(h,10);if(u>=r&&(!n||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const r=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<r.wordsData.length;n++)s.push(...this._wrapLine(n,e,r));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=e?"":" ";let s=0;return{wordsData:t.map((n,o)=>{let a=0;const l=e?this.graphemeSplit(n):this.wordSplit(n);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return s=Math.max(u,s),a+=h.length+r.length,{word:h,width:u}})}),largestWordWidth:s}}_measureWord(t,e){let r,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=0;for(let o=0,a=t.length;o<a;o++)n+=this._getGraphemeBox(t[o],e,o+s,r,!0).kernedWidth,r=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:s,wordsData:n}=r,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],g=0,f=0,m=!0;e-=o;const y=Math.max(e,s,this.dynamicMinWidth),b=n[t];let x;for(g=0,x=0;x<b.length;x++){const{word:T,width:C}=b[x];g+=T.length,u+=f+C-a,u>y&&!m?(c.push(d),d=[],u=C,m=!0):u+=a,m||l||d.push(h),d=d.concat(T),f=l?0:this._measureWord([h],t,g),g++,m=!1}return x&&c.push(d),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),r=this._wrapText(e.lines,this.width),s=new Array(r.length);for(let n=0;n<r.length;n++)s[n]=r[n].join("");return e.lines=s,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){const s=this._styleMap[e].line;t.set(`${s}`,!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v($e,"type","Textbox"),v($e,"textLayoutProperties",[...ne.textLayoutProperties,"width"]),v($e,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),I.setClass($e);class Wo extends hi{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:s,group:n}=r;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=me(Tl(r,s)),l=new w(o,a);if(s.absolutePositioned)return{center:ar(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}v(Wo,"type","clip-path"),I.setClass(Wo);class Xo extends hi{getInitialSize(t,e){let{target:r}=t,{size:s}=e;return new w(r.width||s.x,r.height||s.y)}}v(Xo,"type","fixed"),I.setClass(Xo);class Jd extends is{subscribeTargets(t){const e=t.target;t.targets.reduce((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{r.layoutManager.subscribeTargets({target:r,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((s,n)=>(n.parent&&s.add(n.parent),s),new Set).forEach(s=>{!r.some(n=>n.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class ze extends Oe{static getDefaults(){return{...super.getDefaults(),...ze.ownDefaults}}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,ze.ownDefaults),this.setOptions(e);const{left:r,top:s,layoutManager:n}=e;this.groupInit(t,{left:r,top:s,layoutManager:n??new Jd})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(s=>{const n=this._objects.findIndex(a=>a.isInFrontOf(s)),o=n===-1?this.size():n;this.insertAt(o,s)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(Me("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const r=new Set;e.forEach(s=>{const{parent:n}=s;n&&r.add(n)}),t===Hn?r.forEach(s=>{s._onAfterObjectsChange(Ns,e)}):r.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s={hasControls:!1,...r,forActiveSelection:!0};for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(ze,"type","ActiveSelection"),v(ze,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),I.setClass(ze),I.setClass(ze,"activeSelection");class Qd{constructor(){v(this,"resources",{})}applyFilters(t,e,r,s,n){const o=n.getContext("2d",{willReadFrequently:!0,desynchronized:!0});if(!o)return;o.drawImage(e,0,0,r,s);const a={sourceWidth:r,sourceHeight:s,imageData:o.getImageData(0,0,r,s),originalEl:e,originalImageData:o.getImageData(0,0,r,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===r&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class Wl{constructor(){let{tileSize:t=et.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const r=Yt({width:t,height:e}),s=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=r,this.gl=s)}applyFilters(t,e,r,s,n,o){const a=this.gl,l=n.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:r,sourceHeight:s,destinationWidth:r,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,r,s,c?void 0:e),targetTexture:this.createTexture(a,r,s),originalTexture:c||this.createTexture(a,r,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const g=d.targetCanvas,f=g.width,m=g.height,y=d.destinationWidth,b=d.destinationHeight;f===y&&m===b||(g.width=y,g.height=b)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,r,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:f}=t,m=t.createTexture();return t.bindTexture(a,m),t.texParameteri(a,u,n||o),t.texParameteri(a,d,n||o),t.texParameteri(a,g,h),t.texParameteri(a,f,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,r,0,l,c,null),m}getCachedTexture(t,e,r){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,r);return n&&(s[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const r=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=r.height-s.height;n.drawImage(r,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!r)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,n,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,n);r.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const s=t.getParameter(r.UNMASKED_RENDERER_WEBGL),n=t.getParameter(r.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let Ai;function tg(){const{WebGLProbe:i}=le();return i.queryWebGL(be()),et.enableGLFiltering&&i.isSupported(et.textureSize)?new Wl({tileSize:et.textureSize}):new Qd}function Li(){return!Ai&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Ai=tg()),Ai}const Xl=["cropX","cropY"];class kt extends dt{static getDefaults(){return{...super.getDefaults(),...kt.ownDefaults}}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,kt.ownDefaults),this.setOptions(e),this.cacheKey=`texture${Ee()}`,this.setElement(typeof t=="string"?(this.canvas&&Zt(this.canvas.getElement())||gr()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=t,this._originalElement=t,this._setWidthHeight(e),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Li(!1);e instanceof Wl&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&le().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(r=>{r&&e.push(r.toObject())}),{...super.toObject([...Xl,...t]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,r=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Ee();n.push('<clipPath id="imageCrop_'+c+`">
93
+ `,' <rect x="'+r+'" y="'+s+'" width="'+Z(this.width)+'" height="'+Z(this.height)+`" />
139
94
  `,`</clipPath>
140
- `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(r-this.cropX,'" y="').concat(i-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
141
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(r,'" y="').concat(i,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
142
- `)],this.fill=c}return s=this.paintFirst!==at?s.concat(o,t):s.concat(t,o),s}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return $r(t,{crossOrigin:e,signal:r}).then(i=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(i)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),i=r.x,s=r.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||i>e&&s>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,void(this._lastScaleY=s);const a=jt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=s,Vi().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(s=>s&&!s.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,r=e.naturalWidth||e.width,i=e.naturalHeight||e.height;if(this._element===this._originalElement){const s=jt({width:r,height:i});this._element=s,this._filteredEl=s}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,i),this._lastScaleX=1,this._lastScaleY=1);Vi().applyFilters(t,this._originalElement,r,i,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(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const r=this._filterScalingX,i=this._filterScalingY,s=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,u=a*r,d=l*i,g=Math.min(s*r,c-u),f=Math.min(o*i,h-d),m=-s/2,b=-o/2,y=Math.min(s,c/r-a),w=Math.min(o,h/i-l);e&&t.drawImage(e,u,d,g,f,m,b,y,w)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=Jl(this.preserveAspectRatio||""),e=this.width,r=this.height,i={width:e,height:r};let s,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,g=0;return!t||t.alignX===_t&&t.alignY===_t?(l=e/o,c=r/a):(t.meetOrSlice==="meet"&&(l=c=fh(this._element,i),s=(e-o*l)/2,t.alignX==="Min"&&(h=-s),t.alignX==="Max"&&(h=s),s=(r-a*c)/2,t.alignY==="Min"&&(u=-s),t.alignY==="Max"&&(u=s)),t.meetOrSlice==="slice"&&(l=c=ph(this._element,i),s=o-e/l,t.alignX==="Mid"&&(d=s/2),t.alignX==="Max"&&(d=s),s=a-r/c,t.alignY==="Mid"&&(g=s/2),t.alignY==="Max"&&(g=s),o=e/l,a=r/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:g}}static fromObject(t,e){let{filters:r,resizeFilter:i,src:s,crossOrigin:o,type:a}=t,l=J(t,au);return Promise.all([$r(s,v(v({},e),{},{crossOrigin:o})),r&&nr(r,e),i&&nr([i],e),yi(l,e)]).then(c=>{let[h,u=[],[d]=[],g={}]=c;return new this(h,v(v({},l),{},{src:s,filters:u,resizeFilter:d},g))})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return $r(t,{crossOrigin:e,signal:r}).then(s=>new this(s,i))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;const i=le(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(i["xlink:href"]||i.href,e,i).catch(s=>(ge("log","Unable to parse Image",s),null))}}p(Dt,"type","Image"),p(Dt,"cacheProperties",[...ae,...Da]),p(Dt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),p(Dt,"CSS_CANVAS","canvas-img"),p(Dt,"ATTRIBUTE_NAMES",[...pe,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),E.setClass(Dt),E.setSVGClass(Dt);xi(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Ti=n=>n.webgl!==void 0,zs="precision highp float",lu=`
143
- `.concat(zs,`;
95
+ `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",`xlink:href="${Z(this.getSrc(!0))}" x="${r-this.cropX}" y="${s-this.cropY}" width="${e.width||e.naturalWidth}" height="${e.height||e.naturalHeight}"${l}${a}></image>
96
+ `),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[` <rect x="${r}" y="${s}" width="${Z(this.width)}" height="${Z(this.height)}" style="${this.getSvgStyles()}" />
97
+ `],this.fill=c}return n=this.paintFirst!==_t?n.concat(o,t):n.concat(t,o),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ls(t,{crossOrigin:e,signal:r}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),s=r.x,n=r.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&n>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=n);const a=Yt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Li().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(n=>n&&!n.isNeutralState()),this.set("dirty",!0),this.removeTexture(`${this.cacheKey}_filtered`),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,r=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=Yt({width:r,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,s),this._lastScaleX=1,this._lastScaleY=1);Li().applyFilters(t,this._originalElement,r,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(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const r=this._filterScalingX,s=this._filterScalingY,n=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,u=a*r,d=l*s,g=Math.min(n*r,c-u),f=Math.min(o*s,h-d),m=-n/2,y=-o/2,b=Math.min(n,c/r-a),x=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,g,f,m,y,b,x)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=vu(this.preserveAspectRatio||""),e=this.width,r=this.height,s={width:e,height:r};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,g=0;return!t||t.alignX===Lt&&t.alignY===Lt?(l=e/o,c=r/a):(t.meetOrSlice==="meet"&&(l=c=vd(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(r-a*c)/2,t.alignY==="Min"&&(u=-n),t.alignY==="Max"&&(u=n)),t.meetOrSlice==="slice"&&(l=c=yd(this._element,s),n=o-e/l,t.alignX==="Mid"&&(d=n/2),t.alignX==="Max"&&(d=n),n=a-r/c,t.alignY==="Mid"&&(g=n/2),t.alignY==="Max"&&(g=n),o=e/l,a=r/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:g}}static fromObject(t,e){let{filters:r,resizeFilter:s,src:n,crossOrigin:o,type:a,...l}=t;return Promise.all([Ls(n,{...e,crossOrigin:o}),r&&ts(r,e),s?ts([s],e):[],oi(l,e)]).then(c=>{let[h,u=[],[d],g={}]=c;return new this(h,{...l,src:n,filters:u,resizeFilter:d,...g})})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ls(t,{crossOrigin:e,signal:r}).then(n=>new this(n,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;const s=we(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(s["xlink:href"]||s.href,e,s).catch(n=>(Me("log","Unable to parse Image",n),null))}}v(kt,"type","Image"),v(kt,"cacheProperties",[...xe,...Xl]),v(kt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(kt,"ATTRIBUTE_NAMES",[...Ae,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),I.setClass(kt),I.setSVGClass(kt);li(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const di=i=>i.webgl!==void 0,Vn="precision highp float",eg=`
98
+ ${Vn};
144
99
  varying vec2 vTexCoord;
145
100
  uniform sampler2D uTexture;
146
101
  void main() {
147
102
  gl_FragColor = texture2D(uTexture, vTexCoord);
148
- }`),cu=["type"],hu=["type"],uu=new RegExp(zs,"g");class lt{get type(){return this.constructor.type}constructor(){let t=J(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},cu);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return lu}getVertexSource(){return`
103
+ }`,rg=new RegExp(Vn,"g");class yt{get type(){return this.constructor.type}constructor(){let{type:t,...e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return eg}getVertexSource(){return`
149
104
  attribute vec2 aPosition;
150
105
  varying vec2 vTexCoord;
151
106
  void main() {
152
107
  vTexCoord = aPosition;
153
108
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
154
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:i="highp"}}=$t();i!=="highp"&&(e=e.replace(uu,zs.replace("highp",i)));const s=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!s||!o||!a)throw new Ut("Vertex, fragment shader or program creation error");if(t.shaderSource(s,r),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new Ut("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(s)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Ut("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,s),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new Ut('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const r=this.constructor.uniformLocations,i={};for(let s=0;s<r.length;s++)i[r[s]]=t.getUniformLocation(e,r[s]);return i}sendAttributeData(t,e,r){const i=e.aPosition,s=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,s),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const r=t.destinationWidth,i=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===i||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,i)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){Ti(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,r=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:r}=t,i=jt({width:e,height:r});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return v({type:this.type},t.reduce((e,r)=>(e[r]=this[r],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(J(t,hu))}}p(lt,"type","BaseFilter"),p(lt,"uniformLocations",[]);const du={multiply:`gl_FragColor.rgb *= uColor.rgb;
109
+ }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=le();s!=="highp"&&(e=e.replace(rg,Vn.replace("highp",s)));const n=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!n||!o||!a)throw new se("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new se(`Vertex shader compile error for ${this.type}: ${t.getShaderInfoLog(n)}`);if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new se(`Fragment shader compile error for ${this.type}: ${t.getShaderInfoLog(o)}`);if(t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new se(`Shader link error for "${this.type}" ${t.getProgramInfoLog(a)}`);const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const r=this.constructor.uniformLocations,s={};for(let n=0;n<r.length;n++)s[r[n]]=t.getUniformLocation(e,r[n]);return s}sendAttributeData(t,e,r){const s=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const r=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){di(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,r=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:r}=t,s=Yt({width:e,height:r});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return{type:this.type,...t.reduce((e,r)=>(e[r]=this[r],e),{})}}toJSON(){return this.toObject()}static async fromObject(t,e){let{type:r,...s}=t;return new this(s)}}v(yt,"type","BaseFilter"),v(yt,"uniformLocations",[]);const sg={multiply:`gl_FragColor.rgb *= uColor.rgb;
155
110
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
156
111
  `,add:`gl_FragColor.rgb += uColor.rgb;
157
112
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -178,7 +133,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
178
133
  `,tint:`
179
134
  gl_FragColor.rgb *= (1.0 - uColor.a);
180
135
  gl_FragColor.rgb += uColor.rgb;
181
- `};class kr extends lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
136
+ `};class Dr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
182
137
  precision highp float;
183
138
  uniform sampler2D uTexture;
184
139
  uniform vec4 uColor;
@@ -187,10 +142,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
187
142
  vec4 color = texture2D(uTexture, vTexCoord);
188
143
  gl_FragColor = color;
189
144
  if (color.a > 0.0) {
190
- `.concat(du[this.mode],`
145
+ ${sg[this.mode]}
191
146
  }
192
147
  }
193
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const r=new G(this.color).getSource(),i=this.alpha,s=r[0]*i,o=r[1]*i,a=r[2]*i,l=1-i;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let g,f,m;switch(this.mode){case"multiply":g=h*s/255,f=u*o/255,m=d*a/255;break;case"screen":g=255-(255-h)*(255-s)/255,f=255-(255-u)*(255-o)/255,m=255-(255-d)*(255-a)/255;break;case"add":g=h+s,f=u+o,m=d+a;break;case"difference":g=Math.abs(h-s),f=Math.abs(u-o),m=Math.abs(d-a);break;case"subtract":g=h-s,f=u-o,m=d-a;break;case"darken":g=Math.min(h,s),f=Math.min(u,o),m=Math.min(d,a);break;case"lighten":g=Math.max(h,s),f=Math.max(u,o),m=Math.max(d,a);break;case"overlay":g=s<128?2*h*s/255:255-2*(255-h)*(255-s)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,m=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":g=s+h-2*s*h/255,f=o+u-2*o*u/255,m=a+d-2*a*d/255;break;case"tint":g=s+h*l,f=o+u*l,m=a+d*l}e[c]=g,e[c+1]=f,e[c+2]=m}}sendUniformData(t,e){const r=new G(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}p(kr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),p(kr,"type","BlendColor"),p(kr,"uniformLocations",["uColor"]),E.setClass(kr);const gu={multiply:`
148
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=new rt(this.color).getSource(),s=this.alpha,n=r[0]*s,o=r[1]*s,a=r[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let g,f,m;switch(this.mode){case"multiply":g=h*n/255,f=u*o/255,m=d*a/255;break;case"screen":g=255-(255-h)*(255-n)/255,f=255-(255-u)*(255-o)/255,m=255-(255-d)*(255-a)/255;break;case"add":g=h+n,f=u+o,m=d+a;break;case"difference":g=Math.abs(h-n),f=Math.abs(u-o),m=Math.abs(d-a);break;case"subtract":g=h-n,f=u-o,m=d-a;break;case"darken":g=Math.min(h,n),f=Math.min(u,o),m=Math.min(d,a);break;case"lighten":g=Math.max(h,n),f=Math.max(u,o),m=Math.max(d,a);break;case"overlay":g=n<128?2*h*n/255:255-2*(255-h)*(255-n)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,m=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":g=n+h-2*n*h/255,f=o+u-2*o*u/255,m=a+d-2*a*d/255;break;case"tint":g=n+h*l,f=o+u*l,m=a+d*l}e[c]=g,e[c+1]=f,e[c+2]=m}}sendUniformData(t,e){const r=new rt(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}v(Dr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(Dr,"type","BlendColor"),v(Dr,"uniformLocations",["uColor"]),I.setClass(Dr);const ig={multiply:`
194
149
  precision highp float;
195
150
  uniform sampler2D uTexture;
196
151
  uniform sampler2D uImage;
@@ -216,7 +171,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
216
171
  color.a = color2.a;
217
172
  gl_FragColor = color;
218
173
  }
219
- `},fu=["type","image"];class Or extends lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return gu[this.mode]}getVertexSource(){return`
174
+ `};class Mr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return ig[this.mode]}getVertexSource(){return`
220
175
  attribute vec2 aPosition;
221
176
  varying vec2 vTexCoord;
222
177
  varying vec2 vTexCoord2;
@@ -226,7 +181,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
226
181
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
227
182
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
228
183
  }
229
- `}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:i},filterBackend:{resources:s}}=t;const o=this.image;s.blendImage||(s.blendImage=ne());const a=s.blendImage,l=a.getContext("2d");a.width!==r||a.height!==i?(a.width=r,a.height=i):l.clearRect(0,0,r,i),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,r,i);const c=l.getImageData(0,0,r,i).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],g=e[h+2],f=e[h+3],m=c[h],b=c[h+1],y=c[h+2],w=c[h+3];switch(this.mode){case"multiply":e[h]=u*m/255,e[h+1]=d*b/255,e[h+2]=g*y/255,e[h+3]=f*w/255;break;case"mask":e[h+3]=w}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return v(v({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:r,image:i}=t,s=J(t,fu);return Dt.fromObject(i,e).then(o=>new this(v(v({},s),{},{image:o})))}}p(Or,"type","BlendImage"),p(Or,"defaults",{mode:"multiply",alpha:1}),p(Or,"uniformLocations",["uTransformMatrix","uImage"]),E.setClass(Or);class Dr extends lt{getFragmentSource(){return`
184
+ `}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:s},filterBackend:{resources:n}}=t;const o=this.image;n.blendImage||(n.blendImage=be());const a=n.blendImage,l=a.getContext("2d");a.width!==r||a.height!==s?(a.width=r,a.height=s):l.clearRect(0,0,r,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,r,s);const c=l.getImageData(0,0,r,s).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],g=e[h+2],f=e[h+3],m=c[h],y=c[h+1],b=c[h+2],x=c[h+3];switch(this.mode){case"multiply":e[h]=u*m/255,e[h+1]=d*y/255,e[h+2]=g*b/255,e[h+3]=f*x/255;break;case"mask":e[h+3]=x}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject(t,e){let{type:r,image:s,...n}=t;return kt.fromObject(s,e).then(o=>new this({...n,image:o}))}}v(Mr,"type","BlendImage"),v(Mr,"defaults",{mode:"multiply",alpha:1}),v(Mr,"uniformLocations",["uTransformMatrix","uImage"]),I.setClass(Mr);class Er extends yt{getFragmentSource(){return`
230
185
  precision highp float;
231
186
  uniform sampler2D uTexture;
232
187
  uniform vec2 uDelta;
@@ -255,7 +210,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
255
210
  gl_FragColor.rgb = color.rgb / totalC;
256
211
  gl_FragColor.a = color.a / totalA;
257
212
  }
258
- `}applyTo(t){Ti(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;this.aspectRatio=r/i,this.horizontal=!0;let s=this.getBlurValue()*r;const o=new Uint8ClampedArray(e),a=15,l=4*r;for(let c=0;c<e.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c-c%l,b=m+l;for(let y=-14;y<a;y++){const w=y/a,O=4*Math.floor(s*w),k=1-Math.abs(w);let S=c+O;S<m?S=m:S>b&&(S=b);const C=e[S+3]*k;h+=e[S]*C,u+=e[S+1]*C,d+=e[S+2]*C,g+=C,f+=k}o[c]=h/g,o[c+1]=u/g,o[c+2]=d/g,o[c+3]=g/f}this.horizontal=!1,s=this.getBlurValue()*i;for(let c=0;c<o.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c%l,b=o.length-l+m;for(let y=-14;y<a;y++){const w=y/a,O=Math.floor(s*w)*l,k=1-Math.abs(w);let S=c+O;S<m?S=m:S>b&&(S=b);const C=o[S+3]*k;h+=o[S]*C,u+=o[S+1]*C,d+=o[S+2]*C,g+=C,f+=k}e[c]=h/g,e[c+1]=u/g,e[c+2]=d/g,e[c+3]=g/f}}sendUniformData(t,e){const r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}p(Dr,"type","Blur"),p(Dr,"defaults",{blur:0}),p(Dr,"uniformLocations",["uDelta"]),E.setClass(Dr);class Mr extends lt{getFragmentSource(){return`
213
+ `}applyTo(t){di(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:r,height:s}}=t;this.aspectRatio=r/s,this.horizontal=!0;let n=this.getBlurValue()*r;const o=new Uint8ClampedArray(e),a=15,l=4*r;for(let c=0;c<e.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c-c%l,y=m+l;for(let b=-14;b<a;b++){const x=b/a,T=4*Math.floor(n*x),C=1-Math.abs(x);let S=c+T;S<m?S=m:S>y&&(S=y);const D=e[S+3]*C;h+=e[S]*D,u+=e[S+1]*D,d+=e[S+2]*D,g+=D,f+=C}o[c]=h/g,o[c+1]=u/g,o[c+2]=d/g,o[c+3]=g/f}this.horizontal=!1,n=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c%l,y=o.length-l+m;for(let b=-14;b<a;b++){const x=b/a,T=Math.floor(n*x)*l,C=1-Math.abs(x);let S=c+T;S<m?S=m:S>y&&(S=y);const D=o[S+3]*C;h+=o[S]*D,u+=o[S+1]*D,d+=o[S+2]*D,g+=D,f+=C}e[c]=h/g,e[c+1]=u/g,e[c+2]=d/g,e[c+3]=g/f}}sendUniformData(t,e){const r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(Er,"type","Blur"),v(Er,"defaults",{blur:0}),v(Er,"uniformLocations",["uDelta"]),I.setClass(Er);class Pr extends yt{getFragmentSource(){return`
259
214
  precision highp float;
260
215
  uniform sampler2D uTexture;
261
216
  uniform float uBrightness;
@@ -265,7 +220,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
265
220
  color.rgb += uBrightness;
266
221
  gl_FragColor = color;
267
222
  }
268
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let i=0;i<e.length;i+=4)e[i]+=r,e[i+1]+=r,e[i+2]+=r}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}p(Mr,"type","Brightness"),p(Mr,"defaults",{brightness:0}),p(Mr,"uniformLocations",["uBrightness"]),E.setClass(Mr);const Ma={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ae extends lt{getFragmentSource(){return`
223
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=r,e[s+1]+=r,e[s+2]+=r}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(Pr,"type","Brightness"),v(Pr,"defaults",{brightness:0}),v(Pr,"uniformLocations",["uBrightness"]),I.setClass(Pr);const Yl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class He extends yt{getFragmentSource(){return`
269
224
  precision highp float;
270
225
  uniform sampler2D uTexture;
271
226
  varying vec2 vTexCoord;
@@ -276,7 +231,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
276
231
  color *= uColorMatrix;
277
232
  color += uConstants;
278
233
  gl_FragColor = color;
279
- }`}applyTo2d(t){const e=t.imageData.data,r=this.matrix,i=this.colorsOnly;for(let s=0;s<e.length;s+=4){const o=e[s],a=e[s+1],l=e[s+2];if(e[s]=o*r[0]+a*r[1]+l*r[2]+255*r[4],e[s+1]=o*r[5]+a*r[6]+l*r[7]+255*r[9],e[s+2]=o*r[10]+a*r[11]+l*r[12]+255*r[14],!i){const c=e[s+3];e[s]+=c*r[3],e[s+1]+=c*r[8],e[s+2]+=c*r[13],e[s+3]=o*r[15]+a*r[16]+l*r[17]+c*r[18]+255*r[19]}}}sendUniformData(t,e){const r=this.matrix,i=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],s=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,i),t.uniform4fv(e.uConstants,s)}toObject(){return v(v({},super.toObject()),{},{matrix:[...this.matrix]})}}function Se(n,t){var e;const r=(p(e=class extends Ae{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),p(e,"defaults",{colorsOnly:!1,matrix:t}),e);return E.setClass(r,n),r}p(Ae,"type","ColorMatrix"),p(Ae,"defaults",Ma),p(Ae,"uniformLocations",["uColorMatrix","uConstants"]),E.setClass(Ae);Se("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Se("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Se("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Se("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Se("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Se("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Se("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 Yn extends lt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Ti(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(r=>E.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}p(Yn,"type","Composed"),E.setClass(Yn);class Er extends lt{getFragmentSource(){return`
234
+ }`}applyTo2d(t){const e=t.imageData.data,r=this.matrix,s=this.colorsOnly;for(let n=0;n<e.length;n+=4){const o=e[n],a=e[n+1],l=e[n+2];if(e[n]=o*r[0]+a*r[1]+l*r[2]+255*r[4],e[n+1]=o*r[5]+a*r[6]+l*r[7]+255*r[9],e[n+2]=o*r[10]+a*r[11]+l*r[12]+255*r[14],!s){const c=e[n+3];e[n]+=c*r[3],e[n+1]+=c*r[8],e[n+2]+=c*r[13],e[n+3]=o*r[15]+a*r[16]+l*r[17]+c*r[18]+255*r[19]}}}sendUniformData(t,e){const r=this.matrix,s=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],n=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}}function Ye(i,t){var e;const r=(v(e=class extends He{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",i),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return I.setClass(r,i),r}v(He,"type","ColorMatrix"),v(He,"defaults",Yl),v(He,"uniformLocations",["uColorMatrix","uConstants"]),I.setClass(He);const ng=Ye("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),og=Ye("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),ag=Ye("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),lg=Ye("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),cg=Ye("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),hg=Ye("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),ug=Ye("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 ln extends yt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){di(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(r=>I.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}v(ln,"type","Composed"),I.setClass(ln);class Ar extends yt{getFragmentSource(){return`
280
235
  precision highp float;
281
236
  uniform sampler2D uTexture;
282
237
  uniform float uContrast;
@@ -286,7 +241,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
286
241
  float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
287
242
  color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
288
243
  gl_FragColor = color;
289
- }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),i=259*(r+255)/(255*(259-r));for(let s=0;s<e.length;s+=4)e[s]=i*(e[s]-128)+128,e[s+1]=i*(e[s+1]-128)+128,e[s+2]=i*(e[s+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}p(Er,"type","Contrast"),p(Er,"defaults",{contrast:0}),p(Er,"uniformLocations",["uContrast"]),E.setClass(Er);const pu={Convolute_3_1:`
244
+ }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(let n=0;n<e.length;n+=4)e[n]=s*(e[n]-128)+128,e[n+1]=s*(e[n+1]-128)+128,e[n+2]=s*(e[n+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}v(Ar,"type","Contrast"),v(Ar,"defaults",{contrast:0}),v(Ar,"uniformLocations",["uContrast"]),I.setClass(Ar);const dg={Convolute_3_1:`
290
245
  precision highp float;
291
246
  uniform sampler2D uTexture;
292
247
  uniform float uMatrix[9];
@@ -430,7 +385,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
430
385
  gl_FragColor = color;
431
386
  gl_FragColor.a = alpha;
432
387
  }
433
- `};class Pr extends lt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return pu[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,r=e.data,i=this.matrix,s=Math.round(Math.sqrt(i.length)),o=Math.floor(s/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,g,f,m,b,y,w,O,k,S,C,A,D;for(C=0;C<l;C++)for(S=0;S<a;S++){for(b=4*(C*a+S),d=0,g=0,f=0,m=0,D=0;D<s;D++)for(A=0;A<s;A++)w=C+D-o,y=S+A-o,w<0||w>=l||y<0||y>=a||(O=4*(w*a+y),k=i[D*s+A],d+=r[O]*k,g+=r[O+1]*k,f+=r[O+2]*k,u||(m+=r[O+3]*k));h[b]=d,h[b+1]=g,h[b+2]=f,h[b+3]=u?r[b+3]:m}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return v(v({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}p(Pr,"type","Convolute"),p(Pr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),p(Pr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),E.setClass(Pr);const Ea="Gamma";class Ar extends lt{getFragmentSource(){return`
388
+ `};class Lr extends yt{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${this.opaque?1:0}`}getFragmentSource(){return dg[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,r=e.data,s=this.matrix,n=Math.round(Math.sqrt(s.length)),o=Math.floor(n/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,g,f,m,y,b,x,T,C,S,D,A,_;for(D=0;D<l;D++)for(S=0;S<a;S++){for(y=4*(D*a+S),d=0,g=0,f=0,m=0,_=0;_<n;_++)for(A=0;A<n;A++)x=D+_-o,b=S+A-o,x<0||x>=l||b<0||b>=a||(T=4*(x*a+b),C=s[_*n+A],d+=r[T]*C,g+=r[T+1]*C,f+=r[T+2]*C,u||(m+=r[T+3]*C));h[y]=d,h[y+1]=g,h[y+2]=f,h[y+3]=u?r[y+3]:m}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}}v(Lr,"type","Convolute"),v(Lr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(Lr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),I.setClass(Lr);const Ul="Gamma";class Fr extends yt{getFragmentSource(){return`
434
389
  precision highp float;
435
390
  uniform sampler2D uTexture;
436
391
  uniform vec3 uGamma;
@@ -444,7 +399,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
444
399
  gl_FragColor = color;
445
400
  gl_FragColor.rgb *= color.a;
446
401
  }
447
- `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,i=1/r[0],s=1/r[1],o=1/r[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,i),a.g[l]=255*Math.pow(l/255,s),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:Ea,gamma:this.gamma.concat()}}}p(Ar,"type",Ea),p(Ar,"defaults",{gamma:[1,1,1]}),p(Ar,"uniformLocations",["uGamma"]),E.setClass(Ar);const mu={average:`
402
+ `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,s=1/r[0],n=1/r[1],o=1/r[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,n),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:Ul,gamma:this.gamma.concat()}}}v(Fr,"type",Ul),v(Fr,"defaults",{gamma:[1,1,1]}),v(Fr,"uniformLocations",["uGamma"]),I.setClass(Fr);const gg={average:`
448
403
  precision highp float;
449
404
  uniform sampler2D uTexture;
450
405
  varying vec2 vTexCoord;
@@ -473,7 +428,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
473
428
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
474
429
  gl_FragColor = vec4(average, average, average, col.a);
475
430
  }
476
- `};class jr extends lt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r,i=0;i<e.length;i+=4){const s=e[i],o=e[i+1],a=e[i+2];switch(this.mode){case"average":r=(s+o+a)/3;break;case"lightness":r=(Math.min(s,o,a)+Math.max(s,o,a))/2;break;case"luminosity":r=.21*s+.72*o+.07*a}e[i+2]=e[i+1]=e[i]=r}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return mu[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}p(jr,"type","Grayscale"),p(jr,"defaults",{mode:"average"}),p(jr,"uniformLocations",["uMode"]),E.setClass(jr);const vu=v(v({},Ma),{},{rotation:0});class Xi extends Ae{calculateMatrix(){const t=this.rotation*Math.PI,e=ie(t),r=se(t),i=1/3,s=Math.sqrt(i)*r,o=1-e;this.matrix=[e+o/3,i*o-s,i*o+s,0,0,i*o+s,e+i*o,i*o-s,0,0,i*o-s,i*o+s,e+i*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}p(Xi,"type","HueRotation"),p(Xi,"defaults",vu),E.setClass(Xi);class Lr extends lt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r=0;r<e.length;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2],this.alpha&&(e[r+3]=255-e[r+3])}getFragmentSource(){return`
431
+ `};class jr extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":r=(n+o+a)/3;break;case"lightness":r=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":r=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=r}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return gg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(jr,"type","Grayscale"),v(jr,"defaults",{mode:"average"}),v(jr,"uniformLocations",["uMode"]),I.setClass(jr);const fg={...Yl,rotation:0};class js extends He{calculateMatrix(){const t=this.rotation*Math.PI,e=ve(t),r=ye(t),s=1/3,n=Math.sqrt(s)*r,o=1-e;this.matrix=[e+o/3,s*o-n,s*o+n,0,0,s*o+n,e+s*o,s*o-n,0,0,s*o-n,s*o+n,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(js,"type","HueRotation"),v(js,"defaults",fg),I.setClass(js);class Ir extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r=0;r<e.length;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2],this.alpha&&(e[r+3]=255-e[r+3])}getFragmentSource(){return`
477
432
  precision highp float;
478
433
  uniform sampler2D uTexture;
479
434
  uniform int uInvert;
@@ -491,7 +446,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
491
446
  gl_FragColor = color;
492
447
  }
493
448
  }
494
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}p(Lr,"type","Invert"),p(Lr,"defaults",{alpha:!1,invert:!0}),p(Lr,"uniformLocations",["uInvert","uAlpha"]),E.setClass(Lr);class Fr extends lt{getFragmentSource(){return`
449
+ `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}v(Ir,"type","Invert"),v(Ir,"defaults",{alpha:!1,invert:!0}),v(Ir,"uniformLocations",["uInvert","uAlpha"]),I.setClass(Ir);class Br extends yt{getFragmentSource(){return`
495
450
  precision highp float;
496
451
  uniform sampler2D uTexture;
497
452
  uniform float uStepH;
@@ -506,7 +461,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
506
461
  color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
507
462
  gl_FragColor = color;
508
463
  }
509
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let i=0;i<e.length;i+=4){const s=(.5-Math.random())*r;e[i]+=s,e[i+1]+=s,e[i+2]+=s}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}p(Fr,"type","Noise"),p(Fr,"defaults",{noise:0}),p(Fr,"uniformLocations",["uNoise","uSeed"]),E.setClass(Fr);class Rr extends lt{applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;for(let s=0;s<i;s+=this.blocksize)for(let o=0;o<r;o+=this.blocksize){const a=4*s*r+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=s;d<Math.min(s+this.blocksize,i);d++)for(let g=o;g<Math.min(o+this.blocksize,r);g++){const f=4*d*r+4*g;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
464
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let s=0;s<e.length;s+=4){const n=(.5-Math.random())*r;e[s]+=n,e[s+1]+=n,e[s+2]+=n}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}v(Br,"type","Noise"),v(Br,"defaults",{noise:0}),v(Br,"uniformLocations",["uNoise","uSeed"]),I.setClass(Br);class Rr extends yt{applyTo2d(t){let{imageData:{data:e,width:r,height:s}}=t;for(let n=0;n<s;n+=this.blocksize)for(let o=0;o<r;o+=this.blocksize){const a=4*n*r+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=n;d<Math.min(n+this.blocksize,s);d++)for(let g=o;g<Math.min(o+this.blocksize,r);g++){const f=4*d*r+4*g;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
510
465
  precision highp float;
511
466
  uniform sampler2D uTexture;
512
467
  uniform float uBlocksize;
@@ -524,7 +479,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
524
479
  vec4 color = texture2D(uTexture, squareCoords);
525
480
  gl_FragColor = color;
526
481
  }
527
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}p(Rr,"type","Pixelate"),p(Rr,"defaults",{blocksize:4}),p(Rr,"uniformLocations",["uBlocksize"]),E.setClass(Rr);class Br extends lt{getFragmentSource(){return`
482
+ `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}v(Rr,"type","Pixelate"),v(Rr,"defaults",{blocksize:4}),v(Rr,"uniformLocations",["uBlocksize"]),I.setClass(Rr);class $r extends yt{getFragmentSource(){return`
528
483
  precision highp float;
529
484
  uniform sampler2D uTexture;
530
485
  uniform vec4 uLow;
@@ -536,23 +491,23 @@ void main() {
536
491
  gl_FragColor.a = 0.0;
537
492
  }
538
493
  }
539
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,i=new G(this.color).getSource(),s=[i[0]-r,i[1]-r,i[2]-r],o=[i[0]+r,i[1]+r,i[2]+r];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>s[0]&&c>s[1]&&h>s[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const r=new G(this.color).getSource(),i=this.distance,s=[0+r[0]/255-i,0+r[1]/255-i,0+r[2]/255-i,1],o=[r[0]/255+i,r[1]/255+i,r[2]/255+i,1];t.uniform4fv(e.uLow,s),t.uniform4fv(e.uHigh,o)}}p(Br,"type","RemoveColor"),p(Br,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),p(Br,"uniformLocations",["uLow","uHigh"]),E.setClass(Br);class Ir extends lt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),i=new Array(r);for(let s=1;s<=r;s++)i[s-1]=t(s*e);return i}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]="".concat(r,".0 * uDelta");return`
494
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,s=new rt(this.color).getSource(),n=[s[0]-r,s[1]-r,s[2]-r],o=[s[0]+r,s[1]+r,s[2]+r];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>n[0]&&c>n[1]&&h>n[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const r=new rt(this.color).getSource(),s=this.distance,n=[0+r[0]/255-s,0+r[1]/255-s,0+r[2]/255-s,1],o=[r[0]/255+s,r[1]/255+s,r[2]/255+s,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,o)}}v($r,"type","RemoveColor"),v($r,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v($r,"uniformLocations",["uLow","uHigh"]),I.setClass($r);class zr extends yt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return`${this.type}_${t}`}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),s=new Array(r);for(let n=1;n<=r;n++)s[n-1]=t(n*e);return s}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]=`${r}.0 * uDelta`;return`
540
495
  precision highp float;
541
496
  uniform sampler2D uTexture;
542
497
  uniform vec2 uDelta;
543
498
  varying vec2 vTexCoord;
544
- uniform float uTaps[`.concat(t,`];
499
+ uniform float uTaps[${t}];
545
500
  void main() {
546
501
  vec4 color = texture2D(uTexture, vTexCoord);
547
502
  float sum = 1.0;
548
- `).concat(e.map((r,i)=>`
549
- color += texture2D(uTexture, vTexCoord + `.concat(r,") * uTaps[").concat(i,"] + texture2D(uTexture, vTexCoord - ").concat(r,") * uTaps[").concat(i,`];
550
- sum += 2.0 * uTaps[`).concat(i,`];
551
- `)).join(`
552
- `),`
503
+ ${e.map((r,s)=>`
504
+ color += texture2D(uTexture, vTexCoord + ${r}) * uTaps[${s}] + texture2D(uTexture, vTexCoord - ${r}) * uTaps[${s}];
505
+ sum += 2.0 * uTaps[${s}];
506
+ `).join(`
507
+ `)}
553
508
  gl_FragColor = color / sum;
554
509
  }
555
- `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){Ti(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){const e=t.imageData,r=this.scaleX,i=this.scaleY;this.rcpScaleX=1/r,this.rcpScaleY=1/i;const s=e.width,o=e.height,a=Math.round(s*r),l=Math.round(o*i);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,s,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,s,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,s,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,s,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,r,i,s){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=r*a;const d=t.filterBackend.resources;let g=0,f=0;const m=e;let b=0;d.sliceByTwo||(d.sliceByTwo=ne());const y=d.sliceByTwo;(y.width<1.5*e||y.height<r)&&(y.width=1.5*e,y.height=r);const w=y.getContext("2d");for(w.clearRect(0,0,1.5*e,r),w.putImageData(o,0,0),i=Math.floor(i),s=Math.floor(s);!l||!c;)e=h,r=u,i<Math.floor(h*a)?h=Math.floor(h*a):(h=i,l=!0),s<Math.floor(u*a)?u=Math.floor(u*a):(u=s,c=!0),w.drawImage(y,g,f,e,r,m,b,h,u),g=m,f=b,b+=u;return w.getImageData(g,f,i,s)}lanczosResize(t,e,r,i,s){const o=t.imageData.data,a=t.ctx.createImageData(i,s),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,g=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),m=Math.ceil(u*this.lanczosLobes/2),b={},y={x:0,y:0},w={x:0,y:0};return function O(k){let S,C,A,D,L,R,H,I,M,j,z;for(y.x=(k+.5)*h,w.x=Math.floor(y.x),S=0;S<s;S++){for(y.y=(S+.5)*u,w.y=Math.floor(y.y),L=0,R=0,H=0,I=0,M=0,C=w.x-f;C<=w.x+f;C++)if(!(C<0||C>=e)){j=Math.floor(1e3*Math.abs(C-y.x)),b[j]||(b[j]={});for(let V=w.y-m;V<=w.y+m;V++)V<0||V>=r||(z=Math.floor(1e3*Math.abs(V-y.y)),b[j][z]||(b[j][z]=c(Math.sqrt(Math.pow(j*d,2)+Math.pow(z*g,2))/1e3)),A=b[j][z],A>0&&(D=4*(V*e+C),L+=A,R+=A*o[D],H+=A*o[D+1],I+=A*o[D+2],M+=A*o[D+3]))}D=4*(S*i+k),l[D]=R/L,l[D+1]=H/L,l[D+2]=I/L,l[D+3]=M/L}return++k<i?O(k):a}(0)}bilinearFiltering(t,e,r,i,s){let o,a,l,c,h,u,d,g,f,m,b,y,w,O=0;const k=this.rcpScaleX,S=this.rcpScaleY,C=4*(e-1),A=t.imageData.data,D=t.ctx.createImageData(i,s),L=D.data;for(d=0;d<s;d++)for(g=0;g<i;g++)for(h=Math.floor(k*g),u=Math.floor(S*d),f=k*g-h,m=S*d-u,w=4*(u*e+h),b=0;b<4;b++)o=A[w+b],a=A[w+4+b],l=A[w+C+b],c=A[w+C+4+b],y=o*(1-f)*(1-m)+a*f*(1-m)+l*m*(1-f)+c*f*m,L[O++]=y;return D}hermiteFastResize(t,e,r,i,s){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(i,s),d=u.data;for(let g=0;g<s;g++)for(let f=0;f<i;f++){const m=4*(f+g*i);let b=0,y=0,w=0,O=0,k=0,S=0,C=0;const A=(g+.5)*a;for(let D=Math.floor(g*a);D<(g+1)*a;D++){const L=Math.abs(A-(D+.5))/c,R=(f+.5)*o,H=L*L;for(let I=Math.floor(f*o);I<(f+1)*o;I++){let M=Math.abs(R-(I+.5))/l;const j=Math.sqrt(H+M*M);j>1&&j<-1||(b=2*j*j*j-3*j*j+1,b>0&&(M=4*(I+D*e),C+=b*h[M+3],w+=b,h[M+3]<255&&(b=b*h[M+3]/250),O+=b*h[M],k+=b*h[M+1],S+=b*h[M+2],y+=b))}}d[m]=O/y,d[m+1]=k/y,d[m+2]=S/y,d[m+3]=C/w}return u}}p(Ir,"type","Resize"),p(Ir,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),p(Ir,"uniformLocations",["uDelta","uTaps"]),E.setClass(Ir);class Hr extends lt{getFragmentSource(){return`
510
+ `}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){di(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){const e=t.imageData,r=this.scaleX,s=this.scaleY;this.rcpScaleX=1/r,this.rcpScaleY=1/s;const n=e.width,o=e.height,a=Math.round(n*r),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,n,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,n,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,n,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,n,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,r,s,n){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=r*a;const d=t.filterBackend.resources;let g=0,f=0;const m=e;let y=0;d.sliceByTwo||(d.sliceByTwo=be());const b=d.sliceByTwo;(b.width<1.5*e||b.height<r)&&(b.width=1.5*e,b.height=r);const x=b.getContext("2d");for(x.clearRect(0,0,1.5*e,r),x.putImageData(o,0,0),s=Math.floor(s),n=Math.floor(n);!l||!c;)e=h,r=u,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),n<Math.floor(u*a)?u=Math.floor(u*a):(u=n,c=!0),x.drawImage(b,g,f,e,r,m,y,h,u),g=m,f=y,y+=u;return x.getImageData(g,f,s,n)}lanczosResize(t,e,r,s,n){const o=t.imageData.data,a=t.ctx.createImageData(s,n),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,g=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),m=Math.ceil(u*this.lanczosLobes/2),y={},b={x:0,y:0},x={x:0,y:0};return function T(C){let S,D,A,_,M,O,V,z,X,W,G;for(b.x=(C+.5)*h,x.x=Math.floor(b.x),S=0;S<n;S++){for(b.y=(S+.5)*u,x.y=Math.floor(b.y),M=0,O=0,V=0,z=0,X=0,D=x.x-f;D<=x.x+f;D++)if(!(D<0||D>=e)){W=Math.floor(1e3*Math.abs(D-b.x)),y[W]||(y[W]={});for(let q=x.y-m;q<=x.y+m;q++)q<0||q>=r||(G=Math.floor(1e3*Math.abs(q-b.y)),y[W][G]||(y[W][G]=c(Math.sqrt(Math.pow(W*d,2)+Math.pow(G*g,2))/1e3)),A=y[W][G],A>0&&(_=4*(q*e+D),M+=A,O+=A*o[_],V+=A*o[_+1],z+=A*o[_+2],X+=A*o[_+3]))}_=4*(S*s+C),l[_]=O/M,l[_+1]=V/M,l[_+2]=z/M,l[_+3]=X/M}return++C<s?T(C):a}(0)}bilinearFiltering(t,e,r,s,n){let o,a,l,c,h,u,d,g,f,m,y,b,x,T=0;const C=this.rcpScaleX,S=this.rcpScaleY,D=4*(e-1),A=t.imageData.data,_=t.ctx.createImageData(s,n),M=_.data;for(d=0;d<n;d++)for(g=0;g<s;g++)for(h=Math.floor(C*g),u=Math.floor(S*d),f=C*g-h,m=S*d-u,x=4*(u*e+h),y=0;y<4;y++)o=A[x+y],a=A[x+4+y],l=A[x+D+y],c=A[x+D+4+y],b=o*(1-f)*(1-m)+a*f*(1-m)+l*m*(1-f)+c*f*m,M[T++]=b;return _}hermiteFastResize(t,e,r,s,n){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(s,n),d=u.data;for(let g=0;g<n;g++)for(let f=0;f<s;f++){const m=4*(f+g*s);let y=0,b=0,x=0,T=0,C=0,S=0,D=0;const A=(g+.5)*a;for(let _=Math.floor(g*a);_<(g+1)*a;_++){const M=Math.abs(A-(_+.5))/c,O=(f+.5)*o,V=M*M;for(let z=Math.floor(f*o);z<(f+1)*o;z++){let X=Math.abs(O-(z+.5))/l;const W=Math.sqrt(V+X*X);W>1&&W<-1||(y=2*W*W*W-3*W*W+1,y>0&&(X=4*(z+_*e),D+=y*h[X+3],x+=y,h[X+3]<255&&(y=y*h[X+3]/250),T+=y*h[X],C+=y*h[X+1],S+=y*h[X+2],b+=y))}}d[m]=T/b,d[m+1]=C/b,d[m+2]=S/b,d[m+3]=D/x}return u}}v(zr,"type","Resize"),v(zr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(zr,"uniformLocations",["uDelta","uTaps"]),I.setClass(zr);class Hr extends yt{getFragmentSource(){return`
556
511
  precision highp float;
557
512
  uniform sampler2D uTexture;
558
513
  uniform float uSaturation;
@@ -566,7 +521,7 @@ void main() {
566
521
  color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
567
522
  gl_FragColor = color;
568
523
  }
569
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let i=0;i<e.length;i+=4){const s=e[i],o=e[i+1],a=e[i+2],l=Math.max(s,o,a);e[i]+=l!==s?(l-s)*r:0,e[i+1]+=l!==o?(l-o)*r:0,e[i+2]+=l!==a?(l-a)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}p(Hr,"type","Saturation"),p(Hr,"defaults",{saturation:0}),p(Hr,"uniformLocations",["uSaturation"]),E.setClass(Hr);class zr extends lt{getFragmentSource(){return`
524
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a);e[s]+=l!==n?(l-n)*r:0,e[s+1]+=l!==o?(l-o)*r:0,e[s+2]+=l!==a?(l-a)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}v(Hr,"type","Saturation"),v(Hr,"defaults",{saturation:0}),v(Hr,"uniformLocations",["uSaturation"]),I.setClass(Hr);class Vr extends yt{getFragmentSource(){return`
570
525
  precision highp float;
571
526
  uniform sampler2D uTexture;
572
527
  uniform float uVibrance;
@@ -581,6 +536,6 @@ void main() {
581
536
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
582
537
  gl_FragColor = color;
583
538
  }
584
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let i=0;i<e.length;i+=4){const s=e[i],o=e[i+1],a=e[i+2],l=Math.max(s,o,a),c=(s+o+a)/3,h=2*Math.abs(l-c)/255*r;e[i]+=l!==s?(l-s)*h:0,e[i+1]+=l!==o?(l-o)*h:0,e[i+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}p(zr,"type","Vibrance"),p(zr,"defaults",{vibrance:0}),p(zr,"uniformLocations",["uVibrance"]),E.setClass(zr);const bu=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],yu=[2,4,6,8],_u=({screenshot:n,onSave:t,onCancel:e})=>{const r=Ot(null),i=Ot(null),s=Ot(null),[o,a]=et("select"),[l,c]=et("#ef4444"),[h,u]=et(4),[d,g]=et(!1),[f,m]=et(!1),[b,y]=et(1),[w,O]=et(!1),k=Ot([]),S=Ot(-1),C=Ot(!1),A=Ot(!1),D=Ot(null),L=Ot(null);It(()=>{if(!r.current)return;const T=new ls(r.current,{isDrawingMode:!1,selection:!0});return s.current=T,Dt.fromURL(n).then(F=>{var gt;L.current={width:F.width||800,height:F.height||600};const P=(gt=i.current)==null?void 0:gt.getBoundingClientRect(),B=P?P.width-32:800,$=P?P.height-32:600,q=Math.min(B/(F.width||800),$/(F.height||600));T.setDimensions({width:(F.width||800)*q,height:(F.height||600)*q}),F.scaleToWidth(T.width),T.backgroundImage=F,T.renderAll(),R()}),T.freeDrawingBrush=new hi(T),T.freeDrawingBrush.color=l,T.freeDrawingBrush.width=h,T.on("object:added",()=>{C.current||R()}),T.on("path:created",()=>{R()}),()=>{T.dispose()}},[n]),It(()=>{if(!s.current)return;const T=s.current;T.freeDrawingBrush&&(T.freeDrawingBrush.color=l,T.freeDrawingBrush.width=h)},[l,h]),It(()=>{if(!s.current)return;const T=s.current;T.isDrawingMode=o==="pen",T.selection=o==="select",o==="select"?T.defaultCursor="default":T.defaultCursor="crosshair"},[o]);const R=Y(()=>{if(!s.current)return;const T=JSON.stringify(s.current.toJSON());k.current=k.current.slice(0,S.current+1),k.current.push(T),S.current=k.current.length-1,g(S.current>0),m(!1)},[]),H=Y(()=>{if(!s.current||S.current<=0)return;S.current--;const T=k.current[S.current];s.current.loadFromJSON(JSON.parse(T)).then(()=>{var F;(F=s.current)==null||F.renderAll(),g(S.current>0),m(S.current<k.current.length-1)})},[]),I=Y(()=>{if(!s.current||S.current>=k.current.length-1)return;S.current++;const T=k.current[S.current];s.current.loadFromJSON(JSON.parse(T)).then(()=>{var F;(F=s.current)==null||F.renderAll(),g(S.current>0),m(S.current<k.current.length-1)})},[]),M=Y(T=>{if(!s.current||o==="pen"||o==="select")return;C.current=!0;const F=s.current,P=F.getViewportPoint(T.e);let B=null;switch(o){case"rectangle":B=new Mt({left:P.x,top:P.y,width:0,height:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!0});break;case"circle":B=new Ht({left:P.x,top:P.y,rx:0,ry:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!0});break;case"arrow":B=new Qt([P.x,P.y,P.x,P.y],{stroke:l,strokeWidth:h,selectable:!0});break;case"text":B=new Gt("Text",{left:P.x,top:P.y,fontSize:20,fill:l,selectable:!0,editable:!0}),F.add(B),F.setActiveObject(B),B.enterEditing(),C.current=!1;return;case"blur":B=new Mt({left:P.x,top:P.y,width:0,height:0,fill:"rgba(128, 128, 128, 0.8)",stroke:"#666",strokeWidth:1,selectable:!0});break}B&&(B._startPoint={x:P.x,y:P.y},F.add(B),F.setActiveObject(B))},[o,l,h]),j=Y(T=>{if(!s.current||!C.current)return;const F=s.current,P=F.getActiveObject();if(!P||!P._startPoint)return;const B=F.getViewportPoint(T.e),$=P._startPoint;if(P instanceof Mt){const q=B.x-$.x,gt=B.y-$.y;P.set({left:q>0?$.x:B.x,top:gt>0?$.y:B.y,width:Math.abs(q),height:Math.abs(gt)})}else if(P instanceof Ht){const q=Math.abs(B.x-$.x)/2,gt=Math.abs(B.y-$.y)/2;P.set({left:Math.min($.x,B.x),top:Math.min($.y,B.y),rx:q,ry:gt})}else P instanceof Qt&&P.set({x2:B.x,y2:B.y});F.renderAll()},[]),z=Y(()=>{C.current&&(C.current=!1,R())},[R]);It(()=>{if(!s.current)return;const T=s.current;return T.on("mouse:down",M),T.on("mouse:move",j),T.on("mouse:up",z),()=>{T.off("mouse:down",M),T.off("mouse:move",j),T.off("mouse:up",z)}},[M,j,z]);const V=Y(()=>{var ut;if(!s.current)return;const T=s.current,F=T.getZoom(),P=((ut=T.viewportTransform)==null?void 0:ut.slice())||[1,0,0,1,0,0];T.setZoom(1),T.setViewportTransform([1,0,0,1,0,0]),T.renderAll();const B=L.current,$=B?B.width/(T.width||1):1,q=T.toDataURL({format:"png",quality:1,multiplier:$});T.setZoom(F),T.setViewportTransform(P),T.renderAll();const Kt=T.getObjects().map(Ya=>Ya.toObject());t(q,{objects:Kt})},[t]),Q=Y(()=>{if(!s.current)return;const T=s.current,F=T.getActiveObjects();F.length>0&&(F.forEach(P=>T.remove(P)),T.discardActiveObject(),T.renderAll(),R())},[R]),U=Y(()=>{if(!s.current)return;const T=s.current,F=Math.min(b*1.2,3),P=new x(T.width/2,T.height/2);T.zoomToPoint(P,F),y(F)},[b]),vt=Y(()=>{if(!s.current)return;const T=s.current,F=Math.max(b/1.2,.5),P=new x(T.width/2,T.height/2);T.zoomToPoint(P,F),y(F)},[b]),St=Y(()=>{if(!s.current)return;const T=s.current;y(1),T.setZoom(1),T.setViewportTransform([1,0,0,1,0,0]),T.renderAll()},[]);It(()=>{if(!s.current)return;const T=s.current,F=$=>{const q=$.e;(q.buttons===2||q.buttons===1&&w)&&(q.preventDefault(),A.current=!0,T.selection=!1,D.current={x:q.clientX,y:q.clientY},T.setCursor("grabbing"))},P=$=>{if(A.current&&D.current){const q=$.e,gt=T.viewportTransform;gt[4]+=q.clientX-D.current.x,gt[5]+=q.clientY-D.current.y,T.requestRenderAll(),D.current={x:q.clientX,y:q.clientY}}},B=()=>{A.current&&(A.current=!1,D.current=null,T.setCursor(w?"grab":"default"))};return T.on("mouse:down",F),T.on("mouse:move",P),T.on("mouse:up",B),()=>{T.off("mouse:down",F),T.off("mouse:move",P),T.off("mouse:up",B)}},[w]),It(()=>{const T=P=>{if(P.key===" "&&!w&&(P.preventDefault(),O(!0),s.current&&s.current.setCursor("grab")),P.key==="Delete"||P.key==="Backspace"){const B=document.activeElement;(B==null?void 0:B.tagName)!=="INPUT"&&(B==null?void 0:B.tagName)!=="TEXTAREA"&&Q()}(P.ctrlKey||P.metaKey)&&P.key==="z"&&(P.preventDefault(),P.shiftKey?I():H())},F=P=>{P.key===" "&&w&&(O(!1),s.current&&s.current.setCursor("default"))};return window.addEventListener("keydown",T),window.addEventListener("keyup",F),()=>{window.removeEventListener("keydown",T),window.removeEventListener("keyup",F)}},[Q,H,I,w]);const ct=({tool:T,icon:F,label:P})=>_("button",{class:`bugpin-tool-btn ${o===T?"active":""}`,onClick:()=>a(T),title:P,children:_("span",{dangerouslySetInnerHTML:{__html:F}})});return _("div",{class:"bugpin-annotation-container",children:[_("div",{class:"bugpin-annotation-toolbar",children:[_("div",{class:"bugpin-tool-group",children:[_(ct,{tool:"select",label:"Select",icon:'<svg viewBox="0 0 24 24"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z" fill="currentColor"/></svg>'}),_(ct,{tool:"pen",label:"Pen",icon:'<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>'}),_(ct,{tool:"arrow",label:"Arrow",icon:'<svg viewBox="0 0 24 24"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" fill="currentColor"/></svg>'}),_(ct,{tool:"rectangle",label:"Rectangle",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),_(ct,{tool:"circle",label:"Circle",icon:'<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),_(ct,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),_(ct,{tool:"blur",label:"Blur/Mask",icon:'<svg viewBox="0 0 24 24"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z" fill="currentColor"/></svg>'})]}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-color-picker",children:bu.map(T=>_("button",{class:`bugpin-color-btn ${l===T?"active":""}`,style:{backgroundColor:T},onClick:()=>c(T),title:T},T))}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-stroke-picker",children:yu.map(T=>_("button",{class:`bugpin-stroke-btn ${h===T?"active":""}`,onClick:()=>u(T),title:`${T}px`,children:_("span",{style:{height:`${T}px`}})},T))}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-tool-group",children:[_("button",{class:"bugpin-tool-btn",onClick:H,disabled:!d,title:"Undo (Ctrl+Z)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:I,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:Q,title:"Delete selected (Del)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-tool-group",children:[_("button",{class:"bugpin-tool-btn",onClick:vt,disabled:b<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:St,title:`Reset Zoom (${Math.round(b*100)}%) - Hold Space to pan`,children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:U,disabled:b>=3,title:"Zoom In - Hold Space to pan when zoomed",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z",fill:"currentColor"})})})]})]}),_("div",{class:"bugpin-canvas-wrapper",ref:i,children:_("canvas",{ref:r})}),_("div",{class:"bugpin-annotation-actions",children:[_("button",{class:"bugpin-btn-cancel",onClick:e,children:"Cancel"}),_("button",{class:"bugpin-btn-submit",onClick:V,children:"Done"})]})]})};function xu(n,t){if(n.match(/^[a-z]+:\/\//i))return n;if(n.match(/^\/\//))return window.location.protocol+n;if(n.match(/^[a-z]+:/i))return n;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),i=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(i),t&&(r.href=t),i.href=n,i.href}const wu=(()=>{let n=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(n+=1,`u${t()}${n}`)})();function de(n){const t=[];for(let e=0,r=n.length;e<r;e++)t.push(n[e]);return t}let Oe=null;function Pa(n={}){return Oe||(n.includeStyleProperties?(Oe=n.includeStyleProperties,Oe):(Oe=de(window.getComputedStyle(document.documentElement)),Oe))}function ui(n,t){const r=(n.ownerDocument.defaultView||window).getComputedStyle(n).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Cu(n){const t=ui(n,"border-left-width"),e=ui(n,"border-right-width");return n.clientWidth+t+e}function Su(n){const t=ui(n,"border-top-width"),e=ui(n,"border-bottom-width");return n.clientHeight+t+e}function Aa(n,t={}){const e=t.width||Cu(n),r=t.height||Su(n);return{width:e,height:r}}function Tu(){let n,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(n=parseInt(e,10),Number.isNaN(n)&&(n=1)),n||window.devicePixelRatio||1}const kt=16384;function ku(n){(n.width>kt||n.height>kt)&&(n.width>kt&&n.height>kt?n.width>n.height?(n.height*=kt/n.width,n.width=kt):(n.width*=kt/n.height,n.height=kt):n.width>kt?(n.height*=kt/n.width,n.width=kt):(n.width*=kt/n.height,n.height=kt))}function di(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=n})}async function Ou(n){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(n)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Du(n,t,e){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${e}`),i.setAttribute("viewBox",`0 0 ${t} ${e}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(n),Ou(i)}const wt=(n,t)=>{if(n instanceof t)return!0;const e=Object.getPrototypeOf(n);return e===null?!1:e.constructor.name===t.name||wt(e,t)};function Mu(n){const t=n.getPropertyValue("content");return`${n.cssText} content: '${t.replace(/'|"/g,"")}';`}function Eu(n,t){return Pa(t).map(e=>{const r=n.getPropertyValue(e),i=n.getPropertyPriority(e);return`${e}: ${r}${i?" !important":""};`}).join(" ")}function Pu(n,t,e,r){const i=`.${n}:${t}`,s=e.cssText?Mu(e):Eu(e,r);return document.createTextNode(`${i}{${s}}`)}function Un(n,t,e,r){const i=window.getComputedStyle(n,e),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=wu();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Pu(o,e,i,r)),t.appendChild(a)}function Au(n,t,e){Un(n,t,":before",e),Un(n,t,":after",e)}const Gn="application/font-woff",Nn="image/jpeg",ju={woff:Gn,woff2:Gn,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Nn,jpeg:Nn,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Lu(n){const t=/\.([^./]*?)$/g.exec(n);return t?t[1]:""}function Ws(n){const t=Lu(n).toLowerCase();return ju[t]||""}function Fu(n){return n.split(/,/)[1]}function hs(n){return n.search(/^(data:)/)!==-1}function Ru(n,t){return`data:${t};base64,${n}`}async function ja(n,t,e){const r=await fetch(n,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(i)})}const Yi={};function Bu(n,t,e){let r=n.replace(/\?.*/,"");return e&&(r=n),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Vs(n,t,e){const r=Bu(n,t,e.includeQueryParams);if(Yi[r]!=null)return Yi[r];e.cacheBust&&(n+=(/\?/.test(n)?"&":"?")+new Date().getTime());let i;try{const s=await ja(n,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Fu(a)));i=Ru(s,t)}catch(s){i=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${n}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return Yi[r]=i,i}async function Iu(n){const t=n.toDataURL();return t==="data:,"?n.cloneNode(!1):di(t)}async function Hu(n,t){if(n.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=n.clientWidth,s.height=n.clientHeight,o==null||o.drawImage(n,0,0,s.width,s.height);const a=s.toDataURL();return di(a)}const e=n.poster,r=Ws(e),i=await Vs(e,r,t);return di(i)}async function zu(n,t){var e;try{if(!((e=n==null?void 0:n.contentDocument)===null||e===void 0)&&e.body)return await ki(n.contentDocument.body,t,!0)}catch{}return n.cloneNode(!1)}async function Wu(n,t){return wt(n,HTMLCanvasElement)?Iu(n):wt(n,HTMLVideoElement)?Hu(n,t):wt(n,HTMLIFrameElement)?zu(n,t):n.cloneNode(La(n))}const Vu=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SLOT",La=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SVG";async function Xu(n,t,e){var r,i;if(La(t))return t;let s=[];return Vu(n)&&n.assignedNodes?s=de(n.assignedNodes()):wt(n,HTMLIFrameElement)&&(!((r=n.contentDocument)===null||r===void 0)&&r.body)?s=de(n.contentDocument.body.childNodes):s=de(((i=n.shadowRoot)!==null&&i!==void 0?i:n).childNodes),s.length===0||wt(n,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>ki(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function Yu(n,t,e){const r=t.style;if(!r)return;const i=window.getComputedStyle(n);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Pa(e).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),wt(n,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function Uu(n,t){wt(n,HTMLTextAreaElement)&&(t.innerHTML=n.value),wt(n,HTMLInputElement)&&t.setAttribute("value",n.value)}function Gu(n,t){if(wt(n,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(i=>n.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function Nu(n,t,e){return wt(t,Element)&&(Yu(n,t,e),Au(n,t,e),Uu(n,t),Gu(n,t)),t}async function $u(n,t){const e=n.querySelectorAll?n.querySelectorAll("use"):[];if(e.length===0)return n;const r={};for(let s=0;s<e.length;s++){const a=e[s].getAttribute("xlink:href");if(a){const l=n.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await ki(c,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<i.length;l++)a.appendChild(i[l]);n.appendChild(o)}return n}async function ki(n,t,e){return!e&&t.filter&&!t.filter(n)?null:Promise.resolve(n).then(r=>Wu(r,t)).then(r=>Xu(n,r,t)).then(r=>Nu(n,r,t)).then(r=>$u(r,t))}const Fa=/url\((['"]?)([^'"]+?)\1\)/g,qu=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ku=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Zu(n){const t=n.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ju(n){const t=[];return n.replace(Fa,(e,r,i)=>(t.push(i),e)),t.filter(e=>!hs(e))}async function Qu(n,t,e,r,i){try{const s=e?xu(t,e):t,o=Ws(t);let a;return i||(a=await Vs(s,o,r)),n.replace(Zu(t),`$1${a}$3`)}catch{}return n}function td(n,{preferredFontFormat:t}){return t?n.replace(Ku,e=>{for(;;){const[r,,i]=qu.exec(e)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):n}function Ra(n){return n.search(Fa)!==-1}async function Ba(n,t,e){if(!Ra(n))return n;const r=td(n,e);return Ju(r).reduce((s,o)=>s.then(a=>Qu(a,o,t,e)),Promise.resolve(r))}async function De(n,t,e){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(n);if(i){const s=await Ba(i,null,e);return t.style.setProperty(n,s,t.style.getPropertyPriority(n)),!0}return!1}async function ed(n,t){await De("background",n,t)||await De("background-image",n,t),await De("mask",n,t)||await De("-webkit-mask",n,t)||await De("mask-image",n,t)||await De("-webkit-mask-image",n,t)}async function rd(n,t){const e=wt(n,HTMLImageElement);if(!(e&&!hs(n.src))&&!(wt(n,SVGImageElement)&&!hs(n.href.baseVal)))return;const r=e?n.src:n.href.baseVal,i=await Vs(r,Ws(r),t);await new Promise((s,o)=>{n.onload=s,n.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=n;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),e?(n.srcset="",n.src=i):n.href.baseVal=i})}async function id(n,t){const r=de(n.childNodes).map(i=>Ia(i,t));await Promise.all(r).then(()=>n)}async function Ia(n,t){wt(n,Element)&&(await ed(n,t),await rd(n,t),await id(n,t))}function sd(n,t){const{style:e}=n;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{e[i]=r[i]}),n}const $n={};async function qn(n){let t=$n[n];if(t!=null)return t;const r=await(await fetch(n)).text();return t={url:n,cssText:r},$n[n]=t,t}async function Kn(n,t){let e=n.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,n.url).href),ja(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>e)}function Zn(n){if(n==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=n.replace(e,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function nd(n,t){const e=[],r=[];return n.forEach(i=>{if("cssRules"in i)try{de(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,c=qn(l).then(h=>Kn(h,t)).then(h=>Zn(h).forEach(u=>{try{i.insertRule(u,u.startsWith("@import")?a+=1:i.cssRules.length)}catch(d){console.error("Error inserting rule from remote css",{rule:u,error:d})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(s){const o=n.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(qn(i.href).then(a=>Kn(a,t)).then(a=>Zn(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(n.forEach(i=>{if("cssRules"in i)try{de(i.cssRules||[]).forEach(s=>{e.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),e))}function od(n){return n.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Ra(t.style.getPropertyValue("src")))}async function ad(n,t){if(n.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=de(n.ownerDocument.styleSheets),r=await nd(e,t);return od(r)}function Ha(n){return n.trim().replace(/["']/g,"")}function ld(n){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(Ha(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&e(s)})}return e(n),t}async function cd(n,t){const e=await ad(n,t),r=ld(n);return(await Promise.all(e.filter(s=>r.has(Ha(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return Ba(s.cssText,o,t)}))).join(`
585
- `)}async function hd(n,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await cd(n,t);if(e){const r=document.createElement("style"),i=document.createTextNode(e);r.appendChild(i),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)}}async function ud(n,t={}){const{width:e,height:r}=Aa(n,t),i=await ki(n,t,!0);return await hd(i,t),await Ia(i,t),sd(i,t),await Du(i,e,r)}async function dd(n,t={}){const{width:e,height:r}=Aa(n,t),i=await ud(n,t),s=await di(i),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Tu(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||ku(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function gd(){try{const n=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1}),t=document.createElement("video");t.srcObject=n,t.autoplay=!0,await new Promise(i=>{t.onloadedmetadata=()=>i()}),await new Promise(i=>setTimeout(i,100));const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;const r=e.getContext("2d");if(!r)throw new Error("Failed to get canvas context");return r.drawImage(t,0,0),n.getTracks().forEach(i=>i.stop()),e.toDataURL("image/png")}catch(n){throw n instanceof Error&&n.name==="NotAllowedError"?new Error("Screen capture permission denied"):n}}async function fd(n="visible",t,e=!1){if(e)return gd();let r;switch(n){case"element":throw new Error("Selector required for element capture");case"fullpage":r=document.documentElement;break;case"visible":default:r=document.documentElement;break}const i=document.getElementById("bugpin-widget");i&&(i.style.display="none");let s={};if(n==="visible"&&r===document.documentElement){const o=document.documentElement,a=window.getComputedStyle(document.body);s={background:o.style.background||void 0,minHeight:o.style.minHeight||void 0,minWidth:o.style.minWidth||void 0},o.style.minWidth="100vw",o.style.minHeight="100vh",o.style.background=a.backgroundColor||a.background||"#ffffff"}try{const a={cacheBust:!0,quality:1,pixelRatio:window.devicePixelRatio||1,skipAutoScale:!0,filter:c=>!(c instanceof HTMLElement&&(c.tagName==="SCRIPT"||c.id==="bugpin-widget"))};return n==="visible"&&(a.width=window.innerWidth,a.height=window.innerHeight,console.log("[BugPin] Capturing element:",r.tagName),console.log("[BugPin] Element dimensions:",{scrollWidth:r.scrollWidth,scrollHeight:r.scrollHeight,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),console.log("[BugPin] Viewport dimensions:",{innerWidth:window.innerWidth,innerHeight:window.innerHeight}),console.log("[BugPin] Capture options:",a)),(await dd(r,a)).toDataURL("image/png")}finally{if(n==="visible"&&r===document.documentElement){const o=document.documentElement;s.background!==void 0?o.style.background=s.background:o.style.removeProperty("background"),s.minHeight!==void 0?o.style.minHeight=s.minHeight:o.style.removeProperty("min-height"),s.minWidth!==void 0?o.style.minWidth=s.minWidth:o.style.removeProperty("min-width")}i&&(i.style.display="")}}function za(n){const t=n.split(","),e=t[0].match(/:(.*?);/),r=e?e[1]:"image/png",i=atob(t[1]),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return new Blob([s],{type:r})}function Wa(n){return n.startsWith("data:image/webp")?"webp":n.startsWith("data:image/jpeg")?"jpg":n.startsWith("data:image/gif")?"gif":"png"}const je=[];let Jn=!1;function pd(){if(Jn)return;Jn=!0;const n=console.error;console.error=(...r)=>{je.push({type:"error",message:r.map(i=>String(i)).join(" "),timestamp:new Date().toISOString()}),n.apply(console,r)};const t=console.warn;console.warn=(...r)=>{je.push({type:"warn",message:r.map(i=>String(i)).join(" "),timestamp:new Date().toISOString()}),t.apply(console,r)};const e=window.onerror;window.onerror=(r,i,s,o,a)=>(je.push({type:"error",message:String(r),source:i||void 0,line:s||void 0,timestamp:new Date().toISOString()}),e?e.apply(window,[r,i,s,o,a]):!1),window.addEventListener("unhandledrejection",r=>{je.push({type:"error",message:`Unhandled Promise Rejection: ${String(r.reason)}`,timestamp:new Date().toISOString()})})}function md(){var r,i,s,o,a;const n=navigator.userAgent;let t="Unknown",e="";return n.includes("Firefox/")?(t="Firefox",e=((r=n.match(/Firefox\/([\d.]+)/))==null?void 0:r[1])||""):n.includes("Edg/")?(t="Edge",e=((i=n.match(/Edg\/([\d.]+)/))==null?void 0:i[1])||""):n.includes("Chrome/")?(t="Chrome",e=((s=n.match(/Chrome\/([\d.]+)/))==null?void 0:s[1])||""):n.includes("Safari/")&&!n.includes("Chrome")?(t="Safari",e=((o=n.match(/Version\/([\d.]+)/))==null?void 0:o[1])||""):(n.includes("Opera/")||n.includes("OPR/"))&&(t="Opera",e=((a=n.match(/(?:Opera|OPR)\/([\d.]+)/))==null?void 0:a[1])||""),{name:t,version:e,userAgent:n}}function vd(){var i,s,o,a,l;const n=navigator.userAgent;let t="desktop",e="Unknown",r;if(/Mobi|Android|iPhone|iPad|iPod/i.test(n)&&(/iPad|Tablet/i.test(n)||window.innerWidth>=768&&/Android/i.test(n)?t="tablet":t="mobile"),n.includes("Windows")){e="Windows";const c=n.match(/Windows NT ([\d.]+)/);if(c){const h=c[1];r={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista"}[h]||h}}else n.includes("Mac OS X")?(e="macOS",r=(s=(i=n.match(/Mac OS X ([\d._]+)/))==null?void 0:i[1])==null?void 0:s.replace(/_/g,".")):n.includes("Linux")?(e=n.includes("Android")?"Android":"Linux",e==="Android"&&(r=(o=n.match(/Android ([\d.]+)/))==null?void 0:o[1])):(n.includes("iPhone")||n.includes("iPad"))&&(e="iOS",r=(l=(a=n.match(/OS ([\d_]+)/))==null?void 0:a[1])==null?void 0:l.replace(/_/g,"."));return{type:t,os:e,osVersion:r}}function bd(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function yd(){try{const n=performance.getEntriesByType("navigation");if(n.length>0){const t=n[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function _d(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:md(),device:vd(),viewport:bd(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:yd(),consoleErrors:je.length>0?[...je]:void 0}}pd();const us=(n,t)=>t.some(e=>n instanceof e);let Qn,to;function xd(){return Qn||(Qn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function wd(){return to||(to=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const ds=new WeakMap,Ui=new WeakMap,Oi=new WeakMap;function Cd(n){const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",o)},s=()=>{e(we(n.result)),i()},o=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",o)});return Oi.set(t,n),t}function Sd(n){if(ds.has(n))return;const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",o),n.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",o),n.addEventListener("abort",o)});ds.set(n,t)}let gs={get(n,t,e){if(n instanceof IDBTransaction){if(t==="done")return ds.get(n);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return we(n[t])},set(n,t,e){return n[t]=e,!0},has(n,t){return n instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in n}};function Va(n){gs=n(gs)}function Td(n){return wd().includes(n)?function(...t){return n.apply(fs(this),t),we(this.request)}:function(...t){return we(n.apply(fs(this),t))}}function kd(n){return typeof n=="function"?Td(n):(n instanceof IDBTransaction&&Sd(n),us(n,xd())?new Proxy(n,gs):n)}function we(n){if(n instanceof IDBRequest)return Cd(n);if(Ui.has(n))return Ui.get(n);const t=kd(n);return t!==n&&(Ui.set(n,t),Oi.set(t,n)),t}const fs=n=>Oi.get(n);function Od(n,t,{blocked:e,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(n,t),a=we(o);return r&&o.addEventListener("upgradeneeded",l=>{r(we(o.result),l.oldVersion,l.newVersion,we(o.transaction),l)}),e&&o.addEventListener("blocked",l=>e(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),i&&l.addEventListener("versionchange",c=>i(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Dd=["get","getKey","getAll","getAllKeys","count"],Md=["put","add","delete","clear"],Gi=new Map;function eo(n,t){if(!(n instanceof IDBDatabase&&!(t in n)&&typeof t=="string"))return;if(Gi.get(t))return Gi.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,i=Md.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Dd.includes(e)))return;const s=async function(o,...a){const l=this.transaction(o,i?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[e](...a),i&&l.done]))[0]};return Gi.set(t,s),s}Va(n=>({...n,get:(t,e,r)=>eo(t,e)||n.get(t,e,r),has:(t,e)=>!!eo(t,e)||n.has(t,e)}));const Ed=["continue","continuePrimaryKey","advance"],ro={},ps=new WeakMap,Xa=new WeakMap,Pd={get(n,t){if(!Ed.includes(t))return n[t];let e=ro[t];return e||(e=ro[t]=function(...r){ps.set(this,Xa.get(this)[t](...r))}),e}};async function*Ad(...n){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...n)),!t)return;t=t;const e=new Proxy(t,Pd);for(Xa.set(e,t),Oi.set(e,fs(t));t;)yield e,t=await(ps.get(e)||t.continue()),ps.delete(e)}function io(n,t){return t===Symbol.asyncIterator&&us(n,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&us(n,[IDBIndex,IDBObjectStore])}Va(n=>({...n,get(t,e,r){return io(t,e)?Ad:n.get(t,e,r)},has(t,e){return io(t,e)||n.has(t,e)}}));const jd="bugpin-reports",Ld=2,He="pending-reports",so=5,Fd=5e3,Rd=3e5,Bd=2;let Wr=null,no=null;function Id(n){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[n]||"bin"}async function Di(){if(Wr)return Wr;try{return Wr=await Od(jd,Ld,{upgrade(n){n.objectStoreNames.contains(He)||n.createObjectStore(He,{keyPath:"id"}).createIndex("by-created","createdAt")}}),Wr}catch(n){throw console.error("[BugPin] Failed to initialize IndexedDB:",n),n}}function Hd(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function gi(){return navigator.onLine!==!1}function zd(n){const t=Fd*Math.pow(Bd,n);return Math.min(t,Rd)}async function oo(n){const t=await Di(),e={...n,id:Hd(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(He,e),console.log("[BugPin] Report buffered for later submission:",e.id),gi()&&Kr().catch(console.error),e.id}async function Wd(){try{return await(await Di()).getAllFromIndex(He,"by-created")}catch{return[]}}async function ao(n){try{await(await Di()).delete(He,n),console.log("[BugPin] Removed buffered report:",n)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function Vd(n){try{await(await Di()).put(He,n)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function Xd(n){var t,e;try{const r=new URL("/api/widget/submit",n.serverUrl);r.searchParams.set("apiKey",n.apiKey);const i=new FormData;if(i.append("data",JSON.stringify({title:n.title,description:n.description,priority:n.priority,reporterEmail:n.reporterEmail,reporterName:n.reporterName,metadata:n.metadata,mediaCount:((t=n.media)==null?void 0:t.length)||0,mediaAnnotations:(e=n.media)==null?void 0:e.map(o=>o.annotations).filter(Boolean)})),n.media&&n.media.length>0)for(let o=0;o<n.media.length;o++){const a=n.media[o],l=za(a.dataUrl),c=Wa(a.dataUrl)||Id(a.mimeType),u=a.mimeType.startsWith("video/")?"video":"screenshot";i.append("media",l,`${u}-${o}.${c}`)}const s=await fetch(r.toString(),{method:"POST",body:i});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.message||`HTTP ${s.status}`)}return!0}catch(r){throw console.error("[BugPin] Failed to submit buffered report:",r),r}}async function Kr(){if(!gi())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const n=await Wd();if(n.length===0)return{synced:0,failed:0};console.log(`[BugPin] Syncing ${n.length} pending reports...`);let t=0,e=0;for(const r of n){if(r.lastRetryAt){const s=new Date(r.lastRetryAt).getTime()+zd(r.retryCount);if(Date.now()<s)continue}try{await Xd(r),await ao(r.id),t++,console.log("[BugPin] Successfully synced report:",r.id)}catch(i){e++,r.retryCount++,r.lastRetryAt=new Date().toISOString(),r.error=i instanceof Error?i.message:"Unknown error",r.retryCount>=so?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await ao(r.id)):(await Vd(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${so}):`,r.id))}}return{synced:t,failed:e}}function Yd(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),Kr().catch(console.error)}),no||(no=setInterval(()=>{gi()&&Kr().catch(console.error)},3e4)),gi()&&Kr().catch(console.error)}Yd();function Ud(){return navigator.onLine!==!1}function Gd(n){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[n]||"bin"}async function Nd(n){const{apiKey:t,serverUrl:e,media:r,...i}=n;if(!Ud())return console.log("[BugPin] Offline, buffering report for later submission"),await oo({apiKey:t,serverUrl:e,title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,media:r,metadata:i.metadata}),{success:!0,message:"Report saved. It will be submitted when you're back online."};const s=new URL("/api/widget/submit",e);s.searchParams.set("apiKey",t);const o=new FormData;if(o.append("data",JSON.stringify({title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,metadata:i.metadata,mediaCount:(r==null?void 0:r.length)||0,mediaAnnotations:r==null?void 0:r.map(a=>a.annotations).filter(Boolean)})),r&&r.length>0)for(let a=0;a<r.length;a++){const l=r[a],c=za(l.dataUrl),h=Wa(l.dataUrl)||Gd(l.mimeType),d=l.mimeType.startsWith("video/")?"video":"screenshot";console.log(`[BugPin] Media ${a}: dataUrl length=${l.dataUrl.length}, blob size=${c.size}, type=${c.type}`),o.append("media",c,`${d}-${a}.${h}`)}try{const a=await fetch(s.toString(),{method:"POST",body:o}),l=await a.json();if(!a.ok||!l.success)throw new Error(l.message||l.error||"Failed to submit report");return l}catch(a){if(a instanceof TypeError&&a.message.includes("fetch"))return console.log("[BugPin] Network error, buffering report for later submission"),await oo({apiKey:t,serverUrl:e,title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,media:r,metadata:i.metadata}),{success:!0,message:"Report saved. It will be submitted when the connection is restored."};throw a}}function $d(n){return n==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":n}const lo={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},qd=({config:n})=>{const t=Ot(null),[e,r]=et("closed"),[i,s]=et(!1),[o,a]=et(!1),[l,c]=et([]),[h,u]=et(null),[d,g]=et(null),[f,m]=et("details"),[b,y]=et(lo);It(()=>{const M=()=>w(),j=()=>O();return document.addEventListener("bugpin:open",M),document.addEventListener("bugpin:close",j),()=>{document.removeEventListener("bugpin:open",M),document.removeEventListener("bugpin:close",j)}},[]),It(()=>{const M=t.current;if(!M)return;const j=()=>{$d(n.theme)==="dark"?(M.style.setProperty("--button-color",n.dialogDarkButtonColor),M.style.setProperty("--button-text-color",n.dialogDarkTextColor),M.style.setProperty("--button-hover-color",n.dialogDarkButtonHoverColor),M.style.setProperty("--button-hover-text-color",n.dialogDarkTextHoverColor)):(M.style.setProperty("--button-color",n.dialogLightButtonColor),M.style.setProperty("--button-text-color",n.dialogLightTextColor),M.style.setProperty("--button-hover-color",n.dialogLightButtonHoverColor),M.style.setProperty("--button-hover-text-color",n.dialogLightTextHoverColor))};if(j(),n.theme==="auto"){const z=window.matchMedia("(prefers-color-scheme: dark)"),V=()=>j();return z.addEventListener("change",V),()=>z.removeEventListener("change",V)}},[n.theme,n.dialogLightButtonColor,n.dialogLightTextColor,n.dialogLightButtonHoverColor,n.dialogLightTextHoverColor,n.dialogDarkButtonColor,n.dialogDarkTextColor,n.dialogDarkButtonHoverColor,n.dialogDarkTextHoverColor]);const w=Y(()=>{r("form")},[]),O=Y(()=>{r("closed"),c([]),u(null),m("details"),y(lo)},[]),k=Y(async()=>{if(n.enableScreenshot){a(!0),r("closed"),await new Promise(M=>setTimeout(M,100));try{const M=await fd(n.captureMethod,void 0,n.useScreenCaptureAPI),j=new Image;j.onload=()=>{console.log(`[BugPin] Captured screenshot: ${j.width}x${j.height}, dataUrl length=${M.length}`);const z={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png",width:j.width,height:j.height};c(V=>[...V,z]),a(!1),m("media"),r("form")},j.onerror=()=>{const z={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png"};c(V=>[...V,z]),a(!1),m("media"),r("form")},j.src=M}catch(M){console.error("[BugPin] Failed to capture screenshot:",M),a(!1),r("form"),g({message:"Failed to capture screenshot",type:"error"})}}},[n]),S=Y(M=>{c(j=>[...j,M])},[]),C=Y(M=>{c(j=>j.filter(z=>z.id!==M))},[]),A=Y(M=>{u(M),r("annotating")},[]),D=Y((M,j)=>{h&&c(z=>z.map(V=>V.id===h?{...V,dataUrl:M,annotated:!0,annotations:j}:V)),u(null),r("form")},[h]),L=Y(()=>{u(null),r("form")},[]),R=Y(async(M,j)=>{s(!0);try{const z=_d();await Nd({apiKey:n.apiKey,serverUrl:n.serverUrl,title:M.title,description:M.description,priority:M.priority,reporterEmail:M.reporterEmail||void 0,reporterName:M.reporterName||void 0,media:j.map(V=>({dataUrl:V.dataUrl,mimeType:V.mimeType,annotations:V.annotations})),metadata:z}),g({message:"Bug report submitted successfully!",type:"success"}),O()}catch(z){console.error("[BugPin] Failed to submit report:",z),g({message:z instanceof Error?z.message:"Failed to submit report",type:"error"})}finally{s(!1)}},[n,O]),H=Y(()=>{g(null)},[]),I=h?l.find(M=>M.id===h):null;return _("div",{ref:t,class:`bugpin-container bugpin-theme-${n.theme}`,children:[_(yl,{position:n.position,buttonText:n.buttonText,buttonShape:n.buttonShape,buttonIcon:n.buttonIcon,buttonIconSize:n.buttonIconSize,buttonIconStroke:n.buttonIconStroke,theme:n.theme,lightButtonColor:n.lightButtonColor,lightTextColor:n.lightTextColor,lightButtonHoverColor:n.lightButtonHoverColor,lightTextHoverColor:n.lightTextHoverColor,darkButtonColor:n.darkButtonColor,darkTextColor:n.darkTextColor,darkButtonHoverColor:n.darkButtonHoverColor,darkTextHoverColor:n.darkTextHoverColor,enableHoverScaleEffect:n.enableHoverScaleEffect,tooltipEnabled:n.tooltipEnabled,tooltipText:n.tooltipText,onClick:w}),e==="annotating"&&I&&_("div",{class:"bugpin-overlay",children:_("div",{class:"bugpin-annotation-modal",children:_(_u,{screenshot:I.dataUrl,onSave:D,onCancel:L})})}),e==="form"&&_(Ol,{onClose:O,onSubmit:R,onCaptureScreenshot:k,onAnnotateMedia:A,media:l,onAddMedia:S,onRemoveMedia:C,isSubmitting:i,isCapturing:o,enableAnnotation:n.enableAnnotation,activeTab:f,onActiveTabChange:m,formData:b,onFormDataChange:y}),d&&_(Dl,{message:d.message,type:d.type,onClose:H})]})},ms={apiKey:"",serverUrl:window.location.origin,position:"bottom-right",buttonText:null,buttonShape:"rectangle",buttonIcon:"bug",buttonIconSize:18,buttonIconStroke:2,theme:"auto",lightButtonColor:"#6366f1",lightTextColor:"#ffffff",lightButtonHoverColor:"#4f46e5",lightTextHoverColor:"#ffffff",darkButtonColor:"#818cf8",darkTextColor:"#1e1b4b",darkButtonHoverColor:"#a5b4fc",darkTextHoverColor:"#1e1b4b",dialogLightButtonColor:"#ebebeb",dialogLightTextColor:"#575757",dialogLightButtonHoverColor:"#ebebeb",dialogLightTextHoverColor:"#575757",dialogDarkButtonColor:"#3c3c3c",dialogDarkTextColor:"#c3c3c3",dialogDarkButtonHoverColor:"#3c3c3c",dialogDarkTextHoverColor:"#c3c3c3",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024},Kd='*{box-sizing:border-box;margin:0;padding:0}#bugpin-root{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;font-size:14px;line-height:1.5;--background: #ffffff;--foreground: #0a0a0a;--muted: #f5f5f5;--muted-foreground: #737373;--border: #e5e5e5;--input: #e5e5e5;--ring: #a3a3a3;--primary: var(--button-color, #18181b);--primary-foreground: var(--button-text-color, #fafafa);--primary-hover: var(--button-hover-color, #27272a);--primary-hover-foreground: var(--button-hover-text-color, #fafafa);--destructive: #ef4444;--destructive-foreground: #fafafa;--radius: .5rem;--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);color:var(--foreground)}.bugpin-launcher-button{display:flex;align-items:center;justify-content:center;gap:8px;border:none;font-size:14px;font-weight:500;cursor:pointer;box-shadow:0 4px 12px #00000026}.bugpin-launcher-button.hover-scale{transition:transform .3s ease,box-shadow .3s ease}.bugpin-launcher-button.hover-scale:hover{transform:scale(1.1);box-shadow:0 8px 20px #00000040}.bugpin-launcher-button.hover-scale:active{transform:scale(1.05)}.bugpin-launcher-button-container.bottom-right{bottom:20px;right:20px}.bugpin-launcher-button-container.bottom-left{bottom:20px;left:20px}.bugpin-launcher-button-container.top-right{top:20px;right:20px}.bugpin-launcher-button-container.top-left{top:20px;left:20px}.bugpin-launcher-button svg{stroke:currentColor;fill:none}.bugpin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483646;background:#00000080;display:flex;align-items:center;justify-content:center;padding:20px;animation:fadeIn .2s ease-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.bugpin-dialog{position:relative;width:100%;max-width:480px;max-height:90vh;background:var(--background);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg);overflow:hidden;display:flex;flex-direction:column;animation:slideUp .2s ease-out}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.bugpin-header{display:flex;align-items:center;justify-content:space-between;padding:1.5rem;border-bottom:1px solid var(--border)}.bugpin-header h2{font-size:1.125rem;font-weight:600;color:var(--foreground);letter-spacing:-.025em}.bugpin-close{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;border:none;border-radius:calc(var(--radius) - 4px);background:transparent;color:var(--muted-foreground);cursor:pointer;transition:background .15s,color .15s}.bugpin-close:hover{background:var(--muted);color:var(--foreground)}.bugpin-close svg{width:1.25rem;height:1.25rem}.bugpin-body{flex:1;overflow-y:auto;padding:1.5rem}.bugpin-form{display:flex;flex-direction:column;gap:16px}.bugpin-field{display:flex;flex-direction:column;gap:6px}.bugpin-label{font-size:.875rem;font-weight:500;color:var(--foreground)}.bugpin-label.required:after{content:" *";color:var(--destructive)}.bugpin-input,.bugpin-textarea{height:2.5rem;padding:.5rem .75rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);font-size:.875rem;font-family:inherit;color:var(--foreground);background:transparent;transition:border-color .15s,box-shadow .15s}.bugpin-input:focus,.bugpin-textarea:focus{outline:none;border-color:var(--ring);box-shadow:0 0 0 2px var(--background),0 0 0 4px var(--ring)}.bugpin-input::placeholder,.bugpin-textarea::placeholder{color:var(--muted-foreground)}.bugpin-textarea{height:auto;min-height:5rem;resize:vertical}.bugpin-select{height:2.5rem;padding:.5rem .75rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);font-size:.875rem;font-family:inherit;color:var(--foreground);background:transparent;cursor:pointer;transition:border-color .15s,box-shadow .15s}.bugpin-select:focus{outline:none;border-color:var(--ring);box-shadow:0 0 0 2px var(--background),0 0 0 4px var(--ring)}.bugpin-screenshot{margin-top:8px;border-radius:8px;overflow:hidden;background:#f9fafb;border:1px solid #e5e7eb}.bugpin-screenshot img{display:block;width:100%;height:auto;max-height:200px;object-fit:contain}.bugpin-screenshot-actions{display:flex;gap:8px;padding:8px;border-top:1px solid #e5e7eb}.bugpin-btn-secondary{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;border:1px solid #d1d5db;border-radius:6px;background:#fff;color:#374151;font-size:13px;font-weight:500;cursor:pointer;transition:background .15s,border-color .15s}.bugpin-btn-secondary:hover{background:#f9fafb;border-color:#9ca3af}.bugpin-btn-secondary svg{width:16px;height:16px}.bugpin-footer{display:flex;gap:.75rem;padding:1.5rem;border-top:1px solid var(--border);background:var(--muted)}.bugpin-btn-cancel{flex:1;height:2.5rem;padding:0 1rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);background:var(--background);color:var(--foreground);font-size:.875rem;font-weight:500;cursor:pointer;transition:background .15s}.bugpin-btn-cancel:hover{background:var(--muted)}.bugpin-btn-submit{flex:1;height:2.5rem;padding:0 1rem;border:none;border-radius:calc(var(--radius) - 2px);background:var(--primary);color:var(--primary-foreground);font-size:.875rem;font-weight:500;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-submit:hover{background:var(--primary-hover);color:var(--primary-hover-foreground)}.bugpin-btn-submit:disabled{opacity:.5;cursor:not-allowed}.bugpin-toast{position:fixed;bottom:80px;right:20px;z-index:2147483647;display:flex;align-items:center;gap:.75rem;padding:1rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--background);color:var(--foreground);font-size:.875rem;box-shadow:var(--shadow-lg);animation:slideIn .3s ease-out}.bugpin-toast.success{border-color:#22c55e}.bugpin-toast.error{border-color:var(--destructive)}@keyframes slideIn{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}.bugpin-toast svg{width:20px;height:20px;flex-shrink:0}.bugpin-spinner{width:18px;height:18px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.priority-lowest{color:#6b7280}.priority-low{color:#3b82f6}.priority-medium{color:#f59e0b}.priority-high{color:#ef4444}.priority-highest{color:#dc2626}.bugpin-theme-dark,.bugpin-container.bugpin-theme-dark{--background: #0a0a0a;--foreground: #fafafa;--muted: #262626;--muted-foreground: #a3a3a3;--border: #262626;--input: #262626;--ring: #d4d4d4}.bugpin-theme-dark .bugpin-dialog{background:var(--background);color:var(--foreground)}.bugpin-theme-dark .bugpin-header{border-color:var(--border)}.bugpin-theme-dark .bugpin-header h2{color:var(--foreground)}.bugpin-theme-dark .bugpin-close:hover{background:var(--muted);color:var(--foreground)}.bugpin-theme-dark .bugpin-label{color:var(--foreground)}.bugpin-theme-dark .bugpin-input,.bugpin-theme-dark .bugpin-textarea,.bugpin-theme-dark .bugpin-select{background:var(--muted);border-color:var(--input);color:var(--foreground)}.bugpin-theme-dark .bugpin-input::placeholder,.bugpin-theme-dark .bugpin-textarea::placeholder{color:var(--muted-foreground)}.bugpin-theme-dark .bugpin-screenshot{background:var(--muted);border-color:var(--border)}.bugpin-theme-dark .bugpin-screenshot-actions{border-color:var(--border)}.bugpin-theme-dark .bugpin-btn-secondary{background:var(--muted);border-color:var(--border);color:var(--foreground)}.bugpin-theme-dark .bugpin-btn-secondary:hover{background:#3f3f46}.bugpin-theme-dark .bugpin-footer{background:#171717;border-color:var(--border)}.bugpin-theme-dark .bugpin-btn-cancel{background:var(--muted);border-color:var(--border);color:var(--foreground)}.bugpin-theme-dark .bugpin-btn-cancel:hover{background:#3f3f46}.bugpin-error{color:var(--destructive);font-size:.75rem;margin-top:.25rem}.bugpin-annotation-container{display:flex;flex-direction:column;height:100%;background:#1f2937}.bugpin-annotation-toolbar{display:flex;align-items:center;gap:8px;padding:12px 16px;background:#111827;border-bottom:1px solid #374151;flex-wrap:wrap}.bugpin-tool-group{display:flex;gap:4px}.bugpin-tool-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:6px;background:transparent;color:#9ca3af;cursor:pointer;transition:background .15s,color .15s}.bugpin-tool-btn:hover{background:#374151;color:#f3f4f6}.bugpin-tool-btn.active{background:var(--button-color, #6366f1);color:var(--button-text-color, white)}.bugpin-tool-btn:disabled{opacity:.4;cursor:not-allowed}.bugpin-tool-btn svg{width:20px;height:20px}.bugpin-tool-divider{width:1px;height:24px;background:#374151;margin:0 4px}.bugpin-color-picker{display:flex;gap:4px}.bugpin-color-btn{width:24px;height:24px;border:2px solid transparent;border-radius:50%;cursor:pointer;transition:transform .15s,border-color .15s}.bugpin-color-btn:hover{transform:scale(1.1)}.bugpin-color-btn.active{border-color:#fff}.bugpin-stroke-picker{display:flex;gap:4px;align-items:center}.bugpin-stroke-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #4b5563;border-radius:6px;background:#374151;cursor:pointer;transition:border-color .15s}.bugpin-stroke-btn:hover{border-color:#6b7280}.bugpin-stroke-btn.active{border-color:var(--button-color, #6366f1);background:var(--button-color, #6366f1)}.bugpin-stroke-btn span{width:16px;background:#fff;border-radius:2px}.bugpin-canvas-wrapper{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;overflow:auto}.bugpin-canvas-wrapper canvas{border-radius:4px;box-shadow:0 4px 12px #0000004d}.bugpin-annotation-actions{display:flex;gap:12px;padding:12px 16px;background:#111827;border-top:1px solid #374151}.bugpin-annotation-actions .bugpin-btn-cancel,.bugpin-annotation-actions .bugpin-btn-submit{flex:1}.bugpin-annotation-modal{width:90vw;max-width:900px;height:80vh;max-height:700px;background:#1f2937;border-radius:12px;overflow:hidden;box-shadow:0 20px 40px #0006;animation:slideUp .2s ease-out}.bugpin-tabs-container{padding:1rem 1.5rem 0;background:transparent}.bugpin-tabs{display:inline-flex;padding:.25rem;background:var(--muted);border-radius:var(--radius);gap:.25rem}.bugpin-tab{display:flex;align-items:center;gap:.5rem;padding:.375rem .75rem;border:none;border-radius:calc(var(--radius) - 4px);background:transparent;color:var(--muted-foreground);font-size:.875rem;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s,color .15s,box-shadow .15s}.bugpin-tab:hover{color:var(--foreground)}.bugpin-tab.active{background:var(--background);color:var(--foreground);box-shadow:var(--shadow-sm)}.bugpin-tab-icon{display:flex;align-items:center;justify-content:center}.bugpin-tab-icon svg{width:1rem;height:1rem}.bugpin-dialog-tabbed{max-width:560px}.bugpin-theme-dark .bugpin-tabs{background:var(--muted)}.bugpin-theme-dark .bugpin-tab{color:var(--muted-foreground)}.bugpin-theme-dark .bugpin-tab:hover{color:var(--foreground)}.bugpin-theme-dark .bugpin-tab.active{background:var(--background);color:var(--foreground)}.bugpin-screenshot-manager{display:flex;flex-direction:column;gap:16px}.bugpin-media-actions{display:flex;gap:8px}.bugpin-btn-action{flex:1;display:flex;align-items:center;justify-content:center;gap:.5rem;height:2.5rem;padding:0 1rem;border:none;border-radius:calc(var(--radius) - 2px);background:var(--primary);color:var(--primary-foreground);font-size:.875rem;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-action:hover{background:var(--primary-hover);color:var(--primary-hover-foreground)}.bugpin-btn-action:disabled{opacity:.5;cursor:not-allowed}.bugpin-btn-action svg{width:1.125rem;height:1.125rem}.bugpin-btn-action-secondary{background:var(--background);color:var(--foreground);border:1px solid var(--input)}.bugpin-btn-action-secondary:hover{background:var(--muted)}.bugpin-upload-error{display:flex;align-items:center;gap:8px;padding:10px 12px;background:#fef2f2;border:1px solid #fecaca;border-radius:8px;color:#dc2626;font-size:13px}.bugpin-upload-error svg{width:18px;height:18px;flex-shrink:0}.bugpin-drop-zone{min-height:160px;border:2px dashed var(--border);border-radius:var(--radius);background:var(--muted);transition:border-color .15s,background .15s}.bugpin-drop-zone.dragging{border-color:var(--primary);background:color-mix(in srgb,var(--primary) 5%,transparent)}.bugpin-drop-zone.has-media{border-style:solid;border-color:var(--border);background:var(--background);min-height:auto}.bugpin-drop-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 16px;color:#6b7280;text-align:center}.bugpin-drop-placeholder svg{width:48px;height:48px;margin-bottom:12px;color:#9ca3af}.bugpin-drop-placeholder p{font-size:14px;font-weight:500;margin-bottom:4px}.bugpin-drop-placeholder span{font-size:12px;color:#9ca3af}.bugpin-drop-more{display:flex;align-items:center;justify-content:center;padding:12px;margin:8px 12px 12px;border:2px dashed #d1d5db;border-radius:6px;background:#f9fafb;transition:border-color .15s,background .15s}.bugpin-drop-more span{font-size:12px;color:#9ca3af}.bugpin-drop-zone.dragging .bugpin-drop-more{border-color:var(--button-color, #6366f1);background:#6366f10d}.bugpin-media-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;padding:12px}.bugpin-media-card{position:relative;border-radius:var(--radius);overflow:hidden;background:var(--background);border:1px solid var(--border)}.bugpin-media-preview{position:relative;aspect-ratio:16/9;background:#1f2937}.bugpin-media-preview img,.bugpin-media-preview video{width:100%;height:100%;object-fit:contain}.bugpin-media-badges{position:absolute;top:6px;left:6px;display:flex;gap:4px}.bugpin-badge{padding:.125rem .5rem;border-radius:calc(var(--radius) - 4px);font-size:.625rem;font-weight:500;text-transform:uppercase;letter-spacing:.025em}.bugpin-badge.annotated{background:#dbeafe;color:#1d4ed8}.bugpin-badge.video{background:#e5e7eb;color:#374151}.bugpin-media-info{display:flex;justify-content:space-between;padding:6px 8px;font-size:11px;color:#6b7280;border-top:1px solid #e5e7eb}.bugpin-media-item-actions{display:flex;gap:4px;padding:6px 8px;border-top:1px solid #e5e7eb;background:#f9fafb}.bugpin-btn-icon{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:6px;background:#fff;color:#6b7280;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-icon:hover{background:#e5e7eb;color:#374151}.bugpin-btn-icon svg{width:16px;height:16px}.bugpin-btn-icon-danger:hover{background:#fef2f2;color:#dc2626}.bugpin-helper-text{font-size:12px;color:#9ca3af;text-align:center}.bugpin-theme-dark .bugpin-btn-action-secondary{background:#374151;border-color:#4b5563;color:#d1d5db}.bugpin-theme-dark .bugpin-btn-action-secondary:hover{background:#4b5563}.bugpin-theme-dark .bugpin-upload-error{background:#450a0a;border-color:#7f1d1d;color:#fca5a5}.bugpin-theme-dark .bugpin-drop-zone{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-drop-zone.dragging{background:#6366f11a}.bugpin-theme-dark .bugpin-drop-zone.has-media{border-color:#4b5563;background:#1f2937}.bugpin-theme-dark .bugpin-drop-placeholder{color:#9ca3af}.bugpin-theme-dark .bugpin-drop-placeholder svg{color:#6b7280}.bugpin-theme-dark .bugpin-drop-more{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-drop-more span{color:#6b7280}.bugpin-theme-dark .bugpin-media-card{background:#374151;border-color:#4b5563}.bugpin-theme-dark .bugpin-media-info{border-color:#4b5563;color:#9ca3af}.bugpin-theme-dark .bugpin-media-item-actions{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-btn-icon{background:#4b5563;color:#9ca3af}.bugpin-theme-dark .bugpin-btn-icon:hover{background:#6b7280;color:#f3f4f6}.bugpin-theme-dark .bugpin-btn-icon-danger:hover{background:#450a0a;color:#fca5a5}.bugpin-theme-dark .bugpin-badge.annotated{background:#1e3a8a;color:#93c5fd}.bugpin-theme-dark .bugpin-badge.video{background:#4b5563;color:#d1d5db}@keyframes bugpin-tooltip-fade-in{0%{opacity:0}to{opacity:1}}';async function co(){var o,a,l;const n=document.querySelectorAll('script[src*="widget.js"]'),t=n[n.length-1];if(!t){console.error("[BugPin] Could not find widget script tag");return}const e=t.getAttribute("data-api-key");if(!e){console.error("[BugPin] Missing data-api-key attribute");return}const r=t.getAttribute("data-server-url")||ms.serverUrl;let i={};try{const c=await fetch(`${r}/api/widget/config/${e}`);if(c.ok){const h=await c.json();h.success&&h.config&&(i={buttonText:h.config.buttonText,buttonShape:h.config.buttonShape,buttonIcon:h.config.buttonIcon,buttonIconSize:h.config.buttonIconSize,buttonIconStroke:h.config.buttonIconStroke,position:h.config.position,theme:h.config.theme,lightButtonColor:h.config.lightButtonColor,lightTextColor:h.config.lightTextColor,lightButtonHoverColor:h.config.lightButtonHoverColor,lightTextHoverColor:h.config.lightTextHoverColor,darkButtonColor:h.config.darkButtonColor,darkTextColor:h.config.darkTextColor,darkButtonHoverColor:h.config.darkButtonHoverColor,darkTextHoverColor:h.config.darkTextHoverColor,dialogLightButtonColor:h.config.dialogLightButtonColor,dialogLightTextColor:h.config.dialogLightTextColor,dialogLightButtonHoverColor:h.config.dialogLightButtonHoverColor,dialogLightTextHoverColor:h.config.dialogLightTextHoverColor,dialogDarkButtonColor:h.config.dialogDarkButtonColor,dialogDarkTextColor:h.config.dialogDarkTextColor,dialogDarkButtonHoverColor:h.config.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:h.config.dialogDarkTextHoverColor,enableHoverScaleEffect:h.config.enableHoverScaleEffect??!0,tooltipEnabled:h.config.tooltipEnabled??!1,tooltipText:h.config.tooltipText??null,enableScreenshot:((o=h.config.features)==null?void 0:o.screenshot)??!0,enableAnnotation:((a=h.config.features)==null?void 0:a.annotation)??!0,enableConsoleCapture:((l=h.config.features)==null?void 0:l.consoleCapture)??!0,captureMethod:h.config.captureMethod||"visible",useScreenCaptureAPI:h.config.useScreenCaptureAPI??!1})}}catch(c){console.warn("[BugPin] Failed to fetch widget config, using defaults",c)}const s={...ms,...i,apiKey:e,serverUrl:r,...t.getAttribute("data-position")&&{position:t.getAttribute("data-position")},...t.getAttribute("data-button-text")&&{buttonText:t.getAttribute("data-button-text")},...t.getAttribute("data-theme")&&{theme:t.getAttribute("data-theme")}};Xs(s)}function Xs(n){const t=document.createElement("div");t.id="bugpin-widget";const e=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=Kd,e.appendChild(r);const i=document.createElement("div");i.id="bugpin-root",e.appendChild(i),document.body.appendChild(t),Ka(er(qd,{config:n}),i)}const Ys={init:n=>{const t={...ms,...n};Xs(t)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};typeof window<"u"&&(window.BugPin=Ys);const Zd=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Mi&&Mi.tagName.toUpperCase()==="SCRIPT"&&Mi.src||new URL("widget.cjs.js",document.baseURI).href}<"u";Zd||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",co):co());exports.BugPin=Ys;exports.createWidget=Xs;exports.default=Ys;
539
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a),c=(n+o+a)/3,h=2*Math.abs(l-c)/255*r;e[s]+=l!==n?(l-n)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(Vr,"type","Vibrance"),v(Vr,"defaults",{vibrance:0}),v(Vr,"uniformLocations",["uVibrance"]),I.setClass(Vr);var cn=Object.freeze({__proto__:null,BaseFilter:yt,BlackWhite:ug,BlendColor:Dr,BlendImage:Mr,Blur:Er,Brightness:Pr,Brownie:ng,ColorMatrix:He,Composed:ln,Contrast:Ar,Convolute:Lr,Gamma:Fr,Grayscale:jr,HueRotation:js,Invert:Ir,Kodachrome:ag,Noise:Br,Pixelate:Rr,Polaroid:cg,RemoveColor:$r,Resize:zr,Saturation:Hr,Sepia:hg,Technicolor:lg,Vibrance:Vr,Vintage:og});dt.ownDefaults.originX="left";dt.ownDefaults.originY="top";const Yo=Symbol.for("bugpin-toObject-patched");if(!dt.prototype[Yo]){const i=dt.prototype.toObject;dt.prototype.toObject=function(t){const e=[...new Set(["data",...t||[]])];return i.call(this,e)},dt.prototype[Yo]=!0}const pg=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],mg=[2,4,6,8];let vg=0;function yg(i,t,e){var T,C,S;const r=t,s=++vg;r.data&&(r.data.generationId=s);const n=i.getZoom(),o=((T=i.viewportTransform)==null?void 0:T.slice())||[1,0,0,1,0,0];i.setZoom(1),i.setViewportTransform([1,0,0,1,0,0]),i.renderAll(),t.setCoords();const a=t.getBoundingRect(),l=a.left,c=a.top,h=a.width,u=a.height;if(h<5||u<5){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}const d=e.getElement(),g=e.scaleX||1,f=e.scaleY||1,y=((C=r.data)==null?void 0:C.blockSize)||Math.max(3,Math.round(Math.min(h,u)/20)),b=document.createElement("canvas");b.width=h,b.height=u;const x=b.getContext("2d");if(x){x.drawImage(d,l/g,c/f,h/g,u/f,0,0,h,u);const D=new kt(b);D.filters=[new cn.Pixelate({blocksize:y})],D.applyFilters();const A=D.getElement();if(((S=r.data)==null?void 0:S.generationId)!==s){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}t.setElement(A),t.set({scaleX:1,scaleY:1,width:h,height:u}),r.data={type:"pixelate",blockSize:y,generationId:s}}i.setZoom(n),i.setViewportTransform(o),i.renderAll()}const bg=({screenshot:i,onSave:t,onCancel:e})=>{const r=Rt(null),s=Rt(null),n=Rt(null),[o,a]=at("select"),[l,c]=at("#ef4444"),[h,u]=at(4),[d,g]=at(!1),[f,m]=at(!1),[y,b]=at(1),[x,T]=at(!1),C=Rt([]),S=Rt(-1),D=Rt(!1),A=Rt(!1),_=Rt(null),M=Rt(null);Vt(()=>{if(!r.current)return;const k=new on(r.current,{isDrawingMode:!1,selection:!0});n.current=k,kt.fromURL(i).then(B=>{var st;M.current={width:B.width||800,height:B.height||600};const j=(st=s.current)==null?void 0:st.getBoundingClientRect(),H=j?j.width-32:800,ut=j?j.height-32:600,ct=Math.min(H/(B.width||800),ut/(B.height||600));k.setDimensions({width:(B.width||800)*ct,height:(B.height||600)*ct}),B.scaleToWidth(k.width),k.backgroundImage=B,k.renderAll(),O()}),k.freeDrawingBrush=new Zs(k),k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h,k.on("path:created",()=>{O()}),k.on("object:modified",B=>{var H;const j=B.target;((H=j==null?void 0:j.data)==null?void 0:H.type)==="pixelate"&&j instanceof kt&&k.backgroundImage&&(yg(k,j,k.backgroundImage),O())});const P=r.current,E=B=>B.preventDefault();return P==null||P.addEventListener("contextmenu",E),()=>{P==null||P.removeEventListener("contextmenu",E),k.dispose()}},[i]),Vt(()=>{if(!n.current)return;const k=n.current;k.freeDrawingBrush&&(k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h)},[l,h]),Vt(()=>{if(!n.current)return;const k=n.current;k.isDrawingMode=o==="pen",k.selection=o==="select",o==="select"?k.defaultCursor="default":o==="pan"?k.defaultCursor="grab":k.defaultCursor="crosshair",T(o==="pan")},[o]);const O=N(()=>{if(!n.current)return;const k=JSON.stringify(n.current.toJSON());C.current=C.current.slice(0,S.current+1),C.current.push(k),S.current=C.current.length-1,g(S.current>0),m(!1)},[]),V=N(()=>{if(!n.current||S.current<=0)return;S.current--;const k=C.current[S.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(S.current>0),m(S.current<C.current.length-1)})},[]),z=N(()=>{if(!n.current||S.current>=C.current.length-1)return;S.current++;const k=C.current[S.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(S.current>0),m(S.current<C.current.length-1)})},[]),X=N(k=>{var j;if(!n.current||o==="pen"||o==="select"||o==="pan"||k.target||(j=n.current)!=null&&j.findTarget(k.e).target)return;D.current=!0;const P=n.current,E=k.scenePoint;let B=null;switch(o){case"rectangle":B=new Pt({left:E.x,top:E.y,width:0,height:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"circle":B=new Kt({left:E.x,top:E.y,rx:0,ry:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"line":B=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1});break;case"arrow":B=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1}),B._isArrow=!0;break;case"text":B=new ne("Text",{left:E.x,top:E.y,fontSize:20,fill:l,selectable:!0,editable:!0}),P.add(B),P.setActiveObject(B),B.enterEditing(),D.current=!1;return;case"pixelate":B=new Pt({left:E.x,top:E.y,width:0,height:0,fill:"rgba(128, 128, 128, 0.3)",stroke:"#666",strokeWidth:1,strokeDashArray:[5,5],selectable:!1,hasControls:!1,hasBorders:!1});break}B&&(B._startPoint={x:E.x,y:E.y},P.add(B),P._drawingShape=B)},[o,l,h]),W=N(k=>{if(!n.current||!D.current)return;const P=n.current,E=P._drawingShape;if(!E||!E._startPoint)return;const B=k.scenePoint,j=E._startPoint;if(E instanceof Pt){const H=B.x-j.x,ut=B.y-j.y;E.set({left:H>0?j.x:B.x,top:ut>0?j.y:B.y,width:Math.abs(H),height:Math.abs(ut)})}else if(E instanceof Kt){const H=Math.abs(B.x-j.x)/2,ut=Math.abs(B.y-j.y)/2;E.set({left:Math.min(j.x,B.x),top:Math.min(j.y,B.y),rx:H,ry:ut})}else E instanceof Jt&&E.set({x2:B.x,y2:B.y});P.renderAll()},[]),G=N(async()=>{var k;if(D.current&&n.current){D.current=!1;const P=n.current,E=P._drawingShape;if(E){if(o==="pixelate"&&E instanceof Pt&&P.backgroundImage){const j=E,H=P.getZoom(),ut=((k=P.viewportTransform)==null?void 0:k.slice())||[1,0,0,1,0,0];P.setZoom(1),P.setViewportTransform([1,0,0,1,0,0]),P.renderAll(),j.setCoords();const ct=j.getBoundingRect(),st=ct.left,St=ct.top,F=ct.width,J=ct.height;if(F>5&&J>5){const tt=P.backgroundImage,xt=tt.getElement(),nt=tt.scaleX||1,ee=tt.scaleY||1,Ut=document.createElement("canvas");Ut.width=F,Ut.height=J;const ce=Ut.getContext("2d");if(ce){ce.drawImage(xt,st/nt,St/ee,F/nt,J/ee,0,0,F,J);const Ue=Math.max(3,Math.round(Math.min(F,J)/20)),_e=new kt(Ut,{left:st,top:St,selectable:!0,hasControls:!0,hasBorders:!0});_e.data={type:"pixelate",blockSize:Ue},_e.filters=[new cn.Pixelate({blocksize:Ue})],_e.applyFilters(),P.remove(j),P.add(_e)}}else P.remove(j);P.setZoom(H),P.setViewportTransform(ut),P.renderAll()}else if(E._isArrow&&E instanceof Jt){const j=E,H=j.x1||0,ut=j.y1||0,ct=j.x2||0,st=j.y2||0,St=ct-H,F=st-ut,J=Math.sqrt(St*St+F*F);if(J>10){const tt=Math.atan2(F,St),xt=j.strokeWidth||2,nt=Math.max(xt*5,Math.min(xt*7,J/3)),ee=nt*.35,Ut=ct-nt*Math.cos(tt),ce=st-nt*Math.sin(tt),Ue=Ut-ee*Math.cos(tt-Math.PI/2),_e=ce-ee*Math.sin(tt-Math.PI/2),re=Ut-ee*Math.cos(tt+Math.PI/2),xr=ce-ee*Math.sin(tt+Math.PI/2);j.set({x2:Ut,y2:ce});const wr=new Or([{x:ct,y:st},{x:Ue,y:_e},{x:re,y:xr}],{fill:j.stroke,stroke:j.stroke,strokeWidth:1,selectable:!1}),Ge=new Oe([j,wr],{selectable:!0,hasControls:!0,hasBorders:!0});P.remove(j),P.add(Ge)}else E.set({selectable:!0,hasControls:!0,hasBorders:!0})}else E.set({selectable:!0,hasControls:!0,hasBorders:!0});P._drawingShape=void 0}O()}},[O,o]);Vt(()=>{if(!n.current)return;const k=n.current;return k.on("mouse:down",X),k.on("mouse:move",W),k.on("mouse:up",G),()=>{k.off("mouse:down",X),k.off("mouse:move",W),k.off("mouse:up",G)}},[X,W,G]);const q=N(()=>{var St;if(!n.current)return;const k=n.current,P=k.getZoom(),E=((St=k.viewportTransform)==null?void 0:St.slice())||[1,0,0,1,0,0];k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll();const B=M.current,j=B?B.width/(k.width||1):1,H=[];if(k.backgroundImage&&j>1){const F=k.backgroundImage,J=F.getElement(),tt=F.scaleX||1,xt=F.scaleY||1;k.getObjects().forEach(nt=>{var Ut,ce;const ee=nt;if(((Ut=ee.data)==null?void 0:Ut.type)==="pixelate"&&nt instanceof kt){const Ue=nt.getElement(),_e={width:nt.width||0,height:nt.height||0,scaleX:nt.scaleX||1,scaleY:nt.scaleY||1,left:nt.left||0,top:nt.top||0,angle:nt.angle||0,skewX:nt.skewX||0,skewY:nt.skewY||0,flipX:nt.flipX||!1,flipY:nt.flipY||!1};H.push({obj:nt,originalElement:Ue,originalState:_e}),nt.setCoords();const re=nt.getBoundingRect(),xr=re.width*j,wr=re.height*j,Ge=document.createElement("canvas");Ge.width=xr,Ge.height=wr;const Nn=Ge.getContext("2d");if(Nn){Nn.drawImage(J,re.left/tt,re.top/xt,re.width/tt,re.height/xt,0,0,xr,wr);const uc=((ce=ee.data)==null?void 0:ce.blockSize)||Math.max(3,Math.round(Math.min(re.width,re.height)/20)),dc=Math.round(uc*j),vi=new kt(Ge);vi.filters=[new cn.Pixelate({blocksize:dc})],vi.applyFilters(),nt.setElement(vi.getElement()),nt.set({width:xr,height:wr,scaleX:1/j,scaleY:1/j})}}}),k.renderAll()}const ut=k.toDataURL({format:"png",quality:1,multiplier:j});H.forEach(({obj:F,originalElement:J,originalState:tt})=>{F.setElement(J),F.set(tt)}),k.setZoom(P),k.setViewportTransform(E),k.renderAll();const st=k.getObjects().map(F=>F.toObject());t(ut,{objects:st})},[t]),K=N(()=>{if(!n.current)return;const k=n.current,P=k.getActiveObjects();P.length>0&&(P.forEach(E=>k.remove(E)),k.discardActiveObject(),k.renderAll(),O())},[O]),L=N(()=>{if(!n.current)return;const k=n.current,P=Math.min(y*1.2,3),E=new w(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),bt=N(()=>{if(!n.current)return;const k=n.current,P=Math.max(y/1.2,.5),E=new w(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),gt=N(()=>{if(!n.current)return;const k=n.current;b(1),k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll()},[]);Vt(()=>{if(!n.current)return;const k=n.current,P=j=>{const H=j.e;(H.buttons===2||H.buttons===1&&x||H.buttons===1&&o==="pan")&&(H.preventDefault(),A.current=!0,k.selection=!1,_.current={x:H.clientX,y:H.clientY},k.setCursor("grabbing"))},E=j=>{if(A.current&&_.current){const H=j.e,ut=k.viewportTransform;ut[4]+=H.clientX-_.current.x,ut[5]+=H.clientY-_.current.y,k.requestRenderAll(),_.current={x:H.clientX,y:H.clientY}}},B=()=>{A.current&&(A.current=!1,_.current=null,k.setCursor(x||o==="pan"?"grab":"default"),k.selection=o==="select")};return k.on("mouse:down",P),k.on("mouse:move",E),k.on("mouse:up",B),()=>{k.off("mouse:down",P),k.off("mouse:move",E),k.off("mouse:up",B)}},[x,o]),Vt(()=>{const k=E=>{if(E.key===" "&&!x&&(E.preventDefault(),T(!0),n.current&&n.current.setCursor("grab")),E.key==="Delete"||E.key==="Backspace"){const B=document.activeElement;(B==null?void 0:B.tagName)!=="INPUT"&&(B==null?void 0:B.tagName)!=="TEXTAREA"&&K()}(E.ctrlKey||E.metaKey)&&E.key==="z"&&(E.preventDefault(),E.shiftKey?z():V())},P=E=>{E.key===" "&&x&&(T(!1),n.current&&n.current.setCursor(o==="pan"?"grab":"default"))};return window.addEventListener("keydown",k),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",k),window.removeEventListener("keyup",P)}},[K,V,z,x,o]);const lt=({tool:k,icon:P,label:E})=>p("button",{class:$t("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors","hover:bg-gray-100 hover:text-gray-800","[&_svg]:w-4.5 [&_svg]:h-4.5",o===k&&"bg-primary/10 text-primary"),onClick:()=>a(k),title:E,children:p("span",{dangerouslySetInnerHTML:{__html:P}})});return p("div",{class:"flex flex-col",children:[p("div",{class:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-solid border-border bg-muted",children:[p("div",{class:"flex items-center gap-1",children:[p(lt,{tool:"select",label:"Select",icon:'<svg viewBox="0 0 24 24"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z" fill="currentColor"/></svg>'}),p(lt,{tool:"pan",label:"Pan (or hold Space)",icon:'<svg viewBox="0 0 24 24"><path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z" fill="currentColor"/></svg>'}),p(lt,{tool:"pen",label:"Pen",icon:'<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>'}),p(lt,{tool:"line",label:"Line",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'}),p(lt,{tool:"arrow",label:"Arrow",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M19 5l-6 2 4 4 2-6z" fill="currentColor"/></svg>'}),p(lt,{tool:"rectangle",label:"Rectangle",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),p(lt,{tool:"circle",label:"Circle",icon:'<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),p(lt,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),p(lt,{tool:"pixelate",label:"Pixelate",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="4" height="4" fill="currentColor"/><rect x="10" y="3" width="4" height="4" fill="currentColor"/><rect x="17" y="3" width="4" height="4" fill="currentColor"/><rect x="3" y="10" width="4" height="4" fill="currentColor"/><rect x="10" y="10" width="4" height="4" fill="currentColor"/><rect x="17" y="10" width="4" height="4" fill="currentColor"/><rect x="3" y="17" width="4" height="4" fill="currentColor"/><rect x="10" y="17" width="4" height="4" fill="currentColor"/><rect x="17" y="17" width="4" height="4" fill="currentColor"/></svg>'})]}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:pg.map(k=>p("button",{class:$t("w-6 h-6 rounded-full border-2 border-solid cursor-pointer transition-transform hover:scale-110",l===k?"border-gray-800 scale-110":"border-transparent"),style:{backgroundColor:k},onClick:()=>c(k),title:k},k))}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:mg.map(k=>p("button",{class:$t("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent cursor-pointer transition-colors","hover:bg-gray-100",h===k&&"bg-primary/10"),onClick:()=>u(k),title:`${k}px`,children:p("span",{class:"w-5 bg-gray-800 rounded-full",style:{height:`${k}px`}})},k))}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:[p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:V,disabled:!d,title:"Undo (Ctrl+Z)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:z,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:K,title:"Delete selected (Del)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:[p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:bt,disabled:y<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:gt,title:`Reset Zoom (${Math.round(y*100)}%) - Hold Space to pan`,children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:L,disabled:y>=3,title:"Zoom In - Hold Space to pan when zoomed",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z",fill:"currentColor"})})})]})]}),p("div",{class:"min-h-[600px] min-w-[700px] max-h-[70vh] overflow-auto flex items-center justify-center p-4 bg-gray-800",ref:s,children:p("canvas",{ref:r})}),p("div",{class:"flex gap-3 p-4 border-t border-solid border-border bg-muted",children:[p(oe,{variant:"outline",class:"flex-1",onClick:e,children:"Cancel"}),p(oe,{class:"flex-1",onClick:q,children:"Done"})]})]})};function xg(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),s=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(s),t&&(r.href=t),s.href=i,s.href}const wg=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function De(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let Ke=null;function Gl(i={}){return Ke||(i.includeStyleProperties?(Ke=i.includeStyleProperties,Ke):(Ke=De(window.getComputedStyle(document.documentElement)),Ke))}function Js(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function _g(i){const t=Js(i,"border-left-width"),e=Js(i,"border-right-width");return i.clientWidth+t+e}function Cg(i){const t=Js(i,"border-top-width"),e=Js(i,"border-bottom-width");return i.clientHeight+t+e}function Nl(i,t={}){const e=t.width||_g(i),r=t.height||Cg(i);return{width:e,height:r}}function Sg(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const Bt=16384;function kg(i){(i.width>Bt||i.height>Bt)&&(i.width>Bt&&i.height>Bt?i.width>i.height?(i.height*=Bt/i.width,i.width=Bt):(i.width*=Bt/i.height,i.height=Bt):i.width>Bt?(i.height*=Bt/i.width,i.width=Bt):(i.width*=Bt/i.height,i.height=Bt))}function Qs(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function Tg(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Og(i,t,e){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${e}`),s.setAttribute("viewBox",`0 0 ${t} ${e}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(i),Tg(s)}const Ft=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||Ft(e,t)};function Dg(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function Mg(i,t){return Gl(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function Eg(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?Dg(e):Mg(e,r);return document.createTextNode(`${s}{${n}}`)}function Uo(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=wg();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Eg(o,e,s,r)),t.appendChild(a)}function Pg(i,t,e){Uo(i,t,":before",e),Uo(i,t,":after",e)}const Go="application/font-woff",No="image/jpeg",Ag={woff:Go,woff2:Go,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:No,jpeg:No,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Lg(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function Wn(i){const t=Lg(i).toLowerCase();return Ag[t]||""}function Fg(i){return i.split(/,/)[1]}function hn(i){return i.search(/^(data:)/)!==-1}function jg(i,t){return`data:${t};base64,${i}`}async function ql(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const Fi={};function Ig(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Xn(i,t,e){const r=Ig(i,t,e.includeQueryParams);if(Fi[r]!=null)return Fi[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await ql(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Fg(a)));s=jg(n,t)}catch(n){s=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return Fi[r]=s,s}async function Bg(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):Qs(t)}async function Rg(i,t){if(i.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=i.clientWidth,n.height=i.clientHeight,o==null||o.drawImage(i,0,0,n.width,n.height);const a=n.toDataURL();return Qs(a)}const e=i.poster,r=Wn(e),s=await Xn(e,r,t);return Qs(s)}async function $g(i,t){var e;try{if(!((e=i==null?void 0:i.contentDocument)===null||e===void 0)&&e.body)return await gi(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function zg(i,t){return Ft(i,HTMLCanvasElement)?Bg(i):Ft(i,HTMLVideoElement)?Rg(i,t):Ft(i,HTMLIFrameElement)?$g(i,t):i.cloneNode(Kl(i))}const Hg=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",Kl=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function Vg(i,t,e){var r,s;if(Kl(t))return t;let n=[];return Hg(i)&&i.assignedNodes?n=De(i.assignedNodes()):Ft(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=De(i.contentDocument.body.childNodes):n=De(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||Ft(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>gi(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function Wg(i,t,e){const r=t.style;if(!r)return;const s=window.getComputedStyle(i);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):Gl(e).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),Ft(i,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function Xg(i,t){Ft(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),Ft(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function Yg(i,t){if(Ft(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Ug(i,t,e){return Ft(t,Element)&&(Wg(i,t,e),Pg(i,t,e),Xg(i,t),Yg(i,t)),t}async function Gg(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let n=0;n<e.length;n++){const a=e[n].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await gi(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);i.appendChild(o)}return i}async function gi(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>zg(r,t)).then(r=>Vg(i,r,t)).then(r=>Ug(i,r,t)).then(r=>Gg(r,t))}const Zl=/url\((['"]?)([^'"]+?)\1\)/g,Ng=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,qg=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Kg(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Zg(i){const t=[];return i.replace(Zl,(e,r,s)=>(t.push(s),e)),t.filter(e=>!hn(e))}async function Jg(i,t,e,r,s){try{const n=e?xg(t,e):t,o=Wn(t);let a;return s||(a=await Xn(n,o,r)),i.replace(Kg(t),`$1${a}$3`)}catch{}return i}function Qg(i,{preferredFontFormat:t}){return t?i.replace(qg,e=>{for(;;){const[r,,s]=Ng.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function Jl(i){return i.search(Zl)!==-1}async function Ql(i,t,e){if(!Jl(i))return i;const r=Qg(i,e);return Zg(r).reduce((n,o)=>n.then(a=>Jg(a,o,t,e)),Promise.resolve(r))}async function Ze(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await Ql(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function tf(i,t){await Ze("background",i,t)||await Ze("background-image",i,t),await Ze("mask",i,t)||await Ze("-webkit-mask",i,t)||await Ze("mask-image",i,t)||await Ze("-webkit-mask-image",i,t)}async function ef(i,t){const e=Ft(i,HTMLImageElement);if(!(e&&!hn(i.src))&&!(Ft(i,SVGImageElement)&&!hn(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await Xn(r,Wn(r),t);await new Promise((n,o)=>{i.onload=n,i.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=s):i.href.baseVal=s})}async function rf(i,t){const r=De(i.childNodes).map(s=>tc(s,t));await Promise.all(r).then(()=>i)}async function tc(i,t){Ft(i,Element)&&(await tf(i,t),await ef(i,t),await rf(i,t))}function sf(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{e[s]=r[s]}),i}const qo={};async function Ko(i){let t=qo[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},qo[i]=t,t}async function Zo(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),ql(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function Jo(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function nf(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{De(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=Ko(l).then(h=>Zo(h,t)).then(h=>Jo(h).forEach(u=>{try{s.insertRule(u,u.startsWith("@import")?a+=1:s.cssRules.length)}catch(d){console.error("Error inserting rule from remote css",{rule:u,error:d})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(n){const o=i.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(Ko(s.href).then(a=>Zo(a,t)).then(a=>Jo(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(i.forEach(s=>{if("cssRules"in s)try{De(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function of(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Jl(t.style.getPropertyValue("src")))}async function af(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=De(i.ownerDocument.styleSheets),r=await nf(e,t);return of(r)}function ec(i){return i.trim().replace(/["']/g,"")}function lf(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(ec(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function cf(i,t){const e=await af(i,t),r=lf(i);return(await Promise.all(e.filter(n=>r.has(ec(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return Ql(n.cssText,o,t)}))).join(`
540
+ `)}async function hf(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await cf(i,t);if(e){const r=document.createElement("style"),s=document.createTextNode(e);r.appendChild(s),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function uf(i,t={}){const{width:e,height:r}=Nl(i,t),s=await gi(i,t,!0);return await hf(s,t),await tc(s,t),sf(s,t),await Og(s,e,r)}async function ji(i,t={}){const{width:e,height:r}=Nl(i,t),s=await uf(i,t),n=await Qs(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Sg(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||kg(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}const df=2,Je=16384,_s=4e7,rc="data-bugpin-exclude";async function gf(){document.fonts&&document.fonts.ready&&await document.fonts.ready}async function ff(i){const t=i.querySelectorAll("img"),e=[];t.forEach(r=>{r.complete?r.decode&&e.push(r.decode().catch(()=>{})):e.push(new Promise(s=>{const n=async()=>{if(r.removeEventListener("load",n),r.removeEventListener("error",o),r.decode)try{await r.decode()}catch{}s()},o=()=>{r.removeEventListener("load",n),r.removeEventListener("error",o),s()};r.addEventListener("load",n,{once:!0}),r.addEventListener("error",o,{once:!0})}))}),e.length>0&&await Promise.all(e)}function Ii(i,t,e="visible"){const r=Math.ceil(i),s=Math.ceil(t);if(r>Je||s>Je)throw e==="fullpage"?new Error(`Full page dimensions (${r}x${s}) exceed maximum canvas size (${Je}px). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot dimensions (${r}x${s}) exceed maximum canvas size (${Je}px). Try capturing a smaller element or use visible viewport mode.`);if(r*s>_s)throw e==="fullpage"?new Error(`Full page total pixels (${r*s}) exceed maximum (${_s}). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot total pixels (${r*s}) exceed maximum (${_s}). Try capturing a smaller element or use visible viewport mode.`);let n=Math.min(window.devicePixelRatio||1,df),o=r*n,a=s*n,l=o*a;for(;n>1&&(o>Je||a>Je||l>_s);)n-=.5,o=r*n,a=s*n,l=o*a;return Math.max(1,n)}function Bi(i){return!(i instanceof HTMLElement&&(i.tagName==="SCRIPT"||i.hasAttribute(rc)))}function pf(){if(window.scrollY>0||window.scrollX>0)return null;const i=document.querySelectorAll("*");for(const t of i){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t),r=e.overflowY,s=e.overflowX;if(r==="auto"||r==="scroll"||s==="auto"||s==="scroll"){const o=t.scrollHeight>t.clientHeight&&t.scrollTop>0,a=t.scrollWidth>t.clientWidth&&t.scrollLeft>0;if(o||a)return t}}return null}function Ri(){const i=window.getComputedStyle(document.body).backgroundColor,t=window.getComputedStyle(document.documentElement).backgroundColor,e=r=>!r||r==="transparent"||r==="rgba(0, 0, 0, 0)";return e(i)?e(t)?"#ffffff":t:i}const mf="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAA0lEQVQI12P4z8BQDwAEgAF/QualzQAAAABJRU5ErkJggg==";function vf(){try{for(const i of document.styleSheets)if(i.href)try{i.cssRules}catch{return!0}}catch{return!0}return!1}function $i(){const i=vf();return i&&console.log("[BugPin] Cross-origin stylesheets detected, skipping font embedding"),{skipFonts:i,imagePlaceholder:mf,onImageErrorHandler:()=>{}}}function yf(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}async function bf(){if(!yf())throw new Error("Screen Capture API is not available. The host page must be served over HTTPS and include the header: Permissions-Policy: display-capture=self");const i=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0});try{const t=document.createElement("video");t.srcObject=i,t.autoplay=!0,await new Promise(s=>{t.onloadedmetadata=()=>s()}),await new Promise(s=>setTimeout(s,100));const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;const r=e.getContext("2d");if(!r)throw new Error("Failed to get canvas context");return r.drawImage(t,0,0),e.toDataURL("image/png")}finally{i.getTracks().forEach(t=>t.stop())}}async function xf(i={}){const{method:t="visible",selector:e,useScreenCaptureAPI:r=!1,cacheBust:s}=i;if(r)try{return await bf()}catch(g){console.warn("[BugPin] Screen Capture API unavailable, falling back to DOM capture.","Ensure the page is served over HTTPS and the browser has screen recording permission.",`(${g instanceof Error?g.message:g})`)}let n;switch(t){case"element":if(!e)throw new Error("Selector required for element capture");const g=document.querySelector(e);if(!g||!(g instanceof HTMLElement))throw new Error(`Element not found: ${e}`);n=g;break;case"fullpage":case"visible":default:n=document.documentElement;break}const o=pf();let a,l,c,h;o&&o!==document.documentElement&&o!==document.body?(a=o.scrollLeft,l=o.scrollTop,c=o.clientWidth,h=o.clientHeight,t==="visible"&&(n=o)):(a=window.scrollX||window.pageXOffset||0,l=window.scrollY||window.pageYOffset||0,c=document.documentElement.clientWidth,h=document.documentElement.clientHeight);const u=document.querySelectorAll(`[${rc}]`),d=new Map;u.forEach(g=>{g instanceof HTMLElement&&(d.set(g,g.style.visibility),g.style.visibility="hidden")});try{if(await gf(),await ff(n),t==="visible"){const x=Ii(c,h,"visible"),T=Ri(),C=a+c,S=l+h;console.log("[BugPin] Capture debug:",{scrollX:a,scrollY:l,viewportWidth:c,viewportHeight:h,captureWidth:C,captureHeight:S,dpr:x});const D={...$i(),cacheBust:s??!1,pixelRatio:x,width:C,height:S,backgroundColor:T,filter:Bi},A=await ji(n,D);console.log("[BugPin] Canvas captured:",{canvasWidth:A.width,canvasHeight:A.height,expectedWidth:C*x,expectedHeight:S*x});const _=document.createElement("canvas");_.width=c*x,_.height=h*x;const M=_.getContext("2d");if(!M)throw new Error("Failed to get canvas context");return M.fillStyle=T,M.fillRect(0,0,_.width,_.height),M.drawImage(A,a*x,l*x,c*x,h*x,0,0,c*x,h*x),_.toDataURL("image/png")}if(t==="fullpage"){const x=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth),T=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight),C=Ii(x,T,"fullpage"),S=Ri(),D={...$i(),cacheBust:s??!0,pixelRatio:C,width:x,height:T,backgroundColor:S,filter:Bi};return(await ji(n,D)).toDataURL("image/png")}const g=n.getBoundingClientRect(),f=Ii(g.width,g.height,"element"),m=Ri(),y={...$i(),cacheBust:s??!1,pixelRatio:f,backgroundColor:m,filter:Bi};return(await ji(n,y)).toDataURL("image/png")}finally{u.forEach(g=>{g instanceof HTMLElement&&(g.style.visibility=d.get(g)||"")})}}function sc(i){const t=i.split(","),e=t[0].match(/:(.*?);/),r=e?e[1]:"image/png",s=atob(t[1]),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}function ic(i){return i.startsWith("data:image/webp")?"webp":i.startsWith("data:image/jpeg")?"jpg":i.startsWith("data:image/gif")?"gif":"png"}const rr=[],Gr=[],Nr=[],wf=30;let Qo=!1;function _f(){if(Qo)return;Qo=!0;const i=console.error;console.error=(...o)=>{rr.push({type:"error",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),i.apply(console,o)};const t=console.warn;console.warn=(...o)=>{rr.push({type:"warn",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),t.apply(console,o)};const e=window.onerror;window.onerror=(o,a,l,c,h)=>(rr.push({type:"error",message:String(o),source:a||void 0,line:l||void 0,timestamp:new Date().toISOString()}),e?e.apply(window,[o,a,l,c,h]):!1),window.addEventListener("unhandledrejection",o=>{rr.push({type:"error",message:`Unhandled Promise Rejection: ${String(o.reason)}`,timestamp:new Date().toISOString()})});const r=window.fetch.bind(window);window.fetch=async function(o,a){const l=typeof o=="string"?o:o instanceof URL?o.href:o.url,c=(a==null?void 0:a.method)||"GET";try{const h=await r(o,a);return h.status>=300&&Gr.push({url:l,method:c,status:h.status,statusText:h.statusText,timestamp:new Date().toISOString()}),h}catch(h){throw Gr.push({url:l,method:c,status:0,statusText:h instanceof Error?h.message:"Network Error",timestamp:new Date().toISOString()}),h}};const s=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(o,a){return this._bugpinMethod=o,this._bugpinUrl=typeof a=="string"?a:a.href,s.apply(this,arguments)},XMLHttpRequest.prototype.send=function(){return this.addEventListener("load",function(){this.status>=300&&Gr.push({url:this._bugpinUrl||"",method:this._bugpinMethod||"GET",status:this.status,statusText:this.statusText,timestamp:new Date().toISOString()})}),n.apply(this,arguments)},document.addEventListener("click",o=>{var c,h,u,d;const a=o.target;if(!a||a.closest("[data-bugpin-exclude]"))return;let l=null;if(a.tagName==="BUTTON"||a.closest("button"))l={type:"button",text:((c=(a.tagName==="BUTTON"?a:a.closest("button")).textContent)==null?void 0:c.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()};else if(a.tagName==="A"||a.closest("a")){const g=a.tagName==="A"?a:a.closest("a");l={type:"link",text:((h=g.textContent)==null?void 0:h.trim().slice(0,50))||void 0,url:g.href||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"&&a.type==="checkbox"){const g=a;l={type:"checkbox",text:g.name||g.id||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"){const g=a;l={type:"input",inputType:g.type||"text",text:g.name||((u=g.placeholder)==null?void 0:u.slice(0,30))||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="SELECT"||a.closest('[role="combobox"]')){const g=a.tagName==="SELECT"?a:null;l={type:"select",text:(g==null?void 0:g.name)||void 0,timestamp:new Date().toISOString()}}else(a.onclick||a.getAttribute("role")==="button"||a.classList.contains("btn")||a.closest('[role="button"]'))&&(l={type:"other",text:((d=a.textContent)==null?void 0:d.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()});l&&Cf(l)},!0)}function Cf(i){Nr.push(i),Nr.length>wf&&Nr.shift()}function Sf(){var r,s,n,o,a;const i=navigator.userAgent;let t="Unknown",e="";return i.includes("Firefox/")?(t="Firefox",e=((r=i.match(/Firefox\/([\d.]+)/))==null?void 0:r[1])||""):i.includes("Edg/")?(t="Edge",e=((s=i.match(/Edg\/([\d.]+)/))==null?void 0:s[1])||""):i.includes("Chrome/")?(t="Chrome",e=((n=i.match(/Chrome\/([\d.]+)/))==null?void 0:n[1])||""):i.includes("Safari/")&&!i.includes("Chrome")?(t="Safari",e=((o=i.match(/Version\/([\d.]+)/))==null?void 0:o[1])||""):(i.includes("Opera/")||i.includes("OPR/"))&&(t="Opera",e=((a=i.match(/(?:Opera|OPR)\/([\d.]+)/))==null?void 0:a[1])||""),{name:t,version:e,userAgent:i}}function kf(){var s,n,o,a,l;const i=navigator.userAgent;let t="desktop",e="Unknown",r;if(/Mobi|Android|iPhone|iPad|iPod/i.test(i)&&(/iPad|Tablet/i.test(i)||window.innerWidth>=768&&/Android/i.test(i)?t="tablet":t="mobile"),i.includes("Windows")){e="Windows";const c=i.match(/Windows NT ([\d.]+)/);if(c){const h=c[1];r={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista"}[h]||h}}else i.includes("Mac OS X")?(e="macOS",r=(n=(s=i.match(/Mac OS X ([\d._]+)/))==null?void 0:s[1])==null?void 0:n.replace(/_/g,".")):i.includes("Linux")?(e=i.includes("Android")?"Android":"Linux",e==="Android"&&(r=(o=i.match(/Android ([\d.]+)/))==null?void 0:o[1])):(i.includes("iPhone")||i.includes("iPad"))&&(e="iOS",r=(l=(a=i.match(/OS ([\d_]+)/))==null?void 0:a[1])==null?void 0:l.replace(/_/g,"."));return{type:t,os:e,osVersion:r}}function Tf(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function Of(){const i={cookies:[],localStorage:[],sessionStorage:[]};try{const t=document.cookie;t&&(i.cookies=t.split(";").map(e=>e.split("=")[0].trim()))}catch{}try{for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&i.localStorage.push(e)}}catch{}try{for(let t=0;t<sessionStorage.length;t++){const e=sessionStorage.key(t);e&&i.sessionStorage.push(e)}}catch{}return i}function Df(){try{const i=performance.getEntriesByType("navigation");if(i.length>0){const t=i[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function Mf(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:Sf(),device:kf(),viewport:Tf(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:Df(),consoleErrors:rr.length>0?[...rr]:void 0,networkErrors:Gr.length>0?[...Gr]:void 0,userActivity:Nr.length>0?[...Nr]:void 0,storageKeys:Of()}}const un=(i,t)=>t.some(e=>i instanceof e);let ta,ea;function Ef(){return ta||(ta=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Pf(){return ea||(ea=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const dn=new WeakMap,zi=new WeakMap,fi=new WeakMap;function Af(i){const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("success",n),i.removeEventListener("error",o)},n=()=>{e(Ve(i.result)),s()},o=()=>{r(i.error),s()};i.addEventListener("success",n),i.addEventListener("error",o)});return fi.set(t,i),t}function Lf(i){if(dn.has(i))return;const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("complete",n),i.removeEventListener("error",o),i.removeEventListener("abort",o)},n=()=>{e(),s()},o=()=>{r(i.error||new DOMException("AbortError","AbortError")),s()};i.addEventListener("complete",n),i.addEventListener("error",o),i.addEventListener("abort",o)});dn.set(i,t)}let gn={get(i,t,e){if(i instanceof IDBTransaction){if(t==="done")return dn.get(i);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Ve(i[t])},set(i,t,e){return i[t]=e,!0},has(i,t){return i instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in i}};function nc(i){gn=i(gn)}function Ff(i){return Pf().includes(i)?function(...t){return i.apply(fn(this),t),Ve(this.request)}:function(...t){return Ve(i.apply(fn(this),t))}}function jf(i){return typeof i=="function"?Ff(i):(i instanceof IDBTransaction&&Lf(i),un(i,Ef())?new Proxy(i,gn):i)}function Ve(i){if(i instanceof IDBRequest)return Af(i);if(zi.has(i))return zi.get(i);const t=jf(i);return t!==i&&(zi.set(i,t),fi.set(t,i)),t}const fn=i=>fi.get(i);function oc(i,t,{blocked:e,upgrade:r,blocking:s,terminated:n}={}){const o=indexedDB.open(i,t),a=Ve(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Ve(o.result),l.oldVersion,l.newVersion,Ve(o.transaction),l)}),e&&o.addEventListener("blocked",l=>e(l.oldVersion,l.newVersion,l)),a.then(l=>{n&&l.addEventListener("close",()=>n()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const If=["get","getKey","getAll","getAllKeys","count"],Bf=["put","add","delete","clear"],Hi=new Map;function ra(i,t){if(!(i instanceof IDBDatabase&&!(t in i)&&typeof t=="string"))return;if(Hi.get(t))return Hi.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=Bf.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||If.includes(e)))return;const n=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[e](...a),s&&l.done]))[0]};return Hi.set(t,n),n}nc(i=>({...i,get:(t,e,r)=>ra(t,e)||i.get(t,e,r),has:(t,e)=>!!ra(t,e)||i.has(t,e)}));const Rf=["continue","continuePrimaryKey","advance"],sa={},pn=new WeakMap,ac=new WeakMap,$f={get(i,t){if(!Rf.includes(t))return i[t];let e=sa[t];return e||(e=sa[t]=function(...r){pn.set(this,ac.get(this)[t](...r))}),e}};async function*zf(...i){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...i)),!t)return;t=t;const e=new Proxy(t,$f);for(ac.set(e,t),fi.set(e,fn(t));t;)yield e,t=await(pn.get(e)||t.continue()),pn.delete(e)}function ia(i,t){return t===Symbol.asyncIterator&&un(i,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&un(i,[IDBIndex,IDBObjectStore])}nc(i=>({...i,get(t,e,r){return ia(t,e)?zf:i.get(t,e,r)},has(t,e){return ia(t,e)||i.has(t,e)}}));const Hf="bugpin-reports",Vf=2,cr="pending-reports",na=5,Wf=5e3,Xf=3e5,Yf=2;let Cs=null,oa=null;function Uf(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function pi(){if(Cs)return Cs;try{return Cs=await oc(Hf,Vf,{upgrade(i){i.objectStoreNames.contains(cr)||i.createObjectStore(cr,{keyPath:"id"}).createIndex("by-created","createdAt")}}),Cs}catch(i){throw console.error("[BugPin] Failed to initialize IndexedDB:",i),i}}function Gf(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function ti(){return navigator.onLine!==!1}function Nf(i){const t=Wf*Math.pow(Yf,i);return Math.min(t,Xf)}async function aa(i){const t=await pi(),e={...i,id:Gf(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(cr,e),console.log("[BugPin] Report buffered for later submission:",e.id),ti()&&Is().catch(console.error),e.id}async function qf(){try{return await(await pi()).getAllFromIndex(cr,"by-created")}catch{return[]}}async function la(i){try{await(await pi()).delete(cr,i),console.log("[BugPin] Removed buffered report:",i)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function Kf(i){try{await(await pi()).put(cr,i)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function Zf(i){var t,e;try{const r=new URL("/api/widget/submit",i.serverUrl),s=new FormData;if(s.append("data",JSON.stringify({title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,metadata:i.metadata,mediaCount:((t=i.media)==null?void 0:t.length)||0,mediaAnnotations:(e=i.media)==null?void 0:e.map(o=>o.annotations).filter(Boolean)})),i.media&&i.media.length>0)for(let o=0;o<i.media.length;o++){const a=i.media[o],l=sc(a.dataUrl),c=ic(a.dataUrl)||Uf(a.mimeType),u=a.mimeType.startsWith("video/")?"video":"screenshot";s.append("media",l,`${u}-${o}.${c}`)}const n=await fetch(r.toString(),{method:"POST",body:s,headers:{"x-api-key":i.apiKey}});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.message||`HTTP ${n.status}`)}return!0}catch(r){throw console.error("[BugPin] Failed to submit buffered report:",r),r}}async function Is(){if(!ti())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const i=await qf();if(i.length===0)return{synced:0,failed:0};console.log(`[BugPin] Syncing ${i.length} pending reports...`);let t=0,e=0;for(const r of i){if(r.lastRetryAt){const n=new Date(r.lastRetryAt).getTime()+Nf(r.retryCount);if(Date.now()<n)continue}try{await Zf(r),await la(r.id),t++,console.log("[BugPin] Successfully synced report:",r.id)}catch(s){e++,r.retryCount++,r.lastRetryAt=new Date().toISOString(),r.error=s instanceof Error?s.message:"Unknown error",r.retryCount>=na?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await la(r.id)):(await Kf(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${na}):`,r.id))}}return{synced:t,failed:e}}function Jf(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),Is().catch(console.error)}),oa||(oa=setInterval(()=>{ti()&&Is().catch(console.error)},3e4)),ti()&&Is().catch(console.error)}Jf();function Qf(){return navigator.onLine!==!1}function tp(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function ep(i){const{apiKey:t,serverUrl:e,media:r,...s}=i;if(!Qf())return console.log("[BugPin] Offline, buffering report for later submission"),await aa({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when you're back online."};const n=new URL("/api/widget/submit",e),o=new FormData;if(o.append("data",JSON.stringify({title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,metadata:s.metadata,mediaCount:(r==null?void 0:r.length)||0,mediaAnnotations:r==null?void 0:r.map(a=>a.annotations).filter(Boolean)})),r&&r.length>0)for(let a=0;a<r.length;a++){const l=r[a],c=sc(l.dataUrl),h=ic(l.dataUrl)||tp(l.mimeType),d=l.mimeType.startsWith("video/")?"video":"screenshot";console.log(`[BugPin] Media ${a}: dataUrl length=${l.dataUrl.length}, blob size=${c.size}, type=${c.type}`),o.append("media",c,`${d}-${a}.${h}`)}try{const a=await fetch(n.toString(),{method:"POST",body:o,headers:{"x-api-key":t}}),l=await a.json();if(!a.ok||!l.success)throw new Error(l.message||l.error||"Failed to submit report");return l}catch(a){if(a instanceof TypeError&&a.message.includes("fetch"))return console.log("[BugPin] Network error, buffering report for later submission"),await aa({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when the connection is restored."};throw a}}const rp="bugpin-drafts",sp=1,hr="draft-media",ip="bugpin-draft-";let Ss=null;async function mi(){if(Ss)return Ss;try{return Ss=await oc(rp,sp,{upgrade(i){i.objectStoreNames.contains(hr)||i.createObjectStore(hr,{keyPath:"apiKey"})}}),Ss}catch(i){throw console.error("[BugPin] Failed to initialize draft database:",i),i}}function Yn(i){return`${ip}${i}`}function np(i,t,e){try{const r={formData:t,activeTab:e,savedAt:new Date().toISOString()};localStorage.setItem(Yn(i),JSON.stringify(r))}catch(r){console.error("[BugPin] Failed to save form draft:",r)}}function lc(i){try{const t=localStorage.getItem(Yn(i));return t?JSON.parse(t):null}catch(t){return console.error("[BugPin] Failed to load form draft:",t),null}}function op(i){try{localStorage.removeItem(Yn(i))}catch(t){console.error("[BugPin] Failed to clear form draft:",t)}}async function ap(i,t){try{await(await mi()).put(hr,{apiKey:i,media:t,savedAt:new Date().toISOString()})}catch(e){console.error("[BugPin] Failed to save media draft:",e)}}async function lp(i){try{const e=await(await mi()).get(hr,i);return(e==null?void 0:e.media)||[]}catch(t){return console.error("[BugPin] Failed to load media draft:",t),[]}}async function cc(i){try{await(await mi()).delete(hr,i)}catch(t){console.error("[BugPin] Failed to clear media draft:",t)}}async function cp(i){if(lc(i))return!0;try{const r=await(await mi()).get(hr,i);return r!==void 0&&r.media.length>0}catch{return!1}}async function hp(i,t,e,r){np(i,t,e),r.length>0?await ap(i,r):await cc(i)}async function up(i){const t=lc(i),e=await lp(i);return!t&&e.length===0?null:{formData:(t==null?void 0:t.formData)||{title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},activeTab:(t==null?void 0:t.activeTab)||"details",media:e}}async function dp(i){op(i),await cc(i)}const ks={save:hp,load:up,clear:dp,has:cp},Vi={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},gp=({config:i,deps:t})=>{const e=(t==null?void 0:t.WidgetDialog)??Yh,r=(t==null?void 0:t.AnnotationCanvas)??bg,s=(t==null?void 0:t.captureScreenshot)??xf,n=(t==null?void 0:t.captureContext)??Mf,o=(t==null?void 0:t.submitReport)??ep,a=Rt(null),l=Ha(i.theme),[c,h]=at("closed"),[u,d]=at(!1),[g,f]=at(!1),[m,y]=at([]),[b,x]=at(null),[T,C]=at(null),[S,D]=at("details"),[A,_]=at(Vi),[M,O]=at(!1),[V,z]=at(!1),[X,W]=at(!1);Vt(()=>{c==="form"&&!M&&ks.load(i.apiKey).then(F=>{F&&(_(F.formData),D(F.activeTab),y(F.media)),O(!0)})},[c,M,i.apiKey]),Vt(()=>{const F=a.current;F&&(l==="dark"?(F.style.setProperty("--button-color",i.dialogDarkButtonColor),F.style.setProperty("--button-text-color",i.dialogDarkTextColor),F.style.setProperty("--button-hover-color",i.dialogDarkButtonHoverColor),F.style.setProperty("--button-hover-text-color",i.dialogDarkTextHoverColor),F.style.setProperty("--background",i.dialogDarkBackgroundColor),F.style.setProperty("--muted",i.dialogDarkSecondaryColor),F.style.setProperty("--input-background",i.dialogDarkInputColor),F.style.setProperty("--foreground",i.dialogDarkForegroundColor)):(F.style.setProperty("--button-color",i.dialogLightButtonColor),F.style.setProperty("--button-text-color",i.dialogLightTextColor),F.style.setProperty("--button-hover-color",i.dialogLightButtonHoverColor),F.style.setProperty("--button-hover-text-color",i.dialogLightTextHoverColor),F.style.setProperty("--background",i.dialogLightBackgroundColor),F.style.setProperty("--muted",i.dialogLightSecondaryColor),F.style.setProperty("--input-background",i.dialogLightInputColor),F.style.setProperty("--foreground",i.dialogLightForegroundColor)))},[l,i.dialogLightButtonColor,i.dialogLightTextColor,i.dialogLightButtonHoverColor,i.dialogLightTextHoverColor,i.dialogLightBackgroundColor,i.dialogLightSecondaryColor,i.dialogLightInputColor,i.dialogLightForegroundColor,i.dialogDarkButtonColor,i.dialogDarkTextColor,i.dialogDarkButtonHoverColor,i.dialogDarkTextHoverColor,i.dialogDarkBackgroundColor,i.dialogDarkSecondaryColor,i.dialogDarkInputColor,i.dialogDarkForegroundColor]);const G=N(()=>{h("form")},[]),q=A.title.trim()||A.description.trim()||A.reporterEmail.trim()||A.reporterName.trim()||m.length>0,K=N(()=>{q?z(!0):(h("closed"),x(null),O(!1))},[q]),L=N(()=>{ks.save(i.apiKey,A,S,m),z(!1),h("closed"),x(null),O(!1)},[i.apiKey,A,S,m]),bt=N(()=>{y([]),D("details"),_(Vi),ks.clear(i.apiKey),z(!1),h("closed"),x(null),O(!1)},[i.apiKey]),gt=N((F=!1)=>{F===!0&&(y([]),D("details"),_(Vi),ks.clear(i.apiKey)),z(!1),h("closed"),x(null),O(!1)},[i.apiKey]);Vt(()=>{const F=()=>G(),J=()=>K();return document.addEventListener("bugpin:open",F),document.addEventListener("bugpin:close",J),()=>{document.removeEventListener("bugpin:open",F),document.removeEventListener("bugpin:close",J)}},[G,K]);const lt=N(async()=>{if(i.enableScreenshot){if(i.useScreenCaptureAPI&&!X&&!(localStorage.getItem("bugpin-skip-screen-capture-consent")==="true")){W(!0);return}W(!1),f(!0),h("closed"),await new Promise(F=>setTimeout(F,100));try{const F=await s({method:i.captureMethod,useScreenCaptureAPI:i.useScreenCaptureAPI}),J=new Image;J.onload=()=>{console.log(`[BugPin] Captured screenshot: ${J.width}x${J.height}, dataUrl length=${F.length}`);const tt={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:F,timestamp:new Date,annotated:!1,mimeType:"image/png",width:J.width,height:J.height};y(xt=>[...xt,tt]),f(!1),D("media"),h("form")},J.onerror=()=>{const tt={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:F,timestamp:new Date,annotated:!1,mimeType:"image/png"};y(xt=>[...xt,tt]),f(!1),D("media"),h("form")},J.src=F}catch(F){console.error("[BugPin] Failed to capture screenshot:",F),f(!1),h("form"),C({message:"Failed to capture screenshot",type:"error"})}}},[i,s,X]),k=N(()=>{lt()},[lt]),P=N(()=>{W(!1)},[]),E=N(F=>{y(J=>[...J,F])},[]),B=N(F=>{y(J=>J.filter(tt=>tt.id!==F))},[]),j=N(F=>{x(F),h("annotating")},[]),H=N((F,J)=>{b&&y(tt=>tt.map(xt=>xt.id===b?{...xt,dataUrl:F,annotated:!0,annotations:J}:xt)),x(null),h("form")},[b]),ut=N(()=>{x(null),h("form")},[]),ct=N(async(F,J)=>{d(!0);try{const tt=n();await o({apiKey:i.apiKey,serverUrl:i.serverUrl,title:F.title,description:F.description,priority:F.priority,reporterEmail:F.reporterEmail||void 0,reporterName:F.reporterName||void 0,media:J.map(xt=>({dataUrl:xt.dataUrl,mimeType:xt.mimeType,annotations:xt.annotations})),metadata:tt}),C({message:"Bug report submitted successfully!",type:"success"}),gt(!0)}catch(tt){console.error("[BugPin] Failed to submit report:",tt),C({message:tt instanceof Error?tt.message:"Failed to submit report",type:"error"})}finally{d(!1)}},[i,gt,n,o]),st=N(()=>{C(null)},[]),St=b?m.find(F=>F.id===b):null;return p("div",{ref:a,class:`bugpin-container bugpin-theme-${l}`,children:[p(Mh,{position:i.position,buttonText:i.buttonText,buttonShape:i.buttonShape,buttonIcon:i.buttonIcon,buttonIconSize:i.buttonIconSize,buttonIconStroke:i.buttonIconStroke,theme:i.theme,lightButtonColor:i.lightButtonColor,lightTextColor:i.lightTextColor,lightButtonHoverColor:i.lightButtonHoverColor,lightTextHoverColor:i.lightTextHoverColor,darkButtonColor:i.darkButtonColor,darkTextColor:i.darkTextColor,darkButtonHoverColor:i.darkButtonHoverColor,darkTextHoverColor:i.darkTextHoverColor,enableHoverScaleEffect:i.enableHoverScaleEffect,tooltipEnabled:i.tooltipEnabled,tooltipText:i.tooltipText,onClick:G}),c==="annotating"&&St&&p("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative max-w-4xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",children:p(r,{screenshot:St.dataUrl,onSave:H,onCancel:ut})})}),c==="form"&&p(e,{onClose:K,onSubmit:ct,onCaptureScreenshot:lt,onAnnotateMedia:j,media:m,onAddMedia:E,onRemoveMedia:B,isSubmitting:u,isCapturing:g,enableAnnotation:i.enableAnnotation,maxImageSize:i.maxImageUploadSize,maxVideoSize:i.maxVideoUploadSize,activeTab:S,onActiveTabChange:D,formData:A,onFormDataChange:_,showScreenCaptureConsent:X,onConsentConfirm:k,onConsentCancel:P}),V&&p("div",{class:"fixed inset-0 z-[2147483647] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative w-full max-w-sm bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-confirm-title",children:p("div",{class:"p-6",children:[p("h1",{id:"bugpin-confirm-title",class:"tracking-tight mb-2",children:"Save draft?"}),p("p",{class:"text-sm text-muted-foreground mb-6",children:"You have unsaved changes. Would you like to save them as a draft for later?"}),p("div",{class:"flex gap-3",children:[p("button",{type:"button",onClick:bt,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-border bg-background text-foreground hover:bg-muted transition-colors",children:"Discard"}),p("button",{type:"button",onClick:L,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-transparent text-[var(--button-text-color)] bg-[var(--button-color)] hover:bg-[var(--button-hover-color)] hover:text-[var(--button-hover-text-color)] transition-colors",children:"Save Draft"})]})]})})}),T&&p(Ih,{message:T.message,type:T.type,onClose:st})]})},mn={apiKey:"",serverUrl:window.location.origin,position:"bottom-right",buttonText:null,buttonShape:"round",buttonIcon:"bug",buttonIconSize:18,buttonIconStroke:2,theme:"auto",lightButtonColor:"#02658D",lightTextColor:"#ffffff",lightButtonHoverColor:"#024F6F",lightTextHoverColor:"#ffffff",darkButtonColor:"#02658D",darkTextColor:"#ffffff",darkButtonHoverColor:"#036F9B",darkTextHoverColor:"#ffffff",dialogLightButtonColor:"#02658D",dialogLightTextColor:"#ffffff",dialogLightButtonHoverColor:"#024F6F",dialogLightTextHoverColor:"#ffffff",dialogLightBackgroundColor:"#ffffff",dialogLightSecondaryColor:"#f5f5f5",dialogLightInputColor:"#ffffff",dialogLightForegroundColor:"#0a0a0a",dialogDarkButtonColor:"#02658D",dialogDarkTextColor:"#ffffff",dialogDarkButtonHoverColor:"#036F9B",dialogDarkTextHoverColor:"#ffffff",dialogDarkBackgroundColor:"#0a0a0a",dialogDarkSecondaryColor:"#262626",dialogDarkInputColor:"#1a1a1a",dialogDarkForegroundColor:"#fafafa",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024,maxImageUploadSize:10*1024*1024,maxVideoUploadSize:50*1024*1024},fp='/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-400:oklch(70.4% .191 22.216);--color-red-600:oklch(57.7% .245 27.325);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-green-50:oklch(98.2% .018 155.826);--color-green-200:oklch(92.5% .084 155.995);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-900:oklch(37.9% .146 265.522);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-xl:36rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-medium:500;--tracking-tight:-.025em;--tracking-wide:.025em;--shadow-sm:var(--shadow-sm);--shadow-lg:var(--shadow-lg);--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{box-sizing:border-box;margin:0;padding:0}h1,h2,h3,h4,h5,h6{color:var(--foreground);font-weight:600;line-height:1.3}h1{font-size:1.25rem}h2{font-size:1rem}h3{font-size:.9375rem}h4,h5,h6{font-size:.875rem}p{color:var(--foreground);font-size:.875rem;line-height:1.5}#bugpin-root{--bugpin-primary-50:#e6f3f9;--bugpin-primary-100:#cbe7f2;--bugpin-primary-200:#9ed1e6;--bugpin-primary-300:#6ab8d8;--bugpin-primary-400:#2e9bc6;--bugpin-primary-500:#0e84b1;--bugpin-primary-600:#036f9b;--bugpin-primary-700:#02658d;--bugpin-primary-800:#024f6f;--bugpin-primary-900:#013a52;--bugpin-primary-950:#012738;--background:#fff;--foreground:#0a0a0a;--muted:#f5f5f5;--muted-foreground:#737373;--border:#e5e5e5;--input:#e5e5e5;--ring:#a3a3a3;--destructive:#ef4444;--destructive-foreground:#fafafa;--radius:.5rem;--shadow-sm:0 1px 2px 0 #0000000d;--shadow:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--shadow-lg:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;color:var(--foreground);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;font-size:14px;line-height:1.5}.bugpin-container{--primary:var(--button-color,var(--bugpin-primary-700));--primary-foreground:var(--button-text-color,#fafafa);--primary-hover:var(--button-hover-color,var(--bugpin-primary-800));--primary-hover-foreground:var(--button-hover-text-color,#fafafa)}.bugpin-theme-dark,.bugpin-container.bugpin-theme-dark{--background:#0a0a0a;--foreground:#fafafa;--muted:#262626;--muted-foreground:#a3a3a3;--border:#262626;--input:#262626;--ring:#d4d4d4}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes bugpin-tooltip-fade-in{0%{opacity:0}to{opacity:1}}.priority-lowest{color:#6b7280}.priority-low{color:#3b82f6}.priority-medium{color:#f59e0b}.priority-high{color:#ef4444}.priority-highest{color:#dc2626}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.top-1\\.5{top:calc(var(--spacing)*1.5)}.top-5{top:calc(var(--spacing)*5)}.top-full{top:100%}.right-5{right:calc(var(--spacing)*5)}.bottom-5{bottom:calc(var(--spacing)*5)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.left-1\\.5{left:calc(var(--spacing)*1.5)}.left-5{left:calc(var(--spacing)*5)}.z-\\[2147483646\\]{z-index:2147483646}.z-\\[2147483647\\]{z-index:2147483647}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.ml-0\\.5{margin-left:calc(var(--spacing)*.5)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.aspect-video{aspect-ratio:var(--aspect-video)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-4\\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-full{height:100%}.max-h-\\[70vh\\]{max-height:70vh}.max-h-\\[90vh\\]{max-height:90vh}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-20{min-height:calc(var(--spacing)*20)}.min-h-28{min-height:calc(var(--spacing)*28)}.min-h-40{min-height:calc(var(--spacing)*40)}.min-h-\\[600px\\]{min-height:600px}.w-3\\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-12{width:calc(var(--spacing)*12)}.w-full{width:100%}.w-px{width:1px}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-\\[700px\\]{min-width:700px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-\\[bugpin-tooltip-fade-in_0\\.2s_ease-in-out_forwards\\]{animation:.2s ease-in-out forwards bugpin-tooltip-fade-in}.animate-\\[fadeIn_0\\.2s_ease-out\\]{animation:.2s ease-out fadeIn}.animate-\\[slideIn_0\\.3s_ease-out\\]{animation:.3s ease-out slideIn}.animate-\\[slideUp_0\\.2s_ease-out\\]{animation:.2s ease-out slideUp}.animate-\\[spin_0\\.8s_linear_infinite\\]{animation:.8s linear infinite spin}.cursor-pointer{cursor:pointer}.resize-y{resize:vertical}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:calc(var(--radius) + 2px)}.rounded-md{border-radius:calc(var(--radius) - 4px)}.rounded-sm{border-radius:calc(var(--radius) - 2px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-none{--tw-border-style:none;border-style:none}.border-solid{--tw-border-style:solid;border-style:solid}.border-blue-200{border-color:var(--color-blue-200)}.border-border{border-color:var(--border)}.border-destructive{border-color:var(--destructive)}.border-gray-800{border-color:var(--color-gray-800)}.border-green-200{border-color:var(--color-green-200)}.border-input{border-color:var(--input)}.border-primary{border-color:var(--primary)}.border-red-200{border-color:var(--color-red-200)}.border-transparent{border-color:#0000}.border-white\\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-t-white{border-top-color:var(--color-white)}.bg-\\[var\\(--button-color\\)\\]{background-color:var(--button-color)}.bg-\\[var\\(--input-background\\,transparent\\)\\]{background-color:var(--input-background,transparent)}.bg-background{background-color:var(--background)}.bg-black\\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-border{background-color:var(--border)}.bg-destructive{background-color:var(--destructive)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-green-50{background-color:var(--color-green-50)}.bg-muted{background-color:var(--muted)}.bg-primary,.bg-primary\\/5{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/5{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.bg-primary\\/10{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/10{background-color:color-mix(in oklab,var(--primary)10%,transparent)}}.bg-red-50{background-color:var(--color-red-50)}.bg-transparent{background-color:#0000}.object-contain{object-fit:contain}.p-1{padding:calc(var(--spacing)*1)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-8{padding-block:calc(var(--spacing)*8)}.pb-0{padding-bottom:calc(var(--spacing)*0)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.text-center{text-align:center}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-\\[var\\(--button-text-color\\)\\]{color:var(--button-text-color)}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-destructive{color:var(--destructive)}.text-destructive-foreground{color:var(--destructive-foreground)}.text-foreground{color:var(--foreground)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-600{color:var(--color-green-600)}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-600{color:var(--color-red-600)}.uppercase{text-transform:uppercase}.no-underline{text-decoration-line:none}.accent-primary{accent-color:var(--primary)}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.select-none{-webkit-user-select:none;user-select:none}.placeholder\\:text-muted-foreground::placeholder{color:var(--muted-foreground)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-\\[var\\(--button-hover-color\\)\\]:hover{background-color:var(--button-hover-color)}.hover\\:bg-destructive\\/90:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-destructive\\/90:hover{background-color:color-mix(in oklab,var(--destructive)90%,transparent)}}.hover\\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/5:hover{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-primary\\/5:hover{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.hover\\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\\:text-\\[var\\(--button-hover-text-color\\)\\]:hover{color:var(--button-hover-text-color)}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-gray-800:hover{color:var(--color-gray-800)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-hover:hover{color:var(--primary-hover)}.hover\\:text-primary-hover-foreground:hover{color:var(--primary-hover-foreground)}.hover\\:text-red-600:hover{color:var(--color-red-600)}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:border-destructive:focus{border-color:var(--destructive)}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-destructive\\/20:focus{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-destructive\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--destructive)20%,transparent)}}.focus\\:ring-ring\\/20:focus{--tw-ring-color:var(--ring)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-ring\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--ring)20%,transparent)}}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color:var(--ring)}.focus-visible\\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\\:scale-105:active{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}.dark\\:border-red-800:is(.bugpin-theme-dark *){border-color:var(--color-red-800)}.dark\\:bg-blue-900\\/70:is(.bugpin-theme-dark *){background-color:#1c398eb3}@supports (color:color-mix(in lab,red,red)){.dark\\:bg-blue-900\\/70:is(.bugpin-theme-dark *){background-color:color-mix(in oklab,var(--color-blue-900)70%,transparent)}}.dark\\:bg-gray-700:is(.bugpin-theme-dark *){background-color:var(--color-gray-700)}.dark\\:bg-red-950\\/50:is(.bugpin-theme-dark *){background-color:#46080980}@supports (color:color-mix(in lab,red,red)){.dark\\:bg-red-950\\/50:is(.bugpin-theme-dark *){background-color:color-mix(in oklab,var(--color-red-950)50%,transparent)}}.dark\\:text-blue-300:is(.bugpin-theme-dark *){color:var(--color-blue-300)}.dark\\:text-gray-300:is(.bugpin-theme-dark *){color:var(--color-gray-300)}.dark\\:text-red-400:is(.bugpin-theme-dark *){color:var(--color-red-400)}@media (hover:hover){.dark\\:hover\\:bg-red-950:is(.bugpin-theme-dark *):hover{background-color:var(--color-red-950)}.\\[\\&_span\\]\\:hover\\:text-primary span:hover{color:var(--primary)}}.\\[\\&_svg\\]\\:h-4 svg{height:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:h-4\\.5 svg{height:calc(var(--spacing)*4.5)}.\\[\\&_svg\\]\\:w-4 svg{width:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:w-4\\.5 svg{width:calc(var(--spacing)*4.5)}@media (hover:hover){.\\[\\&_svg\\]\\:hover\\:text-primary svg:hover{color:var(--primary)}}}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}';_f();let ca=!1;async function hc(i,t){var e,r,s;try{const n=await fetch(`${t}/api/widget/config/${i}`);if(n.ok){const o=await n.json();if(o.success&&o.config){const a=o.config;return{buttonText:a.buttonText,buttonShape:a.buttonShape,buttonIcon:a.buttonIcon,buttonIconSize:a.buttonIconSize,buttonIconStroke:a.buttonIconStroke,position:a.position,theme:a.theme,lightButtonColor:a.lightButtonColor,lightTextColor:a.lightTextColor,lightButtonHoverColor:a.lightButtonHoverColor,lightTextHoverColor:a.lightTextHoverColor,darkButtonColor:a.darkButtonColor,darkTextColor:a.darkTextColor,darkButtonHoverColor:a.darkButtonHoverColor,darkTextHoverColor:a.darkTextHoverColor,dialogLightButtonColor:a.dialogLightButtonColor,dialogLightTextColor:a.dialogLightTextColor,dialogLightButtonHoverColor:a.dialogLightButtonHoverColor,dialogLightTextHoverColor:a.dialogLightTextHoverColor,dialogLightBackgroundColor:a.dialogLightBackgroundColor,dialogLightSecondaryColor:a.dialogLightSecondaryColor,dialogLightInputColor:a.dialogLightInputColor,dialogLightForegroundColor:a.dialogLightForegroundColor,dialogDarkButtonColor:a.dialogDarkButtonColor,dialogDarkTextColor:a.dialogDarkTextColor,dialogDarkButtonHoverColor:a.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:a.dialogDarkTextHoverColor,dialogDarkBackgroundColor:a.dialogDarkBackgroundColor,dialogDarkSecondaryColor:a.dialogDarkSecondaryColor,dialogDarkInputColor:a.dialogDarkInputColor,dialogDarkForegroundColor:a.dialogDarkForegroundColor,enableHoverScaleEffect:a.enableHoverScaleEffect,tooltipEnabled:a.tooltipEnabled,tooltipText:a.tooltipText,enableScreenshot:((e=a.features)==null?void 0:e.screenshot)??!0,enableAnnotation:((r=a.features)==null?void 0:r.annotation)??!0,enableConsoleCapture:((s=a.features)==null?void 0:s.consoleCapture)??!0,captureMethod:a.captureMethod,useScreenCaptureAPI:a.useScreenCaptureAPI,maxImageUploadSize:a.maxImageUploadSizeMb?a.maxImageUploadSizeMb*1024*1024:void 0,maxVideoUploadSize:a.maxVideoUploadSizeMb?a.maxVideoUploadSizeMb*1024*1024:void 0}}}else if(n.status===403&&(await n.json()).error==="PROJECT_PAUSED")return console.info("[BugPin] Widget disabled - project is paused"),null}catch(n){console.warn("[BugPin] Failed to fetch widget config, using defaults",n)}return{}}function Un(i){if(ca){console.warn("[BugPin] Widget already initialized");return}ca=!0;const t=document.createElement("div");t.id="bugpin-widget",t.setAttribute("data-bugpin-exclude","true");const e=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=fp,e.appendChild(r);const s=document.createElement("div");s.id="bugpin-root",e.appendChild(s),document.body.appendChild(t),yc(Kr(gp,{config:i}),s)}async function pp(i){const t=i.getAttribute("data-api-key");if(!t){console.error("[BugPin] Missing data-api-key attribute");return}const e=i.getAttribute("data-server-url")||new URL(i.src).origin,r=await hc(t,e);if(r===null)return;const s={...mn,...r,apiKey:t,serverUrl:e,...i.getAttribute("data-position")&&{position:i.getAttribute("data-position")},...i.getAttribute("data-button-text")&&{buttonText:i.getAttribute("data-button-text")},...i.getAttribute("data-theme")&&{theme:i.getAttribute("data-theme")}};Un(s)}const Gn={init:async i=>{const t=i.serverUrl||mn.serverUrl,e=await hc(i.apiKey,t);if(e===null)return;const r={...mn,...e,...i,serverUrl:t};Un(r)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};typeof window<"u"&&(window.BugPin=Gn);const Ts=document.currentScript;if(Ts!=null&&Ts.hasAttribute("data-api-key")){const i=()=>pp(Ts);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}exports.BugPin=Gn;exports.createWidget=Un;exports.default=Gn;
586
541
  //# sourceMappingURL=widget.cjs.js.map