@arantic/bugpin-widget 1.0.0 → 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,112 +1,112 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var Qs,st,ya,Re,Gn,ba,wa,xa,pn,Vi,Wi,$r={},_a=[],yc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,is=Array.isArray;function fe(i,t){for(var e in t)i[e]=t[e];return i}function mn(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function qr(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?Qs.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 Ts(i,o,r,s,null)}function Ts(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??++ya,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(n),n}function ti(i){return i.children}function ks(i,t){this.props=i,this.context=t}function or(i,t){if(t==null)return i.__?or(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"?or(i):null}function Ca(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 Ca(i)}}function $n(i){(!i.__d&&(i.__d=!0)&&Re.push(i)&&!Fs.__r++||Gn!=st.debounceRendering)&&((Gn=st.debounceRendering)||ba)(Fs)}function Fs(){for(var i,t,e,r,s,n,o,a=1;Re.length;)Re.length>a&&Re.sort(wa),i=Re.shift(),a=Re.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,st.vnode&&st.vnode(e),vn(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[s]:null,n,s??or(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,Oa(n,e,o),r.__e=r.__=null,e.__e!=s&&Ca(e)));Fs.__r=0}function Sa(i,t,e,r,s,n,o,a,l,c,h){var u,d,g,f,p,v,b,x=r&&r.__k||_a,D=t.length;for(l=bc(e,t,x,l,D),u=0;u<D;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?$r:x[g.__i]||$r,g.__i=u,v=vn(i,g,d,s,n,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&yn(d.ref,null,g),h.push(g.ref,g.__c||f,g)),p==null&&f!=null&&(p=f),(b=!!(4&g.__u))||d.__k===g.__k?l=Ta(g,l,i,b):typeof g.type=="function"&&v!==void 0?l=v:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=p,l}function bc(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]=Ts(null,o,null,null,null):is(o)?o=i.__k[n]=Ts(ti,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=i.__k[n]=Ts(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=wc(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=or(a)),Ma(a,a));return r}function Ta(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=Ta(s[n],t,e,r));return t}i.__e!=t&&(r&&(t&&i.type&&!t.parentNode&&(t=or(i)),e.insertBefore(i.__e,t||null)),t=i.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ka(i,t){return t=t||[],i==null||typeof i=="boolean"||(is(i)?i.some(function(e){ka(e,t)}):t.push(i)),t}function wc(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 qn(i,t,e){t[0]=="-"?i.setProperty(t,e??""):i[t]=e==null?"":typeof e!="number"||yc.test(t)?e:e+"px"}function ls(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||qn(i.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||qn(i.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(xa,"$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=pn,i.addEventListener(t,n?Wi:Vi,n)):i.removeEventListener(t,n?Wi:Vi,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 Kn(i){return function(t){if(this.l){var e=this.l[t.type+i];if(t.t==null)t.t=pn++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function vn(i,t,e,r,s,n,o,a,l,c){var h,u,d,g,f,p,v,b,x,D,C,O,S,j,T,L,H,W=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),n=[a=t.__e=e.__e]),(h=st.__b)&&h(t);t:if(typeof W=="function")try{if(b=t.props,x="prototype"in W&&W.prototype.render,D=(h=W.contextType)&&r[h.__c],C=h?D?D.props.value:h.__:r,e.__c?v=(u=t.__c=e.__c).__=u.__E:(x?t.__c=u=new W(b,C):(t.__c=u=new ks(b,C),u.constructor=W,u.render=_c),D&&D.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&&W.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=fe({},u.__s)),fe(u.__s,W.getDerivedStateFromProps(b,u.__s))),g=u.props,f=u.state,u.__v=t,d)x&&W.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),x&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(x&&W.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(V){V&&(V.__=t)}),O=0;O<u._sb.length;O++)u.__h.push(u._sb[O]);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,p)})}if(u.context=C,u.props=b,u.__P=i,u.__e=!1,S=st.__r,j=0,x){for(u.state=u.__s,u.__d=!1,S&&S(t),h=u.render(u.props,u.state,u.context),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[]}else do u.__d=!1,S&&S(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++j<25);u.state=u.__s,u.getChildContext!=null&&(r=fe(fe({},r),u.getChildContext())),x&&!d&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(g,f)),L=h,h!=null&&h.type===ti&&h.key==null&&(L=Da(h.props.children)),a=Sa(i,is(L)?L:[L],t,e,r,s,n,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),v&&(u.__E=u.__=null)}catch(V){if(t.__v=null,l||n!=null)if(V.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(H=n.length;H--;)mn(n[H]);Xi(t)}else t.__e=e.__e,t.__k=e.__k,V.then||Xi(t);st.__e(V,t,e)}else n==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=xc(e.__e,t,e,r,s,n,o,l,c);return(h=st.diffed)&&h(t),128&t.__u?void 0:a}function Xi(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(Xi)}function Oa(i,t,e){for(var r=0;r<e.length;r++)yn(e[r],e[++r],e[++r]);st.__c&&st.__c(t,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(n){n.call(s)})}catch(n){st.__e(n,s.__v)}})}function Da(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:is(i)?i.map(Da):fe({},i)}function xc(i,t,e,r,s,n,o,a,l){var c,h,u,d,g,f,p,v=e.props||$r,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&&(st.__m&&st.__m(t,n),a=!1),n=null}if(x==null)v===b||a&&i.data==b||(i.data=b);else{if(n=n&&Qs.call(i.childNodes),!a&&n!=null)for(v={},c=0;c<i.attributes.length;c++)v[(g=i.attributes[c]).name]=g.value;for(c in v)if(g=v[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;ls(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"?p=g:a&&typeof g!="function"||v[c]===g||ls(i,c,g,v[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=""),Sa(t.type=="template"?i.content:i,is(d)?d:[d],t,e,r,x=="foreignObject"?"http://www.w3.org/1999/xhtml":s,n,o,n?n[0]:e.__k&&or(e,0),a,l),n!=null)for(c=n.length;c--;)mn(n[c]);a||(c="value",x=="progress"&&f==null?i.removeAttribute("value"):f!=null&&(f!==i[c]||x=="progress"&&!f||x=="option"&&f!=v[c])&&ls(i,c,f,v[c],s),c="checked",p!=null&&p!=i[c]&&ls(i,c,p,v[c],s))}return i}function yn(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){st.__e(s,e)}}function Ma(i,t,e){var r,s;if(st.unmount&&st.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||yn(r,null,t)),(r=i.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(n){st.__e(n,t)}r.base=r.__P=null}if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&Ma(r[s],t,e||typeof i.type!="function");e||mn(i.__e),i.__c=i.__=i.__e=void 0}function _c(i,t,e){return this.constructor(i,e)}function Cc(i,t,e){var r,s,n,o;t==document&&(t=document.documentElement),st.__&&st.__(i,t),s=(r=!1)?null:t.__k,n=[],o=[],vn(t,i=t.__k=qr(ti,null,[i]),s||$r,$r,t.namespaceURI,s?null:t.firstChild?Qs.call(t.childNodes):null,n,s?s.__e:t.firstChild,r,o),Oa(n,i,o)}Qs=_a.slice,st={__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}},ya=0,ks.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),$n(this))},ks.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),$n(this))},ks.prototype.render=ti,Re=[],ba=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,wa=function(i,t){return i.__v.__b-t.__v.__b},Fs.__r=0,xa=/(PointerCapture)$|Capture$/i,pn=0,Vi=Kn(!1),Wi=Kn(!0);var Sc=0;function w(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:--Sc,__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 st.vnode&&st.vnode(c),c}var Kr,gt,vi,Zn,Zr=0,Ea=[],mt=st,Jn=mt.__b,Qn=mt.__r,to=mt.diffed,eo=mt.__c,ro=mt.unmount,so=mt.__;function bn(i,t){mt.__h&&mt.__h(gt,i,Zr||t),Zr=0;var e=gt.__H||(gt.__H={__:[],__h:[]});return i>=e.__.length&&e.__.push({}),e.__[i]}function ct(i){return Zr=1,Tc(La,i)}function Tc(i,t,e){var r=bn(Kr++,2);if(r.t=i,!r.__c&&(r.__=[La(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=gt,!gt.__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};gt.__f=!0;var n=gt.shouldComponentUpdate,o=gt.componentWillUpdate;gt.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)},gt.shouldComponentUpdate=s}return r.__N||r.__}function Wt(i,t){var e=bn(Kr++,3);!mt.__s&&Aa(e.__H,t)&&(e.__=i,e.u=t,gt.__H.__h.push(e))}function Bt(i){return Zr=5,Pa(function(){return{current:i}},[])}function Pa(i,t){var e=bn(Kr++,7);return Aa(e.__H,t)&&(e.__=i(),e.__H=t,e.__h=i),e.__}function J(i,t){return Zr=8,Pa(function(){return i},t)}function kc(){for(var i;i=Ea.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(Os),i.__H.__h.forEach(Yi),i.__H.__h=[]}catch(t){i.__H.__h=[],mt.__e(t,i.__v)}}mt.__b=function(i){gt=null,Jn&&Jn(i)},mt.__=function(i,t){i&&t.__k&&t.__k.__m&&(i.__m=t.__k.__m),so&&so(i,t)},mt.__r=function(i){Qn&&Qn(i),Kr=0;var t=(gt=i.__c).__H;t&&(vi===gt?(t.__h=[],gt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Os),t.__h.forEach(Yi),t.__h=[],Kr=0)),vi=gt},mt.diffed=function(i){to&&to(i);var t=i.__c;t&&t.__H&&(t.__H.__h.length&&(Ea.push(t)!==1&&Zn===mt.requestAnimationFrame||((Zn=mt.requestAnimationFrame)||Oc)(kc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),vi=gt=null},mt.__c=function(i,t){t.some(function(e){try{e.__h.forEach(Os),e.__h=e.__h.filter(function(r){return!r.__||Yi(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],mt.__e(r,e.__v)}}),eo&&eo(i,t)},mt.unmount=function(i){ro&&ro(i);var t,e=i.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{Os(r)}catch(s){t=s}}),e.__H=void 0,t&&mt.__e(t,e.__v))};var io=typeof requestAnimationFrame=="function";function Oc(i){var t,e=function(){clearTimeout(r),io&&cancelAnimationFrame(t),setTimeout(i)},r=setTimeout(e,35);io&&(t=requestAnimationFrame(e))}function Os(i){var t=gt,e=i.__c;typeof e=="function"&&(i.__c=void 0,e()),gt=t}function Yi(i){var t=gt;i.__c=i.__(),gt=t}function Aa(i,t){return!i||i.length!==t.length||t.some(function(e,r){return e!==i[r]})}function La(i,t){return typeof t=="function"?t(i):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 Dc=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Mc=(...i)=>i.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 Ec={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 Pc=({color:i="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:s,iconNode:n,class:o="",...a})=>qr("svg",{...Ec,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])=>qr(l,c)),...ka(s)]);/**
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 wn=(i,t)=>{const e=({class:r="",children:s,...n})=>qr(Pc,{...n,iconNode:t,class:Mc(`lucide-${Dc(i)}`,r)},s);return e.displayName=`${i}`,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 Ac=wn("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 Lc=wn("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 jc=wn("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"}]]),Fc={bug:Ac,"message-square":jc,"alert-circle":Lc},Rc=({name:i,class:t,size:e=18,strokeWidth:r=2})=>{const s=Fc[i];return s?w(s,{class:t,size:e,strokeWidth:r}):null};function ja(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=ja(i[t]))&&(r&&(r+=" "),r+=e)}else for(e in i)i[e]&&(r&&(r+=" "),r+=e);return r}function Fa(){for(var i,t,e=0,r="",s=arguments.length;e<s;e++)(i=arguments[e])&&(t=ja(i))&&(r&&(r+=" "),r+=t);return r}const Ic=(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},Bc=(i,t)=>({classGroupId:i,validator:t}),Ra=(i=new Map,t=null,e)=>({nextPart:i,validators:t,classGroupId:e}),Rs="-",no=[],zc="arbitrary..",Hc=i=>{const t=Wc(i),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=i;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Vc(o);const a=o.split(Rs),l=a[0]===""&&a.length>1?1:0;return Ia(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=e[o];return l?c?Ic(c,l):l:c||no}return e[o]||no}}},Ia=(i,t,e)=>{if(i.length-t===0)return e.classGroupId;const s=i[t],n=e.nextPart.get(s);if(n){const c=Ia(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}},Vc=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?zc+r:void 0})(),Wc=i=>{const{theme:t,classGroups:e}=i;return Xc(e,t)},Xc=(i,t)=>{const e=Ra();for(const r in i){const s=i[r];xn(s,e,r,t)}return e},xn=(i,t,e,r)=>{const s=i.length;for(let n=0;n<s;n++){const o=i[n];Yc(o,t,e,r)}},Yc=(i,t,e,r)=>{if(typeof i=="string"){Uc(i,t,e);return}if(typeof i=="function"){Nc(i,t,e,r);return}Gc(i,t,e,r)},Uc=(i,t,e)=>{const r=i===""?t:Ba(t,i);r.classGroupId=e},Nc=(i,t,e,r)=>{if($c(i)){xn(i(r),t,e,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Bc(e,i))},Gc=(i,t,e,r)=>{const s=Object.entries(i),n=s.length;for(let o=0;o<n;o++){const[a,l]=s[o];xn(l,Ba(t,a),e,r)}},Ba=(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=Ra(),e.nextPart.set(o,a)),e=a}return e},$c=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,qc=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)}}},Ui="!",oo=":",Kc=[],ao=(i,t,e,r,s)=>({modifiers:i,hasImportantModifier:t,baseClassName:e,maybePostfixModifierPosition:r,isExternal:s}),Zc=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 p=0;p<h;p++){const v=s[p];if(o===0&&a===0){if(v===oo){n.push(s.slice(l,p)),l=p+1;continue}if(v==="/"){c=p;continue}}v==="["?o++:v==="]"?o--:v==="("?a++:v===")"&&a--}const u=n.length===0?s:s.slice(l);let d=u,g=!1;u.endsWith(Ui)?(d=u.slice(0,-1),g=!0):u.startsWith(Ui)&&(d=u.slice(1),g=!0);const f=c&&c>l?c-l:void 0;return ao(n,g,d,f)};if(t){const s=t+oo,n=r;r=o=>o.startsWith(s)?n(o.slice(s.length)):ao(Kc,!1,o,void 0,!0)}if(e){const s=r;r=n=>e({className:n,parseClassName:s})}return r},Jc=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}},Qc=i=>({cache:qc(i.cacheSize),parseClassName:Zc(i),sortModifiers:Jc(i),...Hc(i)}),th=/\s+/,eh=(i,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:n}=t,o=[],a=i.trim().split(th);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:p}=e(h);if(u){l=h+(l.length>0?" "+l:l);continue}let v=!!p,b=r(v?f.substring(0,p):f);if(!b){if(!v){l=h+(l.length>0?" "+l:l);continue}if(b=r(f),!b){l=h+(l.length>0?" "+l:l);continue}v=!1}const x=d.length===0?"":d.length===1?d[0]:n(d).join(":"),D=g?x+Ui:x,C=D+b;if(o.indexOf(C)>-1)continue;o.push(C);const O=s(b,v);for(let S=0;S<O.length;++S){const j=O[S];o.push(D+j)}l=h+(l.length>0?" "+l:l)}return l},rh=(...i)=>{let t=0,e,r,s="";for(;t<i.length;)(e=i[t++])&&(r=za(e))&&(s&&(s+=" "),s+=r);return s},za=i=>{if(typeof i=="string")return i;let t,e="";for(let r=0;r<i.length;r++)i[r]&&(t=za(i[r]))&&(e&&(e+=" "),e+=t);return e},sh=(i,...t)=>{let e,r,s,n;const o=l=>{const c=t.reduce((h,u)=>u(h),i());return e=Qc(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=eh(l,e);return s(l,h),h};return n=o,(...l)=>n(rh(...l))},ih=[],wt=i=>{const t=e=>e[i]||ih;return t.isThemeGetter=!0,t},Ha=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Va=/^\((?:(\w[\w-]*):)?(.+)\)$/i,nh=/^\d+\/\d+$/,oh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ah=/\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$/,lh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ch=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ge=i=>nh.test(i),$=i=>!!i&&!Number.isNaN(Number(i)),Se=i=>!!i&&Number.isInteger(Number(i)),yi=i=>i.endsWith("%")&&$(i.slice(0,-1)),ue=i=>oh.test(i),uh=()=>!0,dh=i=>ah.test(i)&&!lh.test(i),Wa=()=>!1,gh=i=>ch.test(i),fh=i=>hh.test(i),ph=i=>!B(i)&&!z(i),mh=i=>hr(i,Ua,Wa),B=i=>Ha.test(i),Fe=i=>hr(i,Na,dh),bi=i=>hr(i,xh,$),lo=i=>hr(i,Xa,Wa),vh=i=>hr(i,Ya,fh),cs=i=>hr(i,Ga,gh),z=i=>Va.test(i),xr=i=>ur(i,Na),yh=i=>ur(i,_h),co=i=>ur(i,Xa),bh=i=>ur(i,Ua),wh=i=>ur(i,Ya),hs=i=>ur(i,Ga,!0),hr=(i,t,e)=>{const r=Ha.exec(i);return r?r[1]?t(r[1]):e(r[2]):!1},ur=(i,t,e=!1)=>{const r=Va.exec(i);return r?r[1]?t(r[1]):e:!1},Xa=i=>i==="position"||i==="percentage",Ya=i=>i==="image"||i==="url",Ua=i=>i==="length"||i==="size"||i==="bg-size",Na=i=>i==="length",xh=i=>i==="number",_h=i=>i==="family-name",Ga=i=>i==="shadow",Ch=()=>{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"),p=wt("perspective"),v=wt("aspect"),b=wt("ease"),x=wt("animate"),D=()=>["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"],O=()=>[...C(),z,B],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],T=()=>[z,B,l],L=()=>[Ge,"full","auto",...T()],H=()=>[Se,"none","subgrid",z,B],W=()=>["auto",{span:["full",Se,z,B]},Se,z,B],V=()=>[Se,"auto",z,B],U=()=>["auto","min","max","fr",z,B],X=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],tt=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",...T()],Z=()=>[Ge,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],A=()=>[i,z,B],ht=()=>[...C(),co,lo,{position:[z,B]}],ut=()=>["no-repeat",{repeat:["","x","y","space","round"]}],dt=()=>["auto","cover","contain",bh,mh,{size:[z,B]}],k=()=>[yi,xr,Fe],P=()=>["","none","full",c,z,B],E=()=>["",$,xr,Fe],I=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>[$,yi,co,lo],Y=()=>["","none",f,z,B],G=()=>["none",$,z,B],N=()=>["none",$,z,B],Ft=()=>[$,z,B],at=()=>[Ge,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ue],breakpoint:[ue],color:[uh],container:[ue],"drop-shadow":[ue],ease:["in","out","in-out"],font:[ph],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ue],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ue],shadow:[ue],spacing:["px",$],text:[ue],"text-shadow":[ue],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ge,B,z,v]}],container:["container"],columns:[{columns:[$,B,z,a]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"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:O()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Se,"auto",z,B]}],basis:[{basis:[Ge,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$,Ge,"auto","initial","none",B]}],grow:[{grow:["",$,z,B]}],shrink:[{shrink:["",$,z,B]}],order:[{order:[Se,"first","last","none",z,B]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...X(),"normal"]}],"justify-items":[{"justify-items":[...tt(),"normal"]}],"justify-self":[{"justify-self":["auto",...tt()]}],"align-content":[{content:["normal",...X()]}],"align-items":[{items:[...tt(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...tt(),{baseline:["","last"]}]}],"place-content":[{"place-content":X()}],"place-items":[{"place-items":[...tt(),"baseline"]}],"place-self":[{"place-self":["auto",...tt()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[a,"screen",...Z()]}],"min-w":[{"min-w":[a,"screen","none",...Z()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",e,xr,Fe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,z,bi]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",yi,B]}],"font-family":[{font:[yh,B,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,z,B]}],"line-clamp":[{"line-clamp":[$,"none",z,bi]}],leading:[{leading:[n,...T()]}],"list-image":[{"list-image":["none",z,B]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",z,B]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...I(),"wavy"]}],"text-decoration-thickness":[{decoration:[$,"from-font","auto",z,Fe]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[$,"auto",z,B]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",z,B]}],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",z,B]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ht()}],"bg-repeat":[{bg:ut()}],"bg-size":[{bg:dt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Se,z,B],radial:["",z,B],conic:[Se,z,B]},wh,vh]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:k()}],"gradient-via-pos":[{via:k()}],"gradient-to-pos":[{to:k()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],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:[...I(),"hidden","none"]}],"divide-style":[{divide:[...I(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...I(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$,z,B]}],"outline-w":[{outline:["",$,xr,Fe]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",h,hs,cs]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",u,hs,cs]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[$,Fe]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",d,hs,cs]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[$,z,B]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"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":[$]}],"mask-image-linear-from-pos":[{"mask-linear-from":M()}],"mask-image-linear-to-pos":[{"mask-linear-to":M()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":M()}],"mask-image-t-to-pos":[{"mask-t-to":M()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":M()}],"mask-image-r-to-pos":[{"mask-r-to":M()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":M()}],"mask-image-b-to-pos":[{"mask-b-to":M()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":M()}],"mask-image-l-to-pos":[{"mask-l-to":M()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":M()}],"mask-image-x-to-pos":[{"mask-x-to":M()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":M()}],"mask-image-y-to-pos":[{"mask-y-to":M()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[z,B]}],"mask-image-radial-from-pos":[{"mask-radial-from":M()}],"mask-image-radial-to-pos":[{"mask-radial-to":M()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"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":[$]}],"mask-image-conic-from-pos":[{"mask-conic-from":M()}],"mask-image-conic-to-pos":[{"mask-conic-to":M()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ht()}],"mask-repeat":[{mask:ut()}],"mask-size":[{mask:dt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",z,B]}],filter:[{filter:["","none",z,B]}],blur:[{blur:Y()}],brightness:[{brightness:[$,z,B]}],contrast:[{contrast:[$,z,B]}],"drop-shadow":[{"drop-shadow":["","none",g,hs,cs]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",$,z,B]}],"hue-rotate":[{"hue-rotate":[$,z,B]}],invert:[{invert:["",$,z,B]}],saturate:[{saturate:[$,z,B]}],sepia:[{sepia:["",$,z,B]}],"backdrop-filter":[{"backdrop-filter":["","none",z,B]}],"backdrop-blur":[{"backdrop-blur":Y()}],"backdrop-brightness":[{"backdrop-brightness":[$,z,B]}],"backdrop-contrast":[{"backdrop-contrast":[$,z,B]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$,z,B]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$,z,B]}],"backdrop-invert":[{"backdrop-invert":["",$,z,B]}],"backdrop-opacity":[{"backdrop-opacity":[$,z,B]}],"backdrop-saturate":[{"backdrop-saturate":[$,z,B]}],"backdrop-sepia":[{"backdrop-sepia":["",$,z,B]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",z,B]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$,"initial",z,B]}],ease:[{ease:["linear","initial",b,z,B]}],delay:[{delay:[$,z,B]}],animate:[{animate:["none",x,z,B]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[p,z,B]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:N()}],"scale-x":[{"scale-x":N()}],"scale-y":[{"scale-y":N()}],"scale-z":[{"scale-z":N()}],"scale-3d":["scale-3d"],skew:[{skew:Ft()}],"skew-x":[{"skew-x":Ft()}],"skew-y":[{"skew-y":Ft()}],transform:[{transform:[z,B,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:at()}],"translate-x":[{"translate-x":at()}],"translate-y":[{"translate-y":at()}],"translate-z":[{"translate-z":at()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"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",z,B]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",z,B]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[$,xr,Fe,bi]}],stroke:[{stroke:["none",...A()]}],"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"]}},Sh=sh(Ch);function zt(...i){return Sh(Fa(i))}const Th={"bottom-right":"bottom-5 right-5","bottom-left":"bottom-5 left-5","top-right":"top-5 right-5","top-left":"top-5 left-5"},kh=({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:p,tooltipEnabled:v,tooltipText:b,onClick:x})=>{const[D,C]=ct(!1),[O,S]=ct(!1),[j,T]=ct({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),L=Bt(null),H=Bt(null);Wt(()=>{if(o==="dark"){S(!0);return}else if(o==="light"){S(!1);return}const A=window.matchMedia("(prefers-color-scheme: dark)");S(A.matches);const ht=ut=>S(ut.matches);return A.addEventListener("change",ht),()=>A.removeEventListener("change",ht)},[o]),Wt(()=>{if(D&&L.current&&H.current){const A=L.current,ht=H.current;requestAnimationFrame(()=>{const ut=A.getBoundingClientRect(),dt=ht.getBoundingClientRect(),k=window.innerWidth,P=4,E=dt.left+dt.width/2,I=ut.width/2;let F=0;const M=E-I;M<P?F=P-M:M+ut.width>k-P&&(F=k-P-(M+ut.width)),T({left:"50%",transform:`translateX(-50%) translateX(${F}px)`,arrowLeft:"50%"})})}},[D,b]);const W=O?D?g:u:D?c:a,V=O?D?f:d:D?h:l,U=O?u:a,X=O?d:l,tt=e==="round"?"50%":"8px",K=t||"Report Bug",Z=e==="round"?`${s/2}px`:"12px 20px";return w("div",{class:zt("fixed z-[2147483647]",Th[i]),children:[w("button",{ref:H,class:zt("relative flex items-center justify-center gap-2 border-none text-sm font-medium cursor-pointer shadow-lg transition-all duration-200",p&&"hover:scale-110 hover:shadow-xl active:scale-105"),style:{backgroundColor:W,color:V,borderRadius:tt,padding:Z},onClick:x,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"aria-label":K,children:[r&&w(Rc,{name:r,size:s,strokeWidth:n}),t&&w("span",{children:t})]}),v&&b&&D&&w("div",{ref:L,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:U,color:X,opacity:0,left:j.left,transform:j.transform},children:[b,w("div",{class:"absolute top-full border-4 border-solid border-transparent",style:{left:j.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderTopColor:U}})]})]})},ho=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,uo=Fa,Oh=(i,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return uo(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=ho(h)||ho(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[p,v]=f;return Array.isArray(v)?v.includes({...n,...a}[p]):{...n,...a}[p]===v})?[...c,u,d]:c},[]);return uo(i,o,l,e==null?void 0:e.class,e==null?void 0:e.className)},Dh=Oh("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"}}),De=({class:i,variant:t,size:e,children:r,type:s="button",...n})=>w("button",{type:s,class:zt(Dh({variant:t,size:e}),i),...n,children:r}),wi=({class:i,error:t,type:e="text",...r})=>w("input",{type:e,class:zt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-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}),Mh=({class:i,error:t,...e})=>w("textarea",{class:zt("min-h-20 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-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}),Eh=({class:i,error:t,children:e,...r})=>w("select",{class:zt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-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}),_r=({class:i,required:t,children:e,for:r,...s})=>w("label",{for:r,class:zt("text-sm font-medium text-foreground",i),...s,children:[e,t&&w("span",{class:"text-destructive ml-0.5",children:"*"})]}),Ph=({tabs:i,activeTab:t,onTabChange:e})=>w("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 w("button",{type:"button",role:"tab",id:`tab-${r.id}`,"aria-selected":s,"aria-controls":`tabpanel-${r.id}`,tabIndex:s?0:-1,class:zt("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&&w("span",{class:"flex items-center justify-center [&_svg]:w-4 [&_svg]:h-4",children:r.icon}),r.label]},r.id)})}),Ah={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"},Lh=({message:i,type:t,onClose:e,duration:r=5e3})=>(Wt(()=>{const s=setTimeout(e,r);return()=>clearTimeout(s)},[e,r]),w("div",{class:zt("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]",Ah[t]),role:"alert","aria-live":"polite",children:[t==="success"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})}),w("span",{children:i})]})),jh=10*1024*1024,Fh=50*1024*1024,Rh=["image/png","image/jpeg","image/gif","image/webp"],Ih=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Bh=({media:i,onCapture:t,onUpload:e,onRemove:r,onAnnotate:s,isCapturing:n,enableAnnotation:o})=>{const[a,l]=ct(!1),[c,h]=ct(null),u=Bt(null),d=S=>S.startsWith("video/"),g=S=>S.startsWith("image/"),f=J(S=>{if(g(S.type)){if(!Rh.includes(S.type))return`Unsupported image format: ${S.type}`;if(S.size>jh)return"Image too large. Maximum size is 10MB."}else if(d(S.type)){if(!Ih.includes(S.type))return`Unsupported video format: ${S.type}`;if(S.size>Fh)return"Video too large. Maximum size is 50MB."}else return`Unsupported file type: ${S.type}`;return null},[]),p=J(async S=>{const j=f(S);if(j){h(j);return}h(null);const T=new FileReader;T.onload=()=>{const L=T.result;if(g(S.type)){const H=new Image;H.onload=()=>{const W={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:S.type,width:H.width,height:H.height};e(W)},H.src=L}else if(d(S.type)){const H=document.createElement("video");H.onloadedmetadata=()=>{const W={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:S.type,width:H.videoWidth,height:H.videoHeight};e(W)},H.src=L}},T.readAsDataURL(S)},[f,e]),v=J(S=>{S.preventDefault(),S.stopPropagation(),l(!0)},[]),b=J(S=>{S.preventDefault(),S.stopPropagation(),l(!1)},[]),x=J(async S=>{var T;S.preventDefault(),S.stopPropagation(),l(!1);const j=(T=S.dataTransfer)==null?void 0:T.files;if(j)for(let L=0;L<j.length;L++)await p(j[L])},[p]),D=J(async S=>{const j=S.target,T=j.files;if(T)for(let L=0;L<T.length;L++)await p(T[L]);j.value=""},[p]),C=J(()=>{var S;(S=u.current)==null||S.click()},[]),O=S=>S.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return w("div",{class:"flex flex-col gap-4",children:[w("p",{class:"text-xs text-muted-foreground",children:"Tip: Use the annotation tool to hide any sensitive data before submitting."}),w("div",{class:"flex gap-2",children:[w(De,{class:"flex-1",onClick:t,disabled:n,children:[w("svg",{class:"w-4.5 h-4.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"]}),w("input",{ref:u,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:D})]}),c&&w("div",{class:"flex items-center gap-2 px-3 py-2.5 bg-red-50 border border-solid border-red-200 rounded text-red-600 text-sm",children:[w("svg",{class:"w-4.5 h-4.5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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]}),w("div",{class:zt("min-h-40 border-2 border-dashed border-border rounded bg-muted transition-colors",a&&"border-primary bg-primary/5",i.length>0&&"border-solid bg-background min-h-0"),onDragOver:v,onDragLeave:b,onDrop:x,children:i.length===0?w("div",{class:"flex flex-col items-center justify-center py-8 px-4 text-gray-500 text-center cursor-pointer transition-colors hover:text-primary [&_svg]:hover:text-primary",onClick:C,children:[w("svg",{class:"w-12 h-12 mb-3 text-gray-400 transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})}),w("p",{class:"text-sm font-medium mb-1",children:"Drag and drop files here"}),w("span",{class:"text-xs text-gray-400",children:"or click to browse"})]}):w("div",{class:"grid grid-cols-2 gap-3 p-3",children:[i.map(S=>w("div",{class:"relative rounded overflow-hidden bg-background border border-solid border-border",children:[w("div",{class:"relative aspect-video bg-gray-800",children:[d(S.mimeType)?w("video",{class:"w-full h-full object-contain",src:S.dataUrl,muted:!0}):w("img",{class:"w-full h-full object-contain",src:S.dataUrl,alt:"Screenshot"}),w("div",{class:"absolute top-1.5 left-1.5 flex gap-1",children:[S.annotated&&w("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-blue-100 text-blue-700",children:"Annotated"}),d(S.mimeType)&&w("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-gray-200 text-gray-700",children:"Video"})]})]}),w("div",{class:"flex justify-between px-2 py-1.5 text-xs text-gray-500 border-t border-solid border-gray-200",children:[w("span",{children:O(S.timestamp)}),S.width&&S.height&&w("span",{children:[S.width," x ",S.height]})]}),w("div",{class:"flex gap-1 px-2 py-1.5 border-t border-solid border-gray-200 bg-gray-50",children:[o&&g(S.mimeType)&&w(De,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-white hover:bg-gray-200",onClick:()=>s(S.id),title:"Annotate",children:w("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})})}),w(De,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-white hover:bg-red-50 hover:text-red-600",onClick:()=>r(S.id),title:"Remove",children:w("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})})})]})]},S.id)),w("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:C,children:[w("svg",{class:"w-8 h-8 text-gray-400 transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})}),w("span",{class:"text-xs text-gray-400 transition-colors",children:"Add more"})]})]})}),w("p",{class:"text-xs text-gray-400 text-center",children:"Supported: PNG, JPG, GIF, WebP (max 10MB) - MP4, WebM, MOV, AVI (max 50MB)"})]})},zh=[{id:"details",label:"Details",icon:w("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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:w("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})})}],Hh=({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})=>{const[f,p]=ct({}),v=J((C,O)=>{g({...d,[C]:O}),f[C]&&p(S=>({...S,[C]:void 0}))},[d,g,f]),b=J(()=>{const C={};return d.title.trim()?d.title.trim().length<4&&(C.title="Title must be at least 4 characters"):C.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(C.reporterEmail="Invalid email address"),p(C),Object.keys(C).length===0},[d]),x=J(C=>{if(C.preventDefault(),!b()){u("details");return}t(d,s)},[d,s,b,t,u]),D=s.length;return w("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("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:[w("div",{class:"flex items-center justify-between p-6 border-b border-solid border-border",children:[w("h2",{id:"bugpin-title",class:"text-lg font-semibold text-foreground tracking-tight",children:"Report a Bug"}),w(De,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close",children:w("svg",{class:"w-5 h-5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("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"})})})]}),w("div",{class:"p-4 pb-0 bg-transparent",children:w(Ph,{tabs:zh.map(C=>({...C,label:C.id==="media"&&D>0?`${C.label} (${D})`:C.label})),activeTab:h,onTabChange:u})}),w("div",{class:"flex-1 overflow-y-auto p-6",children:[h==="details"&&w("form",{class:"flex flex-col gap-4",onSubmit:x,children:[w("div",{class:"flex flex-col gap-1.5",children:[w(_r,{for:"bugpin-title-input",required:!0,children:"Title"}),w(wi,{id:"bugpin-title-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:C=>v("title",C.target.value),maxLength:200,error:!!f.title,"aria-describedby":f.title?"bugpin-title-error":void 0}),f.title&&w("span",{id:"bugpin-title-error",class:"text-destructive text-xs mt-0.5",children:f.title})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(_r,{for:"bugpin-description",children:"Description"}),w(Mh,{id:"bugpin-description",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:C=>v("description",C.target.value)})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(_r,{for:"bugpin-priority",children:"Priority"}),w(Eh,{id:"bugpin-priority",value:d.priority,onChange:C=>v("priority",C.target.value),children:[w("option",{value:"highest",children:"Highest"}),w("option",{value:"high",children:"High"}),w("option",{value:"medium",children:"Medium"}),w("option",{value:"low",children:"Low"}),w("option",{value:"lowest",children:"Lowest"})]})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(_r,{for:"bugpin-name",children:"Name (optional)"}),w(wi,{id:"bugpin-name",type:"text",placeholder:"Your name",value:d.reporterName,onInput:C=>v("reporterName",C.target.value)})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(_r,{for:"bugpin-email",children:"Email (optional)"}),w(wi,{id:"bugpin-email",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:C=>v("reporterEmail",C.target.value),error:!!f.reporterEmail,"aria-describedby":f.reporterEmail?"bugpin-email-error":void 0}),f.reporterEmail&&w("span",{id:"bugpin-email-error",class:"text-destructive text-xs mt-0.5",children:f.reporterEmail})]})]}),h==="media"&&w(Bh,{media:s,onCapture:e,onUpload:n,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c})]}),w("div",{class:"flex gap-3 p-6 border-t border-solid border-border bg-muted",children:[w(De,{variant:"outline",class:"flex-1",onClick:i,disabled:a,children:"Cancel"}),w(De,{class:"flex-1",onClick:x,disabled:a,children:a?w("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"})]}),w("div",{class:"py-3 px-6 text-center text-xs text-muted-foreground border-t border-solid border-border bg-background",children:["Powered by"," ",w("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 m(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}function go(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),e.push.apply(e,r)}return e}function y(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?go(Object(e),!0).forEach(function(r){m(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):go(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function ot(i,t){if(i==null)return{};var e,r,s=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(i,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);for(r=0;r<n.length;r++)e=n[r],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(i,e)&&(s[e]=i[e])}return s}function ce(i,t){return t||(t=i.slice(0)),Object.freeze(Object.defineProperties(i,{raw:{value:Object.freeze(t)}}))}class fo{constructor(){m(this,"browserShadowBlurConstant",1),m(this,"DPI",96),m(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),m(this,"perfLimitSizeTotal",2097152),m(this,"maxCacheSideLimit",4096),m(this,"minCacheSideLimit",256),m(this,"disableStyleCopyPaste",!1),m(this,"enableGLFiltering",!0),m(this,"textureSize",4096),m(this,"forceGLPutImageData",!1),m(this,"cachesBoundsOfCurve",!1),m(this,"fontPaths",{}),m(this,"NUM_FRACTION_DIGITS",4)}}const Q=new class extends fo{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=y(y({},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 fo,e=(i==null?void 0:i.reduce((r,s)=>(r[s]=t[s],r),{}))||t;this.configure(e)}},Pe=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 ne extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Vh extends ne{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Wh{}class Xh extends Wh{testPrecision(t,e){const r="precision ".concat(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(),Pe("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Yh={};let po;const le=()=>po||(po={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Xh,dispose(){},copyPasteData:Yh}),dr=()=>le().document,ei=()=>le().window,$a=()=>{var i;return Math.max((i=Q.devicePixelRatio)!==null&&i!==void 0?i:ei().devicePixelRatio,1)},Wr=new class{constructor(){m(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="".concat(e.toLowerCase(),"_").concat((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}=Q,e=Math.sqrt(t*i);return[Math.floor(e),Math.floor(t/e)]}},Ni="6.9.1";function Ds(){}const ns=Math.PI/2,Is=2*Math.PI,_n=Math.PI/180,Ot=Object.freeze([1,0,0,1,0,0]),Cn=16,Te=.4477152502,q="center",rt="left",Et="top",Gi="bottom",ft="right",Pt="none",Sn=/\r?\n/,qa="moving",ri="scaling",Ka="rotating",Tn="rotate",Za="skewing",Jr="resizing",Uh="modifyPoly",Nh="modifyPath",Bs="changed",si="scale",jt="scaleX",Yt="scaleY",gr="skewX",fr="skewY",xt="fill",At="stroke",zs="modified",$e="json",xi="svg",R=new class{constructor(){this[$e]=new Map,this[xi]=new Map}has(i){return this[$e].has(i)}getClass(i){const t=this[$e].get(i);if(!t)throw new ne("No class registered for ".concat(i));return t}setClass(i,t){t?this[$e].set(t,i):(this[$e].set(i.type,i),this[$e].set(i.type.toLowerCase(),i))}getSVGClass(i){return this[xi].get(i)}setSVGClass(i,t){this[xi].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 Gh{constructor(){m(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)/ns){case 1:case 3:return 0;case 2:return-1}return Math.cos(i)},ye=i=>{if(i===0)return 0;const t=i/ns,e=Math.sign(i);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(i)};class _{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 _(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new _(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new _(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new _(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new _(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new _(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new _(this.x/t.x,this.y/t.y)}scalarDivide(t){return new _(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 _(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 _(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new _(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 _(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:kn;const r=ye(t),s=ve(t),n=this.subtract(e);return new _(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 _(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 kn=new _(0,0),Ms=i=>!!i&&Array.isArray(i._objects);function Ja(i){class t extends i{constructor(){super(...arguments),m(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 _(s,n),u=h.add(new _(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 Qa extends Gh{_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 Es(i){return ei().requestAnimationFrame(i)}function $h(i){return ei().cancelAnimationFrame(i)}let qh=0;const Ae=()=>qh++,be=()=>{const i=dr().createElement("canvas");if(!i||i.getContext===void 0)throw new ne("Failed to create `canvas` element");return i},Kh=()=>dr().createElement("img"),Ut=i=>{const t=be();return t.width=i.width,t.height=i.height,t},tl=(i,t,e)=>i.toDataURL("image/".concat(t),e),el=(i,t,e)=>new Promise((r,s)=>{i.toBlob(r,"image/".concat(t),e)}),pt=i=>i*_n,we=i=>i/_n,Zh=i=>i.every((t,e)=>t===Ot[e]),Dt=(i,t,e)=>new _(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 _(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]],On=(i,t)=>i.reduceRight((e,r)=>r&&e?Ct(r,e,t):r||e,void 0)||Ot.concat(),rl=i=>{let[t,e]=i;return Math.atan2(e,t)},Vs=i=>{const t=rl(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:we(t),scaleX:r,scaleY:s,skewX:we(n),skewY:0,translateX:i[4]||0,translateY:i[5]||0}},os=function(i){return[1,0,0,1,i,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function pr(){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=pt(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 Dn=function(i){return[i,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:i,0,0]},sl=i=>Math.tan(pt(i)),il=i=>[1,0,sl(i),1,0,0],nl=i=>[1,sl(i),0,1,0,0],ii=i=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=i,a=Dn(r?-t:t,s?-e:e);return n&&(a=Ct(a,il(n),!0)),o&&(a=Ct(a,nl(o),!0)),a},Jh=i=>{const{translateX:t=0,translateY:e=0,angle:r=0}=i;let s=os(t,e);r&&(s=Ct(s,pr({angle:r})));const n=ii(i);return Zh(n)||(s=Ct(s,n)),s},Ps=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 Vh("loadImage"));const n=Kh();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 ne("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=i):a()})},Qr=function(i){let{signal:t,reviver:e=Ds}=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=>R.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)})})},ni=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&&R.has(a.type)?Qr([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)})})},mr=function(i){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in i&&(t[e]=i[e]),t),{})},Mn=(i,t)=>Object.keys(i).reduce((e,r)=>(t(i[r],r,i)&&(e[r]=i[r]),e),{}),nt=(i,t)=>parseFloat(Number(i).toFixed(t)),ts=i=>"matrix("+i.map(t=>nt(t,Q.NUM_FRACTION_DIGITS)).join(" ")+")",Xt=i=>!!i&&i.toLive!==void 0,mo=i=>!!i&&typeof i.toObject=="function",vo=i=>!!i&&i.offsetX!==void 0&&"source"in i,Ie=i=>!!i&&"multiSelectionStacking"in i;function ol(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,al=i=>{var t;return((t=i.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},ll=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))},$i=(i,t)=>{let{width:e,height:r}=t;e&&(i.style.width=typeof e=="number"?"".concat(e,"px"):e),r&&(i.style.height=typeof r=="number"?"".concat(r,"px"):r)};function yo(i){return i.onselectstart!==void 0&&(i.onselectstart=()=>!1),i.style.userSelect=Pt,i}class cl{constructor(t){m(this,"_originalCanvasStyle",void 0),m(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&&dr().getElementById(t)||be();var r;if(e.hasAttribute("data-fabric"))throw new ne("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","".concat(e)),s.setAttribute("height","".concat(r)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:s}=this.lower;ll(r,s,t,e)}setCSSDimensions(t){$i(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=al(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=ol(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 Qh={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Ot]},tu=["objects"];class as extends Ja(Qa){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 as.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 cl(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&&(Pe("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?$a():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 s=y({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=Dt(t,Qt(s));s[0]=e,s[3]=e;const o=Dt(n,s);s[4]+=r.x-o.x,s[5]+=r.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new _(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 _(-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=Es(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Qt(this.viewportTransform),s=Dt({x:0,y:0},r),n=Dt({x:t,y:e},r),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new _(a.x,o.y),bl:new _(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&($h(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="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),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["".concat(e,"Color")],s=this["".concat(e,"Image")],n=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!r&&!s)return;const a=Xt(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")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new _(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new _(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new _(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 _(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new _(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Dt(this.getCenterPoint(),Qt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,q,q),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 y(y(y({version:Ni},mr(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 Xt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),Xt(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=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
39
- `)),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>
40
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" ?>
41
41
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
42
- `)}_setSVGHeader(t,e){const r=e.width||"".concat(this.width),s=e.height||"".concat(this.height),n=Q.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(nt(-l[4]/l[0],n)," ").concat(nt(-l[5]/l[3],n)," ").concat(nt(this.width/l[0],n)," ").concat(nt(this.height/l[3],n),'" ')}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="',s,'" ',a,`xml:space="preserve">
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
43
  `,"<desc>Created with Fabric.js ",Ni,`</desc>
44
44
  `,`<defs>
45
45
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
46
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Ae()),'<clipPath id="'.concat(e.clipPathId,`" >
47
- `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
48
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(Xt(e)){const r=this["".concat(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?ts(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=Q.fontPaths;this._objects.forEach(function n(o){t.push(o),Ms(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: '`.concat(n,`';
50
- src: url('`).concat(r[n],`');
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]}');
51
51
  }
52
- `)).join("");return s?` <style type="text/css"><![CDATA[
53
- `.concat(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["".concat(e,"Color")];if(r)if(Xt(r)){const s=r.repeat||"",n=this.width,o=this.height,a=this["".concat(e,"Vpt")]?ts(Qt(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(n/2,",").concat(o/2,')" x="').concat(r.offsetX-n/2,'" y="').concat(r.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!vo(r)?n:r.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!vo(r)?o:r.source.height,'" fill="url(#SVGID_').concat(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 ne("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=ot(s,tu),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:u}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Qr(n,{reviver:e,signal:r}),ni({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:u},{signal:r})]).then(g=>{let[f,p]=g;return this.clear(),this.add(...f),this.set(o),this.set(p),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ut(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 tl(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 el(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,p=[g,0,0,g,(f[4]-(s||0))*t,(f[5]-(n||0))*t],v=this.enableRetinaScaling,b=Ut({width:a,height:l}),x=o?this._objects.filter(D=>o(D)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=p,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=v,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 (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}m(as,"ownDefaults",Qh);const eu=["touchstart","touchmove","touchend"],ru=i=>{const t=ol(i.target),e=function(r){const s=r.changedTouches;return s&&s[0]?s[0]:r}(i);return new _(e.clientX+t.left,e.clientY+t.top)},qi=i=>eu.includes(i.type)||i.pointerType==="touch",bo=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}},su=["translateX","translateY","scaleX","scaleY"],iu=(i,t)=>Ws(i,Ct(t,i.calcOwnMatrix())),Ws=(i,t)=>{const e=Vs(t),{translateX:r,translateY:s,scaleX:n,scaleY:o}=e,a=ot(e,su),l=new _(r,s);i.flipX=!1,i.flipY=!1,Object.assign(i,a),i.set({scaleX:n,scaleY:o}),i.setPositionByOrigin(l,q,q)},nu=i=>{i.scaleX=1,i.scaleY=1,i.skewX=0,i.skewY=0,i.flipX=!1,i.flipY=!1,i.rotate(0)},hl=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}),En=(i,t,e)=>{const r=i/2,s=t/2,n=[new _(-r,-s),new _(r,-s),new _(-r,s),new _(r,s)].map(a=>a.transform(e)),o=me(n);return new _(o.width,o.height)},oi=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ot;return Ct(Qt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ot),i)},sr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ot,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ot;return i.transform(oi(t,e))},ou=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ot,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ot;return i.transform(oi(t,e),!0)},au=(i,t,e)=>{const r=oi(t,e);return Ws(i,Ct(r,i.calcOwnMatrix())),r},ul=(i,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire("object:".concat(i),y(y({},t),{},{target:r})),r.fire(i,t)},lu={left:-.5,top:-.5,center:0,bottom:.5,right:.5},vt=i=>typeof i=="string"?lu[i]:i-.5,Xs="not-allowed";function dl(i){return vt(i.originX)===vt(q)&&vt(i.originY)===vt(q)}function wo(i){return .5-vt(i)}const ee=(i,t)=>i[t],gl=(i,t,e,r)=>({e:i,transform:t,pointer:new _(e,r)});function fl(i,t){const e=i.getTotalAngle()+we(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Pn(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,p){const v=d.getRelativeCenterPoint(),b=f!==void 0&&p!==void 0?d.translateToGivenOrigin(v,q,q,f,p):new _(d.left,d.top);return(d.angle?g.rotate(-pt(d.angle),v):g).subtract(b)}(o,new _(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 cu=(i,t,e,r)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=r-o,c=!ee(s,"lockMovementX")&&s.left!==a,h=!ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(rt,a),h&&s.set(Et,l),(c||h)&&ul(qa,gl(i,t,e,r)),c||h},Ys=i=>i.replace(/\s+/g," "),xo={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"},_i=(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),_o=(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]},Co=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(i)/(i.endsWith("%")?100:1)},us=i=>Math.min(Math.round(i),255).toString(16).toUpperCase().padStart(2,"0"),So=i=>{let[t,e,r,s=1]=i;const n=Math.round(.3*t+.59*e+.11*r);return[n,n,n,s]};class et{constructor(t){if(m(this,"isUnrecognised",!1),t)if(t instanceof et)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 xo&&(t=xo[t]),t==="transparent"?[255,255,255,0]:et.sourceFromHex(t)||et.sourceFromRgb(t)||et.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]=_o(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){const[t,e,r,s]=_o(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(r,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,s]=this.getSource();return"".concat(us(t)).concat(us(e)).concat(us(r)).concat(us(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(So(this.getSource())),this}toBlackWhite(t){const[e,,,r]=So(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,r]),this}overlayWith(t){t instanceof et||(t=new et(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 et.fromRgba(t)}static fromRgba(t){return new et(et.sourceFromRgb(t))}static sourceFromRgb(t){const e=Ys(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,Co(e[4])]}}static fromHsl(t){return et.fromHsla(t)}static fromHsla(t){return new et(et.sourceFromHsl(t))}static sourceFromHsl(t){const e=Ys(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=(et.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=_i(h,c,r+1/3),a=_i(h,c,r),l=_i(h,c,r-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Co(e[4])]}static fromHex(t){return new et(et.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")?we(r):e.includes("turn")?360*r:r}}const ir=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Cn;const e=/\D{0,2}$/.exec(i),r=parseFloat(i),s=Q.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}},hu=i=>{const[t,e]=i.trim().split(" "),[r,s]=(n=t)&&n!==Pt?[n.slice(1,4),n.slice(5,8)]:n===Pt?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:r,alignY:s}},es=function(i,t){let e,r,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new et(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(r=o.toString())}else e="none";return s?"".concat(i,": ").concat(e,"; ").concat(r?"".concat(i,"-opacity: ").concat(r,"; "):""):"".concat(i,'="').concat(e,'" ').concat(r?"".concat(i,'-opacity="').concat(r,'" '):"")};class pl{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Pt,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=es(xt,this.fill);return[es(At,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].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(),s='transform="'.concat(ts(r));return"".concat(s).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 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="'.concat(this.getSvgStyles(),'" '),a=s?'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=[],p=t.indexOf("COMMON_PARTS");let v;l&&(l.clipPathId="CLIPPATH_".concat(Ae()),v='<clipPath id="'.concat(l.clipPathId,`" >
57
- `).concat(l.toClipPathSVG(r),`</clipPath>
58
- `)),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(),` >
59
59
  `),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
60
- `);const b=[o,c,e?"":this.addPaintOrder()," ",n?'transform="'.concat(n,'" '):""].join("");return t[p]=b,Xt(d)&&f.push(d.toSVG(this)),Xt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(v),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>
61
61
  `),h&&f.push(`</g>
62
- `),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==xt?' paint-order="'.concat(this.paintFirst,'" '):""}}function ai(i){return new RegExp("^("+i.join("|")+")\\b","i")}const Xe="textDecorationThickness",ml=["fontSize","fontWeight","fontFamily","fontStyle"],vl=["underline","overline","linethrough"],yl=[...ml,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],bl=[...yl,...vl,"textBackgroundColor","direction",Xe],uu=[...ml,...vl,At,"strokeWidth",xt,"deltaY","textBackgroundColor",Xe],du={_reNewline:Sn,_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:rt,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:rt,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,[Xe]:66.667},ie="justify",Us="justify-left",Xr="justify-right",Yr="justify-center";var To,ko,Oo;const te=String.raw(To||(To=ce(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Ci=String.raw(ko||(ko=ce(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),gu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+te+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+te+"))?\\s+(.*)"),fu={cx:rt,x:rt,r:"radius",cy:Et,y:Et,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":Xe},Si="font-size",Ti="clip-path";ai(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);ai(["symbol","image","marker","pattern","view","svg"]);const Do=ai(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(Oo||(Oo=ce(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),te,Ci,te,Ci,te,Ci,te));const pu=new _(1,0),wl=new _,xl=(i,t)=>i.rotate(t),Ki=(i,t)=>new _(t).subtract(i),Zi=i=>i.distanceFrom(wl),Ji=(i,t)=>Math.atan2(Ur(i,t),vu(i,t)),mu=i=>Ji(pu,i),An=i=>i.eq(wl)?i:i.scalarDivide(Zi(i)),_l=function(i){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return An(new _(-i.y,i.x).scalarMultiply(t?1:-1))},Ur=(i,t)=>i.x*t.y-i.y*t.x,vu=(i,t)=>i.x*t.x+i.y*t.y,Mo=(i,t,e)=>{if(i.eq(t)||i.eq(e))return!0;const r=Ur(t,e),s=Ur(t,i),n=Ur(e,i);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},Eo="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Po=new RegExp("(?:\\s|^)"+Eo+Eo+"("+te+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ae{constructor(t){const e=typeof t=="string"?ae.parseShadow(t):t;Object.assign(this,ae.ownDefaults,e),this.id=Ae()}static parseShadow(t){const e=t.trim(),[,r=0,s=0,n=0]=(Po.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Po,"")||"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=xl(new _(this.offsetX,this.offsetY),pt(-t.angle)),r=new et(this.color);let s=40,n=40;return t.width&&t.height&&(s=100*nt((Math.abs(e.x)+this.blur)/t.width,Q.NUM_FRACTION_DIGITS)+20,n=100*nt((Math.abs(e.y)+this.blur)/t.height,Q.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(n,'%" height="').concat(100+2*n,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
63
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(nt(this.blur?this.blur/2:0,Q.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
64
- <feOffset dx="`).concat(nt(e.x,Q.NUM_FRACTION_DIGITS),'" dy="').concat(nt(e.y,Q.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
65
- <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()}"/>
66
66
  <feComposite in2="oBlur" operator="in" />
67
67
  <feMerge>
68
68
  <feMergeNode></feMergeNode>
69
69
  <feMergeNode in="SourceGraphic"></feMergeNode>
70
70
  </feMerge>
71
71
  </filter>
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:Mn(t,(r,s)=>r!==e[s])}static async fromObject(t){return new this(t)}}m(ae,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),m(ae,"type","shadow"),R.setClass(ae,"shadow");const ar=(i,t,e)=>Math.max(i,Math.min(t,e)),yu=[Et,rt,jt,Yt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",gr,fr],xe=[xt,At,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],bu={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:rt,originY:Et,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:xt,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},wu=(i,t,e,r)=>-e*Math.cos(i/r*ns)+e+t,xu=()=>!1;class Ln{constructor(t){let{startValue:e,byValue:r,duration:s=500,delay:n=0,easing:o=wu,onStart:a=Ds,onChange:l=Ds,onComplete:c=Ds,abort:h=xu,target:u}=t;m(this,"_state","pending"),m(this,"durationProgress",0),m(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(()=>Es(t),this.delay):Es(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),Es(this.tick)))}register(){Hs.push(this)}unregister(){Hs.remove(this)}abort(){this._state="aborted",this.unregister()}}const _u=["startValue","endValue"];class Cu extends Ln{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(y(y({},ot(t,_u)),{},{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 Su=["startValue","endValue"];class Tu extends Ln{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(y(y({},ot(t,Su)),{},{startValue:e,byValue:r.map((s,n)=>s-e[n])}))}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 ku=["startValue","endValue","easing","onChange","onComplete","abort"],Ou=(i,t,e,r)=>t+e*(1-Math.cos(i/r*ns)),ki=i=>i&&((t,e,r)=>i(new et(t).toRgba(),e,r));class Du extends Ln{constructor(t){let{startValue:e,endValue:r,easing:s=Ou,onChange:n,onComplete:o,abort:a}=t,l=ot(t,ku);const c=new et(e).getSource(),h=new et(r).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:ki(n),onComplete:ki(o),abort:ki(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),ar(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 Cl(i){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(i)?new Tu(i):new Cu(i);return t.start(),t}function Mu(i){const t=new Du(i);return t.start(),t}class lt{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=Ki(e,r),o=Ki(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 _(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,p=h*a-c*l;if(p!==0){const v=g/p,b=f/p;return(n||0<=v&&v<=1)&&(o||0<=b&&b<=1)?new lt("Intersection").append(new _(t.x+v*a,t.y+v*l)):new lt}if(g===0||f===0){const v=n||o||lt.isPointContained(t,r,s)||lt.isPointContained(e,r,s)||lt.isPointContained(r,t,e)||lt.isPointContained(s,t,e);return new lt(v?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,r,s){return lt.intersectLineLine(t,e,r,s,!1,!0)}static intersectSegmentSegment(t,e,r,s){return lt.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 lt,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=lt.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 lt.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new lt,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=lt.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 lt("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 _(n.x,s.y),a=new _(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Eu extends Qa{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?Dt(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=Dt(t,Qt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new _(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=>Dt(a,o))}return n}intersectsWithRect(t,e){return lt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=lt.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 lt.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(Yt,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?we(rl(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Ot.concat()}calcACoords(){const t=pr({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),s=os(e,r),n=Ct(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Dt({x:-a,y:-l},n),tr:Dt({x:a,y:-l},n),bl:Dt({x:-a,y:l},n),br:Dt({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,vt(this.originX),vt(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===t)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=Jh(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new _(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=y({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 _(o*e.scaleX,a*e.scaleY):En(o,a,ii(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,r,s,n){let o=t.x,a=t.y;const l=vt(s)-vt(e),c=vt(n)-vt(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new _(o,a)}translateToCenterPoint(t,e,r){if(e===q&&r===q)return t;const s=this.translateToGivenOrigin(t,e,r,q,q);return this.angle?s.rotate(pt(this.angle),t):s}translateToOriginPoint(t,e,r){const s=this.translateToGivenOrigin(t,q,q,e,r);return this.angle?s.rotate(pt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Dt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new _(this.left,this.top),this.originX,this.originY)}getPointByOrigin(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.translateToOriginPoint(this.getRelativeCenterPoint(),rt,Et)}}const Pu=["type"],Au=["extraParam"];let de=class As extends Eu{static getDefaults(){return As.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Pe("warn","Setting type has no effect",t)}constructor(t){super(),m(this,"_cacheContext",null),Object.assign(this,As.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=Q.maxCacheSideLimit,n=Q.minCacheSideLimit;if(e<=s&&r<=s&&e*r<=Q.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;const o=e/r,[a,l]=Wr.limitDimsByArea(o),c=ar(n,a,s),h=ar(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 _(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vs(this.calcTransformMatrix());return new _(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!==Yt||(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===At&&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._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const r=Ut(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,Xt(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&&(Xt(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)||Ot,a=n*s,l=o*s,c=e.nonScaling?new _(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Q.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(!Xt(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===At?(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=Ut({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 _(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=hl(this),r=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?$a():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(x=>new as(x,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&nu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&au(this,this.getViewportTransform()),this.setCoords();const c=be(),h=this.getBoundingRect(),u=this.shadow,d=new _;if(u){const x=u.blur,D=u.nonScaling?new _(1,1):this.getObjectScaling();d.x=2*Math.round(n(u.offsetX)+x)*n(D.x),d.y=2*Math.round(n(u.offsetY)+x)*n(D.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const p=l(c);t.format==="jpeg"&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new _(p.width/2,p.height/2),q,q);const v=this.canvas;p._objects=[this],this.set("canvas",p),this.setCoords();const b=p.toCanvasElement(a||1,t);return this.set("canvas",v),this.shadow=s,r&&(this.group=r),this.set(e),this.setCoords(),p._objects=[],p.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return tl(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return el(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=q,this.originY=q,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),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=y(y({},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,p,v)=>(v===s.length-1&&(f[p]=u),f[p]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}});return n?Mu(h):Cl(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(As.customProperties,this.constructor.customProperties||[]);let e;const r=Q.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:p,strokeLineCap:v,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:D,strokeMiterLimit:C,scaleX:O,scaleY:S,angle:j,flipX:T,flipY:L,opacity:H,visible:W,backgroundColor:V,fillRule:U,paintFirst:X,globalCompositeOperation:tt,skewX:K,skewY:Z}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const A=ut=>nt(ut,r),ht=y(y({},mr(this,t)),{},{type:this.constructor.type,version:Ni,originX:u,originY:d,left:A(c),top:A(h),width:A(g),height:A(f),fill:mo(n)?n.toObject():n,stroke:mo(o)?o.toObject():o,strokeWidth:A(p),strokeDashArray:l&&l.concat(),strokeLineCap:v,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:D,strokeMiterLimit:A(C),scaleX:A(O),scaleY:A(S),angle:A(j),flipX:T,flipY:L,opacity:A(H),shadow:a&&a.toObject(),visible:W,backgroundColor:V,fillRule:U,paintFirst:X,globalCompositeOperation:tt,skewX:A(K),skewY:A(Z)},e?{clipPath:e}:null);return this.includeDefaultValues?ht:this._removeDefaultValues(ht)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Mn(t,(s,n)=>{if(n===rt||n===Et||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"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=ot(t,Pu),r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=r,n=ot(r,Au);return ni(e,n).then(o=>s?(delete o[s],new this(e[s],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};m(de,"stateProperties",yu),m(de,"cacheProperties",xe),m(de,"ownDefaults",bu),m(de,"type","FabricObject"),m(de,"colorProperties",[xt,At,"backgroundColor"]),m(de,"customProperties",[]),R.setClass(de),R.setClass(de,"object");const vr=(i,t,e)=>(r,s,n,o)=>{const a=t(r,s,n,o);return a&&ul(i,y(y({},gl(r,s,n,o)),e)),a};function yr(i){return(t,e,r,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=i(t,e,r,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const Ao=vr(Jr,yr((i,t,e,r)=>{const s=Pn(t,t.originX,t.originY,e,r);if(vt(t.originX)===vt(q)||vt(t.originX)===vt(ft)&&s.x<0||vt(t.originX)===vt(rt)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=dl(t)?2:1,l=n.width,c=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(c,1)),l!==n.width}return!1}));function Lu(i,t,e,r,s){r=r||{};const n=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:s.transparentCorners,l=a?At:xt,c=!a&&(r.cornerStrokeColor||s.cornerStrokeColor);let h,u=t,d=e;i.save(),i.fillStyle=r.cornerColor||s.cornerColor||"",i.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,i.scale(1,o/n),d=e*n/o):o>n?(h=o,i.scale(n/o,1),u=t*o/n):h=n,i.beginPath(),i.arc(u,d,h/2,0,Is,!1),i[l](),c&&i.stroke(),i.restore()}function ju(i,t,e,r,s){r=r||{};const n=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:s.transparentCorners,l=a?At:xt,c=!a&&(r.cornerStrokeColor||s.cornerStrokeColor),h=n/2,u=o/2;i.save(),i.fillStyle=r.cornerColor||s.cornerColor||"",i.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor||"",i.translate(t,e);const d=s.getTotalAngle();i.rotate(pt(d)),i["".concat(l,"Rect")](-h,-u,n,o),c&&i.strokeRect(-h,-u,n,o),i.restore()}class $t{constructor(t){m(this,"visible",!0),m(this,"actionName",si),m(this,"angle",0),m(this,"x",0),m(this,"y",0),m(this,"offsetX",0),m(this,"offsetY",0),m(this,"sizeX",0),m(this,"sizeY",0),m(this,"touchSizeX",0),m(this,"touchSizeY",0),m(this,"cursorStyle","crosshair"),m(this,"withConnection",!1),Object.assign(this,t)}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)&&lt.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,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 _(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,s,n,o){const a=On([os(r,s),pr({angle:t}),Dn((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new _(-.5,-.5).transform(a),tr:new _(.5,-.5).transform(a),br:new _(.5,.5).transform(a),bl:new _(-.5,.5).transform(a)}}render(t,e,r,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Lu.call(this,t,e,r,s,n):ju.call(this,t,e,r,s,n)}}const Fu=(i,t,e)=>e.lockRotation?Xs:t.cursorStyle,Ru=vr(Ka,yr((i,t,e,r)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(ee(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=we(d-u+a);if(s.snapAngle&&s.snapAngle>0){const p=s.snapAngle,v=s.snapThreshold||p,b=Math.ceil(g/p)*p,x=Math.floor(g/p)*p;Math.abs(g-x)<v?g=x:Math.abs(g-b)<v&&(g=b)}g<0&&(g=360+g),g%=360;const f=s.angle!==g;return s.angle=g,f}));function Sl(i,t){const e=t.canvas,r=i[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function Tl(i,t,e){const r=ee(i,"lockScalingX"),s=ee(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 Iu=["e","se","s","sw","w","nw","n","ne","e"],Tr=(i,t,e)=>{const r=Sl(i,e);if(Tl(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",r))return Xs;const s=fl(e,t);return"".concat(Iu[s],"-resize")};function jn(i,t,e,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=Sl(i,n);let l,c,h,u,d,g;if(Tl(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Pn(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),ee(n,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){const v=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,x=v/(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);dl(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=wo(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=wo(t.originY),h*=-1,t.signY=g)}const f=n.scaleX,p=n.scaleY;return o?(o==="x"&&n.set(jt,c),o==="y"&&n.set(Yt,h)):(!ee(n,"lockScalingX")&&n.set(jt,c),!ee(n,"lockScalingY")&&n.set(Yt,h)),f!==n.scaleX||p!==n.scaleY}const ds=vr(ri,yr((i,t,e,r)=>jn(i,t,e,r))),Bu=vr(ri,yr((i,t,e,r)=>jn(i,t,e,r,{by:"x"}))),zu=vr(ri,yr((i,t,e,r)=>jn(i,t,e,r,{by:"y"}))),Hu=["target","ex","ey","skewingSide"],Oi={x:{counterAxis:"y",scale:jt,skew:gr,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Yt,skew:fr,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Vu=["ns","nesw","ew","nwse"],Wu=(i,t,e)=>{if(t.x!==0&&ee(e,"lockSkewingY")||t.y!==0&&ee(e,"lockSkewingX"))return Xs;const r=fl(e,t)%4;return"".concat(Vu[r],"-resize")};function kl(i,t,e,r,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Oi[i];if(ee(n,l))return!1;const{origin:u,flip:d}=Oi[o],g=vt(e[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[h]?-1:1),p=.5*-((n[c]===0&&Pn(e,q,q,r,s)[i]>0||n[c]>0?1:-1)*f)+.5;return vr(Za,yr((b,x,D,C)=>function(O,S,j){let{target:T,ex:L,ey:H,skewingSide:W}=S,V=ot(S,Hu);const{skew:U}=Oi[O],X=j.subtract(new _(L,H)).divide(new _(T.scaleX,T.scaleY))[O],tt=T[U],K=V[U],Z=Math.tan(pt(K)),A=O==="y"?T._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:T._getTransformedDimensions({scaleX:1,scaleY:1}).y,ht=2*X*W/Math.max(A,1)+Z,ut=we(Math.atan(ht));T.set(U,ut);const dt=tt!==T[U];if(dt&&O==="y"){const{skewX:k,scaleX:P}=T,E=T._getTransformedDimensions({skewY:tt}),I=T._getTransformedDimensions(),F=k!==0?E.x/I.x:1;F!==1&&T.set(jt,F*P)}return dt}(i,x,new _(D,C))))(t,y(y({},e),{},{[a]:p,skewingSide:f}),r,s)}const Xu=(i,t,e,r)=>kl("x",i,t,e,r),Yu=(i,t,e,r)=>kl("y",i,t,e,r);function li(i,t){return i[t.canvas.altActionKey]}const gs=(i,t,e)=>{const r=li(i,e);return t.x===0?r?gr:Yt:t.y===0?r?fr:jt:""},tr=(i,t,e)=>li(i,e)?Wu(0,t,e):Tr(i,t,e),Lo=(i,t,e,r)=>li(i,t.target)?Yu(i,t,e,r):Bu(i,t,e,r),jo=(i,t,e,r)=>li(i,t.target)?Xu(i,t,e,r):zu(i,t,e,r),Ol=()=>({ml:new $t({x:-.5,y:0,cursorStyleHandler:tr,actionHandler:Lo,getActionName:gs}),mr:new $t({x:.5,y:0,cursorStyleHandler:tr,actionHandler:Lo,getActionName:gs}),mb:new $t({x:0,y:.5,cursorStyleHandler:tr,actionHandler:jo,getActionName:gs}),mt:new $t({x:0,y:-.5,cursorStyleHandler:tr,actionHandler:jo,getActionName:gs}),tl:new $t({x:-.5,y:-.5,cursorStyleHandler:Tr,actionHandler:ds}),tr:new $t({x:.5,y:-.5,cursorStyleHandler:Tr,actionHandler:ds}),bl:new $t({x:-.5,y:.5,cursorStyleHandler:Tr,actionHandler:ds}),br:new $t({x:.5,y:.5,cursorStyleHandler:Tr,actionHandler:ds}),mtr:new $t({x:0,y:-.5,actionHandler:Ru,cursorStyleHandler:Fu,offsetY:-40,withConnection:!0,actionName:Tn})}),Uu=()=>({mr:new $t({x:.5,y:0,actionHandler:Ao,cursorStyleHandler:tr,actionName:Jr}),ml:new $t({x:-.5,y:0,actionHandler:Ao,cursorStyleHandler:tr,actionName:Jr})}),Nu=()=>y(y({},Ol()),Uu());class rs extends de{static getDefaults(){return y(y({},super.getDefaults()),rs.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),rs.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ol()}}_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(si))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=os(e.x,e.y),s=pr({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(pt(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=y({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=y({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(pt(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=En(this.width,this.height,ii(e)),o=this.isStrokeAccountedForInDimensions()?kn:(this.strokeUniform?new _().scalarAdd(this.canvas?this.canvas.getZoom():1):new _(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=y({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 Dl(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}m(rs,"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 yt extends rs{}Dl(yt,[pl]),R.setClass(yt),R.setClass(yt,"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 Ml{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new _(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new _(1/this.options.scaleX,1/this.options.scaleY):new _(1,1)}createSideVector(t,e){const r=Ki(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 _(t);return e.y+=e.x*Math.tan(pt(this.options.skewY)),e.x+=e.y*Math.tan(pt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const $u=new _;class nr extends Ml{static getOrthogonalRotationFactor(t,e){const r=e?Ji(t,e):mu(t);return Math.abs(r)<ns?-1:1}constructor(t,e,r,s){super(s),m(this,"AB",void 0),m(this,"AC",void 0),m(this,"alpha",void 0),m(this,"bisector",void 0),this.A=new _(t),this.B=new _(e),this.C=new _(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Ji(this.AB,this.AC),this.bisector=An(xl(this.AB.eq($u)?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=_l(s),o=nr.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*o)}projectBevel(){const t=[];return(this.alpha%Is==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?Zi(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Zi(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],s=new _(nr.getOrthogonalRotationFactor(this.bisector),nr.getOrthogonalRotationFactor(new _(this.bisector.y,this.bisector.x)));return[new _(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new _(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(n=>{Mo(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 _(Math.tan(pt(s)),Math.tan(pt(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 _(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 _(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(p=>this.applySkew(l?p.multiply(this.strokeUniformScalar):p)).forEach(p=>{Mo(p,t,e)&&r.push(this.applySkew(this.A).add(p))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Is==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=Ur(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 Ml{constructor(t,e,r){super(r),this.A=new _(t),this.T=new _(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(_l(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 _(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 nr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new _(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(An(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 _(o)),n),[new _(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 nr(n,l,c,t).project()):r.push(...new Fo(n,o===0?c:l,t).project())}),r},Fn=i=>{const t={};return Object.keys(i).forEach(e=>{t[e]={},Object.keys(i[e]).forEach(r=>{t[e][r]=y({},i[e][r])})}),t},Ku=i=>i.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Cr;const Rn=i=>{if(Cr||Cr||(Cr="Intl"in ei()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Cr){const t=Cr.segment(i);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return Zu(i)},Zu=i=>{const t=[];for(let e,r=0;r<i.length;r++)(e=Ju(i,r))!==!1&&t.push(e);return t},Ju=(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},In=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)},Qu=(i,t)=>{const e=t.split(`
73
- `),r=[];let s=-1,n={};i=Fn(i);for(let o=0;o<e.length;o++){const a=Rn(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&&(In(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},td=(i,t)=>{if(!Array.isArray(i))return Fn(i);const e=t.split(Sn),r={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Rn(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]=y({},i[n].style),s===i[n].end-1&&n++)}return r},Le=["display","transform",xt,"fill-opacity","fill-rule","opacity",At,"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 Ro(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 ed(i,t){let e=!0;const r=Ro(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=Ro(s=s.parentElement,o);return n.length===0}(i,t)),r&&e&&t.length===0}const rd=i=>{var t;return(t=fu[i])!==null&&t!==void 0?t:i},sd=new RegExp("(".concat(te,")"),"gi"),id=i=>Ys(i.replace(sd," $1 ").replace(/,/gi," "));var Io,Bo,zo,Ho,Vo,Wo,Xo;const kt="(".concat(te,")"),nd=String.raw(Io||(Io=ce(["(skewX)(",")"],["(skewX)\\(","\\)"])),kt),od=String.raw(Bo||(Bo=ce(["(skewY)(",")"],["(skewY)\\(","\\)"])),kt),ad=String.raw(zo||(zo=ce(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),kt,kt,kt),ld=String.raw(Ho||(Ho=ce(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),kt,kt),cd=String.raw(Vo||(Vo=ce(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),kt,kt),hd=String.raw(Wo||(Wo=ce(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),kt,kt,kt,kt,kt,kt),Bn="(?:".concat(hd,"|").concat(cd,"|").concat(ad,"|").concat(ld,"|").concat(nd,"|").concat(od,")"),ud="(?:".concat(Bn,"*)"),dd=String.raw(Xo||(Xo=ce(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),ud),gd=new RegExp(dd),fd=new RegExp(Bn),pd=new RegExp(Bn,"g");function Qi(i){const t=[];if(!(i=id(i).replace(/\s*([()])\s*/gi,"$1"))||i&&!gd.test(i))return[...Ot];for(const e of i.matchAll(pd)){const r=fd.exec(e[0]);if(!r)continue;let s=Ot;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=os(l,c);break;case Tn:s=pr({angle:l},{x:c,y:h});break;case si:s=Dn(l,c);break;case gr:s=il(l);break;case fr:s=nl(l);break;case"matrix":s=[l,c,h,u,d,g]}t.push(s)}return On(t)}function md(i,t,e,r){const s=Array.isArray(t);let n,o=t;if(i!==xt&&i!==At||t!==Pt){if(i==="strokeUniform")return t==="non-scaling-stroke";if(i==="strokeDashArray")o=t===Pt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(i==="transformMatrix")o=e&&e.transformMatrix?Ct(e.transformMatrix,Qi(t)):Qi(t);else if(i==="visible")o=t!==Pt&&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"?rt:t==="end"?ft:q;else if(i==="charSpacing"||i===Xe)n=ir(t,r)/r*1e3;else if(i==="paintFirst"){const a=t.indexOf(xt),l=t.indexOf(At);o=xt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=At)}else{if(i==="href"||i==="xlink:href"||i==="font"||i==="id")return t;if(i==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(ir):ir(t,r)}}else o="";return!s&&isNaN(n)?o:n}function vd(i,t){const e=i.match(gu);if(!e)return;const r=e[1],s=e[3],n=e[4],o=e[5],a=e[6];r&&(t.fontStyle=r),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(t.fontSize=ir(n)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function yd(i,t){i.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,s]=e.split(":");t[r.trim().toLowerCase()]=s.trim()})}function bd(i){const t={},e=i.getAttribute("style");return e&&(typeof e=="string"?yd(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 wd={stroke:"strokeOpacity",fill:"fillOpacity"};function _e(i,t,e){if(!i)return{};let r,s={},n=Cn;i.parentNode&&Do.test(i.parentNode.nodeName)&&(s=_e(i.parentElement,t,e),s.fontSize&&(r=n=ir(s.fontSize)));const o=y(y(y({},t.reduce((c,h)=>{const u=i.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)ed(c,d.split(" "))&&(u=y(y({},u),h[d]));return u}(i,e)),bd(i));o[Ti]&&i.setAttribute(Ti,o[Ti]),o[Si]&&(r=ir(o[Si],n),o[Si]="".concat(r));const a={};for(const c in o){const h=rd(c),u=md(h,o[c],s,r);a[h]=u}a&&a.font&&vd(a.font,a);const l=y(y({},s),a);return Do.test(i.nodeName)?l:function(c){const h=yt.getDefaults();return Object.entries(wd).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 et(c[d]);c[d]=f.setAlpha(nt(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const xd=["left","top","width","height","visible"],El=["rx","ry"];class Mt extends yt{static getDefaults(){return y(y({},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,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-Te*o,n,s+e,n+Te*a,s+e,n+a),t.lineTo(s+e,n+r-a),l&&t.bezierCurveTo(s+e,n+r-Te*a,s+e-Te*o,n+r,s+e-o,n+r),t.lineTo(s+o,n+r),l&&t.bezierCurveTo(s+Te*o,n+r,s,n+r-Te*a,s,n+r-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+Te*a,s+Te*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([...El,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(r,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
74
- `)]}static async fromElement(t,e,r){const s=_e(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=ot(s,xd);return new this(y(y(y({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}m(Mt,"type","Rect"),m(Mt,"cacheProperties",[...xe,...El]),m(Mt,"ownDefaults",{rx:0,ry:0}),m(Mt,"ATTRIBUTE_NAMES",[...Le,"x","y","rx","ry","width","height"]),R.setClass(Mt),R.setSVGClass(Mt);const pe="initialization",Ns="added",zn="removed",Gs="imperative",Pl=(i,t)=>{const{strokeUniform:e,strokeWidth:r,width:s,height:n,group:o}=t,a=o&&o!==i?oi(o.calcTransformMatrix(),i.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?ou(new _(r,r),void 0,i.calcTransformMatrix()):kn,u=!e&&c?r:0,d=En(s+u,n+u,On([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:s}=t;return e===pe||e===Gs||!!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===Gs&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=me(t.map(u=>Pl(s,u)).reduce((u,d)=>u.concat(d),[])),c=new _(a,l),h=new _(n,o).add(c.scalarDivide(2));if(r===pe){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new _(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}m(ci,"type","strategy");class tn extends ci{shouldPerformLayout(t){return!0}}m(tn,"type","fit-content"),R.setClass(tn);const _d=["strategy"],Cd=["target","strategy","bubbles","prevStrategy"],Al="layoutManager";class ss{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new tn;m(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=y(y({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,qa,Jr,Ka,ri,Za,Bs,Uh,Nh].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===zn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),r===Gs&&t.deep){const n=ot(t,_d);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},n),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:r,type:s}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===pe?new _:e.getRelativeCenterPoint(),{center:a,correction:l=new _,relativeCorrection:c=new _}=n,h=o.subtract(a).add(l).transform(s===pe?Ot: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*vt(r.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*vt(r.originY)}):(r.setPositionByOrigin(n,q,q),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}=t,a=ot(t,Cd),{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(y(y({},a),{},{target:c}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:Al,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(ss,Al);const Sd=["type","objects","layoutManager"];class Td extends ss{performLayout(){}}class Me extends Ja(yt){static getDefaults(){return y(y({},super.getDefaults()),Me.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),m(this,"_activeObjects",[]),m(this,"__objectSelectionTracker",void 0),m(this,"__objectSelectionDisposer",void 0),Object.assign(this,Me.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 ss,this.layoutManager.performLayout({type:pe,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Pe("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Pe("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(zn,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=yt.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(y({target:this,type:Gs},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 y(y(y({},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 s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
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
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: ".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 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}=t,o=ot(t,Sd);return Promise.all([Qr(s,e),ni(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Td}));if(n){const u=R.getClass(n.type),d=R.getClass(n.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new ss;return h.layoutManager.subscribeTargets({type:pe,target:h,targets:h.getObjects()}),h.setCoords(),h})}}m(Me,"type","Group"),m(Me,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(Me);const kd=(i,t)=>Math.min(t.width/i.width,t.height/i.height),Od=(i,t)=>Math.max(t.width/i.width,t.height/i.height),en="\\s*,?\\s*",Sr="".concat(en,"(").concat(te,")"),Dd="".concat(Sr).concat(Sr).concat(Sr).concat(en,"([01])").concat(en,"([01])").concat(Sr).concat(Sr),Md={m:"l",M:"L"},Ed=(i,t,e,r,s,n,o,a,l,c,h)=>{const u=ve(i),d=ye(i),g=ve(t),f=ye(t),p=e*s*g-r*n*f+o,v=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),p+l*(e*s*f+r*n*g),v+l*(r*s*f-e*n*g),p,v]},Yo=(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 Uo(i,t,e,r,s,n,o,a){let l;if(Q.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,p=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,p=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const L=-p/g;0<L&&L<1&&u.push(L);continue}const O=g*g-4*p*f;if(O<0)continue;const S=c(O),j=(-g+S)/(2*f);0<j&&j<1&&u.push(j);const T=(-g-S)/(2*f);0<T&&T<1&&u.push(T)}let v=u.length;const b=v,x=Ll(i,t,e,r,s,n,o,a);for(;v--;){const{x:C,y:O}=x(u[v]);d[0][v]=C,d[1][v]=O}d[0][b]=i,d[1][b]=t,d[0][b+1]=o,d[1][b+1]=a;const D=[new _(Math.min(...d[0]),Math.min(...d[1])),new _(Math.max(...d[0]),Math.max(...d[1]))];return Q.cachesBoundsOfCurve&&(Wr.boundsOfCurveCache[l]=D),D}const Pd=(i,t,e)=>{let[r,s,n,o,a,l,c,h]=e;const u=((d,g,f,p,v,b,x)=>{if(f===0||p===0)return[];let D=0,C=0,O=0;const S=Math.PI,j=x*_n,T=ye(j),L=ve(j),H=.5*(-L*d-T*g),W=.5*(-L*g+T*d),V=f**2,U=p**2,X=W**2,tt=H**2,K=V*U-V*X-U*tt;let Z=Math.abs(f),A=Math.abs(p);if(K<0){const N=Math.sqrt(1-K/(V*U));Z*=N,A*=N}else O=(v===b?-1:1)*Math.sqrt(K/(V*X+U*tt));const ht=O*Z*W/A,ut=-O*A*H/Z,dt=L*ht-T*ut+.5*d,k=T*ht+L*ut+.5*g;let P=Yo(1,0,(H-ht)/Z,(W-ut)/A),E=Yo((H-ht)/Z,(W-ut)/A,(-H-ht)/Z,(-W-ut)/A);b===0&&E>0?E-=2*S:b===1&&E<0&&(E+=2*S);const I=Math.ceil(Math.abs(E/S*2)),F=[],M=E/I,Y=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2);let G=P+M;for(let N=0;N<I;N++)F[N]=Ed(P,G,L,T,Z,A,dt,k,Y,D,C),D=F[N][5],C=F[N][6],P=G,G+=M;return F})(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},Ad=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":Pd(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},$s=(i,t,e,r)=>Math.sqrt((e-i)**2+(r-t)**2),Ll=(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 _(o*c+s*h+e*u+i*d,a*c+n*h+r*u+t*d)},jl=i=>i**2,Fl=i=>2*i*(1-i),Rl=i=>(1-i)**2,Ld=(i,t,e,r,s,n,o,a)=>l=>{const c=jl(l),h=Fl(l),u=Rl(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)},jd=(i,t,e,r,s,n)=>o=>{const a=jl(o),l=Fl(o),c=Rl(o);return new _(s*a+e*l+i*c,n*a+r*l+t*c)},Fd=(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)},No=(i,t,e)=>{let r=new _(t,e),s=0;for(let n=1;n<=100;n+=1){const o=i(n/100);s+=$s(r.x,r.y,o.x,o.y),r=o}return s},Rd=(i,t)=>{let e,r=0,s=0,n={x:i.x,y:i.y},o=y({},n),a=.01,l=0;const c=i.iterator,h=i.angleFinder;for(;s<t&&a>1e-4;)o=c(r),l=r,e=$s(n.x,n.y,o.x,o.y),e+s>t?(r-=a,a/=2):(n=o,r+=a,s+=e);return y(y({},o),{},{angle:h(l)})},Il=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=$s(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Ll(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=Ld(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=No(t,s,n),s=c[5],n=c[6];break;case"Q":t=jd(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Fd(s,n,c[1],c[2],c[3],c[4]),e.length=No(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=$s(s,n,o,a),s=o,n=a}r+=e.length,l.push(e)}return l.push({length:r,x:s,y:n}),l},Id=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Il(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 y(y({},new _(s.x,s.y).lerp(new _(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new _(s.x,s.y).lerp(new _(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return Rd(s,t)}},Bd=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Go=new RegExp(Dd,"g"),zd=new RegExp(te,"gi"),Hd={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Vd=i=>{var t;const e=[],r=(t=i.match(Bd))!==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=Hd[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){Go.lastIndex=0;for(let l=null;l=Go.exec(s);)a.push(...l.slice(1))}else a=s.match(zd)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Md[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},Wd=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new _(i[0]),r=new _(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},Bl=(i,t)=>i.map(e=>e.map((r,s)=>s===0||t===void 0?r:nt(r,t)).join(" ")).join(" ");function rn(i,t){const e=i.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(r=>{let[s,n]=r;return e.setProperty(s,n)}))}class Xd extends cl{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),m(this,"upper",void 0),m(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=dr().createElement("div");return t.setAttribute("data-fabric","wrapper"),rn(t,{position:"relative"}),yo(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:s}=e;rn(t,y(y({},r),{},{"touch-action":s?"manipulation":Pt})),yo(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:s}=this.upper;ll(r,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),$i(this.upper.el,t),$i(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}}class hi extends as{constructor(){super(...arguments),m(this,"targets",[]),m(this,"_hoveredTargets",[]),m(this,"_currentTransform",null),m(this,"_groupSelector",null),m(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),hi.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 Xd(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===si||e===jt||e===Yt||e===Jr?s=this.centeredScaling||t.centeredScaling:e===Tn&&(s=this.centeredRotation||t.centeredRotation),s?!r:r}_getOriginFromCorner(t,e){const r={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=ft:["mr","tr","br"].includes(e)&&(r.x=rt),["tl","mt","tr"].includes(e)?r.y=Gi:["bl","mb","br"].includes(e)&&(r.y=Et)),r}_setupCurrentTransform(t,e,r){var s;const n=e.group?sr(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):cu,c=((g,f,p,v)=>{if(!f||!g)return"drag";const b=v.controls[f];return b.getActionName(p,b,v)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:q,y:q}: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:n.x-e.left,offsetY:n.y-e.top,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:pt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},hl(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:s,deltaY:n}=this._groupSelector,o=new _(e,r).transform(this.viewportTransform),a=new _(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,yt.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,s=this.getActiveObjects();if(this.targets=[],r&&s.length>=1){if(r.findControl(e,qi(t))||s.length>1&&this.searchPossibleTargets([r],e))return r;if(r===this.searchPossibleTargets([r],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==r?(this.targets=n,r):o}return r}}return this.searchPossibleTargets(this._objects,e)}_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 _(o.x-f,o.y-g),new _(a.x+g,a.y-f),new _(l.x+f,l.y+g),new _(c.x-g,c.y+f)]}return lt.isPointInPolygon(e,r)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,sr(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 s=t[r];if(this._checkTarget(s,e)){if(Ms(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e);if(r&&Ms(r)&&r.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Ms(o)||!o.interactive)return o}return s[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,s=r.getBoundingClientRect();let n=ru(t),o=s.width||0,a=s.height||0;o&&a||(Et in s&&Gi in s&&(a=Math.abs(s.top-s.bottom)),ft in s&&rt 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=sr(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new _(1,1):new _(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 Ie(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,Ie(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),Ie(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;Ie(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&&Ie(e)&&this._activeObject===e){const r=mr(t,["angle","flipX","flipY",rt,jt,Yt,gr,fr,Et]);return iu(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(s)}}m(hi,"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 Yd{constructor(t){m(this,"targets",[]),m(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 Ud=["target","oldTarget","fireCanvas","e"],Rt={passive:!1},qe=(i,t)=>{const e=i.getViewportPoint(t),r=i.getScenePoint(t);return{viewportPoint:e,scenePoint:r,pointer:e,absolutePointer:r}},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)},Vt=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)},Nd={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 sn extends hi{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),m(this,"_isClick",void 0),m(this,"textEditingManager",new Yd(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,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const r=this.upperCanvasEl,s=this._getEventPrefix();t(al(r),"resize",this._onResize),t(r,s+"down",this._onMouseDown),t(r,"".concat(s,"move"),this._onMouseMove,Rt),t(r,"".concat(s,"out"),this._onMouseOut),t(r,"".concat(s,"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,Rt)}removeListeners(){this.addOrRemove(Vt,"remove");const t=this._getEventPrefix(),e=Zt(this.upperCanvasEl);Vt(e,"".concat(t,"up"),this._onMouseUp),Vt(e,"touchend",this._onTouchEnd,Rt),Vt(e,"".concat(t,"move"),this._onMouseMove,Rt),Vt(e,"touchmove",this._onMouseMove,Rt),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,r=y({e:t},qe(this,t));this.fire("mouse:out",y(y({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},r)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",y(y({},r),{},{target:s})),s&&s.fire("mouseout",y({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},qe(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)}bo(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 e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Pt,r=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};Vt(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),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:s}=this.findDragTargets(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(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{target:e,targets:r}=this.findDragTargets(t),s={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_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),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:r,dragSource:this._dragSource},qe(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),r=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&bo(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())}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 s=this.upperCanvasEl,n=this._getEventPrefix(),o=Zt(s);ke(o,"touchend",this._onTouchEnd,Rt),e&&ke(o,"touchmove",this._onMouseMove,Rt),Vt(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();Vt(e,"".concat(r,"move"),this._onMouseMove,Rt);const s=Zt(e);ke(s,"".concat(r,"up"),this._onMouseUp),ke(s,"".concat(r,"move"),this._onMouseMove,Rt)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=Zt(this.upperCanvasEl);Vt(r,"touchend",this._onTouchEnd,Rt),Vt(r,"touchmove",this._onMouseMove,Rt),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ke(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 s=Zt(this.upperCanvasEl);Vt(s,"".concat(r,"up"),this._onMouseUp),Vt(s,"".concat(r,"move"),this._onMouseMove,Rt),ke(e,"".concat(r,"move"),this._onMouseMove,Rt)}}_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,s=this._isClick,n=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),!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),qi(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 s=this._target,n=this.targets||[],o=y(y(y({e:t,target:s,subTargets:n},qe(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),s&&s.fire("mouse".concat(e),o);for(let a=0;a<n.length;a++)n[a]!==s&&n[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:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===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 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),qi(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._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=sr(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,s=this._hoveredTargets,n=this.targets,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=this.targets.concat()}_fireEnterLeaveEvents(t,e){const r=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:r,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:n[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:s,fireCanvas:n,e:o}=e,a=ot(e,Ud);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Nd[t],d=s!==r;if(s&&d){const g=y(y({},a),{},{e:o,target:s,nextTarget:r},qe(this,o));n&&this.fire(u,g),s.fire(c,g)}if(r&&d){const g=y(y({},a),{},{e:o,target:r,previousTarget:s},qe(this,o));n&&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,s=r.target,n=s.group?sr(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=Ie(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const o=n.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,s=Ie(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();if(e===r){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,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(n,t)}else{r.isEditing&&r.exitEditing();const n=new(R.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 _(e,r),a=o.add(new _(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=R.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 zl={x1:0,y1:0,x2:0,y2:0},Gd=y(y({},zl),{},{r1:0,r2:0}),er=(i,t)=>isNaN(i)&&typeof t=="number"?t:i;function Hl(i){return i&&/%$/.test(i)&&Number.isFinite(parseFloat(i))}function Vl(i,t){const e=typeof i=="number"?i:typeof i=="string"?parseFloat(i)/(Hl(i)?100:1):NaN;return ar(0,er(e,t),1)}const $d=/\s*;\s*/,qd=/\s*:\s*/;function Kd(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(qd).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}const n=new et(e||i.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Vl(i.getAttribute("offset"),0),color:n.toRgb(),opacity:er(parseFloat(r||i.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function Zd(i,t){const e=[],r=i.getElementsByTagName("stop"),s=Vl(t,1);for(let n=r.length;n--;)e.push(Kd(r[n],s));return e}function Wl(i){return i.nodeName==="linearGradient"||i.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Xl(i){return i.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Gt(i,t){return i.getAttribute(t)}function Jd(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&&Hl(u)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l},{})}(Wl(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),y(y({},t),{},{gradientUnits:Xl(i)}))}class fs{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:y(y({},e==="radial"?Gd:zl),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Ae()):Ae()})}addColorStop(t){for(const e in t){const r=new et(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return y(y({},mr(this,t)),{},{type:this.type,coords:y({},this.coords),colorStops:this.colorStops.map(e=>y({},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():Ot.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>y({},u)).sort((u,d)=>u.offset-d.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_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(ts(s),'"'),""].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,`">
77
- `)}else if(this.type==="radial"){const{x1:u,y1:d,x2:g,y2:f,r1:p,r2:v}=this.coords,b=p>v;r.push("<radialGradient ",h,' cx="',b?u:g,'" cy="',b?d:f,'" r="',b?p:v,'" fx="',b?g:u,'" fy="',b?f:d,`">
78
- `),b&&(o.reverse(),o.forEach(D=>{D.offset=1-D.offset}));const x=Math.min(p,v);if(x>0){const D=x/Math.max(p,v);o.forEach(C=>{C.offset+=D*(1-C.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:";",`"/>
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};"/>
79
79
  `)}),r.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
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,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new et(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this(y(y({},t),{},{colorStops:e?e.map(s=>y({},s)):void 0,gradientTransform:r?[...r]:void 0}))}static fromElement(t,e,r){const s=Xl(t),n=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:Wl(t),coords:Jd(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:Zd(t,r.opacity),gradientUnits:s,gradientTransform:Qi(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}m(fs,"type","Gradient"),R.setClass(fs,"gradient"),R.setClass(fs,"linear"),R.setClass(fs,"radial");const Qd=["type","source","patternTransform"];class Di{get type(){return"pattern"}set type(t){Pe("warn","Setting type has no effect",t)}constructor(t){m(this,"repeat","repeat"),m(this,"offsetX",0),m(this,"offsetY",0),m(this,"crossOrigin",""),this.id=Ae(),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 y(y({},mr(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:nt(this.offsetX,Q.NUM_FRACTION_DIGITS),offsetY:nt(this.offsetY,Q.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_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
81
- `)}static async fromObject(t,e){let{type:r,source:s,patternTransform:n}=t,o=ot(t,Qd);const a=await Ps(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}m(Di,"type","Pattern"),R.setClass(Di),R.setClass(Di,"pattern");class tg{constructor(t){m(this,"color","rgb(0, 0, 0)"),m(this,"width",1),m(this,"shadow",null),m(this,"strokeLineCap","round"),m(this,"strokeLineJoin","round"),m(this,"strokeMiterLimit",10),m(this,"strokeDashArray",null),m(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 et(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()}}const eg=["path","left","top"],rg=["d"];class Oe extends yt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:r,left:s,top:n}=e,o=ot(e,eg);super(),Object.assign(this,Oe.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(rt,s),typeof n=="number"&&this.set(Et,n)}_setPath(t,e){this.path=Ad(Array.isArray(t)?t:Vd(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new _(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 (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},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=Bl(this.path,Q.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
82
- `)]}_getOffsetTransform(){const t=Q.NUM_FRACTION_DIGITS;return" translate(".concat(nt(-this.pathOffset.x,t),", ").concat(nt(-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,q,q)}_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(...Uo(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(...Uo(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 y(y({},t),{},{pathOffset:new _(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 s=_e(t,this.ATTRIBUTE_NAMES,r),{d:n}=s;return new this(n,y(y(y({},ot(s,rg)),e),{},{left:void 0,top:void 0}))}}m(Oe,"type","Path"),m(Oe,"cacheProperties",[...xe,"path","fillRule"]),m(Oe,"ATTRIBUTE_NAMES",[...Le,"d"]),R.setClass(Oe),R.setSVGClass(Oe);class qs extends tg{constructor(t){super(t),m(this,"decimate",.4),m(this,"drawStraightLine",!1),m(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=qs.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++)qs.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 Wd(t,e)}createPath(t){const e=new Oe(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 Bl(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 sg=["left","top","radius"],Yl=["radius","startAngle","endAngle","counterClockwise"];class ge extends yt{static getDefaults(){return y(y({},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,pt(this.startAngle),pt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(jt)}getRadiusY(){return this.get("radius")*this.get(Yt)}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([...Yl,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
83
- `];{const{radius:e}=this,r=pt(this.startAngle),s=pt(this.endAngle),n=ve(r)*e,o=ye(r)*e,a=ve(s)*e,l=ye(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(n," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
84
- `]}}static async fromElement(t,e,r){const s=_e(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:o=0,radius:a=0}=s;return new this(y(y({},ot(s,sg)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}m(ge,"type","Circle"),m(ge,"cacheProperties",[...xe,...Yl]),m(ge,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),m(ge,"ATTRIBUTE_NAMES",["cx","cy","r",...Le]),R.setClass(ge),R.setSVGClass(ge);const ig=["x1","y1","x2","y2"],ng=["x1","y1","x2","y2"],nn=["x1","x2","y1","y2"];class Jt extends yt{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(rt,o),typeof a=="number"&&this.set(Et,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 _(n+a/2,o+l/2);this.setPositionByOrigin(c,q,q)}_set(t,e){return super._set(t,e),nn.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;Xt(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 _((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},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?-1:1,l=r<=s?-1:1;return{x1:a*n/2,x2:a*-n/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:r,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(r,'" x2="').concat(e,'" y2="').concat(s,`" />
85
- `)]}static async fromElement(t,e,r){const s=_e(t,this.ATTRIBUTE_NAMES,r),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],ot(s,ig))}static fromObject(t){let{x1:e,y1:r,x2:s,y2:n}=t,o=ot(t,ng);return this._fromObject(y(y({},o),{},{points:[e,r,s,n]}),{extraParam:"points"})}}m(Jt,"type","Line"),m(Jt,"cacheProperties",[...xe,...nn]),m(Jt,"ATTRIBUTE_NAMES",Le.concat(nn)),R.setClass(Jt),R.setSVGClass(Jt);class Be extends yt{static getDefaults(){return y(y({},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),'" />']}}m(Be,"type","Triangle"),m(Be,"ownDefaults",{width:100,height:100}),R.setClass(Be),R.setSVGClass(Be);const Ul=["rx","ry"];class Kt extends yt{static getDefaults(){return y(y({},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(Yt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Ul,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(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,Is,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const s=_e(t,this.ATTRIBUTE_NAMES,r);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function og(i){if(!i)return[];const t=i.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}m(Kt,"type","Ellipse"),m(Kt,"cacheProperties",[...xe,...Ul]),m(Kt,"ownDefaults",{rx:0,ry:0}),m(Kt,"ATTRIBUTE_NAMES",[...Le,"cx","cy","rx","ry"]),R.setClass(Kt),R.setSVGClass(Kt);const ag=["left","top"],Nl={exactBoundingBox:!1};class qt extends yt{static getDefaults(){return y(y({},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(),m(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(rt,r),typeof s=="number"&&this.set(Et,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return qu(this.points,t,this.isOpen())}_calcDimensions(t){t=y({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 _,strokeOffset:new _,strokeDiff:new _};const r=me(e),s=ii(y(y({},t),{},{scaleX:1,scaleY:1})),n=me(this.points.map(c=>Dt(c,s,!0))),o=new _(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(pt(this.skewX)),l-=a*Math.tan(pt(this.skewY))),y(y({},r),{},{pathOffset:new _(a,l),strokeOffset:new _(n.left,n.top).subtract(new _(r.left,r.top)).multiply(o),strokeDiff:new _(r.width,r.height).subtract(new _(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=me(this.points);return new _(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 _(e+s/2,r+n/2),q,q)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new _(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 _((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r:l)}else{var s,n;o=new _((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new _(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===Yt)&&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 y(y({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:r,y:s}=e;return{x:r,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,r=this.pathOffset.y,s=Q.NUM_FRACTION_DIGITS;for(let n=0,o=this.points.length;n<o;n++)t.push(nt(this.points[n].x-e,s),",",nt(this.points[n].y-r,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
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){return new this(og(t.getAttribute("points")),y(y({},ot(_e(t,this.ATTRIBUTE_NAMES,r),ag)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}m(qt,"ownDefaults",Nl),m(qt,"type","Polyline"),m(qt,"layoutProperties",[gr,fr,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),m(qt,"cacheProperties",[...xe,"points"]),m(qt,"ATTRIBUTE_NAMES",[...Le]),R.setClass(qt),R.setSVGClass(qt);class kr extends qt{isOpen(){return!1}}m(kr,"ownDefaults",Nl),m(kr,"type","Polygon"),R.setClass(kr),R.setSVGClass(kr);class Gl extends yt{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=Mn(y(y({},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 y(y({},mr(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]}}m(Gl,"_styleProperties",uu);const lg=/ +/g,cg=/"/g;function Mi(i,t,e,r,s){return" ".concat(function(n,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q.NUM_FRACTION_DIGITS;const d=es(xt,n,!1),[g,f,p,v]=[a,l,c,h].map(b=>nt(b,u));return"<rect ".concat(d,' x="').concat(g,'" y="').concat(f,'" width="').concat(p,'" height="').concat(v,'"></rect>')}(i,{left:t,top:e,width:r,height:s}),`
88
- `)}const hg=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Ei;class Tt extends Gl{static getDefaults(){return y(y({},super.getDefaults()),Tt.ownDefaults)}constructor(t,e){super(),m(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=Il(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 (".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===At?(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 q:t.textBaseline="middle";break;case"ascender":t.textBaseline=Et;break;case"descender":t.textBaseline=Gi}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 p=this.getHeightOfLineImpl(n);for(let v=0;v<l;v++){const b=this.__charBounds[n][v];u=this.getValueOfPropertyAt(n,v,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=u,u&&t.fillRect(-b.width/2,-p*(1-this._fontSizeFraction),b.width,p),t.restore()):u!==f?(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,s,d,p),g=b.left,d=b.width,f=u):d+=b.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,p)),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 Ei||(Ei=Ut({width:0,height:0}).getContext("2d")),Ei}();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===ft,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 rt:h=n?u-s:0;break;case q:h=(u-s)/2;break;case ft: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=Id(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===ft?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==="ltr"?-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(xt))&&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==="ltr",u=this.direction==="ltr"?1:-1,d=e.direction;let g,f,p,v,b,x="",D=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?rt:ft),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,O=r.length-1;C<=O;C++)v=C===O||this.charSpacing||l,x+=r[C],p=this.__charBounds[o][C],D===0?(s+=u*(p.kernedWidth-p.width),D+=p.width):D+=p.kernedWidth,a&&!v&&this._reSpaceAndTab.test(r[C])&&(v=!0),v||(g=g||this.getCompleteStyleDeclaration(o,C),f=this.getCompleteStyleDeclaration(o,C+1),v=In(g,f,!1)),v&&(l?(e.save(),e.translate(p.renderLeft,p.renderTop),e.rotate(p.angle),this._renderChar(t,e,o,C,x,-D/2,0),e.restore()):(b=s,this._renderChar(t,e,o,C,x,b,n)),x="",g=f,s+=u*D,D=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,s=Ut({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 Xt(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===Yr&&!o||s===Xr&&!o||s===Us&&!o?0:(s===q&&(a=r/2),s===ft&&(a=r),s===Yr&&(a=r/2),s===Xr&&(a=r),n==="rtl"&&(s===ft||s===ie||s===Xr?a=0:s===rt||s===Us?a=-r:s!==q&&s!==Yr||(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 p=0,v=0,b=this.getValueOfPropertyAt(c,0,e),x=this.getValueOfPropertyAt(c,0,xt),D=this.getValueOfPropertyAt(c,0,Xe),C=b,O=x,S=D;const j=r+g*(1-this._fontSizeFraction);let T=this.getHeightOfChar(c,0),L=this.getValueOfPropertyAt(c,0,"deltaY");for(let V=0,U=d.length;V<U;V++){const X=this.__charBounds[c][V];C=this.getValueOfPropertyAt(c,V,e),O=this.getValueOfPropertyAt(c,V,xt),S=this.getValueOfPropertyAt(c,V,Xe);const tt=this.getHeightOfChar(c,V),K=this.getValueOfPropertyAt(c,V,"deltaY");if(n&&C&&O){const Z=this.fontSize*S/1e3;t.save(),t.fillStyle=x,t.translate(X.renderLeft,X.renderTop),t.rotate(X.angle),t.fillRect(-X.kernedWidth/2,l*tt+K-a*Z,X.kernedWidth,Z),t.restore()}else if((C!==b||O!==x||tt!==T||S!==D||K!==L)&&v>0){const Z=this.fontSize*D/1e3;let A=s+f+p;this.direction==="rtl"&&(A=this.width-A-v),b&&x&&D&&(t.fillStyle=x,t.fillRect(A,j+l*T+L-a*Z,v,Z)),p=X.left,v=X.width,b=C,D=S,x=O,T=tt,L=K}else v+=X.kernedWidth}let H=s+f+p;this.direction==="rtl"&&(H=this.width-H-v),t.fillStyle=O;const W=this.fontSize*S/1e3;C&&O&&S&&t.fillRect(H,j+l*T+L-a*W,v-o,W),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:'"'.concat(t,'"');return[e,r,"".concat(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 Rn(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 y(y({},super.toObject([...bl,...t])),{},{styles:Qu(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=_e(t,Tt.ATTRIBUTE_NAMES,r),n=y(y({},e),s),{textAnchor:o=rt,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=Cn,strokeWidth:g=1}=n,f=ot(n,hg),p=new this(Ys(t.textContent||"").trim(),y({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),v=p.getScaledHeight()/p.height,b=((p.height+p.strokeWidth)*p.lineHeight-p.height)*v,x=p.getScaledHeight()+b;let D=0;return o===q&&(D=p.getScaledWidth()/2),o===ft&&(D=p.getScaledWidth()),p.set({left:p.left-D,top:p.top-(x-p.fontSize*(.07+p._fontSizeFraction))/p.lineHeight,strokeWidth:g}),p}static fromObject(t){return this._fromObject(y(y({},t),{},{styles:td(t.styles||{},t.text)}),{extraParam:"text"})}}m(Tt,"textLayoutProperties",yl),m(Tt,"cacheProperties",[...xe,...bl]),m(Tt,"ownDefaults",du),m(Tt,"type","Text"),m(Tt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),m(Tt,"ATTRIBUTE_NAMES",Le.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Dl(Tt,[class extends pl{_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:ts(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="'.concat(this.fontFamily.replace(cg,"'"),'" '),'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>
90
- `]}_getSVGTextAndBg(i,t){const e=[],r=[];let s,n=i;this.backgroundColor&&r.push(...Mi(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=Q.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,i!==i.trim()||!!i.match(lg)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(nt(l,n),'" '):"",{angle:h,renderLeft:u,renderTop:d,width:g}=s;let f="";if(u!==void 0){const p=g/2;h&&(f=' rotate="'.concat(nt(we(h),n),'"'));const v=pr({angle:we(h)});v[4]=u,v[5]=d;const b=new _(-p,0).transform(v);e=b.x,r=b.y}return'<tspan x="'.concat(nt(e,n),'" y="').concat(nt(r,n),'" ').concat(c).concat(f).concat(a,">").concat(Ku(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,p=o.length-1;f<=p;f++)u=f===p||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=In(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(...Mi(c,e+l,r,a,n)),l=u,a=d,c=o):a+=g}o&&i.push(...Mi(c,e+l,r,a,n))}_getSVGLineTopOffset(i){let t,e=0;for(t=0;t<i;t++)e+=this.getHeightOfLine(t);const r=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*r/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(i){return"".concat(super.getSvgStyles(i)," text-decoration-thickness: ").concat(nt(this.textDecorationThickness*this.getObjectScaling().y/10,Q.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(i,t){const{fontFamily:e,strokeWidth:r,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:u,overline:d,underline:g}=i,f=this.getSvgTextDecoration({underline:g??this.underline,overline:d??this.overline,linethrough:u??this.linethrough}),p=h||this.textDecorationThickness;return[s?es(At,s):"",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(nt(p*this.getObjectScaling().y/10,Q.NUM_FRACTION_DIGITS),"%; "):"",n?es(xt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(i){return["overline","underline","line-through"].filter(t=>i[t.replace("-","")]).join(" ")}}]),R.setClass(Tt),R.setSVGClass(Tt);class ug{constructor(t){m(this,"target",void 0),m(this,"__mouseDownInPlace",!1),m(this,"__dragStartFired",!1),m(this,"__isDraggingOver",!1),m(this,"__dragStartSelection",void 0),m(this,"__dragImageDisposer",void 0),m(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 _(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new _(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 _(g.left,g.top)),p=a.viewportTransform,v=f.add(u).transform(p,!0),b=o.backgroundColor,x=Fn(o.styles);o.backgroundColor="";const D={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(D,0,s),o.setSelectionStyles(D,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,rn(C,{position:"fixed",left:"".concat(-C.width,"px"),border:Pt,width:"".concat(C.width/d,"px"),height:"".concat(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,v.x,v.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=y({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(Bs,{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)||Pt;l===Pt?(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(Bs,{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 $o=/[ \n\.,;!\?\-]/;class dg extends Tt{constructor(){super(...arguments),m(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 Cl({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||!Sn.test(r[t-1]))?t-1:t,n=r[s];for(;s>0&&s<r.length&&!$o.test(n);)s+=e,n=r[s];return e===-1&&$o.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.searchWordBoundary(t,-1),s=Math.max(r,this.searchWordBoundary(t,1));this.selectionStart=r,this.selectionEnd=s,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),s=this.findLineBoundaryRight(t);this.selectionStart=r,this.selectionEnd=s,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(){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),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 _(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new _(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(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:y({},s[r-1])}:c?this.styles[t+r]={0:y({},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?y({},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]=y({},s[r]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]=y({},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=rt:this._selectionDirection===ft&&(this._selectionDirection=rt,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===ft?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=ft:this._selectionDirection===rt&&(this._selectionDirection=ft,this.selectionStart=e),this.selectionEnd=r)}}class gg extends dg{initHiddenTextarea(){const t=this.canvas&&Zt(this.canvas.getElement())||dr(),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: ".concat(r,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(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(Bs),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,p,v,b=c-l;const x=this.fromStringToGraphemeSelection(s,n,r),D=h>x.selectionStart;d?(f=this._text.slice(h,u),b+=u-h):c<l&&(f=D?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?(p=h,v=u):D?(p=u-f.length,v=u):(p=u,v=u+f.length),this.removeStyleFromTo(p,v)),C.length){const{copyPasteData:O}=le();e&&C.join("")===O.copiedText&&!Q.disableStyleCopyPaste&&(g=O.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(),Q.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".concat(t,"CursorOffset")](e,this._selectionDirection===ft);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const s=this.text.length;this.selectionStart=ar(0,this.selectionStart,s),this.selectionEnd=ar(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===rt?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".concat(r)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;s=this["findLineBoundary".concat(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=rt,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===ft&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=rt,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===rt&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=ft,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=ft,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const qo=i=>!!i.button;class fg extends gg{constructor(){super(...arguments),m(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 ug(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&&!qo(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||qo(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 _(-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 ps="moveCursorUp",ms="moveCursorDown",vs="moveCursorLeft",ys="moveCursorRight",bs="exitEditing",Ko=(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])},pg=y({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:bs,27:bs,33:ps,34:ms,35:ys,36:vs,37:vs,38:ps,39:ys,40:ms},keysMapRtl:{9:bs,27:bs,33:ps,34:ms,35:vs,36:ys,37:ys,38:ps,39:vs,40:ms},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class oe extends fg{static getDefaults(){return y(y({},super.getDefaults()),oe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},oe.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 sn&&this.canvas.textEditingManager.remove(this),e instanceof sn&&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=Ut(t.canvas),o=n.getContext("2d"),Ko(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=Ut(t.canvas),h=c.getContext("2d");if(Ko(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);for(let c=0;c<n;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(n),a=this.__charBounds[n][s];a&&(r=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());const l={top:e,left:o+(r>0?r:0)};return this.direction==="rtl"&&(this.textAlign===ft||this.textAlign===ie||this.textAlign===Xr?l.left*=-1:this.textAlign===rt||this.textAlign===Us?l.left=o-(r>0?r:0):this.textAlign!==q&&this.textAlign!==Yr||(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),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 s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(ie),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),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 p=this.getHeightOfLine(g),v=0,b=0,x=0;if(g===c&&(b=this.__charBounds[c][u].left),g>=c&&g<h)x=o&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(d===0)x=this.__charBounds[h][d].left;else{const j=this._getWidthOfCharSpacing();x=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-j}v=p,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(p/=this.lineHeight);let D=r.left+f+b,C=p,O=0;const S=x-b;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",C=1,O=p):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===ft||this.textAlign===ie||this.textAlign===Xr?D=this.width-D-S:this.textAlign===rt||this.textAlign===Us?D=r.left+f-x:this.textAlign!==q&&this.textAlign!==Yr||(D=r.left+f-x)),t.fillRect(D,r.top+r.topOffset+O,S,C),r.topOffset+=v}}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,xt)}_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()}}m(oe,"ownDefaults",pg),m(oe,"type","IText"),R.setClass(oe),R.setClass(oe,"i-text");class ze extends oe{static getDefaults(){return y(y({},super.getDefaults()),ze.ownDefaults)}constructor(t,e){super(t,y(y({},ze.ownDefaults),e))}static createControls(){return{controls:Nu()}}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,p=!0;e-=o;const v=Math.max(e,s,this.dynamicMinWidth),b=n[t];let x;for(g=0,x=0;x<b.length;x++){const{word:D,width:C}=b[x];g+=D.length,u+=f+C-a,u>v&&!p?(c.push(d),d=[],u=C,p=!0):u+=a,p||l||d.push(h),d=d.concat(D),f=l?0:this._measureWord([h],t,g),g++,p=!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("".concat(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])}}m(ze,"type","Textbox"),m(ze,"textLayoutProperties",[...oe.textLayoutProperties,"width"]),m(ze,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(ze);class Zo extends ci{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(Pl(r,s)),l=new _(o,a);if(s.absolutePositioned)return{center:sr(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 _,correction:u=new _}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}m(Zo,"type","clip-path"),R.setClass(Zo);class Jo extends ci{getInitialSize(t,e){let{target:r}=t,{size:s}=e;return new _(r.width||s.x,r.height||s.y)}}m(Jo,"type","fixed"),R.setClass(Jo);class mg extends ss{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 He extends Me{static getDefaults(){return y(y({},super.getDefaults()),He.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,He.ownDefaults),this.setOptions(e);const{left:r,top:s,layoutManager:n}=e;this.groupInit(t,{left:r,top:s,layoutManager:n??new mg})}_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))?(Pe("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===zn?r.forEach(s=>{s._onAfterObjectsChange(Ns,e)}):r.forEach(s=>{s._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 s=y(y({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()}}m(He,"type","ActiveSelection"),m(He,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(He),R.setClass(He,"activeSelection");class vg{constructor(){m(this,"resources",{})}applyFilters(t,e,r,s,n){const o=n.getContext("2d");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 $l{constructor(){let{tileSize:t=Q.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};m(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),m(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=Ut({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,p=g.height,v=d.destinationWidth,b=d.destinationHeight;f===v&&p===b||(g.width=v,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,p=t.createTexture();return t.bindTexture(a,p),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),p}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 Pi;function yg(){const{WebGLProbe:i}=le();return i.queryWebGL(be()),Q.enableGLFiltering&&i.isSupported(Q.textureSize)?new $l({tileSize:Q.textureSize}):new vg}function Ai(){return!Pi&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Pi=yg()),Pi}const bg=["filters","resizeFilter","src","crossOrigin","type"],ql=["cropX","cropY"];class _t extends yt{static getDefaults(){return y(y({},super.getDefaults()),_t.ownDefaults)}constructor(t,e){super(),m(this,"_lastScaleX",1),m(this,"_lastScaleY",1),m(this,"_filterScalingX",1),m(this,"_filterScalingY",1),this.filters=[],Object.assign(this,_t.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ae()),this.setElement(typeof t=="string"?(this.canvas&&Zt(this.canvas.getElement())||dr()).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(_t.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Ai(!1);e instanceof $l&&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&&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())}),y(y({},super.toObject([...ql,...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=Ae();n.push('<clipPath id="imageCrop_'+c+`">
93
- `,' <rect x="'+r+'" y="'+s+'" 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)+`" />
94
94
  `,`</clipPath>
95
- `),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(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
96
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(r,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
97
- `)],this.fill=c}return n=this.paintFirst!==xt?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 Ps(t,{crossOrigin:e,signal:r}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(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=Ut(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Ai().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("".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,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=Ut({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);Ai().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),p=-n/2,v=-o/2,b=Math.min(n,c/r-a),x=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,g,f,p,v,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=hu(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===Pt&&t.alignY===Pt?(l=e/o,c=r/a):(t.meetOrSlice==="meet"&&(l=c=kd(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=Od(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}=t,l=ot(t,bg);return Promise.all([Ps(n,y(y({},e),{},{crossOrigin:o})),r&&Qr(r,e),s&&Qr([s],e),ni(l,e)]).then(c=>{let[h,u=[],[d]=[],g={}]=c;return new this(h,y(y({},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 Ps(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=_e(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(s["xlink:href"]||s.href,e,s).catch(n=>(Pe("log","Unable to parse Image",n),null))}}m(_t,"type","Image"),m(_t,"cacheProperties",[...xe,...ql]),m(_t,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),m(_t,"CSS_CANVAS","canvas-img"),m(_t,"ATTRIBUTE_NAMES",[...Le,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),R.setClass(_t),R.setSVGClass(_t);ai(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ui=i=>i.webgl!==void 0,Hn="precision highp float",wg=`
98
- `.concat(Hn,`;
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};
99
99
  varying vec2 vTexCoord;
100
100
  uniform sampler2D uTexture;
101
101
  void main() {
102
102
  gl_FragColor = texture2D(uTexture, vTexCoord);
103
- }`),xg=["type"],_g=["type"],Cg=new RegExp(Hn,"g");class bt{get type(){return this.constructor.type}constructor(){let t=ot(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},xg);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return wg}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`
104
104
  attribute vec2 aPosition;
105
105
  varying vec2 vTexCoord;
106
106
  void main() {
107
107
  vTexCoord = aPosition;
108
108
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
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(Cg,Hn.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 ne("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new ne("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new ne("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new ne('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,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){ui(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=Ut({width:e,height:r});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return y({type:this.type},t.reduce((e,r)=>(e[r]=this[r],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ot(t,_g))}}m(bt,"type","BaseFilter"),m(bt,"uniformLocations",[]);const Sg={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;
110
110
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
111
111
  `,add:`gl_FragColor.rgb += uColor.rgb;
112
112
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -133,7 +133,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
133
133
  `,tint:`
134
134
  gl_FragColor.rgb *= (1.0 - uColor.a);
135
135
  gl_FragColor.rgb += uColor.rgb;
136
- `};class Or extends bt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
136
+ `};class Dr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
137
137
  precision highp float;
138
138
  uniform sampler2D uTexture;
139
139
  uniform vec4 uColor;
@@ -142,10 +142,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
142
142
  vec4 color = texture2D(uTexture, vTexCoord);
143
143
  gl_FragColor = color;
144
144
  if (color.a > 0.0) {
145
- `.concat(Sg[this.mode],`
145
+ ${sg[this.mode]}
146
146
  }
147
147
  }
148
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const r=new et(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,p;switch(this.mode){case"multiply":g=h*n/255,f=u*o/255,p=d*a/255;break;case"screen":g=255-(255-h)*(255-n)/255,f=255-(255-u)*(255-o)/255,p=255-(255-d)*(255-a)/255;break;case"add":g=h+n,f=u+o,p=d+a;break;case"difference":g=Math.abs(h-n),f=Math.abs(u-o),p=Math.abs(d-a);break;case"subtract":g=h-n,f=u-o,p=d-a;break;case"darken":g=Math.min(h,n),f=Math.min(u,o),p=Math.min(d,a);break;case"lighten":g=Math.max(h,n),f=Math.max(u,o),p=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,p=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,p=a+d-2*a*d/255;break;case"tint":g=n+h*l,f=o+u*l,p=a+d*l}e[c]=g,e[c+1]=f,e[c+2]=p}}sendUniformData(t,e){const r=new et(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)}}m(Or,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),m(Or,"type","BlendColor"),m(Or,"uniformLocations",["uColor"]),R.setClass(Or);const Tg={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:`
149
149
  precision highp float;
150
150
  uniform sampler2D uTexture;
151
151
  uniform sampler2D uImage;
@@ -171,7 +171,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
171
171
  color.a = color2.a;
172
172
  gl_FragColor = color;
173
173
  }
174
- `},kg=["type","image"];class Dr extends bt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Tg[this.mode]}getVertexSource(){return`
174
+ `};class Mr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return ig[this.mode]}getVertexSource(){return`
175
175
  attribute vec2 aPosition;
176
176
  varying vec2 vTexCoord;
177
177
  varying vec2 vTexCoord2;
@@ -181,7 +181,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
181
181
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
182
182
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
183
183
  }
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],p=c[h],v=c[h+1],b=c[h+2],x=c[h+3];switch(this.mode){case"multiply":e[h]=u*p/255,e[h+1]=d*v/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 y(y({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:r,image:s}=t,n=ot(t,kg);return _t.fromObject(s,e).then(o=>new this(y(y({},n),{},{image:o})))}}m(Dr,"type","BlendImage"),m(Dr,"defaults",{mode:"multiply",alpha:1}),m(Dr,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(Dr);class Mr extends bt{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`
185
185
  precision highp float;
186
186
  uniform sampler2D uTexture;
187
187
  uniform vec2 uDelta;
@@ -210,7 +210,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
210
210
  gl_FragColor.rgb = color.rgb / totalC;
211
211
  gl_FragColor.a = color.a / totalA;
212
212
  }
213
- `}applyTo(t){ui(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 p=c-c%l,v=p+l;for(let b=-14;b<a;b++){const x=b/a,D=4*Math.floor(n*x),C=1-Math.abs(x);let O=c+D;O<p?O=p:O>v&&(O=v);const S=e[O+3]*C;h+=e[O]*S,u+=e[O+1]*S,d+=e[O+2]*S,g+=S,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 p=c%l,v=o.length-l+p;for(let b=-14;b<a;b++){const x=b/a,D=Math.floor(n*x)*l,C=1-Math.abs(x);let O=c+D;O<p?O=p:O>v&&(O=v);const S=o[O+3]*C;h+=o[O]*S,u+=o[O+1]*S,d+=o[O+2]*S,g+=S,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]}}m(Mr,"type","Blur"),m(Mr,"defaults",{blur:0}),m(Mr,"uniformLocations",["uDelta"]),R.setClass(Mr);class Er extends bt{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`
214
214
  precision highp float;
215
215
  uniform sampler2D uTexture;
216
216
  uniform float uBrightness;
@@ -220,7 +220,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
220
220
  color.rgb += uBrightness;
221
221
  gl_FragColor = color;
222
222
  }
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)}}m(Er,"type","Brightness"),m(Er,"defaults",{brightness:0}),m(Er,"uniformLocations",["uBrightness"]),R.setClass(Er);const Kl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ve extends bt{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`
224
224
  precision highp float;
225
225
  uniform sampler2D uTexture;
226
226
  varying vec2 vTexCoord;
@@ -231,7 +231,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
231
231
  color *= uColorMatrix;
232
232
  color += uConstants;
233
233
  gl_FragColor = color;
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 y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function Ye(i,t){var e;const r=(m(e=class extends Ve{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",i),m(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(r,i),r}m(Ve,"type","ColorMatrix"),m(Ve,"defaults",Kl),m(Ve,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(Ve);const Og=Ye("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Dg=Ye("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Mg=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]),Eg=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]),Pg=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]),Ag=Ye("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Lg=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 on extends bt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ui(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=>R.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}m(on,"type","Composed"),R.setClass(on);class Pr extends bt{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`
235
235
  precision highp float;
236
236
  uniform sampler2D uTexture;
237
237
  uniform float uContrast;
@@ -241,7 +241,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
241
241
  float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
242
242
  color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
243
243
  gl_FragColor = color;
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)}}m(Pr,"type","Contrast"),m(Pr,"defaults",{contrast:0}),m(Pr,"uniformLocations",["uContrast"]),R.setClass(Pr);const jg={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:`
245
245
  precision highp float;
246
246
  uniform sampler2D uTexture;
247
247
  uniform float uMatrix[9];
@@ -385,7 +385,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
385
385
  gl_FragColor = color;
386
386
  gl_FragColor.a = alpha;
387
387
  }
388
- `};class Ar extends bt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return jg[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,p,v,b,x,D,C,O,S,j,T;for(S=0;S<l;S++)for(O=0;O<a;O++){for(v=4*(S*a+O),d=0,g=0,f=0,p=0,T=0;T<n;T++)for(j=0;j<n;j++)x=S+T-o,b=O+j-o,x<0||x>=l||b<0||b>=a||(D=4*(x*a+b),C=s[T*n+j],d+=r[D]*C,g+=r[D+1]*C,f+=r[D+2]*C,u||(p+=r[D+3]*C));h[v]=d,h[v+1]=g,h[v+2]=f,h[v+3]=u?r[v+3]:p}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}m(Ar,"type","Convolute"),m(Ar,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),m(Ar,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(Ar);const Zl="Gamma";class Lr extends bt{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`
389
389
  precision highp float;
390
390
  uniform sampler2D uTexture;
391
391
  uniform vec3 uGamma;
@@ -399,7 +399,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
399
399
  gl_FragColor = color;
400
400
  gl_FragColor.rgb *= color.a;
401
401
  }
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:Zl,gamma:this.gamma.concat()}}}m(Lr,"type",Zl),m(Lr,"defaults",{gamma:[1,1,1]}),m(Lr,"uniformLocations",["uGamma"]),R.setClass(Lr);const Fg={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:`
403
403
  precision highp float;
404
404
  uniform sampler2D uTexture;
405
405
  varying vec2 vTexCoord;
@@ -428,7 +428,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
428
428
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
429
429
  gl_FragColor = vec4(average, average, average, col.a);
430
430
  }
431
- `};class jr extends bt{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"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Fg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}m(jr,"type","Grayscale"),m(jr,"defaults",{mode:"average"}),m(jr,"uniformLocations",["uMode"]),R.setClass(jr);const Rg=y(y({},Kl),{},{rotation:0});class Ls extends Ve{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}}}m(Ls,"type","HueRotation"),m(Ls,"defaults",Rg),R.setClass(Ls);class Fr extends bt{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`
432
432
  precision highp float;
433
433
  uniform sampler2D uTexture;
434
434
  uniform int uInvert;
@@ -446,7 +446,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
446
446
  gl_FragColor = color;
447
447
  }
448
448
  }
449
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}m(Fr,"type","Invert"),m(Fr,"defaults",{alpha:!1,invert:!0}),m(Fr,"uniformLocations",["uInvert","uAlpha"]),R.setClass(Fr);class Rr extends bt{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`
450
450
  precision highp float;
451
451
  uniform sampler2D uTexture;
452
452
  uniform float uStepH;
@@ -461,7 +461,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
461
461
  color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
462
462
  gl_FragColor = color;
463
463
  }
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}}m(Rr,"type","Noise"),m(Rr,"defaults",{noise:0}),m(Rr,"uniformLocations",["uNoise","uSeed"]),R.setClass(Rr);class Ir extends bt{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`
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`
465
465
  precision highp float;
466
466
  uniform sampler2D uTexture;
467
467
  uniform float uBlocksize;
@@ -479,7 +479,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
479
479
  vec4 color = texture2D(uTexture, squareCoords);
480
480
  gl_FragColor = color;
481
481
  }
482
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}m(Ir,"type","Pixelate"),m(Ir,"defaults",{blocksize:4}),m(Ir,"uniformLocations",["uBlocksize"]),R.setClass(Ir);class Br extends bt{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`
483
483
  precision highp float;
484
484
  uniform sampler2D uTexture;
485
485
  uniform vec4 uLow;
@@ -491,23 +491,23 @@ void main() {
491
491
  gl_FragColor.a = 0.0;
492
492
  }
493
493
  }
494
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,s=new et(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 et(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)}}m(Br,"type","RemoveColor"),m(Br,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),m(Br,"uniformLocations",["uLow","uHigh"]),R.setClass(Br);class zr extends bt{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(),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]="".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`
495
495
  precision highp float;
496
496
  uniform sampler2D uTexture;
497
497
  uniform vec2 uDelta;
498
498
  varying vec2 vTexCoord;
499
- uniform float uTaps[`.concat(t,`];
499
+ uniform float uTaps[${t}];
500
500
  void main() {
501
501
  vec4 color = texture2D(uTexture, vTexCoord);
502
502
  float sum = 1.0;
503
- `).concat(e.map((r,s)=>`
504
- color += texture2D(uTexture, vTexCoord + `.concat(r,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(r,") * uTaps[").concat(s,`];
505
- sum += 2.0 * uTaps[`).concat(s,`];
506
- `)).join(`
507
- `),`
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
+ `)}
508
508
  gl_FragColor = color / sum;
509
509
  }
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){ui(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 p=e;let v=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,p,v,h,u),g=p,f=v,v+=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),p=Math.ceil(u*this.lanczosLobes/2),v={},b={x:0,y:0},x={x:0,y:0};return function D(C){let O,S,j,T,L,H,W,V,U,X,tt;for(b.x=(C+.5)*h,x.x=Math.floor(b.x),O=0;O<n;O++){for(b.y=(O+.5)*u,x.y=Math.floor(b.y),L=0,H=0,W=0,V=0,U=0,S=x.x-f;S<=x.x+f;S++)if(!(S<0||S>=e)){X=Math.floor(1e3*Math.abs(S-b.x)),v[X]||(v[X]={});for(let K=x.y-p;K<=x.y+p;K++)K<0||K>=r||(tt=Math.floor(1e3*Math.abs(K-b.y)),v[X][tt]||(v[X][tt]=c(Math.sqrt(Math.pow(X*d,2)+Math.pow(tt*g,2))/1e3)),j=v[X][tt],j>0&&(T=4*(K*e+S),L+=j,H+=j*o[T],W+=j*o[T+1],V+=j*o[T+2],U+=j*o[T+3]))}T=4*(O*s+C),l[T]=H/L,l[T+1]=W/L,l[T+2]=V/L,l[T+3]=U/L}return++C<s?D(C):a}(0)}bilinearFiltering(t,e,r,s,n){let o,a,l,c,h,u,d,g,f,p,v,b,x,D=0;const C=this.rcpScaleX,O=this.rcpScaleY,S=4*(e-1),j=t.imageData.data,T=t.ctx.createImageData(s,n),L=T.data;for(d=0;d<n;d++)for(g=0;g<s;g++)for(h=Math.floor(C*g),u=Math.floor(O*d),f=C*g-h,p=O*d-u,x=4*(u*e+h),v=0;v<4;v++)o=j[x+v],a=j[x+4+v],l=j[x+S+v],c=j[x+S+4+v],b=o*(1-f)*(1-p)+a*f*(1-p)+l*p*(1-f)+c*f*p,L[D++]=b;return T}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 p=4*(f+g*s);let v=0,b=0,x=0,D=0,C=0,O=0,S=0;const j=(g+.5)*a;for(let T=Math.floor(g*a);T<(g+1)*a;T++){const L=Math.abs(j-(T+.5))/c,H=(f+.5)*o,W=L*L;for(let V=Math.floor(f*o);V<(f+1)*o;V++){let U=Math.abs(H-(V+.5))/l;const X=Math.sqrt(W+U*U);X>1&&X<-1||(v=2*X*X*X-3*X*X+1,v>0&&(U=4*(V+T*e),S+=v*h[U+3],x+=v,h[U+3]<255&&(v=v*h[U+3]/250),D+=v*h[U],C+=v*h[U+1],O+=v*h[U+2],b+=v))}}d[p]=D/b,d[p+1]=C/b,d[p+2]=O/b,d[p+3]=S/x}return u}}m(zr,"type","Resize"),m(zr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),m(zr,"uniformLocations",["uDelta","uTaps"]),R.setClass(zr);class Hr extends bt{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`
511
511
  precision highp float;
512
512
  uniform sampler2D uTexture;
513
513
  uniform float uSaturation;
@@ -521,7 +521,7 @@ void main() {
521
521
  color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
522
522
  gl_FragColor = color;
523
523
  }
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}}m(Hr,"type","Saturation"),m(Hr,"defaults",{saturation:0}),m(Hr,"uniformLocations",["uSaturation"]),R.setClass(Hr);class Vr extends bt{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`
525
525
  precision highp float;
526
526
  uniform sampler2D uTexture;
527
527
  uniform float uVibrance;
@@ -536,6 +536,6 @@ void main() {
536
536
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
537
537
  gl_FragColor = color;
538
538
  }
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}}m(Vr,"type","Vibrance"),m(Vr,"defaults",{vibrance:0}),m(Vr,"uniformLocations",["uVibrance"]),R.setClass(Vr);var an=Object.freeze({__proto__:null,BaseFilter:bt,BlackWhite:Lg,BlendColor:Or,BlendImage:Dr,Blur:Mr,Brightness:Er,Brownie:Og,ColorMatrix:Ve,Composed:on,Contrast:Pr,Convolute:Ar,Gamma:Lr,Grayscale:jr,HueRotation:Ls,Invert:Fr,Kodachrome:Mg,Noise:Rr,Pixelate:Ir,Polaroid:Pg,RemoveColor:Br,Resize:zr,Saturation:Hr,Sepia:Ag,Technicolor:Eg,Vibrance:Vr,Vintage:Dg});const Qo=Symbol.for("bugpin-toObject-patched");if(!yt.prototype[Qo]){const i=yt.prototype.toObject;yt.prototype.toObject=function(t){const e=[...new Set(["data",...t||[]])];return i.call(this,e)},yt.prototype[Qo]=!0}const Ig=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],Bg=[2,4,6,8];let zg=0;function Hg(i,t,e){var D,C,O;const r=t,s=++zg;r.data&&(r.data.generationId=s);const n=i.getZoom(),o=((D=i.viewportTransform)==null?void 0:D.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,v=((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 S=new _t(b);S.filters=[new an.Pixelate({blocksize:v})],S.applyFilters();const j=S.getElement();if(((O=r.data)==null?void 0:O.generationId)!==s){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}t.setElement(j),t.set({scaleX:1,scaleY:1,width:h,height:u}),r.data={type:"pixelate",blockSize:v,generationId:s}}i.setZoom(n),i.setViewportTransform(o),i.renderAll()}const Vg=({screenshot:i,onSave:t,onCancel:e})=>{const r=Bt(null),s=Bt(null),n=Bt(null),[o,a]=ct("select"),[l,c]=ct("#ef4444"),[h,u]=ct(4),[d,g]=ct(!1),[f,p]=ct(!1),[v,b]=ct(1),[x,D]=ct(!1),C=Bt([]),O=Bt(-1),S=Bt(!1),j=Bt(!1),T=Bt(null),L=Bt(null);Wt(()=>{if(!r.current)return;const k=new sn(r.current,{isDrawingMode:!1,selection:!0});n.current=k,_t.fromURL(i).then(I=>{var N;L.current={width:I.width||800,height:I.height||600};const F=(N=s.current)==null?void 0:N.getBoundingClientRect(),M=F?F.width-32:800,Y=F?F.height-32:600,G=Math.min(M/(I.width||800),Y/(I.height||600));k.setDimensions({width:(I.width||800)*G,height:(I.height||600)*G}),I.scaleToWidth(k.width),k.backgroundImage=I,k.renderAll(),H()}),k.freeDrawingBrush=new qs(k),k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h,k.on("path:created",()=>{H()}),k.on("object:modified",I=>{var M;const F=I.target;((M=F==null?void 0:F.data)==null?void 0:M.type)==="pixelate"&&F instanceof _t&&k.backgroundImage&&(Hg(k,F,k.backgroundImage),H())});const P=r.current,E=I=>I.preventDefault();return P==null||P.addEventListener("contextmenu",E),()=>{P==null||P.removeEventListener("contextmenu",E),k.dispose()}},[i]),Wt(()=>{if(!n.current)return;const k=n.current;k.freeDrawingBrush&&(k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h)},[l,h]),Wt(()=>{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",D(o==="pan")},[o]);const H=J(()=>{if(!n.current)return;const k=JSON.stringify(n.current.toJSON());C.current=C.current.slice(0,O.current+1),C.current.push(k),O.current=C.current.length-1,g(O.current>0),p(!1)},[]),W=J(()=>{if(!n.current||O.current<=0)return;O.current--;const k=C.current[O.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(O.current>0),p(O.current<C.current.length-1)})},[]),V=J(()=>{if(!n.current||O.current>=C.current.length-1)return;O.current++;const k=C.current[O.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(O.current>0),p(O.current<C.current.length-1)})},[]),U=J(k=>{var F;if(!n.current||o==="pen"||o==="select"||o==="pan"||k.target||(F=n.current)!=null&&F.findTarget(k.e))return;S.current=!0;const P=n.current,E=P.getPointer(k.e);let I=null;switch(o){case"rectangle":I=new Mt({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":I=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":I=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1});break;case"arrow":I=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1}),I._isArrow=!0;break;case"text":I=new oe("Text",{left:E.x,top:E.y,fontSize:20,fill:l,selectable:!0,editable:!0}),P.add(I),P.setActiveObject(I),I.enterEditing(),S.current=!1;return;case"pixelate":I=new Mt({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}I&&(I._startPoint={x:E.x,y:E.y},P.add(I),P._drawingShape=I)},[o,l,h]),X=J(k=>{if(!n.current||!S.current)return;const P=n.current,E=P._drawingShape;if(!E||!E._startPoint)return;const I=P.getPointer(k.e),F=E._startPoint;if(E instanceof Mt){const M=I.x-F.x,Y=I.y-F.y;E.set({left:M>0?F.x:I.x,top:Y>0?F.y:I.y,width:Math.abs(M),height:Math.abs(Y)})}else if(E instanceof Kt){const M=Math.abs(I.x-F.x)/2,Y=Math.abs(I.y-F.y)/2;E.set({left:Math.min(F.x,I.x),top:Math.min(F.y,I.y),rx:M,ry:Y})}else E instanceof Jt&&E.set({x2:I.x,y2:I.y});P.renderAll()},[]),tt=J(async()=>{var k;if(S.current&&n.current){S.current=!1;const P=n.current,E=P._drawingShape;if(E){if(o==="pixelate"&&E instanceof Mt&&P.backgroundImage){const F=E,M=P.getZoom(),Y=((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(),F.setCoords();const G=F.getBoundingRect(),N=G.left,Ft=G.top,at=G.width,Ht=G.height;if(at>5&&Ht>5){const St=P.backgroundImage,je=St.getElement(),it=St.scaleX||1,re=St.scaleY||1,Nt=document.createElement("canvas");Nt.width=at,Nt.height=Ht;const he=Nt.getContext("2d");if(he){he.drawImage(je,N/it,Ft/re,at/it,Ht/re,0,0,at,Ht);const Ue=Math.max(3,Math.round(Math.min(at,Ht)/20)),Ce=new _t(Nt,{left:N,top:Ft,selectable:!0,hasControls:!0,hasBorders:!0});Ce.data={type:"pixelate",blockSize:Ue},Ce.filters=[new an.Pixelate({blocksize:Ue})],Ce.applyFilters(),P.remove(F),P.add(Ce)}}else P.remove(F);P.setZoom(M),P.setViewportTransform(Y),P.renderAll()}else if(E._isArrow&&E instanceof Jt){const F=E,M=F.x1||0,Y=F.y1||0,G=F.x2||0,N=F.y2||0,Ft=G-M,at=N-Y,Ht=Math.sqrt(Ft*Ft+at*at);if(Ht>10){const St=Math.atan2(at,Ft),je=F.strokeWidth||2,it=Math.max(je*5,Math.min(je*7,Ht/3)),re=it*.35,Nt=G-it*Math.cos(St),he=N-it*Math.sin(St),Ue=Nt-re*Math.cos(St-Math.PI/2),Ce=he-re*Math.sin(St-Math.PI/2),se=Nt-re*Math.cos(St+Math.PI/2),br=he-re*Math.sin(St+Math.PI/2);F.set({x2:Nt,y2:he});const wr=new kr([{x:G,y:N},{x:Ue,y:Ce},{x:se,y:br}],{fill:F.stroke,stroke:F.stroke,strokeWidth:1,selectable:!1}),Ne=new Me([F,wr],{selectable:!0,hasControls:!0,hasBorders:!0});P.remove(F),P.add(Ne)}else E.set({selectable:!0,hasControls:!0,hasBorders:!0})}else E.set({selectable:!0,hasControls:!0,hasBorders:!0});P._drawingShape=void 0}H()}},[H,o]);Wt(()=>{if(!n.current)return;const k=n.current;return k.on("mouse:down",U),k.on("mouse:move",X),k.on("mouse:up",tt),()=>{k.off("mouse:down",U),k.off("mouse:move",X),k.off("mouse:up",tt)}},[U,X,tt]);const K=J(()=>{var Ft;if(!n.current)return;const k=n.current,P=k.getZoom(),E=((Ft=k.viewportTransform)==null?void 0:Ft.slice())||[1,0,0,1,0,0];k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll();const I=L.current,F=I?I.width/(k.width||1):1,M=[];if(k.backgroundImage&&F>1){const at=k.backgroundImage,Ht=at.getElement(),St=at.scaleX||1,je=at.scaleY||1;k.getObjects().forEach(it=>{var Nt,he;const re=it;if(((Nt=re.data)==null?void 0:Nt.type)==="pixelate"&&it instanceof _t){const Ue=it.getElement(),Ce={width:it.width||0,height:it.height||0,scaleX:it.scaleX||1,scaleY:it.scaleY||1,left:it.left||0,top:it.top||0,angle:it.angle||0,skewX:it.skewX||0,skewY:it.skewY||0,flipX:it.flipX||!1,flipY:it.flipY||!1};M.push({obj:it,originalElement:Ue,originalState:Ce}),it.setCoords();const se=it.getBoundingRect(),br=se.width*F,wr=se.height*F,Ne=document.createElement("canvas");Ne.width=br,Ne.height=wr;const Nn=Ne.getContext("2d");if(Nn){Nn.drawImage(Ht,se.left/St,se.top/je,se.width/St,se.height/je,0,0,br,wr);const mc=((he=re.data)==null?void 0:he.blockSize)||Math.max(3,Math.round(Math.min(se.width,se.height)/20)),vc=Math.round(mc*F),mi=new _t(Ne);mi.filters=[new an.Pixelate({blocksize:vc})],mi.applyFilters(),it.setElement(mi.getElement()),it.set({width:br,height:wr,scaleX:1/F,scaleY:1/F})}}}),k.renderAll()}const Y=k.toDataURL({format:"png",quality:1,multiplier:F});M.forEach(({obj:at,originalElement:Ht,originalState:St})=>{at.setElement(Ht),at.set(St)}),k.setZoom(P),k.setViewportTransform(E),k.renderAll();const N=k.getObjects().map(at=>at.toObject());t(Y,{objects:N})},[t]),Z=J(()=>{if(!n.current)return;const k=n.current,P=k.getActiveObjects();P.length>0&&(P.forEach(E=>k.remove(E)),k.discardActiveObject(),k.renderAll(),H())},[H]),A=J(()=>{if(!n.current)return;const k=n.current,P=Math.min(v*1.2,3),E=new _(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[v]),ht=J(()=>{if(!n.current)return;const k=n.current,P=Math.max(v/1.2,.5),E=new _(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[v]),ut=J(()=>{if(!n.current)return;const k=n.current;b(1),k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll()},[]);Wt(()=>{if(!n.current)return;const k=n.current,P=F=>{const M=F.e;(M.buttons===2||M.buttons===1&&x||M.buttons===1&&o==="pan")&&(M.preventDefault(),j.current=!0,k.selection=!1,T.current={x:M.clientX,y:M.clientY},k.setCursor("grabbing"))},E=F=>{if(j.current&&T.current){const M=F.e,Y=k.viewportTransform;Y[4]+=M.clientX-T.current.x,Y[5]+=M.clientY-T.current.y,k.requestRenderAll(),T.current={x:M.clientX,y:M.clientY}}},I=()=>{j.current&&(j.current=!1,T.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",I),()=>{k.off("mouse:down",P),k.off("mouse:move",E),k.off("mouse:up",I)}},[x,o]),Wt(()=>{const k=E=>{if(E.key===" "&&!x&&(E.preventDefault(),D(!0),n.current&&n.current.setCursor("grab")),E.key==="Delete"||E.key==="Backspace"){const I=document.activeElement;(I==null?void 0:I.tagName)!=="INPUT"&&(I==null?void 0:I.tagName)!=="TEXTAREA"&&Z()}(E.ctrlKey||E.metaKey)&&E.key==="z"&&(E.preventDefault(),E.shiftKey?V():W())},P=E=>{E.key===" "&&x&&(D(!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)}},[Z,W,V,x,o]);const dt=({tool:k,icon:P,label:E})=>w("button",{class:zt("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:w("span",{dangerouslySetInnerHTML:{__html:P}})});return w("div",{class:"flex flex-col",children:[w("div",{class:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-solid border-border bg-muted",children:[w("div",{class:"flex items-center gap-1",children:[w(dt,{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>'}),w(dt,{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>'}),w(dt,{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>'}),w(dt,{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>'}),w(dt,{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>'}),w(dt,{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>'}),w(dt,{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>'}),w(dt,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),w(dt,{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>'})]}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:Ig.map(k=>w("button",{class:zt("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))}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:Bg.map(k=>w("button",{class:zt("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:w("span",{class:"w-5 bg-gray-800 rounded-full",style:{height:`${k}px`}})},k))}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:[w("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:W,disabled:!d,title:"Undo (Ctrl+Z)",children:w("svg",{viewBox:"0 0 24 24",children:w("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"})})}),w("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:!f,title:"Redo (Ctrl+Shift+Z)",children:w("svg",{viewBox:"0 0 24 24",children:w("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"})})}),w("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,title:"Delete selected (Del)",children:w("svg",{viewBox:"0 0 24 24",children:w("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"})})})]}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:[w("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:ht,disabled:v<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:w("svg",{viewBox:"0 0 24 24",children:w("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"})})}),w("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:ut,title:`Reset Zoom (${Math.round(v*100)}%) - Hold Space to pan`,children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",fill:"currentColor"})})}),w("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:A,disabled:v>=3,title:"Zoom In - Hold Space to pan when zoomed",children:w("svg",{viewBox:"0 0 24 24",children:w("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"})})})]})]}),w("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:w("canvas",{ref:r})}),w("div",{class:"flex gap-3 p-4 border-t border-solid border-border bg-muted",children:[w(De,{variant:"outline",class:"flex-1",onClick:e,children:"Cancel"}),w(De,{class:"flex-1",onClick:K,children:"Done"})]})]})};function Wg(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 Xg=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function Ee(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let Ke=null;function Jl(i={}){return Ke||(i.includeStyleProperties?(Ke=i.includeStyleProperties,Ke):(Ke=Ee(window.getComputedStyle(document.documentElement)),Ke))}function Ks(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Yg(i){const t=Ks(i,"border-left-width"),e=Ks(i,"border-right-width");return i.clientWidth+t+e}function Ug(i){const t=Ks(i,"border-top-width"),e=Ks(i,"border-bottom-width");return i.clientHeight+t+e}function Ql(i,t={}){const e=t.width||Yg(i),r=t.height||Ug(i);return{width:e,height:r}}function Ng(){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 It=16384;function Gg(i){(i.width>It||i.height>It)&&(i.width>It&&i.height>It?i.width>i.height?(i.height*=It/i.width,i.width=It):(i.width*=It/i.height,i.height=It):i.width>It?(i.height*=It/i.width,i.width=It):(i.width*=It/i.height,i.height=It))}function Zs(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 $g(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function qg(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),$g(s)}const Lt=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||Lt(e,t)};function Kg(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function Zg(i,t){return Jl(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function Jg(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?Kg(e):Zg(e,r);return document.createTextNode(`${s}{${n}}`)}function ta(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=Xg();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Jg(o,e,s,r)),t.appendChild(a)}function Qg(i,t,e){ta(i,t,":before",e),ta(i,t,":after",e)}const ea="application/font-woff",ra="image/jpeg",tf={woff:ea,woff2:ea,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ra,jpeg:ra,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function ef(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function Vn(i){const t=ef(i).toLowerCase();return tf[t]||""}function rf(i){return i.split(/,/)[1]}function ln(i){return i.search(/^(data:)/)!==-1}function sf(i,t){return`data:${t};base64,${i}`}async function tc(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 Li={};function nf(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 Wn(i,t,e){const r=nf(i,t,e.includeQueryParams);if(Li[r]!=null)return Li[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await tc(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),rf(a)));s=sf(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 Li[r]=s,s}async function of(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):Zs(t)}async function af(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 Zs(a)}const e=i.poster,r=Vn(e),s=await Wn(e,r,t);return Zs(s)}async function lf(i,t){var e;try{if(!((e=i==null?void 0:i.contentDocument)===null||e===void 0)&&e.body)return await di(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function cf(i,t){return Lt(i,HTMLCanvasElement)?of(i):Lt(i,HTMLVideoElement)?af(i,t):Lt(i,HTMLIFrameElement)?lf(i,t):i.cloneNode(ec(i))}const hf=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",ec=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function uf(i,t,e){var r,s;if(ec(t))return t;let n=[];return hf(i)&&i.assignedNodes?n=Ee(i.assignedNodes()):Lt(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=Ee(i.contentDocument.body.childNodes):n=Ee(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||Lt(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>di(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function df(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):Jl(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`),Lt(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 gf(i,t){Lt(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),Lt(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function ff(i,t){if(Lt(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function pf(i,t,e){return Lt(t,Element)&&(df(i,t,e),Qg(i,t,e),gf(i,t),ff(i,t)),t}async function mf(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 di(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 di(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>cf(r,t)).then(r=>uf(i,r,t)).then(r=>pf(i,r,t)).then(r=>mf(r,t))}const rc=/url\((['"]?)([^'"]+?)\1\)/g,vf=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,yf=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function bf(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function wf(i){const t=[];return i.replace(rc,(e,r,s)=>(t.push(s),e)),t.filter(e=>!ln(e))}async function xf(i,t,e,r,s){try{const n=e?Wg(t,e):t,o=Vn(t);let a;return s||(a=await Wn(n,o,r)),i.replace(bf(t),`$1${a}$3`)}catch{}return i}function _f(i,{preferredFontFormat:t}){return t?i.replace(yf,e=>{for(;;){const[r,,s]=vf.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function sc(i){return i.search(rc)!==-1}async function ic(i,t,e){if(!sc(i))return i;const r=_f(i,e);return wf(r).reduce((n,o)=>n.then(a=>xf(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 ic(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function Cf(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 Sf(i,t){const e=Lt(i,HTMLImageElement);if(!(e&&!ln(i.src))&&!(Lt(i,SVGImageElement)&&!ln(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await Wn(r,Vn(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 Tf(i,t){const r=Ee(i.childNodes).map(s=>nc(s,t));await Promise.all(r).then(()=>i)}async function nc(i,t){Lt(i,Element)&&(await Cf(i,t),await Sf(i,t),await Tf(i,t))}function kf(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 sa={};async function ia(i){let t=sa[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},sa[i]=t,t}async function na(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),tc(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function oa(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 Of(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{Ee(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=ia(l).then(h=>na(h,t)).then(h=>oa(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(ia(s.href).then(a=>na(a,t)).then(a=>oa(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{Ee(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function Df(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>sc(t.style.getPropertyValue("src")))}async function Mf(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=Ee(i.ownerDocument.styleSheets),r=await Of(e,t);return Df(r)}function oc(i){return i.trim().replace(/["']/g,"")}function Ef(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(oc(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function Pf(i,t){const e=await Mf(i,t),r=Ef(i);return(await Promise.all(e.filter(n=>r.has(oc(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return ic(n.cssText,o,t)}))).join(`
540
- `)}async function Af(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Pf(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 Lf(i,t={}){const{width:e,height:r}=Ql(i,t),s=await di(i,t,!0);return await Af(s,t),await nc(s,t),kf(s,t),await qg(s,e,r)}async function ji(i,t={}){const{width:e,height:r}=Ql(i,t),s=await Lf(i,t),n=await Zs(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Ng(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||Gg(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 jf=2,Je=16384,ws=4e7,ac="data-bugpin-exclude";async function Ff(){document.fonts&&document.fonts.ready&&await document.fonts.ready}async function Rf(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 Fi(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>ws)throw e==="fullpage"?new Error(`Full page total pixels (${r*s}) exceed maximum (${ws}). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot total pixels (${r*s}) exceed maximum (${ws}). Try capturing a smaller element or use visible viewport mode.`);let n=Math.min(window.devicePixelRatio||1,jf),o=r*n,a=s*n,l=o*a;for(;n>1&&(o>Je||a>Je||l>ws);)n-=.5,o=r*n,a=s*n,l=o*a;return Math.max(1,n)}function Ri(i){return!(i instanceof HTMLElement&&(i.tagName==="SCRIPT"||i.hasAttribute(ac)))}function If(){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 Ii(){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}async function Bf(){try{const i=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1}),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),i.getTracks().forEach(s=>s.stop()),e.toDataURL("image/png")}catch(i){throw i instanceof Error&&i.name==="NotAllowedError"?new Error("Screen capture permission denied"):i}}async function zf(i={}){const{method:t="visible",selector:e,useScreenCaptureAPI:r=!1,cacheBust:s}=i;if(r)return Bf();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=If();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(`[${ac}]`),d=new Map;u.forEach(g=>{g instanceof HTMLElement&&(d.set(g,g.style.visibility),g.style.visibility="hidden")});try{if(await Ff(),await Rf(n),t==="visible"){const x=Fi(c,h,"visible"),D=Ii(),C=a+c,O=l+h;console.log("[BugPin] Capture debug:",{scrollX:a,scrollY:l,viewportWidth:c,viewportHeight:h,captureWidth:C,captureHeight:O,dpr:x});const j=await ji(n,{cacheBust:s??!1,pixelRatio:x,width:C,height:O,backgroundColor:D,filter:Ri});console.log("[BugPin] Canvas captured:",{canvasWidth:j.width,canvasHeight:j.height,expectedWidth:C*x,expectedHeight:O*x});const T=document.createElement("canvas");T.width=c*x,T.height=h*x;const L=T.getContext("2d");if(!L)throw new Error("Failed to get canvas context");return L.fillStyle=D,L.fillRect(0,0,T.width,T.height),L.drawImage(j,a*x,l*x,c*x,h*x,0,0,c*x,h*x),T.toDataURL("image/png")}if(t==="fullpage"){const x=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth),D=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight),C=Fi(x,D,"fullpage"),O=Ii();return(await ji(n,{cacheBust:s??!0,pixelRatio:C,width:x,height:D,backgroundColor:O,filter:Ri})).toDataURL("image/png")}const g=n.getBoundingClientRect(),f=Fi(g.width,g.height,"element"),p=Ii();return(await ji(n,{cacheBust:s??!1,pixelRatio:f,backgroundColor:p,filter:Ri})).toDataURL("image/png")}finally{u.forEach(g=>{g instanceof HTMLElement&&(g.style.visibility=d.get(g)||"")})}}function lc(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 cc(i){return i.startsWith("data:image/webp")?"webp":i.startsWith("data:image/jpeg")?"jpg":i.startsWith("data:image/gif")?"gif":"png"}const rr=[],Nr=[],Gr=[],Hf=30;let aa=!1;function Vf(){if(aa)return;aa=!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&&Nr.push({url:l,method:c,status:h.status,statusText:h.statusText,timestamp:new Date().toISOString()}),h}catch(h){throw Nr.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&&Nr.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&&Wf(l)},!0)}function Wf(i){Gr.push(i),Gr.length>Hf&&Gr.shift()}function Xf(){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 Yf(){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 Uf(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function Nf(){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 Gf(){try{const i=performance.getEntriesByType("navigation");if(i.length>0){const t=i[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function $f(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:Xf(),device:Yf(),viewport:Uf(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:Gf(),consoleErrors:rr.length>0?[...rr]:void 0,networkErrors:Nr.length>0?[...Nr]:void 0,userActivity:Gr.length>0?[...Gr]:void 0,storageKeys:Nf()}}const cn=(i,t)=>t.some(e=>i instanceof e);let la,ca;function qf(){return la||(la=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Kf(){return ca||(ca=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const hn=new WeakMap,Bi=new WeakMap,gi=new WeakMap;function Zf(i){const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("success",n),i.removeEventListener("error",o)},n=()=>{e(We(i.result)),s()},o=()=>{r(i.error),s()};i.addEventListener("success",n),i.addEventListener("error",o)});return gi.set(t,i),t}function Jf(i){if(hn.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)});hn.set(i,t)}let un={get(i,t,e){if(i instanceof IDBTransaction){if(t==="done")return hn.get(i);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return We(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 hc(i){un=i(un)}function Qf(i){return Kf().includes(i)?function(...t){return i.apply(dn(this),t),We(this.request)}:function(...t){return We(i.apply(dn(this),t))}}function tp(i){return typeof i=="function"?Qf(i):(i instanceof IDBTransaction&&Jf(i),cn(i,qf())?new Proxy(i,un):i)}function We(i){if(i instanceof IDBRequest)return Zf(i);if(Bi.has(i))return Bi.get(i);const t=tp(i);return t!==i&&(Bi.set(i,t),gi.set(t,i)),t}const dn=i=>gi.get(i);function uc(i,t,{blocked:e,upgrade:r,blocking:s,terminated:n}={}){const o=indexedDB.open(i,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=>{n&&l.addEventListener("close",()=>n()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const ep=["get","getKey","getAll","getAllKeys","count"],rp=["put","add","delete","clear"],zi=new Map;function ha(i,t){if(!(i instanceof IDBDatabase&&!(t in i)&&typeof t=="string"))return;if(zi.get(t))return zi.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=rp.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||ep.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 zi.set(t,n),n}hc(i=>({...i,get:(t,e,r)=>ha(t,e)||i.get(t,e,r),has:(t,e)=>!!ha(t,e)||i.has(t,e)}));const sp=["continue","continuePrimaryKey","advance"],ua={},gn=new WeakMap,dc=new WeakMap,ip={get(i,t){if(!sp.includes(t))return i[t];let e=ua[t];return e||(e=ua[t]=function(...r){gn.set(this,dc.get(this)[t](...r))}),e}};async function*np(...i){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...i)),!t)return;t=t;const e=new Proxy(t,ip);for(dc.set(e,t),gi.set(e,dn(t));t;)yield e,t=await(gn.get(e)||t.continue()),gn.delete(e)}function da(i,t){return t===Symbol.asyncIterator&&cn(i,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&cn(i,[IDBIndex,IDBObjectStore])}hc(i=>({...i,get(t,e,r){return da(t,e)?np:i.get(t,e,r)},has(t,e){return da(t,e)||i.has(t,e)}}));const op="bugpin-reports",ap=2,lr="pending-reports",ga=5,lp=5e3,cp=3e5,hp=2;let xs=null,fa=null;function up(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 fi(){if(xs)return xs;try{return xs=await uc(op,ap,{upgrade(i){i.objectStoreNames.contains(lr)||i.createObjectStore(lr,{keyPath:"id"}).createIndex("by-created","createdAt")}}),xs}catch(i){throw console.error("[BugPin] Failed to initialize IndexedDB:",i),i}}function dp(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function Js(){return navigator.onLine!==!1}function gp(i){const t=lp*Math.pow(hp,i);return Math.min(t,cp)}async function pa(i){const t=await fi(),e={...i,id:dp(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(lr,e),console.log("[BugPin] Report buffered for later submission:",e.id),Js()&&js().catch(console.error),e.id}async function fp(){try{return await(await fi()).getAllFromIndex(lr,"by-created")}catch{return[]}}async function ma(i){try{await(await fi()).delete(lr,i),console.log("[BugPin] Removed buffered report:",i)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function pp(i){try{await(await fi()).put(lr,i)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function mp(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=lc(a.dataUrl),c=cc(a.dataUrl)||up(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 js(){if(!Js())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const i=await fp();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()+gp(r.retryCount);if(Date.now()<n)continue}try{await mp(r),await ma(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>=ga?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await ma(r.id)):(await pp(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${ga}):`,r.id))}}return{synced:t,failed:e}}function vp(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),js().catch(console.error)}),fa||(fa=setInterval(()=>{Js()&&js().catch(console.error)},3e4)),Js()&&js().catch(console.error)}vp();function yp(){return navigator.onLine!==!1}function bp(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 wp(i){const{apiKey:t,serverUrl:e,media:r,...s}=i;if(!yp())return console.log("[BugPin] Offline, buffering report for later submission"),await pa({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=lc(l.dataUrl),h=cc(l.dataUrl)||bp(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 pa({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 xp="bugpin-drafts",_p=1,cr="draft-media",Cp="bugpin-draft-";let _s=null;async function pi(){if(_s)return _s;try{return _s=await uc(xp,_p,{upgrade(i){i.objectStoreNames.contains(cr)||i.createObjectStore(cr,{keyPath:"apiKey"})}}),_s}catch(i){throw console.error("[BugPin] Failed to initialize draft database:",i),i}}function Xn(i){return`${Cp}${i}`}function Sp(i,t,e){try{const r={formData:t,activeTab:e,savedAt:new Date().toISOString()};localStorage.setItem(Xn(i),JSON.stringify(r))}catch(r){console.error("[BugPin] Failed to save form draft:",r)}}function gc(i){try{const t=localStorage.getItem(Xn(i));return t?JSON.parse(t):null}catch(t){return console.error("[BugPin] Failed to load form draft:",t),null}}function Tp(i){try{localStorage.removeItem(Xn(i))}catch(t){console.error("[BugPin] Failed to clear form draft:",t)}}async function kp(i,t){try{await(await pi()).put(cr,{apiKey:i,media:t,savedAt:new Date().toISOString()})}catch(e){console.error("[BugPin] Failed to save media draft:",e)}}async function Op(i){try{const e=await(await pi()).get(cr,i);return(e==null?void 0:e.media)||[]}catch(t){return console.error("[BugPin] Failed to load media draft:",t),[]}}async function fc(i){try{await(await pi()).delete(cr,i)}catch(t){console.error("[BugPin] Failed to clear media draft:",t)}}async function Dp(i){if(gc(i))return!0;try{const r=await(await pi()).get(cr,i);return r!==void 0&&r.media.length>0}catch{return!1}}async function Mp(i,t,e,r){Sp(i,t,e),r.length>0?await kp(i,r):await fc(i)}async function Ep(i){const t=gc(i),e=await Op(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 Pp(i){Tp(i),await fc(i)}const Cs={save:Mp,load:Ep,clear:Pp,has:Dp};function Ap(i){return i==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":i}const Hi={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},Lp=({config:i,deps:t})=>{const e=(t==null?void 0:t.WidgetDialog)??Hh,r=(t==null?void 0:t.AnnotationCanvas)??Vg,s=(t==null?void 0:t.captureScreenshot)??zf,n=(t==null?void 0:t.captureContext)??$f,o=(t==null?void 0:t.submitReport)??wp,a=Bt(null),[l,c]=ct("closed"),[h,u]=ct(!1),[d,g]=ct(!1),[f,p]=ct([]),[v,b]=ct(null),[x,D]=ct(null),[C,O]=ct("details"),[S,j]=ct(Hi),[T,L]=ct(!1),[H,W]=ct(!1);Wt(()=>{l==="form"&&!T&&Cs.load(i.apiKey).then(M=>{M&&(j(M.formData),O(M.activeTab),p(M.media)),L(!0)})},[l,T,i.apiKey]),Wt(()=>{const M=a.current;if(!M)return;const Y=()=>{Ap(i.theme)==="dark"?(M.style.setProperty("--button-color",i.dialogDarkButtonColor),M.style.setProperty("--button-text-color",i.dialogDarkTextColor),M.style.setProperty("--button-hover-color",i.dialogDarkButtonHoverColor),M.style.setProperty("--button-hover-text-color",i.dialogDarkTextHoverColor)):(M.style.setProperty("--button-color",i.dialogLightButtonColor),M.style.setProperty("--button-text-color",i.dialogLightTextColor),M.style.setProperty("--button-hover-color",i.dialogLightButtonHoverColor),M.style.setProperty("--button-hover-text-color",i.dialogLightTextHoverColor))};if(Y(),i.theme==="auto"){const G=window.matchMedia("(prefers-color-scheme: dark)"),N=()=>Y();return G.addEventListener("change",N),()=>G.removeEventListener("change",N)}},[i.theme,i.dialogLightButtonColor,i.dialogLightTextColor,i.dialogLightButtonHoverColor,i.dialogLightTextHoverColor,i.dialogDarkButtonColor,i.dialogDarkTextColor,i.dialogDarkButtonHoverColor,i.dialogDarkTextHoverColor]);const V=J(()=>{c("form")},[]),U=S.title.trim()||S.description.trim()||S.reporterEmail.trim()||S.reporterName.trim()||f.length>0,X=J(()=>{U?W(!0):(c("closed"),b(null),L(!1))},[U]),tt=J(()=>{Cs.save(i.apiKey,S,C,f),W(!1),c("closed"),b(null),L(!1)},[i.apiKey,S,C,f]),K=J(()=>{p([]),O("details"),j(Hi),Cs.clear(i.apiKey),W(!1),c("closed"),b(null),L(!1)},[i.apiKey]),Z=J((M=!1)=>{M===!0&&(p([]),O("details"),j(Hi),Cs.clear(i.apiKey)),W(!1),c("closed"),b(null),L(!1)},[i.apiKey]);Wt(()=>{const M=()=>V(),Y=()=>X();return document.addEventListener("bugpin:open",M),document.addEventListener("bugpin:close",Y),()=>{document.removeEventListener("bugpin:open",M),document.removeEventListener("bugpin:close",Y)}},[V,X]);const A=J(async()=>{if(i.enableScreenshot){g(!0),c("closed"),await new Promise(M=>setTimeout(M,100));try{const M=await s({method:i.captureMethod,useScreenCaptureAPI:i.useScreenCaptureAPI}),Y=new Image;Y.onload=()=>{console.log(`[BugPin] Captured screenshot: ${Y.width}x${Y.height}, dataUrl length=${M.length}`);const G={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png",width:Y.width,height:Y.height};p(N=>[...N,G]),g(!1),O("media"),c("form")},Y.onerror=()=>{const G={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png"};p(N=>[...N,G]),g(!1),O("media"),c("form")},Y.src=M}catch(M){console.error("[BugPin] Failed to capture screenshot:",M),g(!1),c("form"),D({message:"Failed to capture screenshot",type:"error"})}}},[i,s]),ht=J(M=>{p(Y=>[...Y,M])},[]),ut=J(M=>{p(Y=>Y.filter(G=>G.id!==M))},[]),dt=J(M=>{b(M),c("annotating")},[]),k=J((M,Y)=>{v&&p(G=>G.map(N=>N.id===v?{...N,dataUrl:M,annotated:!0,annotations:Y}:N)),b(null),c("form")},[v]),P=J(()=>{b(null),c("form")},[]),E=J(async(M,Y)=>{u(!0);try{const G=n();await o({apiKey:i.apiKey,serverUrl:i.serverUrl,title:M.title,description:M.description,priority:M.priority,reporterEmail:M.reporterEmail||void 0,reporterName:M.reporterName||void 0,media:Y.map(N=>({dataUrl:N.dataUrl,mimeType:N.mimeType,annotations:N.annotations})),metadata:G}),D({message:"Bug report submitted successfully!",type:"success"}),Z(!0)}catch(G){console.error("[BugPin] Failed to submit report:",G),D({message:G instanceof Error?G.message:"Failed to submit report",type:"error"})}finally{u(!1)}},[i,Z,n,o]),I=J(()=>{D(null)},[]),F=v?f.find(M=>M.id===v):null;return w("div",{ref:a,class:`bugpin-container bugpin-theme-${i.theme}`,children:[w(kh,{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:V}),l==="annotating"&&F&&w("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("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:w(r,{screenshot:F.dataUrl,onSave:k,onCancel:P})})}),l==="form"&&w(e,{onClose:X,onSubmit:E,onCaptureScreenshot:A,onAnnotateMedia:dt,media:f,onAddMedia:ht,onRemoveMedia:ut,isSubmitting:h,isCapturing:d,enableAnnotation:i.enableAnnotation,activeTab:C,onActiveTabChange:O,formData:S,onFormDataChange:j}),H&&w("div",{class:"fixed inset-0 z-[2147483647] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("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:w("div",{class:"p-6",children:[w("h3",{id:"bugpin-confirm-title",class:"text-lg font-semibold text-foreground tracking-tight mb-2",children:"Save draft?"}),w("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?"}),w("div",{class:"flex gap-3",children:[w("button",{type:"button",onClick:K,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"}),w("button",{type:"button",onClick:tt,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"})]})]})})}),x&&w(Lh,{message:x.message,type:x.type,onClose:I})]})},fn={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",dialogDarkButtonColor:"#02658D",dialogDarkTextColor:"#ffffff",dialogDarkButtonHoverColor:"#036F9B",dialogDarkTextHoverColor:"#ffffff",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024},jp='/*! 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-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-600:oklch(57.7% .245 27.325);--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-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--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-sm:24rem;--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 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--font-weight-medium:500;--font-weight-semibold:600;--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}}@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-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-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)}.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)}.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-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-200{border-color:var(--color-gray-200)}.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-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-50{background-color:var(--color-gray-50)}.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}.bg-white{background-color:var(--color-white)}.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)}.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-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--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)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.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-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.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}.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}.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-gray-200:hover{background-color:var(--color-gray-200)}.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}@media (hover:hover){.\\[\\&_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)}}}#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}@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-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}';Vf();let va=!1;async function pc(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,dialogDarkButtonColor:a.dialogDarkButtonColor,dialogDarkTextColor:a.dialogDarkTextColor,dialogDarkButtonHoverColor:a.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:a.dialogDarkTextHoverColor,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}}}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 Yn(i){if(va){console.warn("[BugPin] Widget already initialized");return}va=!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=jp,e.appendChild(r);const s=document.createElement("div");s.id="bugpin-root",e.appendChild(s),document.body.appendChild(t),Cc(qr(Lp,{config:i}),s)}async function Fp(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 pc(t,e);if(r===null)return;const s={...fn,...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")}};Yn(s)}const Un={init:async i=>{const t=i.serverUrl||fn.serverUrl,e=await pc(i.apiKey,t);if(e===null)return;const r={...fn,...e,...i,serverUrl:t};Yn(r)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};typeof window<"u"&&(window.BugPin=Un);const Ss=document.currentScript;if(Ss!=null&&Ss.hasAttribute("data-api-key")){const i=()=>Fp(Ss);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}exports.BugPin=Un;exports.createWidget=Yn;exports.default=Un;
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;
541
541
  //# sourceMappingURL=widget.cjs.js.map