@arantic/bugpin-widget 0.1.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -18
- package/dist/widget.cjs.js +83 -128
- package/dist/widget.cjs.js.map +1 -1
- package/dist/widget.esm.js +8407 -4467
- package/dist/widget.esm.js.map +1 -1
- package/dist/widget.js +83 -128
- package/dist/widget.js.map +1 -1
- package/package.json +13 -4
package/dist/widget.js
CHANGED
|
@@ -1,157 +1,112 @@
|
|
|
1
|
-
var BugPin=function(Ne){"use strict";var Ei=typeof document<"u"?document.currentScript:null,mr,K,Gs,me,Ns,$s,qs,Ks,Pi,Ai,ji,$e={},Zs=[],Ua=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,qe=Array.isArray;function Kt(n,t){for(var e in t)n[e]=t[e];return n}function Li(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Ke(n,t,e){var r,i,s,o={};for(s in t)s=="key"?r=t[s]:s=="ref"?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?mr.call(arguments,2):e),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)o[s]===void 0&&(o[s]=n.defaultProps[s]);return vr(n,o,r,i,null)}function vr(n,t,e,r,i){var s={type:n,props:t,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Gs,__i:-1,__u:0};return i==null&&K.vnode!=null&&K.vnode(s),s}function Ze(n){return n.children}function br(n,t){this.props=n,this.context=t}function Te(n,t){if(t==null)return n.__?Te(n.__,n.__i+1):null;for(var e;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null)return e.__e;return typeof n.type=="function"?Te(n):null}function Js(n){var t,e;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null){n.__e=n.__c.base=e.__e;break}return Js(n)}}function Qs(n){(!n.__d&&(n.__d=!0)&&me.push(n)&&!yr.__r++||Ns!=K.debounceRendering)&&((Ns=K.debounceRendering)||$s)(yr)}function yr(){for(var n,t,e,r,i,s,o,a=1;me.length;)me.length>a&&me.sort(qs),n=me.shift(),a=me.length,n.__d&&(e=void 0,r=void 0,i=(r=(t=n).__v).__e,s=[],o=[],t.__P&&((e=Kt({},r)).__v=r.__v+1,K.vnode&&K.vnode(e),Fi(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,s,i??Te(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,on(s,e,o),r.__e=r.__=null,e.__e!=i&&Js(e)));yr.__r=0}function tn(n,t,e,r,i,s,o,a,l,c,h){var u,d,g,f,m,b,y,w=r&&r.__k||Zs,O=t.length;for(l=Ga(e,t,w,l,O),u=0;u<O;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?$e:w[g.__i]||$e,g.__i=u,b=Fi(n,g,d,i,s,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&Bi(d.ref,null,g),h.push(g.ref,g.__c||f,g)),m==null&&f!=null&&(m=f),(y=!!(4&g.__u))||d.__k===g.__k?l=en(g,l,n,y):typeof g.type=="function"&&b!==void 0?l=b:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=m,l}function Ga(n,t,e,r,i){var s,o,a,l,c,h=e.length,u=h,d=0;for(n.__k=new Array(i),s=0;s<i;s++)(o=t[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=n.__k[s]=vr(null,o,null,null,null):qe(o)?o=n.__k[s]=vr(Ze,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=n.__k[s]=vr(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):n.__k[s]=o,l=s+d,o.__=n,o.__b=n.__b+1,a=null,(c=o.__i=Na(o,e,l,u))!=-1&&(u--,(a=e[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(i>h?d--:i<h&&d++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,o.__u|=4))):n.__k[s]=null;if(u)for(s=0;s<h;s++)(a=e[s])!=null&&!(2&a.__u)&&(a.__e==r&&(r=Te(a)),ln(a,a));return r}function en(n,t,e,r){var i,s;if(typeof n.type=="function"){for(i=n.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=n,t=en(i[s],t,e,r));return t}n.__e!=t&&(r&&(t&&n.type&&!t.parentNode&&(t=Te(n)),e.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function rn(n,t){return t=t||[],n==null||typeof n=="boolean"||(qe(n)?n.some(function(e){rn(e,t)}):t.push(n)),t}function Na(n,t,e,r){var i,s,o,a=n.key,l=n.type,c=t[e],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return e;if(r>(h?1:0)){for(i=e-1,s=e+1;i>=0||s<t.length;)if((c=t[o=i>=0?i--:s++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function sn(n,t,e){t[0]=="-"?n.setProperty(t,e??""):n[t]=e==null?"":typeof e!="number"||Ua.test(t)?e:e+"px"}function _r(n,t,e,r,i){var s,o;t:if(t=="style")if(typeof e=="string")n.style.cssText=e;else{if(typeof r=="string"&&(n.style.cssText=r=""),r)for(t in r)e&&t in e||sn(n.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||sn(n.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(Ks,"$1")),o=t.toLowerCase(),t=o in n||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),n.l||(n.l={}),n.l[t+s]=e,e?r?e.u=r.u:(e.u=Pi,n.addEventListener(t,s?ji:Ai,s)):n.removeEventListener(t,s?ji:Ai,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in n)try{n[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?n.removeAttribute(t):n.setAttribute(t,t=="popover"&&e==1?"":e))}}function nn(n){return function(t){if(this.l){var e=this.l[t.type+n];if(t.t==null)t.t=Pi++;else if(t.t<e.u)return;return e(K.event?K.event(t):t)}}}function Fi(n,t,e,r,i,s,o,a,l,c){var h,u,d,g,f,m,b,y,w,O,k,S,C,A,D,L,R,H=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),s=[a=t.__e=e.__e]),(h=K.__b)&&h(t);t:if(typeof H=="function")try{if(y=t.props,w="prototype"in H&&H.prototype.render,O=(h=H.contextType)&&r[h.__c],k=h?O?O.props.value:h.__:r,e.__c?b=(u=t.__c=e.__c).__=u.__E:(w?t.__c=u=new H(y,k):(t.__c=u=new br(y,k),u.constructor=H,u.render=qa),O&&O.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&H.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Kt({},u.__s)),Kt(u.__s,H.getDerivedStateFromProps(y,u.__s))),g=u.props,f=u.state,u.__v=t,d)w&&H.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&H.getDerivedStateFromProps==null&&y!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,k),t.__v==e.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,k)===!1){for(t.__v!=e.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(I){I&&(I.__=t)}),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,k),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,f,m)})}if(u.context=k,u.props=y,u.__P=n,u.__e=!1,C=K.__r,A=0,w){for(u.state=u.__s,u.__d=!1,C&&C(t),h=u.render(u.props,u.state,u.context),D=0;D<u._sb.length;D++)u.__h.push(u._sb[D]);u._sb=[]}else do u.__d=!1,C&&C(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++A<25);u.state=u.__s,u.getChildContext!=null&&(r=Kt(Kt({},r),u.getChildContext())),w&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(g,f)),L=h,h!=null&&h.type===Ze&&h.key==null&&(L=an(h.props.children)),a=tn(n,qe(L)?L:[L],t,e,r,i,s,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),b&&(u.__E=u.__=null)}catch(I){if(t.__v=null,l||s!=null)if(I.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else{for(R=s.length;R--;)Li(s[R]);Ri(t)}else t.__e=e.__e,t.__k=e.__k,I.then||Ri(t);K.__e(I,t,e)}else s==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=$a(e.__e,t,e,r,i,s,o,l,c);return(h=K.diffed)&&h(t),128&t.__u?void 0:a}function Ri(n){n&&n.__c&&(n.__c.__e=!0),n&&n.__k&&n.__k.forEach(Ri)}function on(n,t,e){for(var r=0;r<e.length;r++)Bi(e[r],e[++r],e[++r]);K.__c&&K.__c(t,n),n.some(function(i){try{n=i.__h,i.__h=[],n.some(function(s){s.call(i)})}catch(s){K.__e(s,i.__v)}})}function an(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:qe(n)?n.map(an):Kt({},n)}function $a(n,t,e,r,i,s,o,a,l){var c,h,u,d,g,f,m,b=e.props||$e,y=t.props,w=t.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((g=s[c])&&"setAttribute"in g==!!w&&(w?g.localName==w:g.nodeType==3)){n=g,s[c]=null;break}}if(n==null){if(w==null)return document.createTextNode(y);n=document.createElementNS(i,w,y.is&&y),a&&(K.__m&&K.__m(t,s),a=!1),s=null}if(w==null)b===y||a&&n.data==y||(n.data=y);else{if(s=s&&mr.call(n.childNodes),!a&&s!=null)for(b={},c=0;c<n.attributes.length;c++)b[(g=n.attributes[c]).name]=g.value;for(c in b)if(g=b[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in y)){if(c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y)continue;_r(n,c,null,g,i)}}for(c in y)g=y[c],c=="children"?d=g:c=="dangerouslySetInnerHTML"?h=g:c=="value"?f=g:c=="checked"?m=g:a&&typeof g!="function"||b[c]===g||_r(n,c,g,b[c],i);if(h)a||u&&(h.__html==u.__html||h.__html==n.innerHTML)||(n.innerHTML=h.__html),t.__k=[];else if(u&&(n.innerHTML=""),tn(t.type=="template"?n.content:n,qe(d)?d:[d],t,e,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:e.__k&&Te(e,0),a,l),s!=null)for(c=s.length;c--;)Li(s[c]);a||(c="value",w=="progress"&&f==null?n.removeAttribute("value"):f!=null&&(f!==n[c]||w=="progress"&&!f||w=="option"&&f!=b[c])&&_r(n,c,f,b[c],i),c="checked",m!=null&&m!=n[c]&&_r(n,c,m,b[c],i))}return n}function Bi(n,t,e){try{if(typeof n=="function"){var r=typeof n.__u=="function";r&&n.__u(),r&&t==null||(n.__u=n(t))}else n.current=t}catch(i){K.__e(i,e)}}function ln(n,t,e){var r,i;if(K.unmount&&K.unmount(n),(r=n.ref)&&(r.current&&r.current!=n.__e||Bi(r,null,t)),(r=n.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){K.__e(s,t)}r.base=r.__P=null}if(r=n.__k)for(i=0;i<r.length;i++)r[i]&&ln(r[i],t,e||typeof n.type!="function");e||Li(n.__e),n.__c=n.__=n.__e=void 0}function qa(n,t,e){return this.constructor(n,e)}function Ka(n,t,e){var r,i,s,o;t==document&&(t=document.documentElement),K.__&&K.__(n,t),i=(r=!1)?null:t.__k,s=[],o=[],Fi(t,n=t.__k=Ke(Ze,null,[n]),i||$e,$e,t.namespaceURI,i?null:t.firstChild?mr.call(t.childNodes):null,s,i?i.__e:t.firstChild,r,o),on(s,n,o)}mr=Zs.slice,K={__e:function(n,t,e,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(n)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(n,r||{}),o=i.__d),o)return i.__E=i}catch(a){n=a}throw n}},Gs=0,br.prototype.setState=function(n,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Kt({},this.state),typeof n=="function"&&(n=n(Kt({},e),this.props)),n&&Kt(e,n),n!=null&&this.__v&&(t&&this._sb.push(t),Qs(this))},br.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Qs(this))},br.prototype.render=Ze,me=[],$s=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,qs=function(n,t){return n.__v.__b-t.__v.__b},yr.__r=0,Ks=/(PointerCapture)$|Capture$/i,Pi=0,Ai=nn(!1),ji=nn(!0);var Za=0;function _(n,t,e,r,i,s){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var c={type:n,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Za,__i:-1,__u:0,__source:i,__self:s};if(typeof n=="function"&&(o=n.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return K.vnode&&K.vnode(c),c}var Je,et,Ii,cn,Qe=0,hn=[],nt=K,un=nt.__b,dn=nt.__r,gn=nt.diffed,fn=nt.__c,pn=nt.unmount,mn=nt.__;function Hi(n,t){nt.__h&&nt.__h(et,n,Qe||t),Qe=0;var e=et.__H||(et.__H={__:[],__h:[]});return n>=e.__.length&&e.__.push({}),e.__[n]}function rt(n){return Qe=1,Ja(_n,n)}function Ja(n,t,e){var r=Hi(Je++,2);if(r.t=n,!r.__c&&(r.__=[_n(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=et,!et.__f)){var i=function(a,l,c){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return!!d.__c});if(h.every(function(d){return!d.__N}))return!s||s.call(this,a,l,c);var u=r.__c.props!==a;return h.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(u=!0)}}),s&&s.call(this,a,l,c)||u};et.__f=!0;var s=et.shouldComponentUpdate,o=et.componentWillUpdate;et.componentWillUpdate=function(a,l,c){if(this.__e){var h=s;s=void 0,i(a,l,c),s=h}o&&o.call(this,a,l,c)},et.shouldComponentUpdate=i}return r.__N||r.__}function Ft(n,t){var e=Hi(Je++,3);!nt.__s&&yn(e.__H,t)&&(e.__=n,e.u=t,et.__H.__h.push(e))}function St(n){return Qe=5,vn(function(){return{current:n}},[])}function vn(n,t){var e=Hi(Je++,7);return yn(e.__H,t)&&(e.__=n(),e.__H=t,e.__h=n),e.__}function Y(n,t){return Qe=8,vn(function(){return n},t)}function Qa(){for(var n;n=hn.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(xr),n.__H.__h.forEach(zi),n.__H.__h=[]}catch(t){n.__H.__h=[],nt.__e(t,n.__v)}}nt.__b=function(n){et=null,un&&un(n)},nt.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),mn&&mn(n,t)},nt.__r=function(n){dn&&dn(n),Je=0;var t=(et=n.__c).__H;t&&(Ii===et?(t.__h=[],et.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(xr),t.__h.forEach(zi),t.__h=[],Je=0)),Ii=et},nt.diffed=function(n){gn&&gn(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(hn.push(t)!==1&&cn===nt.requestAnimationFrame||((cn=nt.requestAnimationFrame)||tl)(Qa)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Ii=et=null},nt.__c=function(n,t){t.some(function(e){try{e.__h.forEach(xr),e.__h=e.__h.filter(function(r){return!r.__||zi(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],nt.__e(r,e.__v)}}),fn&&fn(n,t)},nt.unmount=function(n){pn&&pn(n);var t,e=n.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{xr(r)}catch(i){t=i}}),e.__H=void 0,t&&nt.__e(t,e.__v))};var bn=typeof requestAnimationFrame=="function";function tl(n){var t,e=function(){clearTimeout(r),bn&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(e,35);bn&&(t=requestAnimationFrame(e))}function xr(n){var t=et,e=n.__c;typeof e=="function"&&(n.__c=void 0,e()),et=t}function zi(n){var t=et;n.__c=n.__(),et=t}function yn(n,t){return!n||n.length!==t.length||t.some(function(e,r){return e!==n[r]})}function _n(n,t){return typeof t=="function"?t(n):t}/**
|
|
1
|
+
var BugPin=function(wr){"use strict";var us,st,qn,Le,Kn,Zn,Jn,Qn,yi,bi,wi,xr={},to=[],dc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_r=Array.isArray;function ce(i,t){for(var e in t)i[e]=t[e];return i}function xi(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function Cr(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?us.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 ds(i,o,r,s,null)}function ds(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??++qn,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(n),n}function Sr(i){return i.children}function gs(i,t){this.props=i,this.context=t}function Ue(i,t){if(t==null)return i.__?Ue(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"?Ue(i):null}function eo(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 eo(i)}}function ro(i){(!i.__d&&(i.__d=!0)&&Le.push(i)&&!fs.__r++||Kn!=st.debounceRendering)&&((Kn=st.debounceRendering)||Zn)(fs)}function fs(){for(var i,t,e,r,s,n,o,a=1;Le.length;)Le.length>a&&Le.sort(Jn),i=Le.shift(),a=Le.length,i.__d&&(e=void 0,r=void 0,s=(r=(t=i).__v).__e,n=[],o=[],t.__P&&((e=ce({},r)).__v=r.__v+1,st.vnode&&st.vnode(e),_i(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[s]:null,n,s??Ue(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,lo(n,e,o),r.__e=r.__=null,e.__e!=s&&eo(e)));fs.__r=0}function so(i,t,e,r,s,n,o,a,l,c,h){var u,d,g,f,m,y,b,w=r&&r.__k||to,T=t.length;for(l=gc(e,t,w,l,T),u=0;u<T;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?xr:w[g.__i]||xr,g.__i=u,y=_i(i,g,d,s,n,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&Si(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=io(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 gc(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]=ds(null,o,null,null,null):_r(o)?o=i.__k[n]=ds(Sr,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=i.__k[n]=ds(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=fc(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=Ue(a)),ho(a,a));return r}function io(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=io(s[n],t,e,r));return t}i.__e!=t&&(r&&(t&&i.type&&!t.parentNode&&(t=Ue(i)),e.insertBefore(i.__e,t||null)),t=i.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function no(i,t){return t=t||[],i==null||typeof i=="boolean"||(_r(i)?i.some(function(e){no(e,t)}):t.push(i)),t}function fc(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 oo(i,t,e){t[0]=="-"?i.setProperty(t,e??""):i[t]=e==null?"":typeof e!="number"||dc.test(t)?e:e+"px"}function ps(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||oo(i.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||oo(i.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(Qn,"$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=yi,i.addEventListener(t,n?wi:bi,n)):i.removeEventListener(t,n?wi:bi,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 ao(i){return function(t){if(this.l){var e=this.l[t.type+i];if(t.t==null)t.t=yi++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function _i(i,t,e,r,s,n,o,a,l,c){var h,u,d,g,f,m,y,b,w,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=st.__b)&&h(t);t:if(typeof V=="function")try{if(b=t.props,w="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:(w?t.__c=u=new V(b,C):(t.__c=u=new gs(b,C),u.constructor=V,u.render=mc),T&&T.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&V.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=ce({},u.__s)),ce(u.__s,V.getDerivedStateFromProps(b,u.__s))),g=u.props,f=u.state,u.__v=t,d)w&&V.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&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),w&&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=st.__r,A=0,w){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=ce(ce({},r),u.getChildContext())),w&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(g,f)),M=h,h!=null&&h.type===Sr&&h.key==null&&(M=co(h.props.children)),a=so(i,_r(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--;)xi(n[O]);Ci(t)}else t.__e=e.__e,t.__k=e.__k,z.then||Ci(t);st.__e(z,t,e)}else n==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=pc(e.__e,t,e,r,s,n,o,l,c);return(h=st.diffed)&&h(t),128&t.__u?void 0:a}function Ci(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(Ci)}function lo(i,t,e){for(var r=0;r<e.length;r++)Si(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 co(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:_r(i)?i.map(co):ce({},i)}function pc(i,t,e,r,s,n,o,a,l){var c,h,u,d,g,f,m,y=e.props||xr,b=t.props,w=t.type;if(w=="svg"?s="http://www.w3.org/2000/svg":w=="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==!!w&&(w?g.localName==w:g.nodeType==3)){i=g,n[c]=null;break}}if(i==null){if(w==null)return document.createTextNode(b);i=document.createElementNS(s,w,b.is&&b),a&&(st.__m&&st.__m(t,n),a=!1),n=null}if(w==null)y===b||a&&i.data==b||(i.data=b);else{if(n=n&&us.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;ps(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||ps(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=""),so(t.type=="template"?i.content:i,_r(d)?d:[d],t,e,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":s,n,o,n?n[0]:e.__k&&Ue(e,0),a,l),n!=null)for(c=n.length;c--;)xi(n[c]);a||(c="value",w=="progress"&&f==null?i.removeAttribute("value"):f!=null&&(f!==i[c]||w=="progress"&&!f||w=="option"&&f!=y[c])&&ps(i,c,f,y[c],s),c="checked",m!=null&&m!=i[c]&&ps(i,c,m,y[c],s))}return i}function Si(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 ho(i,t,e){var r,s;if(st.unmount&&st.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||Si(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]&&ho(r[s],t,e||typeof i.type!="function");e||xi(i.__e),i.__c=i.__=i.__e=void 0}function mc(i,t,e){return this.constructor(i,e)}function vc(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=[],_i(t,i=t.__k=Cr(Sr,null,[i]),s||xr,xr,t.namespaceURI,s?null:t.firstChild?us.call(t.childNodes):null,n,s?s.__e:t.firstChild,r,o),lo(n,i,o)}us=to.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}},qn=0,gs.prototype.setState=function(i,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ce({},this.state),typeof i=="function"&&(i=i(ce({},e),this.props)),i&&ce(e,i),i!=null&&this.__v&&(t&&this._sb.push(t),ro(this))},gs.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),ro(this))},gs.prototype.render=Sr,Le=[],Zn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Jn=function(i,t){return i.__v.__b-t.__v.__b},fs.__r=0,Qn=/(PointerCapture)$|Capture$/i,yi=0,bi=ao(!1),wi=ao(!0);var yc=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:--yc,__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,ki,uo,Tr=0,go=[],vt=st,fo=vt.__b,po=vt.__r,mo=vt.diffed,vo=vt.__c,yo=vt.unmount,bo=vt.__;function Ti(i,t){vt.__h&&vt.__h(gt,i,Tr||t),Tr=0;var e=gt.__H||(gt.__H={__:[],__h:[]});return i>=e.__.length&&e.__.push({}),e.__[i]}function at(i){return Tr=1,bc(Co,i)}function bc(i,t,e){var r=Ti(kr++,2);if(r.t=i,!r.__c&&(r.__=[Co(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 Ht(i,t){var e=Ti(kr++,3);!vt.__s&&_o(e.__H,t)&&(e.__=i,e.u=t,gt.__H.__h.push(e))}function It(i){return Tr=5,wo(function(){return{current:i}},[])}function wo(i,t){var e=Ti(kr++,7);return _o(e.__H,t)&&(e.__=i(),e.__H=t,e.__h=i),e.__}function N(i,t){return Tr=8,wo(function(){return i},t)}function wc(){for(var i;i=go.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(ms),i.__H.__h.forEach(Oi),i.__H.__h=[]}catch(t){i.__H.__h=[],vt.__e(t,i.__v)}}vt.__b=function(i){gt=null,fo&&fo(i)},vt.__=function(i,t){i&&t.__k&&t.__k.__m&&(i.__m=t.__k.__m),bo&&bo(i,t)},vt.__r=function(i){po&&po(i),kr=0;var t=(gt=i.__c).__H;t&&(ki===gt?(t.__h=[],gt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(ms),t.__h.forEach(Oi),t.__h=[],kr=0)),ki=gt},vt.diffed=function(i){mo&&mo(i);var t=i.__c;t&&t.__H&&(t.__H.__h.length&&(go.push(t)!==1&&uo===vt.requestAnimationFrame||((uo=vt.requestAnimationFrame)||xc)(wc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ki=gt=null},vt.__c=function(i,t){t.some(function(e){try{e.__h.forEach(ms),e.__h=e.__h.filter(function(r){return!r.__||Oi(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],vt.__e(r,e.__v)}}),vo&&vo(i,t)},vt.unmount=function(i){yo&&yo(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 xo=typeof requestAnimationFrame=="function";function xc(i){var t,e=function(){clearTimeout(r),xo&&cancelAnimationFrame(t),setTimeout(i)},r=setTimeout(e,35);xo&&(t=requestAnimationFrame(e))}function ms(i){var t=gt,e=i.__c;typeof e=="function"&&(i.__c=void 0,e()),gt=t}function Oi(i){var t=gt;i.__c=i.__(),gt=t}function _o(i,t){return!i||i.length!==t.length||t.some(function(e,r){return e!==i[r]})}function Co(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
|
|
6
|
+
*/const _c=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cc=(...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
|
|
11
|
+
*/var Sc={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
|
|
16
|
+
*/const kc=({color:i="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:s,iconNode:n,class:o="",...a})=>Cr("svg",{...Sc,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])=>Cr(l,c)),...no(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
|
|
21
|
+
*/const Di=(i,t)=>{const e=({class:r="",children:s,...n})=>Cr(kc,{...n,iconNode:t,class:Cc(`lucide-${_c(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
|
|
26
|
+
*/const Tc=Di("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
|
|
31
|
+
*/const Oc=Di("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
32
32
|
* @license lucide-preact v0.460.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const al=Et("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
37
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const ll=Et("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
|
|
42
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const cl=Et("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
|
|
47
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const hl=Et("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
52
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const ul=Et("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
57
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const dl=Et("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
|
62
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const gl=Et("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
|
67
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const fl=Et("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
72
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const pl=Et("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
|
|
77
|
-
* @license lucide-preact v0.460.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const ml=Et("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),vl={bug:nl,"message-square":dl,"alert-circle":ol,"help-circle":al,mail:ul,send:gl,flag:ll,star:pl,zap:ml,heart:cl,info:hl,settings:fl},bl=({name:n,class:t,size:e=18,strokeWidth:r=2})=>{const i=vl[n];return i?_(i,{class:t,size:e,strokeWidth:r}):null},yl=({position:n,buttonText:t,buttonShape:e,buttonIcon:r,buttonIconSize:i,buttonIconStroke:s,theme:o,lightButtonColor:a,lightTextColor:l,lightButtonHoverColor:c,lightTextHoverColor:h,darkButtonColor:u,darkTextColor:d,darkButtonHoverColor:g,darkTextHoverColor:f,enableHoverScaleEffect:m,tooltipEnabled:b,tooltipText:y,onClick:w})=>{const[O,k]=rt(!1),[S,C]=rt(!1),[A,D]=rt({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),L=St(null),R=St(null);Ft(()=>{if(o==="dark"){C(!0);return}else if(o==="light"){C(!1);return}const ct=window.matchMedia("(prefers-color-scheme: dark)");C(ct.matches);const T=F=>C(F.matches);return ct.addEventListener("change",T),()=>ct.removeEventListener("change",T)},[o]),Ft(()=>{if(O&&L.current&&R.current){const ct=L.current,T=R.current;requestAnimationFrame(()=>{const F=ct.getBoundingClientRect(),P=T.getBoundingClientRect(),B=window.innerWidth,$=4,q=P.left+P.width/2,mt=F.width/2;let le=0;const dt=q-mt;dt<$?le=$-dt:dt+F.width>B-$&&(le=B-$-(dt+F.width)),D({left:"50%",transform:`translateX(-50%) translateX(${le}px)`,arrowLeft:"50%"})})}},[O,y]);const H=S?O?g:u:O?c:a,I=S?O?f:d:O?h:l,M=S?u:a,j=S?d:l,z=e==="round"?"50%":"8px",V=t||"Report Bug",tt=e==="round"?`${i/2}px`:"12px 20px",N=`bugpin-launcher-button${m?" hover-scale":""}`,Ct={position:"absolute",bottom:"100%",marginBottom:"8px",padding:"6px 12px",backgroundColor:M,color:j,fontSize:"12px",borderRadius:"4px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"2147483647",opacity:"0",animation:"bugpin-tooltip-fade-in 0.2s ease-in-out forwards",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)",left:A.left,transform:A.transform},Mt={position:"absolute",top:"100%",left:A.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderWidth:"4px",borderStyle:"solid",borderColor:`${M} transparent transparent transparent`};return _("div",{class:`bugpin-launcher-button-container ${n}`,style:{position:"fixed",zIndex:"2147483647"},children:[_("button",{ref:R,class:N,style:{position:"relative",backgroundColor:H,color:I,borderRadius:z,padding:tt,transition:"background-color 0.2s ease, color 0.2s ease"},onClick:w,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),"aria-label":V,children:[r&&_(bl,{name:r,size:i,strokeWidth:s}),t&&_("span",{children:t})]}),b&&y&&O&&_("div",{ref:L,class:"bugpin-tooltip",style:Ct,children:[y,_("div",{style:Mt})]})]})},_l=({tabs:n,activeTab:t,onTabChange:e})=>_("div",{class:"bugpin-tabs",children:n.map(r=>_("button",{type:"button",class:`bugpin-tab ${t===r.id?"active":""}`,onClick:()=>e(r.id),children:[r.icon&&_("span",{class:"bugpin-tab-icon",children:r.icon}),r.label]},r.id))}),xl=10*1024*1024,wl=50*1024*1024,Cl=["image/png","image/jpeg","image/gif","image/webp"],Sl=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Tl=({media:n,onCapture:t,onUpload:e,onRemove:r,onAnnotate:i,isCapturing:s,enableAnnotation:o})=>{const[a,l]=rt(!1),[c,h]=rt(null),u=St(null),d=C=>C.startsWith("video/"),g=C=>C.startsWith("image/"),f=Y(C=>{if(g(C.type)){if(!Cl.includes(C.type))return`Unsupported image format: ${C.type}`;if(C.size>xl)return"Image too large. Maximum size is 10MB."}else if(d(C.type)){if(!Sl.includes(C.type))return`Unsupported video format: ${C.type}`;if(C.size>wl)return"Video too large. Maximum size is 50MB."}else return`Unsupported file type: ${C.type}`;return null},[]),m=Y(async C=>{const A=f(C);if(A){h(A);return}h(null);const D=new FileReader;D.onload=()=>{const L=D.result;if(g(C.type)){const R=new Image;R.onload=()=>{const H={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:C.type,width:R.width,height:R.height};e(H)},R.src=L}else if(d(C.type)){const R=document.createElement("video");R.onloadedmetadata=()=>{const H={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:C.type,width:R.videoWidth,height:R.videoHeight};e(H)},R.src=L}},D.readAsDataURL(C)},[f,e]),b=Y(C=>{C.preventDefault(),C.stopPropagation(),l(!0)},[]),y=Y(C=>{C.preventDefault(),C.stopPropagation(),l(!1)},[]),w=Y(async C=>{var D;C.preventDefault(),C.stopPropagation(),l(!1);const A=(D=C.dataTransfer)==null?void 0:D.files;if(A)for(let L=0;L<A.length;L++)await m(A[L])},[m]),O=Y(async C=>{const A=C.target,D=A.files;if(D)for(let L=0;L<D.length;L++)await m(D[L]);A.value=""},[m]),k=Y(()=>{var C;(C=u.current)==null||C.click()},[]),S=C=>C.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return _("div",{class:"bugpin-screenshot-manager",children:[_("div",{class:"bugpin-media-actions",children:[_("button",{type:"button",class:"bugpin-btn-action",onClick:t,disabled:s,children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 15.2c1.77 0 3.2-1.43 3.2-3.2S13.77 8.8 12 8.8 8.8 10.23 8.8 12s1.43 3.2 3.2 3.2zM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",fill:"currentColor"})}),s?"Capturing...":"Capture Screenshot"]}),_("button",{type:"button",class:"bugpin-btn-action bugpin-btn-action-secondary",onClick:k,children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z",fill:"currentColor"})}),"Upload File"]}),_("input",{ref:u,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:O})]}),c&&_("div",{class:"bugpin-upload-error",children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),c]}),_("div",{class:`bugpin-drop-zone ${a?"dragging":""} ${n.length>0?"has-media":""}`,onDragOver:b,onDragLeave:y,onDrop:w,children:n.length===0?_("div",{class:"bugpin-drop-placeholder",children:[_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})}),_("p",{children:"Drag and drop images or videos here"}),_("span",{children:"or use the buttons above"})]}):_(Ze,{children:[_("div",{class:"bugpin-media-grid",children:n.map(C=>_("div",{class:"bugpin-media-card",children:[_("div",{class:"bugpin-media-preview",children:[d(C.mimeType)?_("video",{src:C.dataUrl,muted:!0}):_("img",{src:C.dataUrl,alt:"Screenshot"}),_("div",{class:"bugpin-media-badges",children:[C.annotated&&_("span",{class:"bugpin-badge annotated",children:"Annotated"}),d(C.mimeType)&&_("span",{class:"bugpin-badge video",children:"Video"})]})]}),_("div",{class:"bugpin-media-info",children:[_("span",{class:"bugpin-media-time",children:S(C.timestamp)}),C.width&&C.height&&_("span",{class:"bugpin-media-dimensions",children:[C.width," × ",C.height]})]}),_("div",{class:"bugpin-media-item-actions",children:[o&&g(C.mimeType)&&_("button",{type:"button",class:"bugpin-btn-icon",onClick:()=>i(C.id),title:"Annotate",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",fill:"currentColor"})})}),_("button",{type:"button",class:"bugpin-btn-icon bugpin-btn-icon-danger",onClick:()=>r(C.id),title:"Remove",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]})]},C.id))}),_("div",{class:"bugpin-drop-more",children:_("span",{children:"Drop more files here"})})]})}),_("p",{class:"bugpin-helper-text",children:"Supported: PNG, JPG, GIF, WebP (max 10MB) • MP4, WebM, MOV, AVI (max 50MB)"})]})},kl=[{id:"details",label:"Details",icon:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",fill:"currentColor"})})},{id:"media",label:"Screenshots",icon:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})})}],Ol=({onClose:n,onSubmit:t,onCaptureScreenshot:e,onAnnotateMedia:r,media:i,onAddMedia:s,onRemoveMedia:o,isSubmitting:a,isCapturing:l,enableAnnotation:c,activeTab:h,onActiveTabChange:u,formData:d,onFormDataChange:g})=>{const[f,m]=rt({}),b=Y((S,C)=>{g({...d,[S]:C}),f[S]&&m(A=>({...A,[S]:void 0}))},[d,g,f]),y=Y(()=>{const S={};return d.title.trim()?d.title.trim().length<4&&(S.title="Title must be at least 4 characters"):S.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(S.reporterEmail="Invalid email address"),m(S),Object.keys(S).length===0},[d]),w=Y(S=>{if(S.preventDefault(),!y()){u("details");return}t(d,i)},[d,i,y,t,u]),O=Y(S=>{S.target.classList.contains("bugpin-overlay")&&n()},[n]),k=i.length;return _("div",{class:"bugpin-overlay",onClick:O,children:_("div",{class:"bugpin-dialog bugpin-dialog-tabbed",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-title",children:[_("div",{class:"bugpin-header",children:[_("h2",{id:"bugpin-title",children:"Report a Bug"}),_("button",{class:"bugpin-close",onClick:n,"aria-label":"Close",children:_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",fill:"currentColor"})})})]}),_("div",{class:"bugpin-tabs-container",children:_(_l,{tabs:kl.map(S=>({...S,label:S.id==="media"&&k>0?`${S.label} (${k})`:S.label})),activeTab:h,onTabChange:u})}),_("div",{class:"bugpin-body",children:[h==="details"&&_("form",{class:"bugpin-form",onSubmit:w,children:[_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label required",for:"bugpin-title-input",children:"Title"}),_("input",{id:"bugpin-title-input",class:"bugpin-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:S=>b("title",S.target.value),maxLength:200}),f.title&&_("span",{class:"bugpin-error",children:f.title})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-description",children:"Description"}),_("textarea",{id:"bugpin-description",class:"bugpin-textarea",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:S=>b("description",S.target.value)})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-priority",children:"Priority"}),_("select",{id:"bugpin-priority",class:"bugpin-select",value:d.priority,onChange:S=>b("priority",S.target.value),children:[_("option",{value:"lowest",children:"Lowest"}),_("option",{value:"low",children:"Low"}),_("option",{value:"medium",children:"Medium"}),_("option",{value:"high",children:"High"}),_("option",{value:"highest",children:"Highest"})]})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-email",children:"Email (optional)"}),_("input",{id:"bugpin-email",class:"bugpin-input",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:S=>b("reporterEmail",S.target.value)}),f.reporterEmail&&_("span",{class:"bugpin-error",children:f.reporterEmail})]}),_("div",{class:"bugpin-field",children:[_("label",{class:"bugpin-label",for:"bugpin-name",children:"Name (optional)"}),_("input",{id:"bugpin-name",class:"bugpin-input",type:"text",placeholder:"Your name",value:d.reporterName,onInput:S=>b("reporterName",S.target.value)})]})]}),h==="media"&&_(Tl,{media:i,onCapture:e,onUpload:s,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c})]}),_("div",{class:"bugpin-footer",children:[_("button",{type:"button",class:"bugpin-btn-cancel",onClick:n,disabled:a,children:"Cancel"}),_("button",{type:"submit",class:"bugpin-btn-submit",onClick:w,disabled:a,children:a?_("span",{class:"bugpin-spinner"}):"Submit Report"})]})]})})},Dl=({message:n,type:t,onClose:e,duration:r=5e3})=>(Ft(()=>{const i=setTimeout(e,r);return()=>clearTimeout(i)},[e,r]),_("div",{class:`bugpin-toast ${t}`,role:"alert",children:[t==="success"&&_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",fill:"currentColor"})}),t==="error"&&_("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),_("span",{children:n})]}));function p(n,t,e){return(t=function(r){var i=function(s,o){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var l=a.call(s,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}(r,"string");return typeof i=="symbol"?i:i+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function xn(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function v(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?xn(Object(e),!0).forEach(function(r){p(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):xn(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function J(n,t){if(n==null)return{};var e,r,i=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(n,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)e=s[r],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(i[e]=n[e])}return i}function Yt(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class wn{constructor(){p(this,"browserShadowBlurConstant",1),p(this,"DPI",96),p(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),p(this,"perfLimitSizeTotal",2097152),p(this,"maxCacheSideLimit",4096),p(this,"minCacheSideLimit",256),p(this,"disableStyleCopyPaste",!1),p(this,"enableGLFiltering",!0),p(this,"textureSize",4096),p(this,"forceGLPutImageData",!1),p(this,"cachesBoundsOfCurve",!1),p(this,"fontPaths",{}),p(this,"NUM_FRACTION_DIGITS",4)}}const X=new class extends wn{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=v(v({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(n=>{delete this.fontPaths[n]})}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new wn,e=(n==null?void 0:n.reduce((r,i)=>(r[i]=t[i],r),{}))||t;this.configure(e)}},ce=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return console[n]("fabric",...e)};class Ut extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Ml extends Ut{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class El{}class Pl extends El{testPrecision(t,e){const r="precision ".concat(e,` float;
|
|
82
|
-
void main(){}`),i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,r),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(r=>this.testPrecision(e,r)),e.getExtension("WEBGL_lose_context").loseContext(),ce("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Al={};let Cn;const Gt=()=>Cn||(Cn={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Pl,dispose(){},copyPasteData:Al}),ke=()=>Gt().document,wr=()=>Gt().window,Sn=()=>{var n;return Math.max((n=X.devicePixelRatio)!==null&&n!==void 0?n:wr().devicePixelRatio,1)},tr=new class{constructor(){p(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:r}=n;t=t.toLowerCase();const i=this.charWidthsCache;i.has(t)||i.set(t,new Map);const s=i.get(t),o="".concat(e.toLowerCase(),"_").concat((r+"").toLowerCase());return s.has(o)||s.set(o,new Map),s.get(o)}clearFontCache(n){n?this.charWidthsCache.delete((n||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(n){const{perfLimitSizeTotal:t}=X,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},Wi="6.9.1";function Cr(){}const er=Math.PI/2,Sr=2*Math.PI,Vi=Math.PI/180,gt=Object.freeze([1,0,0,1,0,0]),Xi=16,he=.4477152502,W="center",U="left",vt="top",Yi="bottom",it="right",bt="none",Ui=/\r?\n/,Tn="moving",Tr="scaling",kn="rotating",Gi="rotate",On="skewing",rr="resizing",jl="modifyPoly",Ll="modifyPath",kr="changed",Or="scale",yt="scaleX",Pt="scaleY",Oe="skewX",De="skewY",at="fill",_t="stroke",Dr="modified",Me="json",Ni="svg",E=new class{constructor(){this[Me]=new Map,this[Ni]=new Map}has(n){return this[Me].has(n)}getClass(n){const t=this[Me].get(n);if(!t)throw new Ut("No class registered for ".concat(n));return t}setClass(n,t){t?this[Me].set(t,n):(this[Me].set(n.type,n),this[Me].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Ni].get(n)}setSVGClass(n,t){this[Ni].set(t??n.type.toLowerCase(),n)}},Mr=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var r;return e.target===n||typeof e.target=="object"&&((r=e.target)===null||r===void 0?void 0:r.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class Fl{constructor(){p(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(r=>{let[i,s]=r;this.on(i,s)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if(typeof t=="object"){const r=[];return Object.entries(t).forEach(i=>{let[s,o]=i;r.push(this.once(s,o))}),()=>r.forEach(i=>i())}if(e){const r=this.on(t,function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];e.call(this,...s),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],i=r.indexOf(e);i>-1&&r.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const r in this.__eventListeners)this._removeEventListener(r);else typeof t=="object"?Object.entries(t).forEach(r=>{let[i,s]=r;this._removeEventListener(i,s)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const i=(r=this.__eventListeners[t])===null||r===void 0?void 0:r.concat();if(i)for(let s=0;s<i.length;s++)i[s].call(this,e||{})}}const Ee=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},Zt=n=>{if(n===0)return 1;switch(Math.abs(n)/er){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},Jt=n=>{if(n===0)return 0;const t=n/er,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$i;const r=Jt(t),i=Zt(t),s=this.subtract(e);return new x(s.x*i-s.y*r,s.x*r+s.y*i).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const $i=new x(0,0),Er=n=>!!n&&Array.isArray(n._objects);function Dn(n){class t extends n{constructor(){super(...arguments),p(this,"_objects",[])}_onObjectAdded(r){}_onObjectRemoved(r){}_onStackOrderChanged(r){}add(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];const o=this._objects.push(...i);return i.forEach(a=>this._onObjectAdded(a)),o}insertAt(r){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return this._objects.splice(r,0,...s),s.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const r=this._objects,i=[];for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return o.forEach(l=>{const c=r.indexOf(l);c!==-1&&(r.splice(c,1),i.push(l),this._onObjectRemoved(l))}),i}forEachObject(r){this.getObjects().forEach((i,s,o)=>r(i,s,o))}getObjects(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...i))}item(r){return this._objects[r]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(r,i){return!!this._objects.includes(r)||!!i&&this._objects.some(s=>s instanceof t&&s.contains(r,!0))}complexity(){return this._objects.reduce((r,i)=>r+=i.complexity?i.complexity():0,0)}sendObjectToBack(r){return!(!r||r===this._objects[0])&&(Ee(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(Ee(this._objects,r),this._objects.push(r),this._onStackOrderChanged(r),!0)}sendObjectBackwards(r,i){if(!r)return!1;const s=this._objects.indexOf(r);if(s!==0){const o=this.findNewLowerIndex(r,s,i);return Ee(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}bringObjectForward(r,i){if(!r)return!1;const s=this._objects.indexOf(r);if(s!==this._objects.length-1){const o=this.findNewUpperIndex(r,s,i);return Ee(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,i){return r!==this._objects[i]&&(Ee(this._objects,r),this._objects.splice(i,0,r),this._onStackOrderChanged(r),!0)}findNewLowerIndex(r,i,s){let o;if(s){o=i;for(let a=i-1;a>=0;--a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=i-1;return o}findNewUpperIndex(r,i,s){let o;if(s){o=i;for(let a=i+1;a<this._objects.length;++a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=i+1;return o}collectObjects(r){let{left:i,top:s,width:o,height:a}=r,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(i,s),u=h.add(new x(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class Mn extends Fl{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Pr(n){return wr().requestAnimationFrame(n)}function Rl(n){return wr().cancelAnimationFrame(n)}let Bl=0;const ue=()=>Bl++,Qt=()=>{const n=ke().createElement("canvas");if(!n||n.getContext===void 0)throw new Ut("Failed to create `canvas` element");return n},Il=()=>ke().createElement("img"),At=n=>{const t=Qt();return t.width=n.width,t.height=n.height,t},En=(n,t,e)=>n.toDataURL("image/".concat(t),e),Pn=(n,t,e)=>new Promise((r,i)=>{n.toBlob(r,"image/".concat(t),e)}),st=n=>n*Vi,te=n=>n/Vi,Hl=n=>n.every((t,e)=>t===gt[e]),xt=(n,t,e)=>new x(n).transform(t,e),Rt=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:r,y:i}=new x(n[4],n[5]).transform(e,!0);return e[4]=-r,e[5]=-i,e},ht=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],qi=(n,t)=>n.reduceRight((e,r)=>r&&e?ht(r,e,t):r||e,void 0)||gt.concat(),An=n=>{let[t,e]=n;return Math.atan2(e,t)},Ar=n=>{const t=An(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),r=Math.sqrt(e),i=(n[0]*n[3]-n[2]*n[1])/r,s=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:te(t),scaleX:r,scaleY:i,skewX:te(s),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},ir=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Pe(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=st(n),i=Zt(r),s=Jt(r);return[i,s,-s,i,t?t-(i*t-s*e):0,e?e-(s*t+i*e):0]}const Ki=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},jn=n=>Math.tan(st(n)),Ln=n=>[1,0,jn(n),1,0,0],Fn=n=>[1,jn(n),0,1,0,0],jr=n=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:i=!1,skewX:s=0,skewY:o=0}=n,a=Ki(r?-t:t,i?-e:e);return s&&(a=ht(a,Ln(s),!0)),o&&(a=ht(a,Fn(o),!0)),a},zl=n=>{const{translateX:t=0,translateY:e=0,angle:r=0}=n;let i=ir(t,e);r&&(i=ht(i,Pe({angle:r})));const s=jr(n);return Hl(s)||(i=ht(i,s)),i},Lr=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,i){if(t&&t.aborted)return i(new Ml("loadImage"));const s=Il();let o;t&&(o=function(l){s.src="",i(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){s.onload=s.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),r(s)};n?(s.onload=a,s.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),i(new Ut("Error loading ".concat(s.src)))},e&&(s.crossOrigin=e),s.src=n):a()})},sr=function(n){let{signal:t,reviver:e=Cr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0}),Promise.all(n.map(o=>E.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),s.push(a),a)))).then(r).catch(o=>{s.forEach(a=>{a.dispose&&a.dispose()}),i(o)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},Fr=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,r)=>{const i=[];t&&t.addEventListener("abort",r,{once:!0});const s=Object.values(n).map(a=>a&&a.type&&E.has(a.type)?sr([a],{signal:t}).then(l=>{let[c]=l;return i.push(c),c}):a),o=Object.keys(n);Promise.all(s).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{i.forEach(l=>{l.dispose&&l.dispose()}),r(a)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},Ae=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},Zi=(n,t)=>Object.keys(n).reduce((e,r)=>(t(n[r],r,n)&&(e[r]=n[r]),e),{}),Z=(n,t)=>parseFloat(Number(n).toFixed(t)),nr=n=>"matrix("+n.map(t=>Z(t,X.NUM_FRACTION_DIGITS)).join(" ")+")",jt=n=>!!n&&n.toLive!==void 0,Rn=n=>!!n&&typeof n.toObject=="function",Bn=n=>!!n&&n.offsetX!==void 0&&"source"in n,ve=n=>!!n&&"multiSelectionStacking"in n;function In(n){const t=n&&Bt(n);let e=0,r=0;if(!n||!t)return{left:e,top:r};let i=n;const s=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(e=o.scrollLeft||s.scrollLeft||0,r=o.scrollTop||s.scrollTop||0):(e+=i.scrollLeft||0,r+=i.scrollTop||0),i.nodeType!==1||i.style.position!=="fixed"););return{left:e,top:r}}const Bt=n=>n.ownerDocument||null,Hn=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},zn=function(n,t,e){let{width:r,height:i}=e,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=r,n.height=i,s>1&&(n.setAttribute("width",(r*s).toString()),n.setAttribute("height",(i*s).toString()),t.scale(s,s))},Ji=(n,t)=>{let{width:e,height:r}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),r&&(n.style.height=typeof r=="number"?"".concat(r,"px"):r)};function Wn(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=bt,n}class Vn{constructor(t){p(this,"_originalCanvasStyle",void 0),p(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(r=t)&&r.getContext!==void 0?t:t&&ke().getElementById(t)||Qt();var r;if(e.hasAttribute("data-fabric"))throw new Ut("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:r}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(r)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:i}=this.lower;zn(r,i,t,e)}setCSSDimensions(t){Ji(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&Bt(t),i={left:0,top:0};if(!r)return i;const s=((e=Hn(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(s.borderLeftWidth,10)||0,i.top+=parseInt(s.borderTopWidth,10)||0,i.left+=parseInt(s.paddingLeft,10)||0,i.top+=parseInt(s.paddingTop,10)||0;let o={left:0,top:0};const a=r.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=In(t);return{left:o.left+l.left-(a.clientLeft||0)+i.left,top:o.top+l.top-(a.clientTop||0)+i.top}}(this.lower.el)}dispose(){Gt().dispose(this.lower.el),delete this.lower}}const Wl={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...gt]},Vl=["objects"];class or extends Dn(Mn){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 or.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 Vn(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const s=super.insertAt(t,...r);return r.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),s}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(ce("warn",`Canvas is trying to add an object that belongs to a different canvas.
|
|
83
|
-
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?Sn():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:r=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const i=v({width:this.width,height:this.height},t);this.elements.setDimensions(i,this.getRetinaScaling()),this.hasLostContext=!0,this.width=i.width,this.height=i.height}r||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const r=t,i=[...this.viewportTransform],s=xt(t,Rt(i));i[0]=e,i[3]=e;const o=xt(s,i);i[4]+=r.x-o.x,i[5]+=r.y-o.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Pr(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Rt(this.viewportTransform),i=xt({x:0,y:0},r),s=xt({x:t,y:e},r),o=i.min(s),a=i.max(s);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Rl(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const r=this.viewportTransform;t.save(),t.transform(...r),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let r=0,i=e.length;r<i;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this["".concat(e,"Color")],i=this["".concat(e,"Image")],s=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!r&&!i)return;const a=jt(r);if(r){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?r.toLive(t):r,o&&t.transform(...s),a){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const l=r.gradientTransform||r.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...s),i.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return xt(this.getCenterPoint(),Rt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,W,W),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const r=this.clipPath,i=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return v(v(v({version:Wi},Ae(this,e)),{},{objects:this._objects.filter(s=>!s.excludeFromExport).map(s=>this._toObject(s,t,e))},this.__serializeBgOverlay(t,e)),i?{clipPath:i}:null)}_toObject(t,e,r){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);const s=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!i),s}__serializeBgOverlay(t,e){const r={},i=this.backgroundImage,s=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return jt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),jt(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),i&&!i.excludeFromExport&&(r.backgroundImage=this._toObject(i,t,e)),s&&!s.excludeFromExport&&(r.overlayImage=this._toObject(s,t,e)),r}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
|
|
84
|
-
`)),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
|
|
36
|
+
*/const Dc=Di("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"}]]),Mc={bug:Tc,"message-square":Dc,"alert-circle":Oc},Ec=({name:i,class:t,size:e=18,strokeWidth:r=2})=>{const s=Mc[i];return s?p(s,{class:t,size:e,strokeWidth:r}):null};function So(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=So(i[t]))&&(r&&(r+=" "),r+=e)}else for(e in i)i[e]&&(r&&(r+=" "),r+=e);return r}function ko(){for(var i,t,e=0,r="",s=arguments.length;e<s;e++)(i=arguments[e])&&(t=So(i))&&(r&&(r+=" "),r+=t);return r}const Pc=(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},Ac=(i,t)=>({classGroupId:i,validator:t}),To=(i=new Map,t=null,e)=>({nextPart:i,validators:t,classGroupId:e}),vs="-",Oo=[],Lc="arbitrary..",Fc=i=>{const t=Ic(i),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=i;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return jc(o);const a=o.split(vs),l=a[0]===""&&a.length>1?1:0;return Do(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=e[o];return l?c?Pc(c,l):l:c||Oo}return e[o]||Oo}}},Do=(i,t,e)=>{if(i.length-t===0)return e.classGroupId;const s=i[t],n=e.nextPart.get(s);if(n){const c=Do(i,t+1,n);if(c)return c}const o=e.validators;if(o===null)return;const a=t===0?i.join(vs):i.slice(t).join(vs),l=o.length;for(let c=0;c<l;c++){const h=o[c];if(h.validator(a))return h.classGroupId}},jc=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?Lc+r:void 0})(),Ic=i=>{const{theme:t,classGroups:e}=i;return Bc(e,t)},Bc=(i,t)=>{const e=To();for(const r in i){const s=i[r];Mi(s,e,r,t)}return e},Mi=(i,t,e,r)=>{const s=i.length;for(let n=0;n<s;n++){const o=i[n];Rc(o,t,e,r)}},Rc=(i,t,e,r)=>{if(typeof i=="string"){$c(i,t,e);return}if(typeof i=="function"){zc(i,t,e,r);return}Hc(i,t,e,r)},$c=(i,t,e)=>{const r=i===""?t:Mo(t,i);r.classGroupId=e},zc=(i,t,e,r)=>{if(Vc(i)){Mi(i(r),t,e,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ac(e,i))},Hc=(i,t,e,r)=>{const s=Object.entries(i),n=s.length;for(let o=0;o<n;o++){const[a,l]=s[o];Mi(l,Mo(t,a),e,r)}},Mo=(i,t)=>{let e=i;const r=t.split(vs),s=r.length;for(let n=0;n<s;n++){const o=r[n];let a=e.nextPart.get(o);a||(a=To(),e.nextPart.set(o,a)),e=a}return e},Vc=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,Wc=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)}}},Ei="!",Eo=":",Xc=[],Po=(i,t,e,r,s)=>({modifiers:i,hasImportantModifier:t,baseClassName:e,maybePostfixModifierPosition:r,isExternal:s}),Yc=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===Eo){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(Ei)?(d=u.slice(0,-1),g=!0):u.startsWith(Ei)&&(d=u.slice(1),g=!0);const f=c&&c>l?c-l:void 0;return Po(n,g,d,f)};if(t){const s=t+Eo,n=r;r=o=>o.startsWith(s)?n(o.slice(s.length)):Po(Xc,!1,o,void 0,!0)}if(e){const s=r;r=n=>e({className:n,parseClassName:s})}return r},Uc=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}},Gc=i=>({cache:Wc(i.cacheSize),parseClassName:Yc(i),sortModifiers:Uc(i),...Fc(i)}),Nc=/\s+/,qc=(i,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:n}=t,o=[],a=i.trim().split(Nc);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 w=d.length===0?"":d.length===1?d[0]:n(d).join(":"),T=g?w+Ei:w,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},Kc=(...i)=>{let t=0,e,r,s="";for(;t<i.length;)(e=i[t++])&&(r=Ao(e))&&(s&&(s+=" "),s+=r);return s},Ao=i=>{if(typeof i=="string")return i;let t,e="";for(let r=0;r<i.length;r++)i[r]&&(t=Ao(i[r]))&&(e&&(e+=" "),e+=t);return e},Zc=(i,...t)=>{let e,r,s,n;const o=l=>{const c=t.reduce((h,u)=>u(h),i());return e=Gc(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=qc(l,e);return s(l,h),h};return n=o,(...l)=>n(Kc(...l))},Jc=[],bt=i=>{const t=e=>e[i]||Jc;return t.isThemeGetter=!0,t},Lo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Qc=/^\d+\/\d+$/,th=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eh=/\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$/,rh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ih=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ge=i=>Qc.test(i),U=i=>!!i&&!Number.isNaN(Number(i)),_e=i=>!!i&&Number.isInteger(Number(i)),Pi=i=>i.endsWith("%")&&U(i.slice(0,-1)),he=i=>th.test(i),nh=()=>!0,oh=i=>eh.test(i)&&!rh.test(i),jo=()=>!1,ah=i=>sh.test(i),lh=i=>ih.test(i),ch=i=>!R(i)&&!$(i),hh=i=>Ne(i,zo,jo),R=i=>Lo.test(i),Fe=i=>Ne(i,Ho,oh),Ai=i=>Ne(i,ph,U),Io=i=>Ne(i,Ro,jo),uh=i=>Ne(i,$o,lh),ys=i=>Ne(i,Vo,ah),$=i=>Fo.test(i),Or=i=>qe(i,Ho),dh=i=>qe(i,mh),Bo=i=>qe(i,Ro),gh=i=>qe(i,zo),fh=i=>qe(i,$o),bs=i=>qe(i,Vo,!0),Ne=(i,t,e)=>{const r=Lo.exec(i);return r?r[1]?t(r[1]):e(r[2]):!1},qe=(i,t,e=!1)=>{const r=Fo.exec(i);return r?r[1]?t(r[1]):e:!1},Ro=i=>i==="position"||i==="percentage",$o=i=>i==="image"||i==="url",zo=i=>i==="length"||i==="size"||i==="bg-size",Ho=i=>i==="length",ph=i=>i==="number",mh=i=>i==="family-name",Vo=i=>i==="shadow",vh=Zc(()=>{const i=bt("color"),t=bt("font"),e=bt("text"),r=bt("font-weight"),s=bt("tracking"),n=bt("leading"),o=bt("breakpoint"),a=bt("container"),l=bt("spacing"),c=bt("radius"),h=bt("shadow"),u=bt("inset-shadow"),d=bt("text-shadow"),g=bt("drop-shadow"),f=bt("blur"),m=bt("perspective"),y=bt("aspect"),b=bt("ease"),w=bt("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=()=>[Ge,"full","auto",..._()],O=()=>[_e,"none","subgrid",$,R],V=()=>["auto",{span:["full",_e,$,R]},_e,$,R],z=()=>[_e,"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"],K=()=>["auto",..._()],Z=()=>[Ge,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],L=()=>[i,$,R],wt=()=>[...C(),Bo,Io,{position:[$,R]}],mt=()=>["no-repeat",{repeat:["","x","y","space","round"]}],lt=()=>["auto","cover","contain",gh,hh,{size:[$,R]}],k=()=>[Pi,Or,Fe],P=()=>["","none","full",c,$,R],E=()=>["",U,Or,Fe],B=()=>["solid","dashed","dotted","double"],I=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[U,Pi,Bo,Io],dt=()=>["","none",f,$,R],ht=()=>["none",U,$,R],it=()=>["none",U,$,R],kt=()=>[U,$,R],F=()=>[Ge,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[he],breakpoint:[he],color:[nh],container:[he],"drop-shadow":[he],ease:["in","out","in-out"],font:[ch],"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",Ge,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:[_e,"auto",$,R]}],basis:[{basis:[Ge,"full","auto",a,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[U,Ge,"auto","initial","none",R]}],grow:[{grow:["",U,$,R]}],shrink:[{shrink:["",U,$,R]}],order:[{order:[_e,"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: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":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"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,Or,Fe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$,Ai]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Pi,R]}],"font-family":[{font:[dh,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",$,Ai]}],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",$,Fe]}],"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:wt()}],"bg-repeat":[{bg:mt()}],"bg-size":[{bg:lt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_e,$,R],radial:["",$,R],conic:[_e,$,R]},fh,uh]}],"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,Or,Fe]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",h,bs,ys]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",u,bs,ys]}],"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,Fe]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",d,bs,ys]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[U,$,R]}],"mix-blend":[{"mix-blend":[...I(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":I()}],"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:wt()}],"mask-repeat":[{mask:mt()}],"mask-size":[{mask:lt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$,R]}],filter:[{filter:["","none",$,R]}],blur:[{blur:dt()}],brightness:[{brightness:[U,$,R]}],contrast:[{contrast:[U,$,R]}],"drop-shadow":[{"drop-shadow":["","none",g,bs,ys]}],"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":dt()}],"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",w,$,R]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,$,R]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:ht()}],"rotate-x":[{"rotate-x":ht()}],"rotate-y":[{"rotate-y":ht()}],"rotate-z":[{"rotate-z":ht()}],scale:[{scale:it()}],"scale-x":[{"scale-x":it()}],"scale-y":[{"scale-y":it()}],"scale-z":[{"scale-z":it()}],"scale-3d":["scale-3d"],skew:[{skew:kt()}],"skew-x":[{"skew-x":kt()}],"skew-y":[{"skew-y":kt()}],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,Or,Fe,Ai]}],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"]}});function Bt(...i){return vh(ko(i))}const yh=["dark","theme-dark","dark-mode","dark-theme","wp-dark-mode-active","flavor-dark","is-dark","night","night-mode"],bh=["light","theme-light","light-mode","light-theme","wp-dark-mode-disabled","is-light"],Wo=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme","data-wp-dark-mode-active","data-dark-mode"],Li=["class","style","color-scheme",...Wo];function wh(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 xh(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 _h(){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 Ch(){var e,r,s;const i=document.documentElement,t=document.body;for(const n of[i,t])if(n){for(const o of yh)if(n.classList.contains(o))return"dark";for(const o of bh)if(n.classList.contains(o))return"light"}for(const n of Wo)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 Sh(){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=wh(t);if(!e)return null;const r=xh(e.r,e.g,e.b);return r<.4?"dark":r>.6?"light":null}function kh(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Xo(){return _h()??Ch()??Sh()??kh()}function Yo(i){const[t,e]=at(()=>i!=="auto"?i:Xo());return Ht(()=>{if(i!=="auto"){e(i);return}const r=()=>e(Xo());r();let s=null;if(typeof MutationObserver<"u")if(s=new MutationObserver(r),s.observe(document.documentElement,{attributes:!0,attributeFilter:Li}),document.body)s.observe(document.body,{attributes:!0,attributeFilter:Li});else{const o=new MutationObserver(()=>{document.body&&(o.disconnect(),s==null||s.observe(document.body,{attributes:!0,attributeFilter:Li}),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 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"},Oh=({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:w})=>{const[T,C]=at(!1),[S,D]=at({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),A=It(null),_=It(null),O=Yo(o)==="dark";Ht(()=>{if(T&&A.current&&_.current){const L=A.current,wt=_.current;requestAnimationFrame(()=>{const mt=L.getBoundingClientRect(),lt=wt.getBoundingClientRect(),k=window.innerWidth,P=4,E=lt.left+lt.width/2,B=mt.width/2;let I=0;const H=E-B;H<P?I=P-H:H+mt.width>k-P&&(I=k-P-(H+mt.width)),D({left:"50%",transform:`translateX(-50%) translateX(${I}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",K=t||"Report Bug",Z=e==="round"?`${s/2}px`:"12px 20px";return p("div",{class:Bt("fixed z-[2147483647]",Th[i]),children:[p("button",{ref:_,class:Bt("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:Z},onClick:w,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"aria-label":K,children:[r&&p(Ec,{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}})]})]})},Uo=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,Go=ko,Dh=((i,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return Go(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=Uo(h)||Uo(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 Go(i,o,l,e==null?void 0:e.class,e==null?void 0:e.className)})("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"}}),ee=({class:i,variant:t,size:e,children:r,type:s="button",...n})=>p("button",{type:s,class:Bt(Dh({variant:t,size:e}),i),...n,children:r}),Fi=({class:i,error:t,type:e="text",...r})=>p("input",{type:e,class:Bt("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}),Mh=({class:i,error:t,...e})=>p("textarea",{class:Bt("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}),Eh=({class:i,error:t,children:e,...r})=>p("select",{class:Bt("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}),Dr=({class:i,required:t,children:e,for:r,...s})=>p("label",{for:r,class:Bt("text-sm font-medium text-foreground",i),...s,children:[e,t&&p("span",{class:"text-destructive ml-0.5",children:"*"})]}),Ph=({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:Bt("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)})}),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})=>(Ht(()=>{const s=setTimeout(e,r);return()=>clearTimeout(s)},[e,r]),p("div",{class:Bt("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"&&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})]})),Fh=10*1024*1024,jh=50*1024*1024,Ih=["image/png","image/jpeg","image/gif","image/webp"],Bh=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Rh=({media:i,onCapture:t,onUpload:e,onRemove:r,onAnnotate:s,isCapturing:n,enableAnnotation:o,maxImageSize:a=Fh,maxVideoSize:l=jh})=>{const[c,h]=at(!1),[u,d]=at(null),g=It(null),f=O=>O.startsWith("video/"),m=O=>O.startsWith("image/"),y=Math.round(a/(1024*1024)),b=Math.round(l/(1024*1024)),w=N(O=>{if(m(O.type)){if(!Ih.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(!Bh.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=w(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)},[w,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(ee,{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:Bt("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(ee,{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(ee,{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)"]})]})},$h="bugpin-skip-screen-capture-consent",zh=({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(ee,{variant:"outline",class:"flex-1",onClick:t,children:"Back"}),p(ee,{class:"flex-1",onClick:()=>{e&&localStorage.setItem($h,"true"),i()},children:"Take Screenshot"})]})]})},Hh=[{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"})})}],Vh=({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:w})=>{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(ee,{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(zh,{onConfirm:m,onCancel:y}):p(Sr,{children:[p("div",{class:"p-4 pb-0 bg-transparent",children:p(Ph,{tabs:Hh.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(Dr,{for:"bugpin-title-input",required:!0,children:"Title"}),p(Fi,{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(Dr,{for:"bugpin-description",children:"Description"}),p(Mh,{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(Dr,{for:"bugpin-priority",children:"Priority"}),p(Eh,{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(Dr,{for:"bugpin-name",children:"Name (optional)"}),p(Fi,{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(Dr,{for:"bugpin-email",children:"Email (optional)"}),p(Fi,{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(Rh,{media:s,onCapture:e,onUpload:n,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c,maxImageSize:b,maxVideoSize:w})]}),p("div",{class:"flex gap-3 p-6 border-t border-solid border-border bg-muted",children:[p(ee,{variant:"outline",class:"flex-1",onClick:i,disabled:a,children:"Cancel"}),p(ee,{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 No{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 tt=new class extends No{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 No,e=(i==null?void 0:i.reduce((r,s)=>(r[s]=t[s],r),{}))||t;this.configure(e)}},Ce=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 re extends Error{constructor(t,e){super(`fabric: ${t}`,e)}}class Wh extends re{constructor(t){super(`${t} 'options.signal' is in 'aborted' state`)}}class Xh{}class Yh extends Xh{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(),Ce("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Uh={};let qo;const se=()=>qo||(qo={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Yh,dispose(){},copyPasteData:Uh}),Ke=()=>se().document,ws=()=>se().window,Ko=()=>{var i;return Math.max((i=tt.devicePixelRatio)!==null&&i!==void 0?i:ws().devicePixelRatio,1)},Mr=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}=tt,e=Math.sqrt(t*i);return[Math.floor(e),Math.floor(t/e)]}},ji="7.2.0";function xs(){}const Er=Math.PI/2,Gh=Math.PI/4,Ze=2*Math.PI,Ii=Math.PI/180,Tt=Object.freeze([1,0,0,1,0,0]),Bi=16,Se=.4477152502,Y="center",Q="left",Et="top",Ri="bottom",ft="right",Pt="none",$i=/\r?\n/,Zo="moving",_s="scaling",Jo="rotating",zi="rotate",Qo="skewing",Pr="resizing",Nh="modifyPoly",qh="modifyPath",Cs="changed",Ss="scale",At="scaleX",Vt="scaleY",Je="skewX",Qe="skewY",_t="fill",Rt="stroke",ks="modified",je="ltr",ue="rtl",Hi="normal",tr="json",Vi="svg",j=new class{constructor(){this[tr]=new Map,this[Vi]=new Map}has(i){return this[tr].has(i)}getClass(i){const t=this[tr].get(i);if(!t)throw new re(`No class registered for ${i}`);return t}setClass(i,t){t?this[tr].set(t,i):(this[tr].set(i.type,i),this[tr].set(i.type.toLowerCase(),i))}getSVGClass(i){return this[Vi].get(i)}setSVGClass(i,t){this[Vi].set(t??i.type.toLowerCase(),i)}},Ts=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 Kh{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 er=(i,t)=>{const e=i.indexOf(t);return e!==-1&&i.splice(e,1),i},de=i=>{if(i===0)return 1;switch(Math.abs(i)/Er){case 1:case 3:return 0;case 2:return-1}return Math.cos(i)},ge=i=>{if(i===0)return 0;const t=i/Er,e=Math.sign(i);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(i)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${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 x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Wi;const r=ge(t),s=de(t),n=this.subtract(e);return new x(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 x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Wi=new x(0,0),Os=i=>!!i&&Array.isArray(i._objects);function ta(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])&&(er(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(er(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 er(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 er(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,s){return r!==this._objects[s]&&(er(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 x(s,n),u=h.add(new x(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class ea extends Kh{_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 Ds(i){return ws().requestAnimationFrame(i)}function Zh(i){return ws().cancelAnimationFrame(i)}let Jh=0;const ke=()=>Jh++,fe=()=>{const i=Ke().createElement("canvas");if(!i||i.getContext===void 0)throw new re("Failed to create `canvas` element");return i},Qh=()=>Ke().createElement("img"),Wt=i=>{const t=fe();return t.width=i.width,t.height=i.height,t},ra=(i,t,e)=>i.toDataURL(`image/${t}`,e),sa=(i,t,e)=>new Promise((r,s)=>{i.toBlob(r,`image/${t}`,e)}),pt=i=>i*Ii,Te=i=>i/Ii,tu=i=>i.every((t,e)=>t===Tt[e]),Lt=(i,t,e)=>new x(i).transform(t,e),Ut=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 x(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]],Xi=(i,t)=>i.reduceRight((e,r)=>r&&e?Ct(r,e,t):r||e,void 0)||Tt.concat(),ia=i=>{let[t,e]=i;return Math.atan2(e,t)},Ms=i=>{const t=ia(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:Te(t),scaleX:r,scaleY:s,skewX:Te(n),skewY:0,translateX:i[4]||0,translateY:i[5]||0}},Ar=function(i){return[1,0,0,1,i,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function rr(){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=de(r),n=ge(r);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const Yi=function(i){return[i,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:i,0,0]},na=i=>Math.tan(pt(i)),oa=i=>[1,0,na(i),1,0,0],aa=i=>[1,na(i),0,1,0,0],Es=i=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=i,a=Yi(r?-t:t,s?-e:e);return n&&(a=Ct(a,oa(n),!0)),o&&(a=Ct(a,aa(o),!0)),a},eu=i=>{const{translateX:t=0,translateY:e=0,angle:r=0}=i;let s=Ar(t,e);r&&(s=Ct(s,rr({angle:r})));const n=Es(i);return tu(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 Wh("loadImage"));const n=Qh();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 re(`Error loading ${n.src}`))},e&&(n.crossOrigin=e),n.src=i):a()})},Lr=function(i){let{signal:t,reviver:e=xs}=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=>j.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)})})},As=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&&j.has(a.type)?Lr([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)})})},sr=function(i){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in i&&(t[e]=i[e]),t),{})},Ui=(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)),Fr=i=>"matrix("+i.map(t=>nt(t,tt.NUM_FRACTION_DIGITS)).join(" ")+")",Xt=i=>!!i&&i.toLive!==void 0,la=i=>!!i&&typeof i.toObject=="function",ca=i=>!!i&&i.offsetX!==void 0&&"source"in i,Ie=i=>!!i&&"multiSelectionStacking"in i;function ha(i){const t=i&&Gt(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 Gt=i=>i.ownerDocument||null,ua=i=>{var t;return((t=i.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},da=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))},Gi=(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 ga(i){return i.onselectstart!==void 0&&(i.onselectstart=()=>!1),i.style.userSelect=Pt,i}class fa{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&&Ke().getElementById(t)||fe();var r;if(e.hasAttribute("data-fabric"))throw new re("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;da(r,s,t,e)}setCSSDimensions(t){Gi(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&Gt(t),s={left:0,top:0};if(!r)return s;const n=((e=ua(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=ha(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(){se().dispose(this.lower.el),delete this.lower}}const ru={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Tt],patternQuality:"best"},q=i=>i.toString().replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let jr;const Ni=i=>{if(jr||jr||(jr="Intl"in ws()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),jr){const t=jr.segment(i);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return su(i)},su=i=>{const t=[];for(let e,r=0;r<i.length;r++)(e=iu(i,r))!==!1&&t.push(e);return t},iu=(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 Ir extends ta(ea){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 Ir.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 fa(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&&(Ce("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?Ko():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=Lt(t,Ut(s));s[0]=e,s[3]=e;const o=Lt(n,s);s[4]+=r.x-o.x,s[5]+=r.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Ds(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Ut(this.viewportTransform),s=Lt({x:0,y:0},r),n=Lt({x:t,y:e},r),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Zh(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=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")}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Lt(this.getCenterPoint(),Ut(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:ji,...sr(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=[];var s;return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push(`<g clip-path="url(#${q((s=this.clipPath.clipPathId)!==null&&s!==void 0?s:"")})" >
|
|
39
|
+
`),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
|
|
85
40
|
`),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
|
|
86
41
|
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
87
|
-
`)}_setSVGHeader(t,e){const r=e.width
|
|
88
|
-
`,"<desc>Created with Fabric.js ",
|
|
42
|
+
`)}_setSVGHeader(t,e){const r=e.width||`${this.width}`,s=e.height||`${this.height}`,n=tt.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="${nt(-l[4]/l[0],n)} ${nt(-l[5]/l[3],n)} ${nt(this.width/l[0],n)} ${nt(this.height/l[3],n)}" `}else a=`viewBox="0 0 ${this.width} ${this.height}" `;t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',s,'" ',a,`xml:space="preserve">
|
|
43
|
+
`,"<desc>Created with Fabric.js ",ji,`</desc>
|
|
89
44
|
`,`<defs>
|
|
90
45
|
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
|
|
91
|
-
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId
|
|
92
|
-
|
|
93
|
-
`)
|
|
94
|
-
font-family: '
|
|
95
|
-
src: url('
|
|
46
|
+
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId=`CLIPPATH_${ke()}`,`<clipPath id="${e.clipPathId}" >
|
|
47
|
+
${e.toClipPathSVG(t.reviver)}</clipPath>
|
|
48
|
+
`):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this[`${t}Color`];if(Xt(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?Fr(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=tt.fontPaths;this._objects.forEach(function n(o){t.push(o),Os(o)&&o._objects.forEach(n)}),t.forEach(n=>{if(!(o=n)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=n;!e[l]&&r[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&r[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(n=>` @font-face {
|
|
49
|
+
font-family: '${n}';
|
|
50
|
+
src: url('${r[n]}');
|
|
96
51
|
}
|
|
97
|
-
`)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
`)
|
|
101
|
-
`)}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new Ut("`json` is undefined"));const i=typeof t=="string"?JSON.parse(t):t,{objects:s=[]}=i,o=J(i,Vl),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:u}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([sr(s,{reviver:e,signal:r}),Fr({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:u},{signal:r})]).then(g=>{let[f,m]=g;return this.clear(),this.add(...f),this.set(o),this.set(m),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=At(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:s=!1}=t,o=i*(s?this.getRetinaScaling():1);return En(this.toCanvasElement(o,t),e,r)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:s=!1}=t,o=i*(s?this.getRetinaScaling():1);return Pn(this.toCanvasElement(o,t),e,r)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:r,left:i,top:s,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(r||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,g=c*t,f=this.viewportTransform,m=[g,0,0,g,(f[4]-(i||0))*t,(f[5]-(s||0))*t],b=this.enableRetinaScaling,y=At({width:a,height:l}),w=o?this._objects.filter(O=>o(O)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(y.getContext("2d"),w),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=d,y}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Mr.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}p(or,"ownDefaults",Wl);const Xl=["touchstart","touchmove","touchend"],Yl=n=>{const t=In(n.target),e=function(r){const i=r.changedTouches;return i&&i[0]?i[0]:r}(n);return new x(e.clientX+t.left,e.clientY+t.top)},Qi=n=>Xl.includes(n.type)||n.pointerType==="touch",Xn=n=>{n.preventDefault(),n.stopPropagation()},ee=n=>{let t=0,e=0,r=0,i=0;for(let s=0,o=n.length;s<o;s++){const{x:a,y:l}=n[s];(a>r||!s)&&(r=a),(a<t||!s)&&(t=a),(l>i||!s)&&(i=l),(l<e||!s)&&(e=l)}return{left:t,top:e,width:r-t,height:i-e}},Ul=["translateX","translateY","scaleX","scaleY"],Gl=(n,t)=>Rr(n,ht(t,n.calcOwnMatrix())),Rr=(n,t)=>{const e=Ar(t),{translateX:r,translateY:i,scaleX:s,scaleY:o}=e,a=J(e,Ul),l=new x(r,i);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:s,scaleY:o}),n.setPositionByOrigin(l,W,W)},Nl=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Yn=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),ts=(n,t,e)=>{const r=n/2,i=t/2,s=[new x(-r,-i),new x(r,-i),new x(-r,i),new x(r,i)].map(a=>a.transform(e)),o=ee(s);return new x(o.width,o.height)},Br=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gt;return ht(Rt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:gt),n)},je=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gt;return n.transform(Br(t,e))},$l=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gt;return n.transform(Br(t,e),!0)},ql=(n,t,e)=>{const r=Br(t,e);return Rr(n,ht(r,n.calcOwnMatrix())),r},Un=(n,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire("object:".concat(n),v(v({},t),{},{target:r})),r.fire(n,t)},Kl={left:-.5,top:-.5,center:0,bottom:.5,right:.5},ot=n=>typeof n=="string"?Kl[n]:n-.5,Ir="not-allowed";function Gn(n){return ot(n.originX)===ot(W)&&ot(n.originY)===ot(W)}function Nn(n){return .5-ot(n)}const It=(n,t)=>n[t],$n=(n,t,e,r)=>({e:n,transform:t,pointer:new x(e,r)});function qn(n,t){const e=n.getTotalAngle()+te(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function es(n,t,e,r,i){var s;let{target:o,corner:a}=n;const l=o.controls[a],c=((s=o.canvas)===null||s===void 0?void 0:s.getZoom())||1,h=o.padding/c,u=function(d,g,f,m){const b=d.getRelativeCenterPoint(),y=f!==void 0&&m!==void 0?d.translateToGivenOrigin(b,W,W,f,m):new x(d.left,d.top);return(d.angle?g.rotate(-st(d.angle),b):g).subtract(y)}(o,new x(r,i),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Zl=(n,t,e,r)=>{const{target:i,offsetX:s,offsetY:o}=t,a=e-s,l=r-o,c=!It(i,"lockMovementX")&&i.left!==a,h=!It(i,"lockMovementY")&&i.top!==l;return c&&i.set(U,a),h&&i.set(vt,l),(c||h)&&Un(Tn,$n(n,t,e,r)),c||h},Hr=n=>n.replace(/\s+/g," "),Kn={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"},rs=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),Zn=(n,t,e,r)=>{n/=255,t/=255,e/=255;const i=Math.max(n,t,e),s=Math.min(n,t,e);let o,a;const l=(i+s)/2;if(i===s)o=a=0;else{const c=i-s;switch(a=l>.5?c/(2-i-s):c/(i+s),i){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},Jn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},zr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),Qn=n=>{let[t,e,r,i=1]=n;const s=Math.round(.3*t+.59*e+.11*r);return[s,s,s,i]};class G{constructor(t){if(p(this,"isUnrecognised",!1),t)if(t instanceof G)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,r,i,s=1]=t;this.setSource([e,r,i,s])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Kn&&(t=Kn[t]),t==="transparent"?[255,255,255,0]:G.sourceFromHex(t)||G.sourceFromRgb(t)||G.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(r,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,r]=Zn(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){const[t,e,r,i]=Zn(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(r,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,i]=this.getSource();return"".concat(zr(t)).concat(zr(e)).concat(zr(r)).concat(zr(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Qn(this.getSource())),this}toBlackWhite(t){const[e,,,r]=Qn(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,r]),this}overlayWith(t){t instanceof G||(t=new G(t));const e=this.getSource(),r=t.getSource(),[i,s,o]=e.map((a,l)=>Math.round(.5*a+.5*r[l]));return this.setSource([i,s,o,e[3]]),this}static fromRgb(t){return G.fromRgba(t)}static fromRgba(t){return new G(G.sourceFromRgb(t))}static sourceFromRgb(t){const e=Hr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[r,i,s]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[r,i,s,Jn(e[4])]}}static fromHsl(t){return G.fromHsla(t)}static fromHsla(t){return new G(G.sourceFromHsl(t))}static sourceFromHsl(t){const e=Hr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const r=(G.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,s=parseFloat(e[3])/100;let o,a,l;if(i===0)o=a=l=s;else{const c=s<=.5?s*(i+1):s+i-s*i,h=2*s-c;o=rs(h,c,r+.3333333333333333),a=rs(h,c,r),l=rs(h,c,r-.3333333333333333)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Jn(e[4])]}static fromHex(t){return new G(G.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let r;r=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[i,s,o,a=255]=r.map(l=>parseInt(l,16));return[i,s,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?te(r):e.includes("turn")?360*r:r}}const Le=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xi;const e=/\D{0,2}$/.exec(n),r=parseFloat(n),i=X.DPI;switch(e==null?void 0:e[0]){case"mm":return r*i/25.4;case"cm":return r*i/2.54;case"in":return r*i;case"pt":return r*i/72;case"pc":return r*i/72*12;case"em":return r*t;default:return r}},Jl=n=>{const[t,e]=n.trim().split(" "),[r,i]=(s=t)&&s!==bt?[s.slice(1,4),s.slice(5,8)]:s===bt?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:e||"meet",alignX:r,alignY:i}},ar=function(n,t){let e,r,i=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const s=new G(t),o=s.getAlpha();e=s.toRgb(),o!==1&&(r=o.toString())}else e="none";return i?"".concat(n,": ").concat(e,"; ").concat(r?"".concat(n,"-opacity: ").concat(r,"; "):""):"".concat(n,'="').concat(e,'" ').concat(r?"".concat(n,'-opacity="').concat(r,'" '):"")};class to{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):bt,s=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),d=ar(at,this.fill);return[ar(_t,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",s,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t?this.calcTransformMatrix():this.calcOwnMatrix(),i='transform="'.concat(nr(r));return"".concat(i).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,withShadow:i,additionalTransform:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=i?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,g=this.shadow,f=[],m=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(ue()),b='<clipPath id="'.concat(l.clipPathId,`" >
|
|
102
|
-
|
|
103
|
-
`)
|
|
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(Xt(r)){const s=r.repeat||"",n=this.width,o=this.height,a=this[`${e}Vpt`]?Fr(Ut(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"||!ca(r)?n:r.source.width}" height="${s!=="repeat-x"&&s!=="no-repeat"||!ca(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 re("`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([Lr(s,{reviver:e,signal:r}),As({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=Wt(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 ra(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 sa(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=Wt({width:a,height:l}),w=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"),w),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}),Ts.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(Ir,"ownDefaults",ru);const nu=["touchstart","touchmove","touchend"],ou=i=>{const t=ha(i.target),e=function(r){const s=r.changedTouches;return s&&s[0]?s[0]:r}(i);return new x(e.clientX+t.left,e.clientY+t.top)},qi=i=>nu.includes(i.type)||i.pointerType==="touch",pa=i=>{i.preventDefault(),i.stopPropagation()},pe=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}},au=(i,t)=>Ls(i,Ct(t,i.calcOwnMatrix())),Ls=(i,t)=>{const{translateX:e,translateY:r,scaleX:s,scaleY:n,...o}=Ms(t),a=new x(e,r);i.flipX=!1,i.flipY=!1,Object.assign(i,o),i.set({scaleX:s,scaleY:n}),i.setPositionByOrigin(a,Y,Y)},lu=i=>{i.scaleX=1,i.scaleY=1,i.skewX=0,i.skewY=0,i.flipX=!1,i.flipY=!1,i.rotate(0)},ma=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}),Ki=(i,t,e)=>{const r=i/2,s=t/2,n=[new x(-r,-s),new x(r,-s),new x(-r,s),new x(r,s)].map(a=>a.transform(e)),o=pe(n);return new x(o.width,o.height)},Fs=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tt;return Ct(Ut(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt),i)},ir=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;return i.transform(Fs(t,e))},cu=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;return i.transform(Fs(t,e),!0)},hu=(i,t,e)=>{const r=Fs(t,e);return Ls(i,Ct(r,i.calcOwnMatrix())),r},uu={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Ot=i=>typeof i=="string"?uu[i]:i-.5,du=new x(1,0),va=new x,ya=(i,t)=>i.rotate(t),js=(i,t)=>new x(t).subtract(i),Zi=i=>i.distanceFrom(va),Ji=(i,t)=>Math.atan2(Br(i,t),gu(i,t)),ba=i=>Ji(du,i),Qi=i=>i.eq(va)?i:i.scalarDivide(Zi(i)),wa=function(i){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Qi(new x(-i.y,i.x).scalarMultiply(t?1:-1))},Br=(i,t)=>i.x*t.y-i.y*t.x,gu=(i,t)=>i.x*t.x+i.y*t.y,xa=(i,t,e)=>{if(i.eq(t)||i.eq(e))return!0;const r=Br(t,e),s=Br(t,i),n=Br(e,i);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},Is="not-allowed";function _a(i){return Ot(i.originX)===Ot(Y)&&Ot(i.originY)===Ot(Y)}function Ca(i){return .5-Ot(i)}const Nt=(i,t)=>i[t],Sa=(i,t,e,r)=>({e:i,transform:t,pointer:new x(e,r)});function ka(i,t,e){const r=e,s=ir(i.getCenterPoint(),i.canvas.viewportTransform,void 0),n=ba(js(s,r))+Ze;return Math.round(n%Ze/Gh)}function tn(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 x(d.left,d.top);return(d.angle?g.rotate(-pt(d.angle),y):g).subtract(b)}(o,new x(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 Bs=i=>i.replace(/\s+/g," "),Ta={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"},en=(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),Oa=(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]},Da=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(i)/(i.endsWith("%")?100:1)},Rs=i=>Math.min(Math.round(i),255).toString(16).toUpperCase().padStart(2,"0"),Ma=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 Ta&&(t=Ta[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]=Oa(...this.getSource());return`hsl(${t},${e}%,${r}%)`}toHsla(){const[t,e,r,s]=Oa(...this.getSource());return`hsla(${t},${e}%,${r}%,${s})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,s]=this.getSource();return`${Rs(t)}${Rs(e)}${Rs(r)}${Rs(Math.round(255*s))}`}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ma(this.getSource())),this}toBlackWhite(t){const[e,,,r]=Ma(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=Bs(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,Da(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.sourceFromHsl(t))}static sourceFromHsl(t){const e=Bs(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=en(h,c,r+.3333333333333333),a=en(h,c,r),l=en(h,c,r-.3333333333333333)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Da(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")?Te(r):e.includes("turn")?360*r:r}}const nr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bi;const e=/\D{0,2}$/.exec(i),r=parseFloat(i),s=tt.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}},fu=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}},Rr=function(i,t){let e,r,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e=`url(#SVGID_${q(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 Ea{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=Rr(_t,this.fill);return[Rr(Rt,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=>q(g)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${q(this.shadow.id)});`:""}getSvgCommons(){return[this.id?`id="${q(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="${Fr(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_${ke()}`,y=`<clipPath id="${l.clipPathId}" >
|
|
57
|
+
${l.toClipPathSVG(r)}</clipPath>
|
|
58
|
+
`),h&&f.push("<g ",a,this.getSvgCommons(),` >
|
|
104
59
|
`),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
|
|
105
|
-
`);const
|
|
60
|
+
`);const b=[o,c,e?"":this.addPaintOrder()," ",n?`transform="${n}" `:""].join("");return t[m]=b,Xt(d)&&f.push(d.toSVG(this)),Xt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(y),f.push(t.join("")),f.push(`</g>
|
|
106
61
|
`),h&&f.push(`</g>
|
|
107
|
-
`),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==
|
|
108
|
-
<feGaussianBlur in="SourceAlpha" stdDeviation="
|
|
109
|
-
<feOffset dx="
|
|
110
|
-
<feFlood flood-color="
|
|
62
|
+
`),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==_t?` paint-order="${q(this.paintFirst)}" `:""}}function $s(i){return new RegExp("^("+i.join("|")+")\\b","i")}const Be="textDecorationThickness",Pa=["fontSize","fontWeight","fontFamily","fontStyle"],Aa=["underline","overline","linethrough"],La=[...Pa,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Fa=[...La,...Aa,"textBackgroundColor","direction",Be],pu=[...Pa,...Aa,Rt,"strokeWidth",_t,"deltaY","textBackgroundColor",Be],mu={_reNewline:$i,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:Hi,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Q,fontStyle:Hi,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Q,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:je,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,[Be]:66.667},ie="justify",zs="justify-left",$r="justify-right",zr="justify-center",Re=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,vu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Re+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Re+"))?\\s+(.*)"),yu={cx:Q,x:Q,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":Be},rn="font-size",sn="clip-path";$s(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),$s(["symbol","image","marker","pattern","view","svg"]);const ja=$s(["symbol","g","a","svg","clipPath","defs"]),Ia="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Ba=new RegExp("(?:\\s|^)"+Ia+Ia+"("+Re+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ne{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=typeof t=="string"?ne.parseShadow(t):t;Object.assign(this,ne.ownDefaults,e),this.id=ke()}static parseShadow(t){const e=t.trim(),[,r=0,s=0,n=0]=(Ba.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Ba,"")||"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=ya(new x(this.offsetX,this.offsetY),pt(-t.angle)),r=tt.NUM_FRACTION_DIGITS,s=new rt(this.color);let n=40,o=40;return t.width&&t.height&&(n=100*nt((Math.abs(e.x)+this.blur)/t.width,r)+20,o=100*nt((Math.abs(e.y)+this.blur)/t.height,r)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),`<filter id="SVGID_${q(this.id)}" y="-${o}%" height="${100+2*o}%" x="-${n}%" width="${100+2*n}%" >
|
|
63
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="${nt(this.blur?this.blur/2:0,r)}"></feGaussianBlur>
|
|
64
|
+
<feOffset dx="${nt(e.x,r)}" dy="${nt(e.y,r)}" result="oBlur" ></feOffset>
|
|
65
|
+
<feFlood flood-color="${s.toRgb()}" flood-opacity="${s.getAlpha()}"/>
|
|
111
66
|
<feComposite in2="oBlur" operator="in" />
|
|
112
67
|
<feMerge>
|
|
113
68
|
<feMergeNode></feMergeNode>
|
|
114
69
|
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
115
70
|
</feMerge>
|
|
116
71
|
</filter>
|
|
117
|
-
`)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=$t.ownDefaults;return this.includeDefaultValues?t:Zi(t,(r,i)=>r!==e[i])}static async fromObject(t){return new this(t)}}p($t,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),p($t,"type","shadow"),E.setClass($t,"shadow");const Fe=(n,t,e)=>Math.max(n,Math.min(t,e)),oc=[vt,U,yt,Pt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Oe,De],re=[at,_t,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ac={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:U,originY:vt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:at,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},lc=(n,t,e,r)=>-e*Math.cos(n/r*er)+e+t,cc=()=>!1;class hs{constructor(t){let{startValue:e,byValue:r,duration:i=500,delay:s=0,easing:o=lc,onStart:a=Cr,onChange:l=Cr,onComplete:c=Cr,abort:h=cc,target:u}=t;p(this,"_state","pending"),p(this,"durationProgress",0),p(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=s,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,this.startValue=e,this.byValue=r,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Pr(t),this.delay):Pr(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:i,valueProgress:s}=this.calculate(r);this.value=Object.freeze(i),this.valueProgress=s,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Pr(this.tick)))}register(){Mr.push(this)}unregister(){Mr.remove(this)}abort(){this._state="aborted",this.unregister()}}const hc=["startValue","endValue"];class uc extends hs{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(v(v({},J(t,hc)),{},{startValue:e,byValue:r-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const dc=["startValue","endValue"];class gc extends hs{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(v(v({},J(t,dc)),{},{startValue:e,byValue:r.map((i,s)=>i-e[s])}))}calculate(t){const e=this.startValue.map((r,i)=>this.easing(t,r,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const fc=["startValue","endValue","easing","onChange","onComplete","abort"],pc=(n,t,e,r)=>t+e*(1-Math.cos(n/r*er)),us=n=>n&&((t,e,r)=>n(new G(t).toRgba(),e,r));class mc extends hs{constructor(t){let{startValue:e,endValue:r,easing:i=pc,onChange:s,onComplete:o,abort:a}=t,l=J(t,fc);const c=new G(e).getSource(),h=new G(r).getSource();super(v(v({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:i,onChange:us(s),onComplete:us(o),abort:us(a)}))}calculate(t){const[e,r,i,s]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,r,i].map(Math.round),Fe(0,s,1)];return{value:o,valueProgress:o.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function mo(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new gc(n):new uc(n);return t.start(),t}function vc(n){const t=new mc(n);return t.start(),t}class Q{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(i=>!this.includes(i))),this}static isPointContained(t,e,r){let i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const s=os(e,r),o=os(e,t).divide(s);return i?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const r=new x(t).setX(Math.min(t.x-1,...e.map(s=>s.x)));let i=0;for(let s=0;s<e.length;s++){const o=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,r);if(o.includes(t))return!0;i+=+(o.status==="Intersection")}return i%2==1}static intersectLineLine(t,e,r,i){let s=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=i.x-r.x,h=i.y-r.y,u=t.x-r.x,d=t.y-r.y,g=c*d-h*u,f=a*d-l*u,m=h*a-c*l;if(m!==0){const b=g/m,y=f/m;return(s||0<=b&&b<=1)&&(o||0<=y&&y<=1)?new Q("Intersection").append(new x(t.x+b*a,t.y+b*l)):new Q}if(g===0||f===0){const b=s||o||Q.isPointContained(t,r,i)||Q.isPointContained(e,r,i)||Q.isPointContained(r,t,e)||Q.isPointContained(i,t,e);return new Q(b?"Coincident":void 0)}return new Q("Parallel")}static intersectSegmentLine(t,e,r,i){return Q.intersectLineLine(t,e,r,i,!1,!0)}static intersectSegmentSegment(t,e,r,i){return Q.intersectLineLine(t,e,r,i,!1,!1)}static intersectLinePolygon(t,e,r){let i=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const s=new Q,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=Q.intersectLineLine(t,e,a,l,i,!1),c.status==="Coincident")return c;s.append(...c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectSegmentPolygon(t,e,r){return Q.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new Q,i=t.length,s=[];for(let o=0;o<i;o++){const a=t[o],l=t[(o+1)%i],c=Q.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(s.push(c),r.append(a,l)):r.append(...c.points)}return s.length>0&&s.length===t.length?new Q("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const i=e.min(r),s=e.max(r),o=new x(s.x,i.y),a=new x(i.x,s.y);return Q.intersectPolygonPolygon(t,[i,o,s,a])}}class bc extends Mn{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?xt(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=xt(t,Rt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,r,i];if(this.group){const o=this.group.calcTransformMatrix();return s.map(a=>xt(a,o))}return s}intersectsWithRect(t,e){return Q.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=Q.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:r,top:i,width:s,height:o}=this.getBoundingRect();return r>=t.x&&r+s<=e.x&&i>=t.y&&i+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return Q.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 ee(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(yt,t),this._set(Pt,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?te(An(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||gt.concat()}calcACoords(){const t=Pe({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),i=ir(e,r),s=ht(i,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:xt({x:-a,y:-l},s),tr:xt({x:a,y:-l},s),bl:xt({x:-a,y:l},s),br:xt({x:a,y:l},s)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,ot(this.originX),ot(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const r=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((s,o)=>s===r[o])?i.value:(this.group&&(e=ht(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const r=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},s=zl(i);return this.ownMatrixCache={key:t,value:s},s}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=v({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),r=e.strokeWidth;let i=r,s=0;this.strokeUniform&&(i=0,s=r);const o=e.width+i,a=e.height+i;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):ts(o,a,jr(e)),l.scalarAdd(s)}translateToGivenOrigin(t,e,r,i,s){let o=t.x,a=t.y;const l=ot(i)-ot(e),c=ot(s)-ot(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,r){if(e===W&&r===W)return t;const i=this.translateToGivenOrigin(t,e,r,W,W);return this.angle?i.rotate(st(this.angle),t):i}translateToOriginPoint(t,e,r){const i=this.translateToGivenOrigin(t,W,W,e,r);return this.angle?i.rotate(st(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?xt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const i=this.translateToCenterPoint(t,e,r),s=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),U,vt)}}const yc=["type"],_c=["extraParam"];let ie=class Mi extends bc{static getDefaults(){return Mi.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){ce("warn","Setting type has no effect",t)}constructor(t){super(),p(this,"_cacheContext",null),Object.assign(this,Mi.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Qt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,i=X.maxCacheSideLimit,s=X.minCacheSideLimit;if(e<=i&&r<=i&&e*r<=X.perfLimitSizeTotal)return e<s&&(t.width=s),r<s&&(t.height=s),t;const o=e/r,[a,l]=tr.limitDimsByArea(o),c=Fe(s,a,i),h=Fe(s,l,i);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:r,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:i,zoomX:s,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=r!==t.width||i!==t.height,h=this.zoomX!==s||this.zoomY!==o;if(!t||!e)return!1;if(c||h){r!==t.width||i!==t.height?(t.width=r,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(s,o),this.zoomX=s,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Ar(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==yt&&t!==Pt||(e=this._constrainScale(e)),t===yt&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof $t||(e=new $t(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:s}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:s,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===_t&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){const i=this.fill,s=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=i,this.stroke=s}createClipPathLayer(t,e){const r=At(e),i=r.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(s=>{s.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const s=Rt(this.calcTransformMatrix());i.transform(s[0],s[1],s[2],s[3],s[4],s[5])}return t.transform(i),t.drawObject(i,!0,e),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,r);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,jt(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&&(jt(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,r=this.canvas,i=this.getCanvasRetinaScaling(),[s,,,o]=(r==null?void 0:r.viewportTransform)||gt,a=s*i,l=o*i,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*X.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!jt(e))return{offsetX:0,offsetY:0};const r=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,i,s):t.transform(1,0,0,1,i,s),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:i,offsetY:s}}_renderPaintInOrder(t){this.paintFirst===_t?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var r;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),o=i.x/this.scaleX/s,a=i.y/this.scaleY/s,l=At({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(i.zoomX/this.scaleX/s,i.zoomY/this.scaleY/s),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(s*this.scaleX/i.zoomX,s*this.scaleY/i.zoomY),t.strokeStyle=(r=c.createPattern(l,"no-repeat"))!==null&&r!==void 0?r:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(E.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Yn(this),r=this.group,i=this.shadow,s=Math.abs,o=t.enableRetinaScaling?Sn():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(w=>new or(w,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Nl(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&ql(this,this.getViewportTransform()),this.setCoords();const c=Qt(),h=this.getBoundingRect(),u=this.shadow,d=new x;if(u){const w=u.blur,O=u.nonScaling?new x(1,1):this.getObjectScaling();d.x=2*Math.round(s(u.offsetX)+w)*s(O.x),d.y=2*Math.round(s(u.offsetY)+w)*s(O.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const m=l(c);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new x(m.width/2,m.height/2),W,W);const b=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const y=m.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=i,r&&(this.group=r),this.set(e),this.setCoords(),m._objects=[],m.destroy(),y}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return En(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Pn(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:i}=this;if(e){const{x:s,y:o}=this.getRelativeCenterPoint();this.originX=W,this.originY=W,this.left=s,this.top=o}if(this.set("angle",t),e){const{x:s,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),r,i);this.left=s,this.top=o,this.originX=r,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Mr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Gt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((r,i)=>{let[s,o]=i;return r[s]=this._animate(s,o,e),r},{})}_animate(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=t.split("."),s=this.constructor.colorProperties.includes(i[i.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=r,h=v(v({},r),{},{target:this,startValue:a??i.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,g)=>{i.reduce((f,m,b)=>(b===i.length-1&&(f[m]=u),f[m]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}});return s?vc(h):mo(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let i,s=0;s<e.length;s++){if(i=e[s],i===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let o=0;o<r.length;o++){if(this===r[o])return{fork:[],otherFork:[t,...r.slice(0,o)],common:[this,...e]};if(i===r[o])return{fork:[this,...e.slice(0,s)],otherFork:[t,...r.slice(0,o)],common:e.slice(s)}}}return{fork:[this,...e],otherFork:[t,...r],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const r=e.common[0]||this.canvas;if(!r)return;const i=e.fork.pop(),s=e.otherFork.pop(),o=r._objects.indexOf(i),a=r._objects.indexOf(s);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Mi.customProperties,this.constructor.customProperties||[]);let e;const r=X.NUM_FRACTION_DIGITS,{clipPath:i,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:g,height:f,strokeWidth:m,strokeLineCap:b,strokeDashOffset:y,strokeLineJoin:w,strokeUniform:O,strokeMiterLimit:k,scaleX:S,scaleY:C,angle:A,flipX:D,flipY:L,opacity:R,visible:H,backgroundColor:I,fillRule:M,paintFirst:j,globalCompositeOperation:z,skewX:V,skewY:tt}=this;i&&!i.excludeFromExport&&(e=i.toObject(t.concat("inverted","absolutePositioned")));const N=Mt=>Z(Mt,r),Ct=v(v({},Ae(this,t)),{},{type:this.constructor.type,version:Wi,originX:u,originY:d,left:N(c),top:N(h),width:N(g),height:N(f),fill:Rn(s)?s.toObject():s,stroke:Rn(o)?o.toObject():o,strokeWidth:N(m),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:y,strokeLineJoin:w,strokeUniform:O,strokeMiterLimit:N(k),scaleX:N(S),scaleY:N(C),angle:N(A),flipX:D,flipY:L,opacity:N(R),shadow:a&&a.toObject(),visible:H,backgroundColor:I,fillRule:M,paintFirst:j,globalCompositeOperation:z,skewX:N(V),skewY:N(tt)},e?{clipPath:e}:null);return this.includeDefaultValues?Ct:this._removeDefaultValues(Ct)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Zi(t,(i,s)=>{if(s===U||s===vt||s==="type")return!0;const o=r[s];return i!==o&&!(Array.isArray(i)&&Array.isArray(o)&&i.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=J(t,yc),r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:i}=r,s=J(r,_c);return Fr(e,s).then(o=>i?(delete o[i],new this(e[i],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};p(ie,"stateProperties",oc),p(ie,"cacheProperties",re),p(ie,"ownDefaults",ac),p(ie,"type","FabricObject"),p(ie,"colorProperties",[at,_t,"backgroundColor"]),p(ie,"customProperties",[]),E.setClass(ie),E.setClass(ie,"object");const Re=(n,t,e)=>(r,i,s,o)=>{const a=t(r,i,s,o);return a&&Un(n,v(v({},$n(r,i,s,o)),e)),a};function Be(n){return(t,e,r,i)=>{const{target:s,originX:o,originY:a}=e,l=s.getRelativeCenterPoint(),c=s.translateToOriginPoint(l,o,a),h=n(t,e,r,i);return s.setPositionByOrigin(c,e.originX,e.originY),h}}const vo=Re(rr,Be((n,t,e,r)=>{const i=es(t,t.originX,t.originY,e,r);if(ot(t.originX)===ot(W)||ot(t.originX)===ot(it)&&i.x<0||ot(t.originX)===ot(U)&&i.x>0){const{target:s}=t,o=s.strokeWidth/(s.strokeUniform?s.scaleX:1),a=Gn(t)?2:1,l=s.width,c=Math.abs(i.x*a/s.scaleX)-o;return s.set("width",Math.max(c,1)),l!==s.width}return!1}));function xc(n,t,e,r,i){r=r||{};const s=this.sizeX||r.cornerSize||i.cornerSize,o=this.sizeY||r.cornerSize||i.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:i.transparentCorners,l=a?_t:at,c=!a&&(r.cornerStrokeColor||i.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=r.cornerColor||i.cornerColor||"",n.strokeStyle=r.cornerStrokeColor||i.cornerStrokeColor||"",s>o?(h=s,n.scale(1,o/s),d=e*s/o):o>s?(h=o,n.scale(s/o,1),u=t*o/s):h=s,n.beginPath(),n.arc(u,d,h/2,0,Sr,!1),n[l](),c&&n.stroke(),n.restore()}function wc(n,t,e,r,i){r=r||{};const s=this.sizeX||r.cornerSize||i.cornerSize,o=this.sizeY||r.cornerSize||i.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:i.transparentCorners,l=a?_t:at,c=!a&&(r.cornerStrokeColor||i.cornerStrokeColor),h=s/2,u=o/2;n.save(),n.fillStyle=r.cornerColor||i.cornerColor||"",n.strokeStyle=r.cornerStrokeColor||i.cornerStrokeColor||"",n.translate(t,e);const d=i.getTotalAngle();n.rotate(st(d)),n["".concat(l,"Rect")](-h,-u,s,o),c&&n.strokeRect(-h,-u,s,o),n.restore()}class zt{constructor(t){p(this,"visible",!0),p(this,"actionName",Or),p(this,"angle",0),p(this,"x",0),p(this,"y",0),p(this,"offsetX",0),p(this,"offsetY",0),p(this,"sizeX",0),p(this,"sizeY",0),p(this,"touchSizeX",0),p(this,"touchSizeY",0),p(this,"cursorStyle","crosshair"),p(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,r,i){var s;let{tl:o,tr:a,br:l,bl:c}=i;return((s=e.canvas)===null||s===void 0?void 0:s.getActiveObject())===e&&e.isControlVisible(t)&&Q.isPointInPolygon(r,[o,a,l,c])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,i;return(r=(i=t._controlsVisibility)===null||i===void 0?void 0:i[e])!==null&&r!==void 0?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,i){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,i,s,o){const a=qi([ir(r,i),Pe({angle:t}),Ki((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,r,i,s){((i=i||{}).cornerStyle||s.cornerStyle)==="circle"?xc.call(this,t,e,r,i,s):wc.call(this,t,e,r,i,s)}}const Cc=(n,t,e)=>e.lockRotation?Ir:t.cursorStyle,Sc=Re(kn,Be((n,t,e,r)=>{let{target:i,ex:s,ey:o,theta:a,originX:l,originY:c}=t;const h=i.translateToOriginPoint(i.getRelativeCenterPoint(),l,c);if(It(i,"lockRotation"))return!1;const u=Math.atan2(o-h.y,s-h.x),d=Math.atan2(r-h.y,e-h.x);let g=te(d-u+a);if(i.snapAngle&&i.snapAngle>0){const m=i.snapAngle,b=i.snapThreshold||m,y=Math.ceil(g/m)*m,w=Math.floor(g/m)*m;Math.abs(g-w)<b?g=w:Math.abs(g-y)<b&&(g=y)}g<0&&(g=360+g),g%=360;const f=i.angle!==g;return i.angle=g,f}));function bo(n,t){const e=t.canvas,r=n[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function yo(n,t,e){const r=It(n,"lockScalingX"),i=It(n,"lockScalingY");if(r&&i||!t&&(r||i)&&e||r&&t==="x"||i&&t==="y")return!0;const{width:s,height:o,strokeWidth:a}=n;return s===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const Tc=["e","se","s","sw","w","nw","n","ne","e"],ur=(n,t,e)=>{const r=bo(n,e);if(yo(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",r))return Ir;const i=qn(e,t);return"".concat(Tc[i],"-resize")};function ds(n,t,e,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const s=t.target,o=i.by,a=bo(n,s);let l,c,h,u,d,g;if(yo(s,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=es(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),It(s,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=s._getTransformedDimensions(),a&&!o){const b=Math.abs(l.x)+Math.abs(l.y),{original:y}=t,w=b/(Math.abs(u.x*y.scaleX/s.scaleX)+Math.abs(u.y*y.scaleY/s.scaleY));c=y.scaleX*w,h=y.scaleY*w}else c=Math.abs(l.x*s.scaleX/u.x),h=Math.abs(l.y*s.scaleY/u.y);Gn(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Nn(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=Nn(t.originY),h*=-1,t.signY=g)}const f=s.scaleX,m=s.scaleY;return o?(o==="x"&&s.set(yt,c),o==="y"&&s.set(Pt,h)):(!It(s,"lockScalingX")&&s.set(yt,c),!It(s,"lockScalingY")&&s.set(Pt,h)),f!==s.scaleX||m!==s.scaleY}const Xr=Re(Tr,Be((n,t,e,r)=>ds(n,t,e,r))),kc=Re(Tr,Be((n,t,e,r)=>ds(n,t,e,r,{by:"x"}))),Oc=Re(Tr,Be((n,t,e,r)=>ds(n,t,e,r,{by:"y"}))),Dc=["target","ex","ey","skewingSide"],gs={x:{counterAxis:"y",scale:yt,skew:Oe,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Pt,skew:De,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Mc=["ns","nesw","ew","nwse"],Ec=(n,t,e)=>{if(t.x!==0&&It(e,"lockSkewingY")||t.y!==0&&It(e,"lockSkewingX"))return Ir;const r=qn(e,t)%4;return"".concat(Mc[r],"-resize")};function _o(n,t,e,r,i){const{target:s}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=gs[n];if(It(s,l))return!1;const{origin:u,flip:d}=gs[o],g=ot(e[u])*(s[d]?-1:1),f=-Math.sign(g)*(s[h]?-1:1),m=.5*-((s[c]===0&&es(e,W,W,r,i)[n]>0||s[c]>0?1:-1)*f)+.5;return Re(On,Be((y,w,O,k)=>function(S,C,A){let{target:D,ex:L,ey:R,skewingSide:H}=C,I=J(C,Dc);const{skew:M}=gs[S],j=A.subtract(new x(L,R)).divide(new x(D.scaleX,D.scaleY))[S],z=D[M],V=I[M],tt=Math.tan(st(V)),N=S==="y"?D._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:D._getTransformedDimensions({scaleX:1,scaleY:1}).y,Ct=2*j*H/Math.max(N,1)+tt,Mt=te(Math.atan(Ct));D.set(M,Mt);const ct=z!==D[M];if(ct&&S==="y"){const{skewX:T,scaleX:F}=D,P=D._getTransformedDimensions({skewY:z}),B=D._getTransformedDimensions(),$=T!==0?P.x/B.x:1;$!==1&&D.set(yt,$*F)}return ct}(n,w,new x(O,k))))(t,v(v({},e),{},{[a]:m,skewingSide:f}),r,i)}const Pc=(n,t,e,r)=>_o("x",n,t,e,r),Ac=(n,t,e,r)=>_o("y",n,t,e,r);function Yr(n,t){return n[t.canvas.altActionKey]}const Ur=(n,t,e)=>{const r=Yr(n,e);return t.x===0?r?Oe:Pt:t.y===0?r?De:yt:""},Ie=(n,t,e)=>Yr(n,e)?Ec(0,t,e):ur(n,t,e),xo=(n,t,e,r)=>Yr(n,t.target)?Ac(n,t,e,r):kc(n,t,e,r),wo=(n,t,e,r)=>Yr(n,t.target)?Pc(n,t,e,r):Oc(n,t,e,r),Co=()=>({ml:new zt({x:-.5,y:0,cursorStyleHandler:Ie,actionHandler:xo,getActionName:Ur}),mr:new zt({x:.5,y:0,cursorStyleHandler:Ie,actionHandler:xo,getActionName:Ur}),mb:new zt({x:0,y:.5,cursorStyleHandler:Ie,actionHandler:wo,getActionName:Ur}),mt:new zt({x:0,y:-.5,cursorStyleHandler:Ie,actionHandler:wo,getActionName:Ur}),tl:new zt({x:-.5,y:-.5,cursorStyleHandler:ur,actionHandler:Xr}),tr:new zt({x:.5,y:-.5,cursorStyleHandler:ur,actionHandler:Xr}),bl:new zt({x:-.5,y:.5,cursorStyleHandler:ur,actionHandler:Xr}),br:new zt({x:.5,y:.5,cursorStyleHandler:ur,actionHandler:Xr}),mtr:new zt({x:0,y:-.5,actionHandler:Sc,cursorStyleHandler:Cc,offsetY:-40,withConnection:!0,actionName:Gi})}),jc=()=>({mr:new zt({x:.5,y:0,actionHandler:vo,cursorStyleHandler:Ie,actionName:rr}),ml:new zt({x:-.5,y:0,actionHandler:vo,cursorStyleHandler:Ie,actionName:rr})}),Lc=()=>v(v({},Co()),jc());class dr extends ie{static getDefaults(){return v(v({},super.getDefaults()),dr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),dr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Co()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,i=e.action;if(this===r&&i&&i.startsWith(Or))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const r=Object.entries(this.oCoords);for(let i=r.length-1;i>=0;i--){const[s,o]=r[i],a=this.controls[s];if(a.shouldActivate(s,this,t,e?o.touchCorner:o.corner))return this.__corner=s,{key:s,control:a,coord:this.oCoords[s]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),r=ir(e.x,e.y),i=Pe({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),s=ht(r,i),o=ht(t,s),a=ht(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Ar(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((u,d)=>{const g=u.positionHandler(c,a,this,u);h[d]=Object.assign(g,this._calcCornerCoords(u,g))}),h}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),r=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(st(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=v({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},r);t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:r,hasControls:i}=this,s=v({hasBorders:r,hasControls:i},e),o=this.getViewportTransform(),a=s.hasBorders,l=s.hasControls,c=ht(o,this.calcTransformMatrix()),h=Ar(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(st(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let i;if(r&&r.forActiveSelection||this.group){const s=ts(this.width,this.height,jr(e)),o=this.isStrokeAccountedForInDimensions()?$i:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=s.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((i,s)=>{i.withConnection&&i.getVisibility(this,s)&&(r=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:s,cornerColor:o}=this,a=v({cornerStrokeColor:i,cornerDashArray:s,cornerColor:o},e);t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[r,i]=e;return this.setControlVisible(r,i)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transform(e);const i=this.width+4,s=this.height+4;return e.clearRect(-i/2,-s/2,i,s),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function So(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),n}p(dr,"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 ut extends dr{}So(ut,[to]),E.setClass(ut),E.setClass(ut,"object");const Fc=(n,t,e,r)=>{const i=2*(r=Math.round(r))+1,{data:s}=n.getImageData(t-r,e-r,i,i);for(let o=3;o<s.length;o+=4)if(s[o]>0)return!1;return!0};class To{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const r=os(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(st(this.options.skewY)),e.x+=e.y*Math.tan(st(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Rc=new x;class He extends To{static getOrthogonalRotationFactor(t,e){const r=e?ls(t,e):sc(t);return Math.abs(r)<er?-1:1}constructor(t,e,r,i){super(i),p(this,"AB",void 0),p(this,"AC",void 0),p(this,"alpha",void 0),p(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ls(this.AB,this.AC),this.bisector=cs(ho(this.AB.eq(Rc)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),s=uo(i),o=He.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,r*o)}projectBevel(){const t=[];return(this.alpha%Sr==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),r=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),s=this.options.strokeUniform?as(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return as(i)/this.strokeProjectionMagnitude<=s&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],i=new x(He.getOrthogonalRotationFactor(this.bisector),He.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(s=>{go(s,t,e)&&r.push(this.A.add(s))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:i,skewY:s,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(st(i)),Math.tan(st(s))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new x(Math.sqrt(Math.max(h**2-u**2,0)),u),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(m=>this.applySkew(l?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{go(m,t,e)&&r.push(this.applySkew(this.A).add(m))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Sr==0,r=this.applySkew(this.A),i=t[e?0:2].subtract(r),s=t[e?1:0].subtract(r),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=hr(i,o)>0,l=a?i:s,c=a?s:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class ko extends To{constructor(t,e,r){super(r),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(uo(i),r)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new He(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(cs(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(r);t.push(i.add(e),i.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const Bc=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const r=[];if(n.length===0)return r;const i=n.reduce((s,o)=>(s[s.length-1].eq(o)||s.push(new x(o)),s),[new x(n[0])]);if(i.length===1)e=!0;else if(!e){const s=i[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(i,a=>!a.eq(s));i.splice(o+1)}return i.forEach((s,o,a)=>{let l,c;o===0?(c=a[1],l=e?s:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?s:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?r.push(...new ko(s,s,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new He(s,l,c,t).project()):r.push(...new ko(s,o===0?c:l,t).project())}),r},fs=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(r=>{t[e][r]=v({},n[e][r])})}),t},Ic=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let gr;const ps=n=>{if(gr||gr||(gr="Intl"in wr()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),gr){const t=gr.segment(n);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return Hc(n)},Hc=n=>{const t=[];for(let e,r=0;r<n.length;r++)(e=zc(n,r))!==!1&&t.push(e);return t},zc=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const i=n.charCodeAt(t+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const r=n.charCodeAt(t-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1},ms=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textDecorationThickness!==t.textDecorationThickness||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Wc=(n,t)=>{const e=t.split(`
|
|
118
|
-
`),r=[];let
|
|
119
|
-
`)]}static async fromElement(t,e,r){const i=se(t,this.ATTRIBUTE_NAMES,r),{left:s=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=i,h=J(i,ch);return new this(v(v(v({},e),h),{},{left:s,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}p(Tt,"type","Rect"),p(Tt,"cacheProperties",[...re,...Fo]),p(Tt,"ownDefaults",{rx:0,ry:0}),p(Tt,"ATTRIBUTE_NAMES",[...de,"x","y","rx","ry","width","height"]),E.setClass(Tt),E.setSVGClass(Tt);const ne="initialization",Gr="added",ys="removed",Nr="imperative",Ro=(n,t)=>{const{strokeUniform:e,strokeWidth:r,width:i,height:s,group:o}=t,a=o&&o!==n?Br(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?$l(new x(r,r),void 0,n.calcTransformMatrix()):$i,u=!e&&c?r:0,d=ts(i+u,s+u,qi([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class $r{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:i}=t;return e===ne||e===Nr||!!r&&i!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==ne&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:i}=e;if(r===Nr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:s,top:o,width:a,height:l}=ee(t.map(u=>Ro(i,u)).reduce((u,d)=>u.concat(d),[])),c=new x(a,l),h=new x(s,o).add(c.scalarDivide(2));if(r===ne){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:u}}return{center:h.transform(i.calcOwnMatrix()),size:c}}}p($r,"type","strategy");class _s extends $r{shouldPerformLayout(t){return!0}}p(_s,"type","fit-content"),E.setClass(_s);const hh=["strategy"],uh=["target","strategy","bubbles","prevStrategy"],Bo="layoutManager";class fr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new _s;p(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=v(v({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[Dr,Tn,rr,kn,Tr,On,kr,jl,Ll].map(i=>t.on(i,s=>this.performLayout(i===Dr?{type:"object_modified",trigger:i,e:s,target:r}:{type:"object_modifying",trigger:i,e:s,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(r=>r()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:r}=t,{canvas:i}=e;if(r===ne||r===Gr?this.subscribeTargets(t):r===ys&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),r===Nr&&t.deep){const s=J(t,hh);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(v(v({},s),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:r,type:i}=t,s=r.calcLayoutResult(t,e.getObjects());if(!s)return;const o=i===ne?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=s,h=o.subtract(a).add(l).transform(i===ne?gt:Rt(e.calcOwnMatrix()),!0).add(c);return{result:s,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:r}=t,{result:{size:i},nextCenter:s}=e;var o,a;r.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===ne?r.set({left:(o=t.x)!==null&&o!==void 0?o:s.x+i.x*ot(r.originX),top:(a=t.y)!==null&&a!==void 0?a:s.y+i.y*ot(r.originY)}):(r.setPositionByOrigin(s,W,W),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(i=>{i.group===r&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:i}=e;r.set({left:r.left+i.x,top:r.top+i.y})}onAfterLayout(t,e){const{target:r,strategy:i,bubbles:s,prevStrategy:o}=t,a=J(t,uh),{canvas:l}=r;r.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:r});const c=r.parent;s&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(r),c.layoutManager.performLayout(v(v({},a),{},{target:c}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:Bo,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}E.setClass(fr,Bo);const dh=["type","objects","layoutManager"];class gh extends fr{performLayout(){}}class ye extends Dn(ut){static getDefaults(){return v(v({},super.getDefaults()),ye.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),p(this,"_activeObjects",[]),p(this,"__objectSelectionTracker",void 0),p(this,"__objectSelectionDisposer",void 0),Object.assign(this,ye.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var r;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(i=>{this.enterGroup(i,!1)}),this.layoutManager=(r=e.layoutManager)!==null&&r!==void 0?r:new fr,this.layoutManager.performLayout({type:ne,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(ce("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(ce("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,r,i)=>this.canEnterGroup(e)&&i.indexOf(e)===r)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const i=this._filterObjectsBeforeEnteringGroup(e),s=super.add(...i);return this._onAfterObjectsChange(Gr,i),s}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(r),o=super.insertAt(t,...s);return this._onAfterObjectsChange(Gr,s),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(ys,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const r=this[t];return super._set(t,e),t==="canvas"&&r!==e&&(this._objects||[]).forEach(i=>{i._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:r}=e;const i=this._activeObjects;if(t)i.push(r),this._set("dirty",!0);else if(i.length>0){const s=i.indexOf(r);s>-1&&(i.splice(s,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Rr(t,ht(Rt(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||(Rr(t,ht(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=ut.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,r){this._renderBackground(t);for(let s=0;s<this._objects.length;s++){var i;const o=this._objects[s];(i=this.canvas)!==null&&i!==void 0&&i.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Rt(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,r)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(v({target:this,type:Nr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(i){return!i.excludeFromExport}).map(function(i){const s=i.includeDefaultValues;i.includeDefaultValues=r;const o=i[t||"toObject"](e);return i.includeDefaultValues=s,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return v(v(v({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=Tt.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const i=e.join("");return t?t(i):i}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
120
|
-
`],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let
|
|
121
|
-
`),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let i=0;i<this._objects.length;i++)e.push(" ",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:r,objects:i=[],layoutManager:s}=t,o=J(t,dh);return Promise.all([sr(i,e),Fr(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,v(v(v({},o),c),{},{layoutManager:new gh}));if(s){const u=E.getClass(s.type),d=E.getClass(s.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new fr;return h.layoutManager.subscribeTargets({type:ne,target:h,targets:h.getObjects()}),h.setCoords(),h})}}p(ye,"type","Group"),p(ye,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),E.setClass(ye);const fh=(n,t)=>Math.min(t.width/n.width,t.height/n.height),ph=(n,t)=>Math.max(t.width/n.width,t.height/n.height),xs="\\s*,?\\s*",pr="".concat(xs,"(").concat(Ht,")"),mh="".concat(pr).concat(pr).concat(pr).concat(xs,"([01])").concat(xs,"([01])").concat(pr).concat(pr),vh={m:"l",M:"L"},bh=(n,t,e,r,i,s,o,a,l,c,h)=>{const u=Zt(n),d=Jt(n),g=Zt(t),f=Jt(t),m=e*i*g-r*s*f+o,b=r*i*g+e*s*f+a;return["C",c+l*(-e*i*d-r*s*u),h+l*(-r*i*d+e*s*u),m+l*(e*i*f+r*s*g),b+l*(r*i*f-e*s*g),m,b]},Io=(n,t,e,r)=>{const i=Math.atan2(t,n),s=Math.atan2(r,e);return s>=i?s-i:2*Math.PI-(i-s)};function Ho(n,t,e,r,i,s,o,a){let l;if(X.cachesBoundsOfCurve&&(l=[...arguments].join(),tr.boundsOfCurveCache[l]))return tr.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*n-12*e+6*i,f=-3*n+9*e-9*i+3*o,m=3*e-3*n;for(let k=0;k<2;++k){if(k>0&&(g=6*t-12*r+6*s,f=-3*t+9*r-9*s+3*a,m=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const L=-m/g;0<L&&L<1&&u.push(L);continue}const S=g*g-4*m*f;if(S<0)continue;const C=c(S),A=(-g+C)/(2*f);0<A&&A<1&&u.push(A);const D=(-g-C)/(2*f);0<D&&D<1&&u.push(D)}let b=u.length;const y=b,w=zo(n,t,e,r,i,s,o,a);for(;b--;){const{x:k,y:S}=w(u[b]);d[0][b]=k,d[1][b]=S}d[0][y]=n,d[1][y]=t,d[0][y+1]=o,d[1][y+1]=a;const O=[new x(Math.min(...d[0]),Math.min(...d[1])),new x(Math.max(...d[0]),Math.max(...d[1]))];return X.cachesBoundsOfCurve&&(tr.boundsOfCurveCache[l]=O),O}const yh=(n,t,e)=>{let[r,i,s,o,a,l,c,h]=e;const u=((d,g,f,m,b,y,w)=>{if(f===0||m===0)return[];let O=0,k=0,S=0;const C=Math.PI,A=w*Vi,D=Jt(A),L=Zt(A),R=.5*(-L*d-D*g),H=.5*(-L*g+D*d),I=f**2,M=m**2,j=H**2,z=R**2,V=I*M-I*j-M*z;let tt=Math.abs(f),N=Math.abs(m);if(V<0){const dt=Math.sqrt(1-V/(I*M));tt*=dt,N*=dt}else S=(b===y?-1:1)*Math.sqrt(V/(I*j+M*z));const Ct=S*tt*H/N,Mt=-S*N*R/tt,ct=L*Ct-D*Mt+.5*d,T=D*Ct+L*Mt+.5*g;let F=Io(1,0,(R-Ct)/tt,(H-Mt)/N),P=Io((R-Ct)/tt,(H-Mt)/N,(-R-Ct)/tt,(-H-Mt)/N);y===0&&P>0?P-=2*C:y===1&&P<0&&(P+=2*C);const B=Math.ceil(Math.abs(P/C*2)),$=[],q=P/B,mt=8/3*Math.sin(q/4)*Math.sin(q/4)/Math.sin(q/2);let le=F+q;for(let dt=0;dt<B;dt++)$[dt]=bh(F,le,L,D,tt,N,ct,T,mt,O,k),O=$[dt][5],k=$[dt][6],F=le,le+=q;return $})(c-n,h-t,i,s,a,l,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},_h=n=>{let t=0,e=0,r=0,i=0;const s=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],r=h[1],i=h[2],u=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],u=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],u=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":yh(t,e,h).forEach(d=>s.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=r,e=i,u=["Z"]}u?(s.push(u),o=u[0]):o=""}return s},qr=(n,t,e,r)=>Math.sqrt((e-n)**2+(r-t)**2),zo=(n,t,e,r,i,s,o,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),u=(g=>3*g*(1-g)**2)(l),d=(g=>(1-g)**3)(l);return new x(o*c+i*h+e*u+n*d,a*c+s*h+r*u+t*d)},Wo=n=>n**2,Vo=n=>2*n*(1-n),Xo=n=>(1-n)**2,xh=(n,t,e,r,i,s,o,a)=>l=>{const c=Wo(l),h=Vo(l),u=Xo(l),d=3*(u*(e-n)+h*(i-e)+c*(o-i)),g=3*(u*(r-t)+h*(s-r)+c*(a-s));return Math.atan2(g,d)},wh=(n,t,e,r,i,s)=>o=>{const a=Wo(o),l=Vo(o),c=Xo(o);return new x(i*a+e*l+n*c,s*a+r*l+t*c)},Ch=(n,t,e,r,i,s)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(i-e)),c=2*(a*(r-t)+o*(s-r));return Math.atan2(c,l)},Yo=(n,t,e)=>{let r=new x(t,e),i=0;for(let s=1;s<=100;s+=1){const o=n(s/100);i+=qr(r.x,r.y,o.x,o.y),r=o}return i},Sh=(n,t)=>{let e,r=0,i=0,s={x:n.x,y:n.y},o=v({},s),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;i<t&&a>1e-4;)o=c(r),l=r,e=qr(s.x,s.y,o.x,o.y),e+i>t?(r-=a,a/=2):(s=o,r+=a,i+=e);return v(v({},o),{},{angle:h(l)})},Uo=n=>{let t,e,r=0,i=0,s=0,o=0,a=0;const l=[];for(const c of n){const h={x:i,y:s,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=i=c[1],e.y=a=s=c[2];break;case"L":e=h,e.length=qr(i,s,c[1],c[2]),i=c[1],s=c[2];break;case"C":t=zo(i,s,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=xh(i,s,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Yo(t,i,s),i=c[5],s=c[6];break;case"Q":t=wh(i,s,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ch(i,s,c[1],c[2],c[3],c[4]),e.length=Yo(t,i,s),i=c[3],s=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=qr(i,s,o,a),i=o,s=a}r+=e.length,l.push(e)}return l.push({length:r,x:i,y:s}),l},Th=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Uo(n),r=0;for(;t-e[r].length>0&&r<e.length-2;)t-=e[r].length,r++;const i=e[r],s=t/i.length,o=n[r];switch(i.command){case"M":return{x:i.x,y:i.y,angle:0};case"Z":return v(v({},new x(i.x,i.y).lerp(new x(i.destX,i.destY),s)),{},{angle:Math.atan2(i.destY-i.y,i.destX-i.x)});case"L":return v(v({},new x(i.x,i.y).lerp(new x(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-i.y,o[1]-i.x)});case"C":case"Q":return Sh(i,t)}},kh=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Go=new RegExp(mh,"g"),Oh=new RegExp(Ht,"gi"),Dh={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Mh=n=>{var t;const e=[],r=(t=n.match(kh))!==null&&t!==void 0?t:[];for(const i of r){const s=i[0];if(s==="z"||s==="Z"){e.push([s]);continue}const o=Dh[s.toLowerCase()];let a=[];if(s==="a"||s==="A"){Go.lastIndex=0;for(let l=null;l=Go.exec(i);)a.push(...l.slice(1))}else a=i.match(Oh)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=vh[s];c[0]=l>0&&h?h:s;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},Eh=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new x(n[0]),r=new x(n[1]),i=1,s=0;const o=[],a=n.length,l=a>2;let c;for(l&&(i=n[2].x<r.x?-1:n[2].x===r.x?0:1,s=n[2].y<r.y?-1:n[2].y===r.y?0:1),o.push(["M",e.x-i*t,e.y-s*t]),c=1;c<a;c++){if(!e.eq(r)){const h=e.midPointFrom(r);o.push(["Q",e.x,e.y,h.x,h.y])}e=n[c],c+1<n.length&&(r=n[c+1])}return l&&(i=e.x>n[c-2].x?1:e.x===n[c-2].x?0:-1,s=e.y>n[c-2].y?1:e.y===n[c-2].y?0:-1),o.push(["L",e.x+i*t,e.y+s*t]),o},No=(n,t)=>n.map(e=>e.map((r,i)=>i===0||t===void 0?r:Z(r,t)).join(" ")).join(" ");function ws(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(r=>{let[i,s]=r;return e.setProperty(i,s)}))}class Ph extends Vn{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),p(this,"upper",void 0),p(this,"container",void 0);const{el:i}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(r),i.parentNode&&i.parentNode.replaceChild(o,i),o.append(i,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Qt();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=ke().createElement("div");return t.setAttribute("data-fabric","wrapper"),ws(t,{position:"relative"}),Wn(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:i}=e;ws(t,v(v({},r),{},{"touch-action":i?"manipulation":bt})),Wn(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:i}=this.upper;zn(r,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Ji(this.upper.el,t),Ji(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),Gt().dispose(this.upper.el),delete this.upper,delete this.container}}class Kr extends or{constructor(){super(...arguments),p(this,"targets",[]),p(this,"_hoveredTargets",[]),p(this,"_currentTransform",null),p(this,"_groupSelector",null),p(this,"contextTopDirty",!1)}static getDefaults(){return v(v({},super.getDefaults()),Kr.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Ph(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const i=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+i,-r+i),s.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=o,s.restore();const a=Math.round(i*this.getRetinaScaling());return Fc(s,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(r=>!!r&&t[r]===!0):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&r.length>1&&r.indexOf(e)===-1&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let i;return e===Or||e===yt||e===Pt||e===rr?i=this.centeredScaling||t.centeredScaling:e===Gi&&(i=this.centeredRotation||t.centeredRotation),i?!r:r}_getOriginFromCorner(t,e){const r={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=it:["mr","tr","br"].includes(e)&&(r.x=U),["tl","mt","tr"].includes(e)?r.y=Yi:["bl","mb","br"].includes(e)&&(r.y=vt)),r}_setupCurrentTransform(t,e,r){var i;const s=e.group?je(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=r&&a?(i=a.getActionHandler(t,e,a))===null||i===void 0?void 0:i.bind(a):Zl,c=((g,f,m,b)=>{if(!f||!g)return"drag";const y=b.controls[f];return y.getActionName(m,y,b)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:W,y:W}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:s.x-e.left,offsetY:s.y-e.top,originX:u.x,originY:u.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:st(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:v(v({},Yn(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:i,deltaY:s}=this._groupSelector,o=new x(e,r).transform(this.viewportTransform),a=new x(e+i,r+s).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,ut.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),r=this._activeObject,i=this.getActiveObjects();if(this.targets=[],r&&i.length>=1){if(r.findControl(e,Qi(t))||i.length>1&&this.searchPossibleTargets([r],e))return r;if(r===this.searchPossibleTargets([r],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==r?(this.targets=s,r):o}return r}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const i=this.getZoom(),s=t.padding/i;if(s){const[o,a,l,c]=r,h=Math.atan2(a.y-o.y,a.x-o.x),u=Zt(h)*s,d=Jt(h)*s,g=u+d,f=u-d;r=[new x(o.x-f,o.y-g),new x(a.x+g,a.y-f),new x(l.x+f,l.y+g),new x(c.x-g,c.y+f)]}return Q.isPointInPolygon(e,r)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,je(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let r=t.length;for(;r--;){const i=t[r];if(this._checkTarget(i,e)){if(Er(i)&&i.subTargetCheck){const s=this._searchPossibleTargets(i._objects,e);s&&this.targets.push(s)}return i}}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e);if(r&&Er(r)&&r.interactive&&this.targets[0]){const i=this.targets;for(let s=i.length-1;s>0;s--){const o=i[s];if(!Er(o)||!o.interactive)return o}return i[0]}return r}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,i=r.getBoundingClientRect();let s=Yl(t),o=i.width||0,a=i.height||0;o&&a||(vt in i&&Yi in i&&(a=Math.abs(i.top-i.bottom)),it in i&&U in i&&(o=Math.abs(i.right-i.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,e||(s=je(s,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(s.x/=l,s.y/=l);const c=o===0||a===0?new x(1,1):new x(r.width/o,r.height/a);return s.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Qt(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return ve(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,i=!1;const s=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{s.includes(l)||(r=!0,l.fire("deselected",{e,target:l}),a.push(l))}),s.forEach(l=>{t.includes(l)||(r=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&s.length>0?(i=!0,r&&this.fire("selection:updated",{e,selected:o,deselected:a})):s.length>0?(i=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(i=!0,this.fire("selection:cleared",{e,deselected:a})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){const r=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),i}_setActiveObject(t,e){const r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,ve(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),ve(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});const i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,r=e.target,i={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),r.fire(Dr,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ve(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,r){const i=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,r);return t.set(i),s}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&ve(e)&&this._activeObject===e){const r=Ae(t,["angle","flipX","flipY",U,yt,Pt,Oe,De,vt]);return Gl(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(i)}}p(Kr,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Ah{constructor(t){p(this,"targets",[]),p(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:i}=t.getActiveObject()||{};i&&i.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),Ee(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const jh=["target","oldTarget","fireCanvas","e"],kt={passive:!1},ze=(n,t)=>{const e=n.getViewportPoint(t),r=n.getScenePoint(t);return{viewportPoint:e,scenePoint:r,pointer:e,absolutePointer:r}},ge=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return n.addEventListener(...e)},Lt=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return n.removeEventListener(...e)},Lh={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class Cs extends Kr{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),p(this,"_isClick",void 0),p(this,"textEditingManager",new Ah(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(ge,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const r=this.upperCanvasEl,i=this._getEventPrefix();t(Hn(r),"resize",this._onResize),t(r,i+"down",this._onMouseDown),t(r,"".concat(i,"move"),this._onMouseMove,kt),t(r,"".concat(i,"out"),this._onMouseOut),t(r,"".concat(i,"enter"),this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),t(r,"click",this._onClick),t(r,"dblclick",this._onClick),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,kt)}removeListeners(){this.addOrRemove(Lt,"remove");const t=this._getEventPrefix(),e=Bt(this.upperCanvasEl);Lt(e,"".concat(t,"up"),this._onMouseUp),Lt(e,"touchend",this._onTouchEnd,kt),Lt(e,"".concat(t,"move"),this._onMouseMove,kt),Lt(e,"touchmove",this._onMouseMove,kt),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,r=v({e:t},ze(this,t));this.fire("mouse:out",v(v({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",v({},r)),this._hoveredTargets.forEach(i=>{this.fire("mouse:out",v(v({},r),{},{target:i})),i&&i.fire("mouseout",v({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",v({e:t},ze(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 ge(this.upperCanvasEl,"drag",this._onDragProgress)}Xn(t)}_renderDragEffects(t,e,r){let i=!1;const s=this._dropTarget;s&&s!==e&&s!==r&&(s.clearContextTop(),i=!0),e==null||e.clearContextTop(),r!==e&&(r==null||r.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),i=!0),r&&(o.save(),r.transform(o),r.renderDropTargetEffect(t),o.restore(),i=!0),o.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==bt,r=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};Lt(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",i),this._dragSource&&this._dragSource.fire("dragend",i),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:r,targets:i}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:r,subTargets:i,dragSource:s,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(r,o),r&&(r.canDrop(t)&&(a=r),r.fire(e,o));for(let l=0;l<i.length;l++){const c=i[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,s,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:r}=this.findDragTargets(t),i={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(e,i)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:r}=this.findDragTargets(t),i=this._basicEventHandler("drop:before",v({e:t,target:e,subTargets:r,dragSource:this._dragSource},ze(this,t)));i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){const e=this.findTarget(t),r=this.targets||[],i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&Xn(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const r=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||r&&this._target===r)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const i=this.upperCanvasEl,s=this._getEventPrefix(),o=Bt(i);ge(o,"touchend",this._onTouchEnd,kt),e&&ge(o,"touchmove",this._onMouseMove,kt),Lt(i,"".concat(s,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();Lt(e,"".concat(r,"move"),this._onMouseMove,kt);const i=Bt(e);ge(i,"".concat(r,"up"),this._onMouseUp),ge(i,"".concat(r,"move"),this._onMouseMove,kt)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=Bt(this.upperCanvasEl);Lt(r,"touchend",this._onTouchEnd,kt),Lt(r,"touchmove",this._onMouseMove,kt),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ge(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const i=Bt(this.upperCanvasEl);Lt(i,"".concat(r,"up"),this._onMouseUp),Lt(i,"".concat(r,"move"),this._onMouseMove,kt),ge(e,"".concat(r,"move"),this._onMouseMove,kt)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const r=this._currentTransform,i=this._isClick,s=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(r&&(this._finalizeCurrentTransform(t),c=r.actionPerformed),!i){const h=s===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){const h=s.findControl(this.getViewportPoint(t),Qi(t)),{key:u,control:d}=h||{};if(l=u,s.selectable&&s!==this._activeObject&&s.activeOn==="up")this.setActiveObject(s,t),c=!0;else if(d){const g=d.getMouseUpHandler(t,s,d);g&&(a=this.getScenePoint(t),g.call(d,t,r,a.x,a.y))}s.isMoving=!1}if(r&&(r.target!==s||r.corner!==l)){const h=r.target&&r.target.controls[r.corner],u=h&&h.getMouseUpHandler(t,r.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,r,a.x,a.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),c?this.requestRenderAll():i||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:r,subTargets:i=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let s=0;s<i.length;s++)i[s]!==r&&i[s].fire(t,e);return e}_handleEvent(t,e,r){const i=this._target,s=this.targets||[],o=v(v(v({e:t,target:i,subTargets:s},ze(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?r:{});this.fire("mouse:".concat(e),o),i&&i.fire("mouse".concat(e),o);for(let a=0;a<s.length;a++)s[a]!==i&&s[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,r=!!e&&e===this._activeObject;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down",{alreadySelected:r}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let s=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(r=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),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)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:r}),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=je(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const r=this.findTarget(t);this._setCursorFromEvent(t,r),this._fireOverOutEvents(t,r)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const r=this._hoveredTarget,i=this._hoveredTargets,s=this.targets,o=Math.max(i.length,s.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let a=0;a<o;a++)s[a]===e||i[a]&&i[a]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:s[a],oldTarget:i[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const r=this._draggedoverTarget,i=this._hoveredTargets,s=this.targets,o=Math.max(i.length,s.length);this.fireSyntheticInOutEvents("drag",v(v({},e),{},{target:t,oldTarget:r,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",v(v({},e),{},{target:s[a],oldTarget:i[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:i,fireCanvas:s,e:o}=e,a=J(e,jh);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Lh[t],d=i!==r;if(i&&d){const g=v(v({},a),{},{e:o,target:i,nextTarget:r},ze(this,o));s&&this.fire(u,g),i.fire(c,g)}if(r&&d){const g=v(v({},a),{},{e:o,target:r,previousTarget:i},ze(this,o));s&&this.fire(h,g),r.fire(l,g)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,i=r.target,s=i.group?je(e,void 0,i.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,s),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:i,actionHandler:s,target:o}=e,a=!!s&&s(t,e,r.x,r.y);a&&o.setCoords(),i==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let r=e.hoverCursor||this.hoverCursor;const i=ve(this._activeObject)?this._activeObject:null,s=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(s){const o=s.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(o=>{r=o.hoverCursor||r}),this.setCursor(r)}handleMultiSelection(t,e){const r=this._activeObject,i=ve(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||i)&&(i||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(i){const s=r.getObjects();if(e===r){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],r.size()===1&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(s,t)}else{r.isEditing&&r.exitEditing();const s=new(E.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(r,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:i,deltaY:s}=this._groupSelector,o=new x(e,r),a=o.add(new x(i,s)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=E.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:r}=this.elements;r.ctx=void 0;const i=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),i}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const $o={x1:0,y1:0,x2:0,y2:0},Fh=v(v({},$o),{},{r1:0,r2:0}),We=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function qo(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function Ko(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(qo(n)?100:1):NaN;return Fe(0,We(e,t),1)}const Rh=/\s*;\s*/,Bh=/\s*:\s*/;function Ih(n,t){let e,r;const i=n.getAttribute("style");if(i){const o=i.split(Rh);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Bh).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}const s=new G(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Ko(n.getAttribute("offset"),0),color:s.toRgb(),opacity:We(parseFloat(r||n.getAttribute("stop-opacity")||""),1)*s.getAlpha()*t}}function Hh(n,t){const e=[],r=n.getElementsByTagName("stop"),i=Ko(t,1);for(let s=r.length;s--;)e.push(Ih(r[s],i));return e}function Zo(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Jo(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Wt(n,t){return n.getAttribute(t)}function zh(n,t){return function(e,r){let i,{width:s,height:o,gradientUnits:a}=r;return Object.entries(e).reduce((l,c)=>{let[h,u]=c;if(u==="Infinity")i=1;else if(u==="-Infinity")i=0;else{const d=typeof u=="string";i=d?parseFloat(u):u,d&&qo(u)&&(i*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(i*=s),h!=="y1"&&h!=="y2"||(i*=o)))}return l[h]=i,l},{})}(Zo(n)==="linear"?function(e){return{x1:Wt(e,"x1")||0,y1:Wt(e,"y1")||0,x2:Wt(e,"x2")||"100%",y2:Wt(e,"y2")||0}}(n):function(e){return{x1:Wt(e,"fx")||Wt(e,"cx")||"50%",y1:Wt(e,"fy")||Wt(e,"cy")||"50%",r1:0,x2:Wt(e,"cx")||"50%",y2:Wt(e,"cy")||"50%",r2:Wt(e,"r")||"50%"}}(n),v(v({},t),{},{gradientUnits:Jo(n)}))}class Zr{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:i={},colorStops:s=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:v(v({},e==="radial"?Fh:$o),i),colorStops:s,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(ue()):ue()})}addColorStop(t){for(const e in t){const r=new G(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return v(v({},Ae(this,t)),{},{type:this.type,coords:v({},this.coords),colorStops:this.colorStops.map(e=>v({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=[],i=this.gradientTransform?this.gradientTransform.concat():gt.concat(),s=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>v({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;s==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),i[4]-=a,i[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(s,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(nr(i),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:g,y2:f}=this.coords;r.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',g,'" y2="',f,`">
|
|
122
|
-
`)}else if(this.type==="radial"){const{x1:
|
|
123
|
-
`),
|
|
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=ne.ownDefaults;return this.includeDefaultValues?t:Ui(t,(r,s)=>r!==e[s])}static async fromObject(t){return new this(t)}}v(ne,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ne,"type","shadow"),j.setClass(ne,"shadow");const or=(i,t,e)=>Math.max(i,Math.min(t,e)),bu=[Et,Q,At,Vt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Je,Qe],me=[_t,Rt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],wu={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},xu=(i,t,e,r)=>-e*Math.cos(i/r*Er)+e+t,_u=()=>!1;class nn{constructor(t){let{startValue:e,byValue:r,duration:s=500,delay:n=0,easing:o=xu,onStart:a=xs,onChange:l=xs,onComplete:c=xs,abort:h=_u,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(()=>Ds(t),this.delay):Ds(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),Ds(this.tick)))}register(){Ts.push(this)}unregister(){Ts.remove(this)}abort(){this._state="aborted",this.unregister()}}class Cu extends nn{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 Su extends nn{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 ku=(i,t,e,r)=>t+e*(1-Math.cos(i/r*Er)),on=i=>i&&((t,e,r)=>i(new rt(t).toRgba(),e,r));class Tu extends nn{constructor(t){let{startValue:e,endValue:r,easing:s=ku,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:on(n),onComplete:on(o),abort:on(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),or(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 Ra(i){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(i)?new Su(i):new Cu(i);return t.start(),t}function Ou(i){const t=new Tu(i);return t.start(),t}class ct{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=js(e,r),o=js(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 x(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 ct("Intersection").append(new x(t.x+y*a,t.y+y*l)):new ct}if(g===0||f===0){const y=n||o||ct.isPointContained(t,r,s)||ct.isPointContained(e,r,s)||ct.isPointContained(r,t,e)||ct.isPointContained(s,t,e);return new ct(y?"Coincident":void 0)}return new ct("Parallel")}static intersectSegmentLine(t,e,r,s){return ct.intersectLineLine(t,e,r,s,!1,!0)}static intersectSegmentSegment(t,e,r,s){return ct.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 ct,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=ct.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 ct.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new ct,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ct.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 ct("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 x(n.x,s.y),a=new x(s.x,n.y);return ct.intersectPolygonPolygon(t,[s,o,n,a])}}class Du extends ea{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?Lt(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=Lt(t,Ut(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map(a=>Lt(a,o))}return n}intersectsWithRect(t,e){return ct.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ct.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 ct.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 pe(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(At,t),this._set(Vt,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?Te(ia(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Tt.concat()}calcACoords(){const t=rr({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),s=Ar(e,r),n=Ct(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Lt({x:-a,y:-l},n),tr:Lt({x:a,y:-l},n),bl:Lt({x:-a,y:l},n),br:Lt({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=eu(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e={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 x(o*e.scaleX,a*e.scaleY):Ki(o,a,Es(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 x(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(pt(this.angle),t):s}translateToOriginPoint(t,e,r){const s=this.translateToGivenOrigin(t,Y,Y,e,r);return this.angle?s.rotate(pt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Lt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(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,Et)}positionByLeftTop(t){return this.setPositionByOrigin(t,Q,Et)}}let ve=class vi extends Du{static getDefaults(){return vi.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Ce("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,vi.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=fe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,s=tt.maxCacheSideLimit,n=tt.minCacheSideLimit;if(e<=s&&r<=s&&e*r<=tt.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;const o=e/r,[a,l]=Mr.limitDimsByArea(o),c=or(n,a,s),h=or(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 x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Ms(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==At&&t!==Vt||(e=this._constrainScale(e)),t===At&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ne||(e=new ne(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===Rt&&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=Wt(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=Ut(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)||Tt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tt.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===Rt?(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=Wt({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 x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(j.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=ma(this),r=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?Ko():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(w=>new Ir(w,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&lu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&hu(this,this.getViewportTransform()),this.setCoords();const c=fe(),h=this.getBoundingRect(),u=this.shadow,d=new x;if(u){const w=u.blur,T=u.nonScaling?new x(1,1):this.getObjectScaling();d.x=2*Math.round(n(u.offsetX)+w)*n(T.x),d.y=2*Math.round(n(u.offsetY)+w)*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 x(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 ra(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return sa(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(){Ts.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&se().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?Ou(h):Ra(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let 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(vi.customProperties,this.constructor.customProperties||[]);let e;const r=tt.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:w,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:K,skewY:Z}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const L=mt=>nt(mt,r),wt={...sr(this,t),type:this.constructor.type,version:ji,originX:u,originY:d,left:L(c),top:L(h),width:L(g),height:L(f),fill:la(n)?n.toObject():n,stroke:la(o)?o.toObject():o,strokeWidth:L(m),strokeDashArray:l&&l.concat(),strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:w,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(K),skewY:L(Z),...e?{clipPath:e}:null};return this.includeDefaultValues?wt:this._removeDefaultValues(wt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Ui(t,(s,n)=>{if(n===Q||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`#<${this.constructor.type}>`}static _fromObject(t){let{type:e,...r}=t,{extraParam:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return As(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(ve,"stateProperties",bu),v(ve,"cacheProperties",me),v(ve,"ownDefaults",wu),v(ve,"type","FabricObject"),v(ve,"colorProperties",[_t,Rt,"backgroundColor"]),v(ve,"customProperties",[]),j.setClass(ve),j.setClass(ve,"object");const $a=(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)},ar=(i,t,e)=>(r,s,n,o)=>{const a=t(r,s,n,o);return a&&$a(i,{...Sa(r,s,n,o),...e}),a};function lr(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 Mu=(i,t,e,r)=>(s,n,o,a)=>{const l=tn(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=_a(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},Eu=Mu("width","originX","x","scaleX"),za=ar(Pr,lr(Eu));function Pu(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,Ze,!1),i[l](),n&&i.stroke(),i.restore()}function Au(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 qt{constructor(t){v(this,"visible",!0),v(this,"actionName",Ss),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 x(.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)&&ct.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 x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,s,n,o){const a=Xi([Ar(r,s),rr({angle:t}),Yi((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}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?Rt:_t,m=c||s.cornerStrokeColor,y=!g&&!!m;return t.fillStyle=a||s.cornerColor||"",t.strokeStyle=m||"",t.translate(e,r),t.rotate(pt(s.getTotalAngle())),{stroke:y,xSize:u,ySize:d,transparentCorners:g,opName:f}}render(t,e,r,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Pu.call(this,t,e,r,s,n):Au.call(this,t,e,r,s,n)}}const Lu=(i,t,e)=>e.lockRotation?Is:t.cursorStyle,Fu=ar(Jo,lr((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(Nt(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=Te(d-u+a);if(s.snapAngle&&s.snapAngle>0){const m=s.snapAngle,y=s.snapThreshold||m,b=Math.ceil(g/m)*m,w=Math.floor(g/m)*m;Math.abs(g-w)<y?g=w: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 Ha(i,t){const e=t.canvas,r=i[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function Va(i,t,e){const r=Nt(i,"lockScalingX"),s=Nt(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 ju=["e","se","s","sw","w","nw","n","ne","e"],Hr=(i,t,e,r)=>{const s=Ha(i,e);if(Va(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return Is;const n=ka(e,0,r);return`${ju[n]}-resize`};function an(i,t,e,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=Ha(i,n);let l,c,h,u,d,g;if(Va(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=tn(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),Nt(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,w=y/(Math.abs(u.x*b.scaleX/n.scaleX)+Math.abs(u.y*b.scaleY/n.scaleY));c=b.scaleX*w,h=b.scaleY*w}else c=Math.abs(l.x*n.scaleX/u.x),h=Math.abs(l.y*n.scaleY/u.y);_a(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Ca(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=Ca(t.originY),h*=-1,t.signY=g)}const f=n.scaleX,m=n.scaleY;return o?(o==="x"&&n.set(At,c),o==="y"&&n.set(Vt,h)):(!Nt(n,"lockScalingX")&&n.set(At,c),!Nt(n,"lockScalingY")&&n.set(Vt,h)),f!==n.scaleX||m!==n.scaleY}const Hs=ar(_s,lr((i,t,e,r)=>an(i,t,e,r))),Iu=ar(_s,lr((i,t,e,r)=>an(i,t,e,r,{by:"x"}))),Bu=ar(_s,lr((i,t,e,r)=>an(i,t,e,r,{by:"y"}))),ln={x:{counterAxis:"y",scale:At,skew:Je,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Vt,skew:Qe,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Ru=["ns","nesw","ew","nwse"],$u=(i,t,e,r)=>{if(t.x!==0&&Nt(e,"lockSkewingY")||t.y!==0&&Nt(e,"lockSkewingX"))return Is;const s=ka(e,0,r)%4;return`${Ru[s]}-resize`};function Wa(i,t,e,r,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=ln[i];if(Nt(n,l))return!1;const{origin:u,flip:d}=ln[o],g=Ot(e[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[h]?-1:1),m=.5*-((n[c]===0&&tn(e,Y,Y,r,s)[i]>0||n[c]>0?1:-1)*f)+.5;return ar(Qo,lr((b,w,T,C)=>function(S,D,A){let{target:_,ex:M,ey:O,skewingSide:V,...z}=D;const{skew:X}=ln[S],W=A.subtract(new x(M,O)).divide(new x(_.scaleX,_.scaleY))[S],G=_[X],K=z[X],Z=Math.tan(pt(K)),L=S==="y"?_._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:_._getTransformedDimensions({scaleX:1,scaleY:1}).y,wt=2*W*V/Math.max(L,1)+Z,mt=Te(Math.atan(wt));_.set(X,mt);const lt=G!==_[X];if(lt&&S==="y"){const{skewX:k,scaleX:P}=_,E=_._getTransformedDimensions({skewY:G}),B=_._getTransformedDimensions(),I=k!==0?E.x/B.x:1;I!==1&&_.set(At,I*P)}return lt}(i,w,new x(T,C))))(t,{...e,[a]:m,skewingSide:f},r,s)}const zu=(i,t,e,r)=>Wa("x",i,t,e,r),Hu=(i,t,e,r)=>Wa("y",i,t,e,r);function Vs(i,t){return i[t.canvas.altActionKey]}const Ws=(i,t,e)=>{const r=Vs(i,e);return t.x===0?r?Je:Vt:t.y===0?r?Qe:At:""},cr=(i,t,e,r)=>Vs(i,e)?$u(0,t,e,r):Hr(i,t,e,r),Xa=(i,t,e,r)=>Vs(i,t.target)?Hu(i,t,e,r):Iu(i,t,e,r),Ya=(i,t,e,r)=>Vs(i,t.target)?zu(i,t,e,r):Bu(i,t,e,r),Ua=()=>({ml:new qt({x:-.5,y:0,cursorStyleHandler:cr,actionHandler:Xa,getActionName:Ws}),mr:new qt({x:.5,y:0,cursorStyleHandler:cr,actionHandler:Xa,getActionName:Ws}),mb:new qt({x:0,y:.5,cursorStyleHandler:cr,actionHandler:Ya,getActionName:Ws}),mt:new qt({x:0,y:-.5,cursorStyleHandler:cr,actionHandler:Ya,getActionName:Ws}),tl:new qt({x:-.5,y:-.5,cursorStyleHandler:Hr,actionHandler:Hs}),tr:new qt({x:.5,y:-.5,cursorStyleHandler:Hr,actionHandler:Hs}),bl:new qt({x:-.5,y:.5,cursorStyleHandler:Hr,actionHandler:Hs}),br:new qt({x:.5,y:.5,cursorStyleHandler:Hr,actionHandler:Hs}),mtr:new qt({x:0,y:-.5,actionHandler:Fu,cursorStyleHandler:Lu,offsetY:-40,withConnection:!0,actionName:zi})}),Vu=()=>({mr:new qt({x:.5,y:0,actionHandler:za,cursorStyleHandler:cr,actionName:Pr}),ml:new qt({x:-.5,y:0,actionHandler:za,cursorStyleHandler:cr,actionName:Pr})}),Wu=()=>({...Ua(),...Vu()});class Vr extends ve{static getDefaults(){return{...super.getDefaults(),...Vr.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Vr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ua()}}_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(Ss))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=Ar(e.x,e.y),s=rr({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?Ms(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={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=Ms(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=Ki(this.width,this.height,Es(e)),o=this.isStrokeAccountedForInDimensions()?Wi:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(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 Ga(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(Vr,"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 ut extends Vr{}Ga(ut,[Ea]),j.setClass(ut),j.setClass(ut,"object");const Xu=(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 Na{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const r=js(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(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 Yu=new x;class hr extends Na{static getOrthogonalRotationFactor(t,e){const r=e?Ji(t,e):ba(t);return Math.abs(r)<Er?-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 x(t),this.B=new x(e),this.C=new x(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Ji(this.AB,this.AC),this.bisector=Qi(ya(this.AB.eq(Yu)?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=wa(s),o=hr.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*o)}projectBevel(){const t=[];return(this.alpha%Ze===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 x(hr.getOrthogonalRotationFactor(this.bisector),hr.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(n=>{xa(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 x(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 x(Math.sqrt(Math.max(h**2-u**2,0)),u),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(m=>this.applySkew(l?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{xa(m,t,e)&&r.push(this.applySkew(this.A).add(m))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Ze===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=Br(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 qa extends Na{constructor(t,e,r){super(r),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(wa(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 x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new hr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(Qi(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 Uu=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 x(o)),n),[new x(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 qa(n,n,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new hr(n,l,c,t).project()):r.push(...new qa(n,o===0?c:l,t).project())}),r},cn=i=>{const t={};return Object.keys(i).forEach(e=>{t[e]={},Object.keys(i[e]).forEach(r=>{t[e][r]={...i[e][r]}})}),t},hn=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)},Gu=(i,t)=>{const e=t.split(`
|
|
73
|
+
`),r=[];let s=-1,n={};i=cn(i);for(let o=0;o<e.length;o++){const a=Ni(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&&(hn(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},Nu=(i,t)=>{if(!Array.isArray(i))return cn(i);const e=t.split($i),r={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Ni(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},Oe=["display","transform",_t,"fill-opacity","fill-rule","opacity",Rt,"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 Ka(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 qu(i,t){let e=!0;const r=Ka(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=Ka(s=s.parentElement,o);return n.length===0}(i,t)),r&&e&&t.length===0}function Ku(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e={};for(const r in t)qu(i,r.split(" "))&&(e={...e,...t[r]});return e}const Zu=i=>{var t;return(t=yu[i])!==null&&t!==void 0?t:i},Ju=new RegExp(`(${Re})`,"gi"),Dt=`(${Re})`,Qu=String.raw`(skewX)\(${Dt}\)`,td=String.raw`(skewY)\(${Dt}\)`,ed=String.raw`(rotate)\(${Dt}(?: ${Dt} ${Dt})?\)`,rd=String.raw`(scale)\(${Dt}(?: ${Dt})?\)`,sd=String.raw`(translate)\(${Dt}(?: ${Dt})?\)`,un=`(?:${String.raw`(matrix)\(${Dt} ${Dt} ${Dt} ${Dt} ${Dt} ${Dt}\)`}|${sd}|${ed}|${rd}|${Qu}|${td})`,id=`(?:${un}*)`,nd=String.raw`^\s*(?:${id}?)\s*$`,od=new RegExp(nd),ad=new RegExp(un),ld=new RegExp(un,"g");function dn(i){const t=[];if(!(i=(e=>Bs(e.replace(Ju," $1 ").replace(/,/gi," ")))(i).replace(/\s*([()])\s*/gi,"$1"))||i&&!od.test(i))return[...Tt];for(const e of i.matchAll(ld)){const r=ad.exec(e[0]);if(!r)continue;let s=Tt;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=Ar(l,c);break;case zi:s=rr({angle:l},{x:c,y:h});break;case Ss:s=Yi(l,c);break;case Je:s=oa(l);break;case Qe:s=aa(l);break;case"matrix":s=[l,c,h,u,d,g]}t.push(s)}return Xi(t)}function cd(i,t,e,r){const s=Array.isArray(t);let n,o=t;if(i!==_t&&i!==Rt||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,dn(t)):dn(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"?Q:t==="end"?ft:Y;else if(i==="charSpacing"||i===Be)n=nr(t,r)/r*1e3;else if(i==="paintFirst"){const a=t.indexOf(_t),l=t.indexOf(Rt);o=_t,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=Rt)}else{if(i==="href"||i==="xlink:href"||i==="font"||i==="id")return t;if(i==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(nr):nr(t,r)}}else o="";return!s&&isNaN(n)?o:n}function hd(i,t){i.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,s]=e.split(":");t[r.trim().toLowerCase()]=s.trim()})}function ud(i){const t={},e=i.getAttribute("style");return e&&(typeof e=="string"?hd(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 dd={stroke:"strokeOpacity",fill:"fillOpacity"};function ye(i,t,e){if(!i)return{};let r,s={},n=Bi;i.parentNode&&ja.test(i.parentNode.nodeName)&&(s=ye(i.parentElement,t,e),s.fontSize&&(r=n=nr(s.fontSize)));const o={...t.reduce((c,h)=>{const u=i.getAttribute(h);return u&&(c[h]=u),c},{}),...Ku(i,e),...ud(i)};o[sn]&&i.setAttribute(sn,o[sn]),o[rn]&&(r=nr(o[rn],n),o[rn]=`${r}`);const a={};for(const c in o){const h=Zu(c),u=cd(h,o[c],s,r);a[h]=u}a&&a.font&&function(c,h){const u=c.match(vu);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=nr(f)),y&&(h.fontFamily=y),m&&(h.lineHeight=m===Hi?1:m)}(a.font,a);const l={...s,...a};return ja.test(i.nodeName)?l:function(c){const h=ut.getDefaults();return Object.entries(dd).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(nt(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const Za=["rx","ry"];class Ft extends ut{static getDefaults(){return{...super.getDefaults(),...Ft.ownDefaults}}constructor(t){super(),Object.assign(this,Ft.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([...Za,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:s}=this;return["<rect ","COMMON_PARTS",`x="${-t/2}" y="${-e/2}" rx="${q(r)}" ry="${q(s)}" width="${q(t)}" height="${q(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}=ye(t,this.ATTRIBUTE_NAMES,r);return new this({...e,...c,left:s,top:n,width:o,height:a,visible:!!(l&&o&&a)})}}v(Ft,"type","Rect"),v(Ft,"cacheProperties",[...me,...Za]),v(Ft,"ownDefaults",{rx:0,ry:0}),v(Ft,"ATTRIBUTE_NAMES",[...Oe,"x","y","rx","ry","width","height"]),j.setClass(Ft),j.setSVGClass(Ft);const be="initialization",Xs="added",gn="removed",Ys="imperative",Ja=(i,t)=>{const{strokeUniform:e,strokeWidth:r,width:s,height:n,group:o}=t,a=o&&o!==i?Fs(o.calcTransformMatrix(),i.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?cu(new x(r,r),void 0,i.calcTransformMatrix()):Wi,u=!e&&c?r:0,d=Ki(s+u,n+u,Xi([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Us{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:s}=t;return e===be||e===Ys||!!r&&s!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==be&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:s}=e;if(r===Ys&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=pe(t.map(u=>Ja(s,u)).reduce((u,d)=>u.concat(d),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(r===be){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(Us,"type","strategy");class fn extends Us{shouldPerformLayout(t){return!0}}v(fn,"type","fit-content"),j.setClass(fn);const Qa="layoutManager";class Wr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new fn;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[ks,Zo,Pr,Jo,_s,Qo,Cs,Nh,qh].map(s=>t.on(s,n=>this.performLayout(s===ks?{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===be||r===Xs?this.subscribeTargets(t):r===gn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),r===Ys&&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===be?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===be?Tt:Ut(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===be?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:Qa,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}j.setClass(Wr,Qa);class gd extends Wr{performLayout(){}}class De extends ta(ut){static getDefaults(){return{...super.getDefaults(),...De.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,De.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 Wr,this.layoutManager.performLayout({type:be,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Ce("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Ce("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(Xs,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(Xs,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(gn,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&&Ls(t,Ct(Ut(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||(Ls(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=ut.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(...Ut(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:Ys,...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=Ft.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
75
|
+
`],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
|
|
76
|
+
`),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?`opacity: ${q(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([Lr(s,e),As(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,{...o,...c,layoutManager:new gd});if(n){const u=j.getClass(n.type),d=j.getClass(n.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Wr;return h.layoutManager.subscribeTargets({type:be,target:h,targets:h.getObjects()}),h.setCoords(),h})}}v(De,"type","Group"),v(De,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),j.setClass(De);const fd=(i,t)=>Math.min(t.width/i.width,t.height/i.height),pd=(i,t)=>Math.max(t.width/i.width,t.height/i.height),pn="\\s*,?\\s*",Xr=`${pn}(${Re})`,md=`${Xr}${Xr}${Xr}${pn}([01])${pn}([01])${Xr}${Xr}`,vd={m:"l",M:"L"},yd=(i,t,e,r,s,n,o,a,l,c,h)=>{const u=de(i),d=ge(i),g=de(t),f=ge(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]},tl=(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 el(i,t,e,r,s,n,o,a){let l;if(tt.cachesBoundsOfCurve&&(l=[...arguments].join(),Mr.boundsOfCurveCache[l]))return Mr.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,w=rl(i,t,e,r,s,n,o,a);for(;y--;){const{x:C,y:S}=w(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 x(Math.min(...d[0]),Math.min(...d[1])),new x(Math.max(...d[0]),Math.max(...d[1]))];return tt.cachesBoundsOfCurve&&(Mr.boundsOfCurveCache[l]=T),T}const bd=(i,t,e)=>{let[r,s,n,o,a,l,c,h]=e;const u=((d,g,f,m,y,b,w)=>{if(f===0||m===0)return[];let T=0,C=0,S=0;const D=Math.PI,A=w*Ii,_=ge(A),M=de(A),O=.5*(-M*d-_*g),V=.5*(-M*g+_*d),z=f**2,X=m**2,W=V**2,G=O**2,K=z*X-z*W-X*G;let Z=Math.abs(f),L=Math.abs(m);if(K<0){const it=Math.sqrt(1-K/(z*X));Z*=it,L*=it}else S=(y===b?-1:1)*Math.sqrt(K/(z*W+X*G));const wt=S*Z*V/L,mt=-S*L*O/Z,lt=M*wt-_*mt+.5*d,k=_*wt+M*mt+.5*g;let P=tl(1,0,(O-wt)/Z,(V-mt)/L),E=tl((O-wt)/Z,(V-mt)/L,(-O-wt)/Z,(-V-mt)/L);b===0&&E>0?E-=2*D:b===1&&E<0&&(E+=2*D);const B=Math.ceil(Math.abs(E/D*2)),I=[],H=E/B,dt=8/3*Math.sin(H/4)*Math.sin(H/4)/Math.sin(H/2);let ht=P+H;for(let it=0;it<B;it++)I[it]=yd(P,ht,M,_,Z,L,lt,k,dt,T,C),T=I[it][5],C=I[it][6],P=ht,ht+=H;return I})(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},wd=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":bd(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},Gs=(i,t,e,r)=>Math.sqrt((e-i)**2+(r-t)**2),rl=(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 x(o*c+s*h+e*u+i*d,a*c+n*h+r*u+t*d)},sl=i=>i**2,il=i=>2*i*(1-i),nl=i=>(1-i)**2,xd=(i,t,e,r,s,n,o,a)=>l=>{const c=sl(l),h=il(l),u=nl(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)},_d=(i,t,e,r,s,n)=>o=>{const a=sl(o),l=il(o),c=nl(o);return new x(s*a+e*l+i*c,n*a+r*l+t*c)},Cd=(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)},ol=(i,t,e)=>{let r=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=i(n/100);s+=Gs(r.x,r.y,o.x,o.y),r=o}return s},Sd=(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=Gs(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=Gs(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=rl(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=xd(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=ol(t,s,n),s=c[5],n=c[6];break;case"Q":t=_d(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Cd(s,n,c[1],c[2],c[3],c[4]),e.length=ol(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Gs(s,n,o,a),s=o,n=a}r+=e.length,l.push(e)}return l.push({length:r,x:s,y:n}),l},kd=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 x(s.x,s.y).lerp(new x(s.destX,s.destY),n),angle:Math.atan2(s.destY-s.y,s.destX-s.x)};case"L":return{...new x(s.x,s.y).lerp(new x(o[1],o[2]),n),angle:Math.atan2(o[2]-s.y,o[1]-s.x)};case"C":case"Q":return Sd(s,t)}},Td=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),ll=new RegExp(md,"g"),Od=new RegExp(Re,"gi"),Dd={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Md=i=>{var t;const e=[],r=(t=i.match(Td))!==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=Dd[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){ll.lastIndex=0;for(let l=null;l=ll.exec(s);)a.push(...l.slice(1))}else a=s.match(Od)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=vd[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},Ed=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new x(i[0]),r=new x(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},cl=(i,t)=>i.map(e=>e.map((r,s)=>s===0||t===void 0?r:nt(r,t)).join(" ")).join(" ");function mn(i,t){const e=i.style;e&&Object.entries(t).forEach(r=>{let[s,n]=r;return e.setProperty(s,n)})}class Pd extends fa{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=fe();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=Ke().createElement("div");return t.setAttribute("data-fabric","wrapper"),mn(t,{position:"relative"}),ga(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:s}=e;mn(t,{...r,"touch-action":s?"manipulation":Pt}),ga(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:s}=this.upper;da(r,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Gi(this.upper.el,t),Gi(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(),se().dispose(this.upper.el),delete this.upper,delete this.container}}const Ad=(i,t,e,r)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=r-o,c=!Nt(s,"lockMovementX")&&s.left!==a,h=!Nt(s,"lockMovementY")&&s.top!==l;return c&&s.set(Q,a),h&&s.set(Et,l),(c||h)&&$a(Zo,Sa(i,t,e,r)),c||h};class Ns extends Ir{constructor(){super(...arguments),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...Ns.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 Pd(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 Xu(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===Ss||e===At||e===Vt||e===Pr?s=this.centeredScaling||t.centeredScaling:e===zi&&(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=ft:["mr","tr","br"].includes(e)&&(r.x=Q),["tl","mt","tr"].includes(e)?r.y=Ri:["bl","mb","br"].includes(e)&&(r.y=Et)),r}_setupCurrentTransform(t,e,r){var s;const n=e.group?ir(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):Ad,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:w,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:pt(w),width:T,height:C,shiftKey:t.shiftKey,altKey:h,original:{...ma(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 x(e,r).transform(this.viewportTransform),a=new x(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,ut.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),qi(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=de(h)*n,d=ge(h)*n,g=u+d,f=u-d;r=[new x(o.x-f,o.y-g),new x(a.x+g,a.y-f),new x(l.x+f,l.y+g),new x(c.x-g,c.y+f)]}return ct.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(Os(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&&Os(s)&&s.interactive&&n[0]){for(let o=n.length-1;o>0;o--){const a=n[o];if(!Os(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=ou(t),o=s.width||0,a=s.height||0;o&&a||(Et in s&&Ri in s&&(a=Math.abs(s.top-s.bottom)),ft 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=ir(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new x(1,1):new x(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=fe(),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(ks,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=sr(t,["angle","flipX","flipY",Q,At,Vt,Je,Qe,Et]);return au(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(s)}}v(Ns,"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 Ld{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),er(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 $t={passive:!1},$e=(i,t)=>({viewportPoint:i.getViewportPoint(t),scenePoint:i.getScenePoint(t)}),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 i.addEventListener(...e)},Yt=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)},Fd={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 vn extends Ns{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Ld(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(Me)}_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(ua(r),"resize",this._onResize),t(r,s+"down",this._onMouseDown),t(r,`${s}move`,this._onMouseMove,$t),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,$t)}removeListeners(){this.addOrRemove(Yt);const t=this._getEventPrefix(),e=Gt(this.upperCanvasEl);Yt(e,`${t}up`,this._onMouseUp),Yt(e,"touchend",this._onTouchEnd,$t),Yt(e,`${t}move`,this._onMouseMove,$t),Yt(e,"touchmove",this._onMouseMove,$t),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_onMouseOut(t){const e=this._hoveredTarget,r={e:t,...$e(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,...$e(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 Me(this.upperCanvasEl,"drag",this._onDragProgress)}pa(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!==Pt,s=r?this._activeObject:void 0,n={e:t,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:r,dropTarget:s};Yt(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,...$e(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&&pa(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,...$e(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=Gt(n);Me(a,"touchend",this._onTouchEnd,$t),e&&Me(a,"touchmove",this._onMouseMove,$t),Yt(n,`${o}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(t){this._cacheTransformEventData(t),this.__onMouseDown(t);const e=this.upperCanvasEl,r=this._getEventPrefix();Yt(e,`${r}move`,this._onMouseMove,$t);const s=Gt(e);Me(s,`${r}up`,this._onMouseUp),Me(s,`${r}move`,this._onMouseMove,$t),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=Gt(this.upperCanvasEl);Yt(r,"touchend",this._onTouchEnd,$t),Yt(r,"touchmove",this._onMouseMove,$t),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{Me(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=Gt(this.upperCanvasEl);Yt(s,`${r}up`,this._onMouseUp),Yt(s,`${r}move`,this._onMouseMove,$t),Me(e,`${r}move`,this._onMouseMove,$t)}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),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{target:s,subTargets:n}=this.findTarget(t),o={e:t,target:s,subTargets:n,...$e(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),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._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(t),this._scenePoint=ir(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}=Fd[t],d=s!==r;if(s&&d){const g={...a,e:o,target:s,nextTarget:r,...$e(this,o)};n&&this.fire(u,g),s.fire(c,g)}if(r&&d){const g={...a,e:o,target:r,previousTarget:s,...$e(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?ir(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{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=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();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(j.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 x(e,r),a=o.add(new x(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=j.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 hl={x1:0,y1:0,x2:0,y2:0},jd={...hl,r1:0,r2:0},ur=(i,t)=>isNaN(i)&&typeof t=="number"?t:i;function ul(i){return i&&/%$/.test(i)&&Number.isFinite(parseFloat(i))}function dl(i,t){const e=typeof i=="number"?i:typeof i=="string"?parseFloat(i)/(ul(i)?100:1):NaN;return or(0,ur(e,t),1)}const Id=/\s*;\s*/,Bd=/\s*:\s*/;function Rd(i,t){let e,r;const s=i.getAttribute("style");if(s){const o=s.split(Id);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Bd).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=ur(parseFloat(r||i.getAttribute("stop-opacity")||""),1);const n=new rt(e);return n.setAlpha(n.getAlpha()*r*t),{offset:dl(i.getAttribute("offset"),0),color:n.toRgba()}}function $d(i,t){const e=[],r=i.getElementsByTagName("stop"),s=dl(t,1);for(let n=r.length;n--;)e.push(Rd(r[n],s));return e}function gl(i){return i.nodeName==="linearGradient"||i.nodeName==="LINEARGRADIENT"?"linear":"radial"}function fl(i){return i.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Kt(i,t){return i.getAttribute(t)}function zd(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&&ul(u)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l},{})}(gl(i)==="linear"?function(e){return{x1:Kt(e,"x1")||0,y1:Kt(e,"y1")||0,x2:Kt(e,"x2")||"100%",y2:Kt(e,"y2")||0}}(i):function(e){return{x1:Kt(e,"fx")||Kt(e,"cx")||"50%",y1:Kt(e,"fy")||Kt(e,"cy")||"50%",r1:0,x2:Kt(e,"cx")||"50%",y2:Kt(e,"cy")||"50%",r2:Kt(e,"r")||"50%"}}(i),{...t,gradientUnits:fl(i)})}class qs{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"?jd:hl,...s},colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?`${c}_${ke()}`:ke()})}addColorStop(t){for(const e in t)this.colorStops.push({offset:parseFloat(e),color:t[e]});return this}toObject(t){return{...sr(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():Tt.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_${q(String(this.id))}"`,`gradientUnits="${n}"`,`gradientTransform="${e?e+" ":""}${Fr(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),w=u(f),T=u(m);r.push("<linearGradient ",h,' x1="',y,'" y1="',b,'" x2="',w,'" y2="',T,`">
|
|
77
|
+
`)}else if(this.type==="radial"){const{x1:d,y1:g,x2:f,y2:m,r1:y,r2:b}=this.coords,w=u(d),T=u(g),C=u(f),S=u(m),D=u(y),A=u(b),_=D>A;r.push("<radialGradient ",h,' cx="',_?w:C,'" cy="',_?T:S,'" r="',_?D:A,'" fx="',_?C:w,'" fy="',_?S:T,`">
|
|
78
|
+
`),_&&(o.reverse(),o.forEach(O=>{O.offset=1-O.offset}));const M=Math.min(D,A);if(M>0){const O=M/Math.max(D,A);o.forEach(V=>{V.offset+=O*(1-V.offset)})}}return o.forEach(d=>{let{color:g,offset:f}=d;r.push(`<stop offset="${100*f}%" style="stop-color:${g};"/>
|
|
124
79
|
`)}),r.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
|
125
|
-
`),r.join("")}toLive(t){const{x1:e,y1:r,x2:
|
|
126
|
-
`)}static async fromObject(t,e){let{type:r,source:
|
|
127
|
-
`
|
|
128
|
-
`];{const
|
|
129
|
-
`]}}static async fromElement(t,e,r){const
|
|
130
|
-
`
|
|
131
|
-
`
|
|
132
|
-
`
|
|
133
|
-
`)}const Jh=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Os;class pt extends ra{static getDefaults(){return v(v({},super.getDefaults()),pt.ownDefaults)}constructor(t,e){super(),p(this,"__charBounds",[]),Object.assign(this,pt.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=Uo(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(Nt)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,i,s,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Nt||l!==c-1&&!this.isEndOfWrapping(l))&&(i=0,s=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){r=a.length,t=(this.width-e)/r;for(let h=0;h<=s.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(s[h])?(o.width+=t,o.kernedWidth+=t,o.left+=i,i+=t):o.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const r=e?this._unwrappedTextLines:this._textLines;let i;for(i=0;i<r.length;i++){if(t<=r[i].length)return{lineIndex:i,charIndex:t};t-=r[i].length+this.missingNewlineOffset(i,e)}return{lineIndex:i-1,charIndex:r[i-1].length<t?r[i-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===_t?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case W:t.textBaseline="middle";break;case"ascender":t.textBaseline=vt;break;case"descender":t.textBaseline=Yi}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,r,i,s,o){this._renderChars(t,e,r,i,s,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=this._getLeftOffset();let i=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){const a=this.getHeightOfLine(s);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",s)){i+=a;continue}const l=this._textLines[s].length,c=this._getLineLeftOffset(s);let h,u,d=0,g=0,f=this.getValueOfPropertyAt(s,0,"textBackgroundColor");const m=this.getHeightOfLineImpl(s);for(let b=0;b<l;b++){const y=this.__charBounds[s][b];u=this.getValueOfPropertyAt(s,b,"textBackgroundColor"),this.path?(t.save(),t.translate(y.renderLeft,y.renderTop),t.rotate(y.angle),t.fillStyle=u,u&&t.fillRect(-y.width/2,-m*(1-this._fontSizeFraction),y.width,m),t.restore()):u!==f?(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,i,d,m),g=y.left,d=y.width,f=u):d+=y.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,i,d,m)),i+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,i){const s=tr.getFontCache(e),o=this._getFontDeclaration(e),a=r?r+t:t,l=r&&o===this._getFontDeclaration(i),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,g;if(r&&s.has(r)&&(d=s.get(r)),s.has(t)&&(g=h=s.get(t)),l&&s.has(a)&&(u=s.get(a),g=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return Os||(Os=At({width:0,height:0}).getContext("2d")),Os}();this._setTextStyles(f,e,!0),h===void 0&&(g=h=f.measureText(t).width,s.set(t,h)),d===void 0&&l&&r&&(d=f.measureText(r).width,s.set(r,d)),l&&u===void 0&&(u=f.measureText(a).width,s.set(a,u),g=u-d)}return{width:h*c,kernedWidth:g*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,r,i=0;const s=this.pathSide===it,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const u=a[h];r=this._getGraphemeBox(u,t,h,e),c[h]=r,i+=r.kernedWidth,e=u}if(c[l]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case U:h=s?u-i:0;break;case W:h=(u-i)/2;break;case it:h=s?0:u-i}h+=this.pathStartOffset*(s?-1:1);for(let d=s?l-1:0;s?d>=0:d<l;s?d--:d++)r=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,r),h+=r.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,i=this.path,s=Th(i.path,r,i.segmentsInfo);e.renderLeft=s.x-i.pathOffset.x,e.renderTop=s.y-i.pathOffset.y,e.angle=s.angle+(this.pathSide===it?Math.PI:0)}_getGraphemeBox(t,e,r,i,s){const o=this.getCompleteStyleDeclaration(e,r),a=i?this.getCompleteStyleDeclaration(e,r-1):{},l=this._measureChar(t,o,i,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(r>0&&!s){const g=this.__charBounds[e][r-1];d.left=g.left+g.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)r=Math.max(this.getHeightOfChar(t,i),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=0;const i=this._getLeftOffset(),s=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],i+this._getLineLeftOffset(o),s+r+this.getHeightOfLineImpl(o),o),r+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(at))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,r,i,s,o){const a=this.textAlign.includes(Nt),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",u=this.direction==="ltr"?1:-1,d=e.direction;let g,f,m,b,y,w="",O=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?U:it),s-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,r.join(""),i,s),void e.restore();for(let k=0,S=r.length-1;k<=S;k++)b=k===S||this.charSpacing||l,w+=r[k],m=this.__charBounds[o][k],O===0?(i+=u*(m.kernedWidth-m.width),O+=m.width):O+=m.kernedWidth,a&&!b&&this._reSpaceAndTab.test(r[k])&&(b=!0),b||(g=g||this.getCompleteStyleDeclaration(o,k),f=this.getCompleteStyleDeclaration(o,k+1),b=ms(g,f,!1)),b&&(l?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,k,w,-O/2,0),e.restore()):(y=i,this._renderChar(t,e,o,k,w,y,s)),w="",g=f,i+=u*O,O=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,i=At({width:e,height:r}),s=i.getContext("2d");return i.width=e,i.height=r,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,r),s.lineTo(0,r),s.closePath(),s.translate(e/2,r/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(i,"no-repeat")}handleFiller(t,e,r){let i,s;return jt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?(i=-this.width/2,s=-this.height/2,t.translate(i,s),t[e]=this._applyPatternGradientTransformText(r),{offsetX:i,offsetY:s}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,strokeWidth:i}=e;return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,i,s,o,a){const l=this._getStyleDeclaration(r,i),c=this.getCompleteStyleDeclaration(r,i),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(s,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(s,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){const i=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),o=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),a={fontSize:s*r.size,deltaY:o+s*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,i=this.textAlign,s=this.direction,o=this.isEndOfWrapping(t);let a=0;return i===Nt||i===cr&&!o||i===lr&&!o||i===Vr&&!o?0:(i===W&&(a=r/2),i===it&&(a=r),i===cr&&(a=r/2),i===lr&&(a=r),s==="rtl"&&(i===it||i===Nt||i===lr?a=0:i===U||i===Vr?a=-r:i!==W&&i!==cr||(a=-r/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,r){var i;return(i=this._getStyleDeclaration(t,e)[r])!==null&&i!==void 0?i:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=this._getTopOffset();const i=this._getLeftOffset(),s=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){r+=u;continue}const d=this._textLines[c],g=u/this.lineHeight,f=this._getLineLeftOffset(c);let m=0,b=0,y=this.getValueOfPropertyAt(c,0,e),w=this.getValueOfPropertyAt(c,0,at),O=this.getValueOfPropertyAt(c,0,be),k=y,S=w,C=O;const A=r+g*(1-this._fontSizeFraction);let D=this.getHeightOfChar(c,0),L=this.getValueOfPropertyAt(c,0,"deltaY");for(let I=0,M=d.length;I<M;I++){const j=this.__charBounds[c][I];k=this.getValueOfPropertyAt(c,I,e),S=this.getValueOfPropertyAt(c,I,at),C=this.getValueOfPropertyAt(c,I,be);const z=this.getHeightOfChar(c,I),V=this.getValueOfPropertyAt(c,I,"deltaY");if(s&&k&&S){const tt=this.fontSize*C/1e3;t.save(),t.fillStyle=w,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,l*z+V-a*tt,j.kernedWidth,tt),t.restore()}else if((k!==y||S!==w||z!==D||C!==O||V!==L)&&b>0){const tt=this.fontSize*O/1e3;let N=i+f+m;this.direction==="rtl"&&(N=this.width-N-b),y&&w&&O&&(t.fillStyle=w,t.fillRect(N,A+l*D+L-a*tt,b,tt)),m=j.left,b=j.width,y=k,O=C,w=S,D=z,L=V}else b+=j.kernedWidth}let R=i+f+m;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=S;const H=this.fontSize*C/1e3;k&&S&&C&&t.fillRect(R,A+l*D+L-a*H,b-o,H),r+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||pt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,r,"".concat(s?this.CACHE_FONT_SIZE:i,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return ps(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),i=[`
|
|
134
|
-
`];let
|
|
135
|
-
`]}_getSVGTextAndBg(n,t){const e=[],r=[];let i,s=n;this.backgroundColor&&r.push(...ks(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)i=this._getLineLeftOffset(o),this.direction==="rtl"&&(i+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(r,o,t+i,s),this._setSVGTextLineText(e,o,t+i,s),s+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:r}}_createTextCharSpan(n,t,e,r,i){const s=X.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Kh)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(Z(l,s),'" '):"",{angle:h,renderLeft:u,renderTop:d,width:g}=i;let f="";if(u!==void 0){const m=g/2;h&&(f=' rotate="'.concat(Z(te(h),s),'"'));const b=Pe({angle:te(h)});b[4]=u,b[5]=d;const y=new x(-m,0).transform(b);e=y.x,r=y.y}return'<tspan x="'.concat(Z(e,s),'" y="').concat(Z(r,s),'" ').concat(c).concat(f).concat(a,">").concat(Ic(n),"</tspan>")}_setSVGTextLineText(n,t,e,r){const i=this.getHeightOfLine(t),s=this.textAlign.includes(Nt),o=this._textLines[t];let a,l,c,h,u,d="",g=0;r+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,m=o.length-1;f<=m;f++)u=f===m||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[t][f],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=ms(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),n.push(this._createTextCharSpan(d,h,e,r,c)),d="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(n,t,e,r){const i=this._textLines[t],s=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<i.length;h++){const{left:u,width:d,kernedWidth:g}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...ks(c,e+l,r,a,s)),l=u,a=d,c=o):a+=g}o&&n.push(...ks(c,e+l,r,a,s))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const r=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*r/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," text-decoration-thickness: ").concat(Z(this.textDecorationThickness*this.getObjectScaling().y/10,X.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:r,stroke:i,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:u,overline:d,underline:g}=n,f=this.getSvgTextDecoration({underline:g??this.underline,overline:d??this.overline,linethrough:u??this.linethrough}),m=h||this.textDecorationThickness;return[i?ar(_t,i):"",r?"stroke-width: ".concat(r,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",f?"text-decoration: ".concat(f,"; text-decoration-thickness: ").concat(Z(m*this.getObjectScaling().y/10,X.NUM_FRACTION_DIGITS),"%; "):"",s?ar(at,s):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),E.setClass(pt),E.setSVGClass(pt);class Qh{constructor(t){p(this,"target",void 0),p(this,"__mouseDownInPlace",!1),p(this,"__dragStartFired",!1),p(this,"__isDraggingOver",!1),p(this,"__dragStartSelection",void 0),p(this,"__dragImageDisposer",void 0),p(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(r=>r()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var r;let{selectionStart:i,selectionEnd:s}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(i),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new x(g.left,g.top)),m=a.viewportTransform,b=f.add(u).transform(m,!0),y=o.backgroundColor,w=fs(o.styles);o.backgroundColor="";const O={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(O,0,i),o.setSelectionStyles(O,s,o.text.length),o.dirty=!0;const k=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=y,o.styles=w,o.dirty=!0,ws(k,{position:"fixed",left:"".concat(-k.width,"px"),border:bt,width:"".concat(k.width/d,"px"),height:"".concat(k.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{k.remove()},Bt(t.target||this.target.hiddenTextarea).body.appendChild(k),(r=t.dataTransfer)===null||r===void 0||r.setDragImage(k,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(i.selectionStart,i.selectionEnd).join(""),o=v({text:e.text,value:s},i);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:r}=t,i=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let s=(e=r.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(s&&!i){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(r);const{styles:c}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},h=s[Math.max(0,s.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>d&&l<=g?l=d:l>g&&(l-=g-d),o.removeChars(d,g),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(s,c,l),a.setActiveObject(o),o.enterEditing(r),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+s.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(kr,{index:l+u,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var r;const i=this.target,s=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((r=e.dataTransfer)===null||r===void 0?void 0:r.dropEffect)||bt;l===bt?(i.selectionStart=o,i.selectionEnd=a,i._updateTextarea(),i.hiddenTextarea.focus()):(i.clearContextTop(),l==="move"&&(i.removeChars(o,a),i.selectionStart=i.selectionEnd=o,i.hiddenTextarea&&(i.hiddenTextarea.value=i.text),i._updateTextarea(),i.fire(kr,{index:o,action:"dragend"}),s.fire("text:changed",{target:i}),s.requestRenderAll()),i.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const ia=/[ \n\.,;!\?\-]/;class tu extends pt{constructor(){super(...arguments),p(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:r,delay:i,onComplete:s}=t;return mo({startValue:this._currentCursorOpacity,endValue:e,duration:r,delay:i,onComplete:s,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let i=t>0&&this._reSpace.test(r[t])&&(e===-1||!Ui.test(r[t-1]))?t-1:t,s=r[i];for(;i>0&&i<r.length&&!ia.test(s);)i+=e,s=r[i];return e===-1&&ia.test(s)&&i++,i}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.searchWordBoundary(t,-1),i=Math.max(r,this.searchWordBoundary(t,1));this.selectionStart=r,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=r,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;Bt(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&i!==s||i!==r&&s!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===s||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,r){const i=r.slice(0,t),s=this.graphemeSplit(i).length;if(t===e)return{selectionStart:s,selectionEnd:s};const o=r.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,r){const i=r.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+r.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),i=r.lineIndex,s=r.charIndex,o=this.getValueOfPropertyAt(i,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,g=u-o,f=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(Dr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:o}=this.get2DCursorLocation(e,!0);if(r!==s){if(this.styles[r])for(let a=i;a<this._unwrappedTextLines[r].length;a++)delete this.styles[r][a];if(this.styles[s])for(let a=o;a<this._unwrappedTextLines[s].length;a++){const l=this.styles[s][a];l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][i+a-o]=l)}for(let a=r+1;a<=s;a++)delete this.styles[a];this.shiftLineStyles(s,r-s)}else if(this.styles[r]){const a=this.styles[r],l=o-i;for(let c=i;c<o;c++)delete a[c];for(const c in this.styles[r]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const i in this.styles){const s=parseInt(i,10);s>t&&(this.styles[s+e]=r[s],r[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,r,i){const s={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;r||(r=1),this.shiftLineStyles(t,r);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,s[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+r]=s,h=!0),(h||o>e)&&r--;r>0;)i&&i[r-1]?this.styles[t+r]={0:v({},i[r-1])}:c?this.styles[t+r]={0:v({},c)}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,i){this.styles||(this.styles={});const s=this.styles[t],o=s?v({},s):{};r||(r=1);for(const l in o){const c=parseInt(l,10);c>=e&&(s[c+r]=o[c],o[c-r]||delete s[c])}if(this._forceClearCache=!0,i){for(;r--;)Object.keys(i[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]=v({},i[r]));return}if(!s)return;const a=s[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]=v({},a)}insertNewStyleBlock(t,e,r){const i=this.get2DCursorLocation(e,!0),s=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
136
|
-
`?(a++,s[a]=0):s[a]++;for(s[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,s[0],r),r=r&&r.slice(s[0]+1)),a&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+s[0],a),o=1;o<a;o++)s[o]>0?this.insertCharStyleObject(i.lineIndex+o,0,s[o],r):r&&this.styles[i.lineIndex+o]&&r[0]&&(this.styles[i.lineIndex+o][0]=r[0]),r=r&&r.slice(s[o]+1);s[o]>0&&this.insertCharStyleObject(i.lineIndex+o,0,s[o],r)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;i>r&&this.removeStyleFromTo(r,i);const s=this.graphemeSplit(t);this.insertNewStyleBlock(s,r,e),this._text=[...this._text.slice(0,r),...s,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=U:this._selectionDirection===it&&(this._selectionDirection=U,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===it?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=it:this._selectionDirection===U&&(this._selectionDirection=it,this.selectionStart=e),this.selectionEnd=r)}}class eu extends tu{initHiddenTextarea(){const t=this.canvas&&Bt(this.canvas.getElement())||ke(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(o=>{let[a,l]=o;return e.setAttribute(a,l)});const{top:r,left:i,fontSize:s}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(r,"; left: ").concat(i,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(s,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:r,selectionStart:i,selectionEnd:s}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(kr),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(r).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,u=this.selectionEnd,d=h!==u;let g,f,m,b,y=c-l;const w=this.fromStringToGraphemeSelection(i,s,r),O=h>w.selectionStart;d?(f=this._text.slice(h,u),y+=u-h):c<l&&(f=O?this._text.slice(u+y,u):this._text.slice(h,h-y));const k=a.slice(w.selectionEnd-y,w.selectionEnd);if(f&&f.length&&(k.length&&(g=this.getSelectionStyles(h,h+1,!1),g=k.map(()=>g[0])),d?(m=h,b=u):O?(m=u-f.length,b=u):(m=u,b=u+f.length),this.removeStyleFromTo(m,b)),k.length){const{copyPasteData:S}=Gt();e&&k.join("")===S.copiedText&&!X.disableStyleCopyPaste&&(g=S.copiedTextStyle),this.insertNewStyleBlock(k,h,g)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:i}=e;this.compositionStart=r,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Gt();t.copiedText=this.getSelectedText(),X.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let r,i=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],i+=r.left+r.width),i}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),s=i.lineIndex;if(s===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-r;const o=i.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s+1,a);return this._textLines[s].slice(o).length+l+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),s=i.lineIndex;if(s===0||t.metaKey||t.keyCode===33)return-r;const o=i.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s-1,a),c=this._textLines[s].slice(0,o),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const r=this._textLines[t];let i,s,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=r.length;l<c;l++)if(i=this.__charBounds[t][l].width,o+=i,o>e){s=!0;const h=o-i,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return s||(a=r.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const r=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===it);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const i=this.text.length;this.selectionStart=Fe(0,this.selectionStart,i),this.selectionEnd=Fe(0,this.selectionEnd,i),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===U?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,r){let i;if(t.altKey)i=this["findWordBoundary".concat(r)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;i=this["findLineBoundary".concat(r)](this[e])}return i!==void 0&&this[e]!==i&&(this[e]=i,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=U,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===it&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=U,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===U&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=it,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=it,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const sa=n=>!!n.button;class ru extends eu{constructor(){super(...arguments),p(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new Qh(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:r}=t;this.canvas&&this.editable&&!sa(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=t;const i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const s=this.canvas._activeObject;if(s&&s!==this)return}!this.editable||this.group&&!this.group.interactive||r&&r.actionPerformed||sa(e)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),r=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Rt(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let r=0,i=0,s=0;for(let c=0;c<this._textLines.length&&r<=e.y;c++)r+=this.getHeightOfLine(c),s=c,c>0&&(i+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(s));const a=this._textLines[s].length,l=this.__charBounds[s];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&i++;break}o=h,i++}return Math.min(this.flipX?a-i:i,this._text.length)}}const ti="moveCursorUp",ei="moveCursorDown",ri="moveCursorLeft",ii="moveCursorRight",si="exitEditing",na=(n,t)=>{const e=t.getRetinaScaling();n.setTransform(e,0,0,e,0,0);const r=t.viewportTransform;n.transform(r[0],r[1],r[2],r[3],r[4],r[5])},iu=v({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:si,27:si,33:ti,34:ei,35:ii,36:ri,37:ri,38:ti,39:ii,40:ei},keysMapRtl:{9:si,27:si,33:ti,34:ei,35:ri,36:ii,37:ii,38:ti,39:ri,40:ei},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class qt extends ru{static getDefaults(){return v(v({},super.getDefaults()),qt.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,v(v({},qt.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 Cs&&this.canvas.textEditingManager.remove(this),e instanceof Cs&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),i=r.length>0;let s,o=t;if(i){s=At(t.canvas),o=s.getContext("2d"),na(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),i)for(const a of r){const l=a.clipPath,c=At(t.canvas),h=c.getContext("2d");if(na(h,this.canvas),!l.absolutePositioned){const u=a.calcTransformMatrix();h.transform(u[0],u[1],u[2],u[3],u[4],u[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const r=this._getLeftOffset(),i=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:r,top:i,leftOffset:s.left,topOffset:s.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,r=0;const{charIndex:i,lineIndex:s}=this.get2DCursorLocation(t);for(let c=0;c<s;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(s),a=this.__charBounds[s][i];a&&(r=a.left),this.charSpacing!==0&&i===this._textLines[s].length&&(r-=this._getWidthOfCharSpacing());const l={top:e,left:o+(r>0?r:0)};return this.direction==="rtl"&&(this.textAlign===it||this.textAlign===Nt||this.textAlign===lr?l.left*=-1:this.textAlign===U||this.textAlign===Vr?l.left=o-(r>0?r:0):this.textAlign!==W&&this.textAlign!==cr||(l.left=o-(r>0?r:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const r=this.get2DCursorLocation(t),i=r.lineIndex,s=r.charIndex>0?r.charIndex-1:0,o=this.getValueOfPropertyAt(i,s,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(i,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,s,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,r){const{color:i,opacity:s,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(r,e);t.fillStyle=i,t.globalAlpha=s,t.fillRect(o,a,l,c)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,r){const i=e.selectionStart,s=e.selectionEnd,o=this.textAlign.includes(Nt),a=this.get2DCursorLocation(i),l=this.get2DCursorLocation(s),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let g=c;g<=h;g++){const f=this._getLineLeftOffset(g)||0;let m=this.getHeightOfLine(g),b=0,y=0,w=0;if(g===c&&(y=this.__charBounds[c][u].left),g>=c&&g<h)w=o&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(d===0)w=this.__charBounds[h][d].left;else{const A=this._getWidthOfCharSpacing();w=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-A}b=m,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(m/=this.lineHeight);let O=r.left+f+y,k=m,S=0;const C=w-y;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",k=1,S=m):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===it||this.textAlign===Nt||this.textAlign===lr?O=this.width-O-C:this.textAlign===U||this.textAlign===Vr?O=r.left+f-w:this.textAlign!==W&&this.textAlign!==cr||(O=r.left+f-w)),t.fillRect(O,r.top+r.topOffset+S,C,k),r.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,at)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}p(qt,"ownDefaults",iu),p(qt,"type","IText"),E.setClass(qt),E.setClass(qt,"i-text");class xe extends qt{static getDefaults(){return v(v({},super.getDefaults()),xe.ownDefaults)}constructor(t,e){super(t,v(v({},xe.ownDefaults),e))}static createControls(){return{controls:Lc()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Nt)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,i=0;const s={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[i]===`
|
|
137
|
-
`&&o>0?(r=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&o>0&&(r++,i++),s[o]={line:e,offset:r},i+=t.graphemeLines[o].length,r+=t.graphemeLines[o].length;return s}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[e];r&&(e=r.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,i=t+1,s=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,r=o.offset),a&&(i=a.line,s=i===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const u=parseInt(h,10);if(u>=r&&(!s||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const r=this.getGraphemeDataForRender(t),i=[];for(let s=0;s<r.wordsData.length;s++)i.push(...this._wrapLine(s,e,r));return this.isWrapping=!1,i}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=e?"":" ";let i=0;return{wordsData:t.map((s,o)=>{let a=0;const l=e?this.graphemeSplit(s):this.wordSplit(s);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return i=Math.max(u,i),a+=h.length+r.length,{word:h,width:u}})}),largestWordWidth:i}}_measureWord(t,e){let r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=0;for(let o=0,a=t.length;o<a;o++)s+=this._getGraphemeBox(t[o],e,o+i,r,!0).kernedWidth,r=t[o];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:i,wordsData:s}=r,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],g=0,f=0,m=!0;e-=o;const b=Math.max(e,i,this.dynamicMinWidth),y=s[t];let w;for(g=0,w=0;w<y.length;w++){const{word:O,width:k}=y[w];g+=O.length,u+=f+k-a,u>b&&!m?(c.push(d),d=[],u=k,m=!0):u+=a,m||l||d.push(h),d=d.concat(O),f=l?0:this._measureWord([h],t,g),g++,m=!1}return w&&c.push(d),i+o>this.dynamicMinWidth&&(this.dynamicMinWidth=i-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),r=this._wrapText(e.lines,this.width),i=new Array(r.length);for(let s=0;s<r.length;s++)i[s]=r[s].join("");return e.lines=i,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){const i=this._styleMap[e].line;t.set("".concat(i),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}p(xe,"type","Textbox"),p(xe,"textLayoutProperties",[...qt.textLayoutProperties,"width"]),p(xe,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),E.setClass(xe);class oa extends $r{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:i,group:s}=r;if(!i||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ee(Ro(r,i)),l=new x(o,a);if(i.absolutePositioned)return{center:je(i.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:l};{const c=i.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:u=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}p(oa,"type","clip-path"),E.setClass(oa);class aa extends $r{getInitialSize(t,e){let{target:r}=t,{size:i}=e;return new x(r.width||i.x,r.height||i.y)}}p(aa,"type","fixed"),E.setClass(aa);class su extends fr{subscribeTargets(t){const e=t.target;t.targets.reduce((r,i)=>(i.parent&&r.add(i.parent),r),new Set).forEach(r=>{r.layoutManager.subscribeTargets({target:r,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((i,s)=>(s.parent&&i.add(s.parent),i),new Set).forEach(i=>{!r.some(s=>s.parent===i)&&i.layoutManager.unsubscribeTargets({target:i,targets:[e]})})}}class we extends ye{static getDefaults(){return v(v({},super.getDefaults()),we.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,we.ownDefaults),this.setOptions(e);const{left:r,top:i,layoutManager:s}=e;this.groupInit(t,{left:r,top:i,layoutManager:s??new su})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(i=>{const s=this._objects.findIndex(a=>a.isInFrontOf(i)),o=s===-1?this.size():s;this.insertAt(o,i)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(ce("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const r=new Set;e.forEach(i=>{const{parent:s}=i;s&&r.add(s)}),t===ys?r.forEach(i=>{i._onAfterObjectsChange(Gr,e)}):r.forEach(i=>{i._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const i=v(v({hasControls:!1},r),{},{forActiveSelection:!0});for(let s=0;s<this._objects.length;s++)this._objects[s]._renderControls(t,i);super._renderControls(t,e),t.restore()}}p(we,"type","ActiveSelection"),p(we,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),E.setClass(we),E.setClass(we,"activeSelection");class nu{constructor(){p(this,"resources",{})}applyFilters(t,e,r,i,s){const o=s.getContext("2d");if(!o)return;o.drawImage(e,0,0,r,i);const a={sourceWidth:r,sourceHeight:i,imageData:o.getImageData(0,0,r,i),originalEl:e,originalImageData:o.getImageData(0,0,r,i),canvasEl:s,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===r&&l.height===i||(s.width=l.width,s.height=l.height),o.putImageData(l,0,0),a}}class la{constructor(){let{tileSize:t=X.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};p(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),p(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const r=At({width:t,height:e}),i=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=r,this.gl=i)}applyFilters(t,e,r,i,s,o){const a=this.gl,l=s.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:r,sourceHeight:i,destinationWidth:r,destinationHeight:i,context:a,sourceTexture:this.createTexture(a,r,i,c?void 0:e),targetTexture:this.createTexture(a,r,i),originalTexture:c||this.createTexture(a,r,i,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const g=d.targetCanvas,f=g.width,m=g.height,b=d.destinationWidth,y=d.destinationHeight;f===b&&m===y||(g.width=b,g.height=y)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,r,i,s){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:f}=t,m=t.createTexture();return t.bindTexture(a,m),t.texParameteri(a,u,s||o),t.texParameteri(a,d,s||o),t.texParameteri(a,g,h),t.texParameteri(a,f,h),i?t.texImage2D(a,0,l,l,c,i):t.texImage2D(a,0,l,e,r,0,l,c,null),m}getCachedTexture(t,e,r){const{textureCache:i}=this;if(i[t])return i[t];{const s=this.createTexture(this.gl,e.width,e.height,e,r);return s&&(i[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const r=t.canvas,i=e.targetCanvas,s=i.getContext("2d");if(!s)return;s.translate(0,i.height),s.scale(1,-1);const o=r.height-i.height;s.drawImage(r,0,o,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),i=e.destinationWidth,s=e.destinationHeight,o=i*s*4;if(!r)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,i,s,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,i,s);r.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const i=t.getParameter(r.UNMASKED_RENDERER_WEBGL),s=t.getParameter(r.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}}let Ds;function ou(){const{WebGLProbe:n}=Gt();return n.queryWebGL(Qt()),X.enableGLFiltering&&n.isSupported(X.textureSize)?new la({tileSize:X.textureSize}):new nu}function Ms(){return!Ds&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Ds=ou()),Ds}const au=["filters","resizeFilter","src","crossOrigin","type"],ca=["cropX","cropY"];class Ot extends ut{static getDefaults(){return v(v({},super.getDefaults()),Ot.ownDefaults)}constructor(t,e){super(),p(this,"_lastScaleX",1),p(this,"_lastScaleY",1),p(this,"_filterScalingX",1),p(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Ot.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(ue()),this.setElement(typeof t=="string"?(this.canvas&&Bt(this.canvas.getElement())||ke()).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(Ot.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Ms(!1);e instanceof la&&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&&Gt().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(r=>{r&&e.push(r.toObject())}),v(v({},super.toObject([...ca,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,r=-this.width/2,i=-this.height/2;let s=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=ue();s.push('<clipPath id="imageCrop_'+c+`">
|
|
138
|
-
`,' <rect x="'+r+'" y="'+
|
|
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=fl(t),n=e._findCenterFromElement();return new this({id:t.getAttribute("id")||void 0,type:gl(t),coords:zd(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:$d(t,r.opacity),gradientUnits:s,gradientTransform:dn(t.getAttribute("gradientTransform")||""),...s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}}v(qs,"type","Gradient"),j.setClass(qs,"gradient"),j.setClass(qs,"linear"),j.setClass(qs,"radial");class yn{get type(){return"pattern"}set type(t){Ce("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=ke(),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{...sr(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:nt(this.offsetX,tt.NUM_FRACTION_DIGITS),offsetY:nt(this.offsetY,tt.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=ur(this.offsetX/e,0),l=ur(this.offsetY/r,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):ur(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):ur(s.height/r,0);return[`<pattern id="SVGID_${q(o)}" x="${a}" y="${l}" width="${c}" height="${h}">`,`<image x="0" y="0" width="${s.width}" height="${s.height}" xlink:href="${q(this.sourceToString())}"></image>`,"</pattern>",""].join(`
|
|
81
|
+
`)}static async fromObject(t,e){let{type:r,source:s,patternTransform:n,...o}=t;const a=await Ps(s,{...e,crossOrigin:o.crossOrigin});return new this({...o,patternTransform:n&&n.slice(0),source:a})}}v(yn,"type","Pattern"),j.setClass(yn),j.setClass(yn,"pattern");class Hd{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 Ee extends ut{constructor(t){let{path:e,left:r,top:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Ee.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof r=="number"&&this.set(Q,r),typeof s=="number"&&this.set(Et,s)}_setPath(t,e){this.path=wd(Array.isArray(t)?t:Md(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,r=-this.pathOffset.y;t.beginPath();for(const 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="${cl(this.path,tt.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />
|
|
82
|
+
`]}_getOffsetTransform(){const t=tt.NUM_FRACTION_DIGITS;return` translate(${nt(-this.pathOffset.x,t)}, ${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,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(...el(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(...el(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 pe(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return{...t,pathOffset:new x(t.left+t.width/2,t.top+t.height/2)}}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const{d:s,...n}=ye(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...n,...e,left:void 0,top:void 0})}}v(Ee,"type","Path"),v(Ee,"cacheProperties",[...me,"path","fillRule"]),v(Ee,"ATTRIBUTE_NAMES",[...Oe,"d"]),j.setClass(Ee),j.setSVGClass(Ee);class Ks extends Hd{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=Ks.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++)Ks.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 Ed(t,e)}createPath(t){const e=new Ee(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 ne(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 cl(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 pl=["radius","startAngle","endAngle","counterClockwise"];class we extends ut{static getDefaults(){return{...super.getDefaults(),...we.ownDefaults}}constructor(t){super(),Object.assign(this,we.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(At)}getRadiusY(){return this.get("radius")*this.get(Vt)}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([...pl,...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="',`${q(t)}`,`" />
|
|
83
|
+
`];{const n=pt(e),o=pt(r),a=de(n)*t,l=ge(n)*t,c=de(o)*t,h=ge(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}=ye(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(we,"type","Circle"),v(we,"cacheProperties",[...me,...pl]),v(we,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(we,"ATTRIBUTE_NAMES",["cx","cy","r",...Oe]),j.setClass(we),j.setSVGClass(we);const bn=["x1","x2","y1","y2"];class Zt extends ut{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,Zt.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(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}=pe([{x:t,y:e},{x:r,y:s}]),c=new x(n+a/2,o+l/2);this.setPositionByOrigin(c,Y,Y)}_set(t,e){return super._set(t,e),bn.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 x((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}=ye(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(Zt,"type","Line"),v(Zt,"cacheProperties",[...me,...bn]),v(Zt,"ATTRIBUTE_NAMES",Oe.concat(bn)),j.setClass(Zt),j.setSVGClass(Zt);class ze extends ut{static getDefaults(){return{...super.getDefaults(),...ze.ownDefaults}}constructor(t){super(),Object.assign(this,ze.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(ze,"type","Triangle"),v(ze,"ownDefaults",{width:100,height:100}),j.setClass(ze),j.setSVGClass(ze);const ml=["rx","ry"];class Jt extends ut{static getDefaults(){return{...super.getDefaults(),...Jt.ownDefaults}}constructor(t){super(),Object.assign(this,Jt.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(At)}getRy(){return this.get("ry")*this.get(Vt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ml,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${q(this.rx)}" ry="${q(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,Ze,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const s=ye(t,this.ATTRIBUTE_NAMES,r);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}v(Jt,"type","Ellipse"),v(Jt,"cacheProperties",[...me,...ml]),v(Jt,"ownDefaults",{rx:0,ry:0}),v(Jt,"ATTRIBUTE_NAMES",[...Oe,"cx","cy","rx","ry"]),j.setClass(Jt),j.setSVGClass(Jt);const vl={exactBoundingBox:!1};class Qt extends ut{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(Et,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Uu(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 x,strokeOffset:new x,strokeDiff:new x};const r=pe(e),s=Es({...t,scaleX:1,scaleY:1}),n=pe(this.points.map(c=>Lt(c,s,!0))),o=new x(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(pt(this.skewX)),l-=a*Math.tan(pt(this.skewY))),{...r,pathOffset:new x(a,l),strokeOffset:new x(n.left,n.top).subtract(new x(r.left,r.top)).multiply(o),strokeDiff:new x(r.width,r.height).subtract(new x(n.width,n.height)).multiply(o)}}_findCenterFromElement(){const t=pe(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,width: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 x(e+s/2,r+n/2),Y,Y)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,r;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r:l)}else{var s,n;o=new x((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const r=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&r&&((t===At||t===Vt)&&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=tt.NUM_FRACTION_DIGITS,s=this.points.map(n=>{let{x:o,y:a}=n;return`${nt(o-t,r)},${nt(a-e,r)}`}).join(" ");return[`<${q(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}=ye(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...a,...e})}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Qt,"ownDefaults",vl),v(Qt,"type","Polyline"),v(Qt,"layoutProperties",[Je,Qe,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Qt,"cacheProperties",[...me,"points"]),v(Qt,"ATTRIBUTE_NAMES",[...Oe]),j.setClass(Qt),j.setSVGClass(Qt);class Yr extends Qt{isOpen(){return!1}}v(Yr,"ownDefaults",vl),v(Yr,"type","Polygon"),j.setClass(Yr),j.setSVGClass(Yr);class yl extends ut{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=Ui({...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{...sr(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(yl,"_styleProperties",pu);const Vd=/ +/g,Wd=/"/g;function wn(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]:tt.NUM_FRACTION_DIGITS;const d=Rr(_t,n,!1),[g,f,m,y]=[a,l,c,h].map(b=>nt(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 xn;class Mt extends yl{static getDefaults(){return{...super.getDefaults(),...Mt.ownDefaults}}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Mt.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===Rt?(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=Et;break;case"descender":t.textBaseline=Ri}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===ue&&(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===ue&&(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=Mr.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 xn||(xn=Wt({width:0,height:0}).getContext("2d")),xn}();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 Q:h=n?u-s:0;break;case Y: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=kd(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===je?-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===je,u=this.direction===je?1:-1,d=e.direction;let g,f,m,y,b,w="",T=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?je:ue),e.direction=h?je:ue,e.textAlign=h?Q: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,S=r.length-1;C<=S;C++)y=C===S||this.charSpacing||l,w+=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=hn(g,f,!1)),y&&(l?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,C,w,-T/2,0),e.restore()):(b=s,this._renderChar(t,e,o,C,w,b,n)),w="",g=f,s+=u*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,s=Wt({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===zr&&!o||s===$r&&!o||s===zs&&!o?0:(s===Y&&(a=r/2),s===ft&&(a=r),s===zr&&(a=r/2),s===$r&&(a=r),n===ue&&(s===ft||s===$r?a=0:s===Q||s===zs?a=-r:s!==Y&&s!==zr||(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),w=this.getValueOfPropertyAt(c,0,_t),T=this.getValueOfPropertyAt(c,0,Be),C=b,S=w,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,Be);const G=this.getHeightOfChar(c,z),K=this.getValueOfPropertyAt(c,z,"deltaY");if(n&&C&&S){const Z=this.fontSize*D/1e3;t.save(),t.fillStyle=w,t.translate(W.renderLeft,W.renderTop),t.rotate(W.angle),t.fillRect(-W.kernedWidth/2,l*G+K-a*Z,W.kernedWidth,Z),t.restore()}else if((C!==b||S!==w||G!==_||D!==T||K!==M)&&y>0){const Z=this.fontSize*T/1e3;let L=s+f+m;this.direction===ue&&(L=this.width-L-y),b&&w&&T&&(t.fillStyle=w,t.fillRect(L,A+l*_+M-a*Z,y,Z)),m=W.left,y=W.width,b=C,T=D,w=S,_=G,M=K}else y+=W.kernedWidth}let O=s+f+m;this.direction===ue&&(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(",")||Mt.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 Ni(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([...Fa,...t]),styles:Gu(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=ye(t,Mt.ATTRIBUTE_NAMES,r),{textAnchor:n=Q,textDecoration:o="",dx:a=0,dy:l=0,top:c=0,left:h=0,fontSize:u=Bi,strokeWidth:d=1,...g}={...e,...s},f=new this(Bs(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 w=0;return n===Y&&(w=f.getScaledWidth()/2),n===ft&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(b-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:d}),f}static fromObject(t){return this._fromObject({...t,styles:Nu(t.styles||{},t.text)},{extraParam:"text"})}}v(Mt,"textLayoutProperties",La),v(Mt,"cacheProperties",[...me,...Fa]),v(Mt,"ownDefaults",mu),v(Mt,"type","Text"),v(Mt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Mt,"ATTRIBUTE_NAMES",Oe.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ga(Mt,[class extends Ea{_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:Fr(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="${q(this.fontFamily.replace(Wd,"'"))}" `,`font-size="${q(this.fontSize)}" `,this.fontStyle?`font-style="${q(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${q(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(wn(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=tt.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,i!==i.trim()||!!i.match(Vd)),a=o?`style="${o}"`:"",l=t.deltaY,c=l?` dy="${nt(l,n)}" `:"",{angle:h,renderLeft:u,renderTop:d,width:g}=s;let f="";if(u!==void 0){const m=g/2;h&&(f=` rotate="${nt(Te(h),n)}"`);const y=rr({angle:Te(h)});y[4]=u,y[5]=d;const b=new x(-m,0).transform(y);e=b.x,r=b.y}return`<tspan x="${nt(e,n)}" y="${nt(r,n)}" ${c}${f}${a}>${q(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=hn(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(wn(c,e+l,r,a,n)),l=u,a=d,c=o):a+=g}o&&i.push(wn(c,e+l,r,a,n))}getSvgStyles(i){return`${super.getSvgStyles(i)} text-decoration-thickness: ${nt(this.textDecorationThickness*this.getObjectScaling().y/10,tt.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?Rr(Rt,s):"",r?`stroke-width: ${q(r)}; `:"",e?`font-family: ${e.includes("'")||e.includes('"')?q(e):`'${q(e)}'`}; `:"",o?`font-size: ${q(o)}px; `:"",a?`font-style: ${q(a)}; `:"",l?`font-weight: ${q(l)}; `:"",g?`text-decoration: ${g}; text-decoration-thickness: ${nt(f*this.getObjectScaling().y/10,tt.NUM_FRACTION_DIGITS)}%; `:"",n?Rr(_t,n):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(i){return["overline","underline","line-through"].filter(t=>i[t.replace("-","")]).join(" ")}}]),j.setClass(Mt),j.setSVGClass(Mt);class Xd{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 x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new x(g.left,g.top)),m=a.viewportTransform,y=f.add(u).transform(m,!0),b=o.backgroundColor,w=cn(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=w,o.dirty=!0,mn(C,{position:"fixed",left:-C.width+"px",border:Pt,width:C.width/d+"px",height:C.height/d+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{C.remove()},Gt(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(Cs,{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(Cs,{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 bl=/[ \n\.,;!\?\-]/;class Yd extends Mt{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 Ra({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||!$i.test(r[t-1]))?t-1:t,n=r[s];for(;s>0&&s<r.length&&!bl.test(n);)s+=e,n=r[s];return e===-1&&bl.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;Gt(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===je?Q:ft,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 x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:`${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(ks),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===ft&&(this._selectionDirection=Q,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===Q&&(this._selectionDirection=ft,this.selectionStart=e),this.selectionEnd=r)}}class Ud extends Yd{initHiddenTextarea(){const t=this.canvas&&Gt(this.canvas.getElement())||Ke(),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(Cs),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 w=this.fromStringToGraphemeSelection(s,n,r),T=h>w.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(w.selectionEnd-b,w.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}=se();e&&C.join("")===S.copiedText&&!tt.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}=se();t.copiedText=this.getSelectedText(),tt.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===ft);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const s=this.text.length;this.selectionStart=or(0,this.selectionStart,s),this.selectionEnd=or(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===ft&&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=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 wl=i=>!!i.button;class Gd extends Ud{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 Xd(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&&!wl(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||wl(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(Ut(this.calcTransformMatrix())).add(new x(-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 Zs="moveCursorUp",Js="moveCursorDown",Qs="moveCursorLeft",ti="moveCursorRight",ei="exitEditing",xl=(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])},Nd={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:ei,27:ei,33:Zs,34:Js,35:ti,36:Qs,37:Qs,38:Zs,39:ti,40:Js},keysMapRtl:{9:ei,27:ei,33:Zs,34:Js,35:Qs,36:ti,37:ti,38:Zs,39:Qs,40:Js},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};class oe extends Gd{static getDefaults(){return{...super.getDefaults(),...oe.ownDefaults}}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,{...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 vn&&this.canvas.textEditingManager.remove(this),e instanceof vn&&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=Wt(t.canvas),o=n.getContext("2d"),xl(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=Wt(t.canvas),h=c.getContext("2d");if(xl(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===ue&&(o===ft||o===ie||o===$r?h*=-1:o===Q||o===zs?h=l-(r>0?r:0):o!==Y&&o!==zr||(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),w=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}w=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===ue&&(s===ft||s===ie||s===$r?S=this.width-S-_:s===Q||s===zs?S=r.left+y-C:s!==Y&&s!==zr||(S=r.left+y-C)),t.fillRect(S,r.top+r.topOffset+A,_,D),r.topOffset+=w}}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(oe,"ownDefaults",Nd),v(oe,"type","IText"),j.setClass(oe),j.setClass(oe,"i-text");class He extends oe{static getDefaults(){return{...super.getDefaults(),...He.ownDefaults}}constructor(t,e){super(t,{...He.ownDefaults,...e})}static createControls(){return{controls:Wu()}}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 w;for(g=0,w=0;w<b.length;w++){const{word:T,width:C}=b[w];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 w&&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(He,"type","Textbox"),v(He,"textLayoutProperties",[...oe.textLayoutProperties,"width"]),v(He,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),j.setClass(He);class _l extends Us{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}=pe(Ja(r,s)),l=new x(o,a);if(s.absolutePositioned)return{center:ir(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 x,correction:u=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}v(_l,"type","clip-path"),j.setClass(_l);class Cl extends Us{getInitialSize(t,e){let{target:r}=t,{size:s}=e;return new x(r.width||s.x,r.height||s.y)}}v(Cl,"type","fixed"),j.setClass(Cl);class qd extends Wr{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 Ve extends De{static getDefaults(){return{...super.getDefaults(),...Ve.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,Ve.ownDefaults),this.setOptions(e);const{left:r,top:s,layoutManager:n}=e;this.groupInit(t,{left:r,top:s,layoutManager:n??new qd})}_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))?(Ce("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===gn?r.forEach(s=>{s._onAfterObjectsChange(Xs,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(Ve,"type","ActiveSelection"),v(Ve,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),j.setClass(Ve),j.setClass(Ve,"activeSelection");class Kd{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 Sl{constructor(){let{tileSize:t=tt.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=Wt({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 _n;function Zd(){const{WebGLProbe:i}=se();return i.queryWebGL(fe()),tt.enableGLFiltering&&i.isSupported(tt.textureSize)?new Sl({tileSize:tt.textureSize}):new Kd}function Cn(){return!_n&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(_n=Zd()),_n}const kl=["cropX","cropY"];class St extends ut{static getDefaults(){return{...super.getDefaults(),...St.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,St.ownDefaults),this.setOptions(e),this.cacheKey=`texture${ke()}`,this.setElement(typeof t=="string"?(this.canvas&&Gt(this.canvas.getElement())||Ke()).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=Cn(!1);e instanceof Sl&&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&&se().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([...kl,...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=ke();n.push('<clipPath id="imageCrop_'+c+`">
|
|
93
|
+
`,' <rect x="'+r+'" y="'+s+'" width="'+q(this.width)+'" height="'+q(this.height)+`" />
|
|
139
94
|
`,`</clipPath>
|
|
140
|
-
`),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS"
|
|
141
|
-
`)
|
|
142
|
-
`
|
|
143
|
-
|
|
95
|
+
`),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",`xlink:href="${q(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="${q(this.width)}" height="${q(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 Ps(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=Wt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Cn().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=Wt({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);Cn().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),w=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,g,f,m,y,b,w)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=fu(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=fd(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=pd(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([Ps(n,{...e,crossOrigin:o}),r&&Lr(r,e),s?Lr([s],e):[],As(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 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=ye(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(s["xlink:href"]||s.href,e,s).catch(n=>(Ce("log","Unable to parse Image",n),null))}}v(St,"type","Image"),v(St,"cacheProperties",[...me,...kl]),v(St,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(St,"ATTRIBUTE_NAMES",[...Oe,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),j.setClass(St),j.setSVGClass(St),$s(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ri=i=>i.webgl!==void 0,Sn="precision highp float",Jd=`
|
|
98
|
+
${Sn};
|
|
144
99
|
varying vec2 vTexCoord;
|
|
145
100
|
uniform sampler2D uTexture;
|
|
146
101
|
void main() {
|
|
147
102
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
148
|
-
}
|
|
103
|
+
}`,Qd=new RegExp(Sn,"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 Jd}getVertexSource(){return`
|
|
149
104
|
attribute vec2 aPosition;
|
|
150
105
|
varying vec2 vTexCoord;
|
|
151
106
|
void main() {
|
|
152
107
|
vTexCoord = aPosition;
|
|
153
108
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
154
|
-
}`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:
|
|
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"}}=se();s!=="highp"&&(e=e.replace(Qd,Sn.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 re("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new re(`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 re(`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 re(`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){ri(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=Wt({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 tg={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
155
110
|
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
156
111
|
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
157
112
|
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
@@ -178,7 +133,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
178
133
|
`,tint:`
|
|
179
134
|
gl_FragColor.rgb *= (1.0 - uColor.a);
|
|
180
135
|
gl_FragColor.rgb += uColor.rgb;
|
|
181
|
-
`};class
|
|
136
|
+
`};class Ur extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
|
|
182
137
|
precision highp float;
|
|
183
138
|
uniform sampler2D uTexture;
|
|
184
139
|
uniform vec4 uColor;
|
|
@@ -187,10 +142,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
187
142
|
vec4 color = texture2D(uTexture, vTexCoord);
|
|
188
143
|
gl_FragColor = color;
|
|
189
144
|
if (color.a > 0.0) {
|
|
190
|
-
|
|
145
|
+
${tg[this.mode]}
|
|
191
146
|
}
|
|
192
147
|
}
|
|
193
|
-
`
|
|
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(Ur,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(Ur,"type","BlendColor"),v(Ur,"uniformLocations",["uColor"]),j.setClass(Ur);const eg={multiply:`
|
|
194
149
|
precision highp float;
|
|
195
150
|
uniform sampler2D uTexture;
|
|
196
151
|
uniform sampler2D uImage;
|
|
@@ -216,7 +171,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
216
171
|
color.a = color2.a;
|
|
217
172
|
gl_FragColor = color;
|
|
218
173
|
}
|
|
219
|
-
`}
|
|
174
|
+
`};class Gr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return eg[this.mode]}getVertexSource(){return`
|
|
220
175
|
attribute vec2 aPosition;
|
|
221
176
|
varying vec2 vTexCoord;
|
|
222
177
|
varying vec2 vTexCoord2;
|
|
@@ -226,7 +181,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
226
181
|
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
227
182
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
228
183
|
}
|
|
229
|
-
`}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:
|
|
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=fe());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],w=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*w/255;break;case"mask":e[h+3]=w}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject(t,e){let{type:r,image:s,...n}=t;return St.fromObject(s,e).then(o=>new this({...n,image:o}))}}v(Gr,"type","BlendImage"),v(Gr,"defaults",{mode:"multiply",alpha:1}),v(Gr,"uniformLocations",["uTransformMatrix","uImage"]),j.setClass(Gr);class Nr extends yt{getFragmentSource(){return`
|
|
230
185
|
precision highp float;
|
|
231
186
|
uniform sampler2D uTexture;
|
|
232
187
|
uniform vec2 uDelta;
|
|
@@ -255,7 +210,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
255
210
|
gl_FragColor.rgb = color.rgb / totalC;
|
|
256
211
|
gl_FragColor.a = color.a / totalA;
|
|
257
212
|
}
|
|
258
|
-
`}applyTo(t){
|
|
213
|
+
`}applyTo(t){ri(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 w=b/a,T=4*Math.floor(n*w),C=1-Math.abs(w);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 w=b/a,T=Math.floor(n*w)*l,C=1-Math.abs(w);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(Nr,"type","Blur"),v(Nr,"defaults",{blur:0}),v(Nr,"uniformLocations",["uDelta"]),j.setClass(Nr);class qr extends yt{getFragmentSource(){return`
|
|
259
214
|
precision highp float;
|
|
260
215
|
uniform sampler2D uTexture;
|
|
261
216
|
uniform float uBrightness;
|
|
@@ -265,7 +220,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
265
220
|
color.rgb += uBrightness;
|
|
266
221
|
gl_FragColor = color;
|
|
267
222
|
}
|
|
268
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let
|
|
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(qr,"type","Brightness"),v(qr,"defaults",{brightness:0}),v(qr,"uniformLocations",["uBrightness"]),j.setClass(qr);const Tl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class We extends yt{getFragmentSource(){return`
|
|
269
224
|
precision highp float;
|
|
270
225
|
uniform sampler2D uTexture;
|
|
271
226
|
varying vec2 vTexCoord;
|
|
@@ -276,7 +231,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
276
231
|
color *= uColorMatrix;
|
|
277
232
|
color += uConstants;
|
|
278
233
|
gl_FragColor = color;
|
|
279
|
-
}`}applyTo2d(t){const e=t.imageData.data,r=this.matrix,
|
|
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 Xe(i,t){var e;const r=(v(e=class extends We{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",i),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return j.setClass(r,i),r}v(We,"type","ColorMatrix"),v(We,"defaults",Tl),v(We,"uniformLocations",["uColorMatrix","uConstants"]),j.setClass(We);const rg=Xe("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),sg=Xe("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),ig=Xe("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),ng=Xe("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),og=Xe("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=Xe("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),lg=Xe("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 kn extends yt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ri(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=>j.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}v(kn,"type","Composed"),j.setClass(kn);class Kr extends yt{getFragmentSource(){return`
|
|
280
235
|
precision highp float;
|
|
281
236
|
uniform sampler2D uTexture;
|
|
282
237
|
uniform float uContrast;
|
|
@@ -286,7 +241,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
286
241
|
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
|
287
242
|
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
|
288
243
|
gl_FragColor = color;
|
|
289
|
-
}`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),
|
|
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(Kr,"type","Contrast"),v(Kr,"defaults",{contrast:0}),v(Kr,"uniformLocations",["uContrast"]),j.setClass(Kr);const cg={Convolute_3_1:`
|
|
290
245
|
precision highp float;
|
|
291
246
|
uniform sampler2D uTexture;
|
|
292
247
|
uniform float uMatrix[9];
|
|
@@ -430,7 +385,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
430
385
|
gl_FragColor = color;
|
|
431
386
|
gl_FragColor.a = alpha;
|
|
432
387
|
}
|
|
433
|
-
`};class
|
|
388
|
+
`};class Zr extends yt{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${this.opaque?1:0}`}getFragmentSource(){return cg[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,w,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++)w=D+_-o,b=S+A-o,w<0||w>=l||b<0||b>=a||(T=4*(w*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(Zr,"type","Convolute"),v(Zr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(Zr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),j.setClass(Zr);const Ol="Gamma";class Jr extends yt{getFragmentSource(){return`
|
|
434
389
|
precision highp float;
|
|
435
390
|
uniform sampler2D uTexture;
|
|
436
391
|
uniform vec3 uGamma;
|
|
@@ -444,7 +399,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
444
399
|
gl_FragColor = color;
|
|
445
400
|
gl_FragColor.rgb *= color.a;
|
|
446
401
|
}
|
|
447
|
-
`}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,
|
|
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:Ol,gamma:this.gamma.concat()}}}v(Jr,"type",Ol),v(Jr,"defaults",{gamma:[1,1,1]}),v(Jr,"uniformLocations",["uGamma"]),j.setClass(Jr);const hg={average:`
|
|
448
403
|
precision highp float;
|
|
449
404
|
uniform sampler2D uTexture;
|
|
450
405
|
varying vec2 vTexCoord;
|
|
@@ -473,7 +428,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
473
428
|
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
474
429
|
gl_FragColor = vec4(average, average, average, col.a);
|
|
475
430
|
}
|
|
476
|
-
`};class
|
|
431
|
+
`};class Qr 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 hg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(Qr,"type","Grayscale"),v(Qr,"defaults",{mode:"average"}),v(Qr,"uniformLocations",["uMode"]),j.setClass(Qr);const ug={...Tl,rotation:0};class si extends We{calculateMatrix(){const t=this.rotation*Math.PI,e=de(t),r=ge(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(si,"type","HueRotation"),v(si,"defaults",ug),j.setClass(si);class ts extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r=0;r<e.length;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2],this.alpha&&(e[r+3]=255-e[r+3])}getFragmentSource(){return`
|
|
477
432
|
precision highp float;
|
|
478
433
|
uniform sampler2D uTexture;
|
|
479
434
|
uniform int uInvert;
|
|
@@ -491,7 +446,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
491
446
|
gl_FragColor = color;
|
|
492
447
|
}
|
|
493
448
|
}
|
|
494
|
-
`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}
|
|
449
|
+
`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}v(ts,"type","Invert"),v(ts,"defaults",{alpha:!1,invert:!0}),v(ts,"uniformLocations",["uInvert","uAlpha"]),j.setClass(ts);class es extends yt{getFragmentSource(){return`
|
|
495
450
|
precision highp float;
|
|
496
451
|
uniform sampler2D uTexture;
|
|
497
452
|
uniform float uStepH;
|
|
@@ -506,7 +461,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
506
461
|
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
|
507
462
|
gl_FragColor = color;
|
|
508
463
|
}
|
|
509
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let
|
|
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(es,"type","Noise"),v(es,"defaults",{noise:0}),v(es,"uniformLocations",["uNoise","uSeed"]),j.setClass(es);class rs extends yt{applyTo2d(t){let{imageData:{data:e,width:r,height:s}}=t;for(let n=0;n<s;n+=this.blocksize)for(let o=0;o<r;o+=this.blocksize){const a=4*n*r+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=n;d<Math.min(n+this.blocksize,s);d++)for(let g=o;g<Math.min(o+this.blocksize,r);g++){const f=4*d*r+4*g;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
|
510
465
|
precision highp float;
|
|
511
466
|
uniform sampler2D uTexture;
|
|
512
467
|
uniform float uBlocksize;
|
|
@@ -524,7 +479,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
524
479
|
vec4 color = texture2D(uTexture, squareCoords);
|
|
525
480
|
gl_FragColor = color;
|
|
526
481
|
}
|
|
527
|
-
`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}
|
|
482
|
+
`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}v(rs,"type","Pixelate"),v(rs,"defaults",{blocksize:4}),v(rs,"uniformLocations",["uBlocksize"]),j.setClass(rs);class ss extends yt{getFragmentSource(){return`
|
|
528
483
|
precision highp float;
|
|
529
484
|
uniform sampler2D uTexture;
|
|
530
485
|
uniform vec4 uLow;
|
|
@@ -536,23 +491,23 @@ void main() {
|
|
|
536
491
|
gl_FragColor.a = 0.0;
|
|
537
492
|
}
|
|
538
493
|
}
|
|
539
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,
|
|
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(ss,"type","RemoveColor"),v(ss,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(ss,"uniformLocations",["uLow","uHigh"]),j.setClass(ss);class is extends yt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return`${this.type}_${t}`}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),s=new Array(r);for(let n=1;n<=r;n++)s[n-1]=t(n*e);return s}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]=`${r}.0 * uDelta`;return`
|
|
540
495
|
precision highp float;
|
|
541
496
|
uniform sampler2D uTexture;
|
|
542
497
|
uniform vec2 uDelta;
|
|
543
498
|
varying vec2 vTexCoord;
|
|
544
|
-
uniform float uTaps[
|
|
499
|
+
uniform float uTaps[${t}];
|
|
545
500
|
void main() {
|
|
546
501
|
vec4 color = texture2D(uTexture, vTexCoord);
|
|
547
502
|
float sum = 1.0;
|
|
548
|
-
|
|
549
|
-
color += texture2D(uTexture, vTexCoord +
|
|
550
|
-
sum += 2.0 * uTaps[
|
|
551
|
-
`)
|
|
552
|
-
`)
|
|
503
|
+
${e.map((r,s)=>`
|
|
504
|
+
color += texture2D(uTexture, vTexCoord + ${r}) * uTaps[${s}] + texture2D(uTexture, vTexCoord - ${r}) * uTaps[${s}];
|
|
505
|
+
sum += 2.0 * uTaps[${s}];
|
|
506
|
+
`).join(`
|
|
507
|
+
`)}
|
|
553
508
|
gl_FragColor = color / sum;
|
|
554
509
|
}
|
|
555
|
-
`
|
|
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){ri(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=fe());const b=d.sliceByTwo;(b.width<1.5*e||b.height<r)&&(b.width=1.5*e,b.height=r);const w=b.getContext("2d");for(w.clearRect(0,0,1.5*e,r),w.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),w.drawImage(b,g,f,e,r,m,y,h,u),g=m,f=y,y+=u;return w.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},w={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,w.x=Math.floor(b.x),S=0;S<n;S++){for(b.y=(S+.5)*u,w.y=Math.floor(b.y),M=0,O=0,V=0,z=0,X=0,D=w.x-f;D<=w.x+f;D++)if(!(D<0||D>=e)){W=Math.floor(1e3*Math.abs(D-b.x)),y[W]||(y[W]={});for(let K=w.y-m;K<=w.y+m;K++)K<0||K>=r||(G=Math.floor(1e3*Math.abs(K-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*(K*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,w,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,w=4*(u*e+h),y=0;y<4;y++)o=A[w+y],a=A[w+4+y],l=A[w+D+y],c=A[w+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,w=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],w+=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/w}return u}}v(is,"type","Resize"),v(is,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(is,"uniformLocations",["uDelta","uTaps"]),j.setClass(is);class ns extends yt{getFragmentSource(){return`
|
|
556
511
|
precision highp float;
|
|
557
512
|
uniform sampler2D uTexture;
|
|
558
513
|
uniform float uSaturation;
|
|
@@ -566,7 +521,7 @@ void main() {
|
|
|
566
521
|
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
|
567
522
|
gl_FragColor = color;
|
|
568
523
|
}
|
|
569
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let
|
|
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(ns,"type","Saturation"),v(ns,"defaults",{saturation:0}),v(ns,"uniformLocations",["uSaturation"]),j.setClass(ns);class os extends yt{getFragmentSource(){return`
|
|
570
525
|
precision highp float;
|
|
571
526
|
uniform sampler2D uTexture;
|
|
572
527
|
uniform float uVibrance;
|
|
@@ -581,6 +536,6 @@ void main() {
|
|
|
581
536
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
582
537
|
gl_FragColor = color;
|
|
583
538
|
}
|
|
584
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let i=0;i<e.length;i+=4){const s=e[i],o=e[i+1],a=e[i+2],l=Math.max(s,o,a),c=(s+o+a)/3,h=2*Math.abs(l-c)/255*r;e[i]+=l!==s?(l-s)*h:0,e[i+1]+=l!==o?(l-o)*h:0,e[i+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}p(_i,"type","Vibrance"),p(_i,"defaults",{vibrance:0}),p(_i,"uniformLocations",["uVibrance"]),E.setClass(_i);const bu=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],yu=[2,4,6,8],_u=({screenshot:n,onSave:t,onCancel:e})=>{const r=St(null),i=St(null),s=St(null),[o,a]=rt("select"),[l,c]=rt("#ef4444"),[h,u]=rt(4),[d,g]=rt(!1),[f,m]=rt(!1),[b,y]=rt(1),[w,O]=rt(!1),k=St([]),S=St(-1),C=St(!1),A=St(!1),D=St(null),L=St(null);Ft(()=>{if(!r.current)return;const T=new Cs(r.current,{isDrawingMode:!1,selection:!0});return s.current=T,Ot.fromURL(n).then(F=>{var mt;L.current={width:F.width||800,height:F.height||600};const P=(mt=i.current)==null?void 0:mt.getBoundingClientRect(),B=P?P.width-32:800,$=P?P.height-32:600,q=Math.min(B/(F.width||800),$/(F.height||600));T.setDimensions({width:(F.width||800)*q,height:(F.height||600)*q}),F.scaleToWidth(T.width),T.backgroundImage=F,T.renderAll(),R()}),T.freeDrawingBrush=new Jr(T),T.freeDrawingBrush.color=l,T.freeDrawingBrush.width=h,T.on("object:added",()=>{C.current||R()}),T.on("path:created",()=>{R()}),()=>{T.dispose()}},[n]),Ft(()=>{if(!s.current)return;const T=s.current;T.freeDrawingBrush&&(T.freeDrawingBrush.color=l,T.freeDrawingBrush.width=h)},[l,h]),Ft(()=>{if(!s.current)return;const T=s.current;T.isDrawingMode=o==="pen",T.selection=o==="select",o==="select"?T.defaultCursor="default":T.defaultCursor="crosshair"},[o]);const R=Y(()=>{if(!s.current)return;const T=JSON.stringify(s.current.toJSON());k.current=k.current.slice(0,S.current+1),k.current.push(T),S.current=k.current.length-1,g(S.current>0),m(!1)},[]),H=Y(()=>{if(!s.current||S.current<=0)return;S.current--;const T=k.current[S.current];s.current.loadFromJSON(JSON.parse(T)).then(()=>{var F;(F=s.current)==null||F.renderAll(),g(S.current>0),m(S.current<k.current.length-1)})},[]),I=Y(()=>{if(!s.current||S.current>=k.current.length-1)return;S.current++;const T=k.current[S.current];s.current.loadFromJSON(JSON.parse(T)).then(()=>{var F;(F=s.current)==null||F.renderAll(),g(S.current>0),m(S.current<k.current.length-1)})},[]),M=Y(T=>{if(!s.current||o==="pen"||o==="select")return;C.current=!0;const F=s.current,P=F.getViewportPoint(T.e);let B=null;switch(o){case"rectangle":B=new Tt({left:P.x,top:P.y,width:0,height:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!0});break;case"circle":B=new Vt({left:P.x,top:P.y,rx:0,ry:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!0});break;case"arrow":B=new ae([P.x,P.y,P.x,P.y],{stroke:l,strokeWidth:h,selectable:!0});break;case"text":B=new qt("Text",{left:P.x,top:P.y,fontSize:20,fill:l,selectable:!0,editable:!0}),F.add(B),F.setActiveObject(B),B.enterEditing(),C.current=!1;return;case"blur":B=new Tt({left:P.x,top:P.y,width:0,height:0,fill:"rgba(128, 128, 128, 0.8)",stroke:"#666",strokeWidth:1,selectable:!0});break}B&&(B._startPoint={x:P.x,y:P.y},F.add(B),F.setActiveObject(B))},[o,l,h]),j=Y(T=>{if(!s.current||!C.current)return;const F=s.current,P=F.getActiveObject();if(!P||!P._startPoint)return;const B=F.getViewportPoint(T.e),$=P._startPoint;if(P instanceof Tt){const q=B.x-$.x,mt=B.y-$.y;P.set({left:q>0?$.x:B.x,top:mt>0?$.y:B.y,width:Math.abs(q),height:Math.abs(mt)})}else if(P instanceof Vt){const q=Math.abs(B.x-$.x)/2,mt=Math.abs(B.y-$.y)/2;P.set({left:Math.min($.x,B.x),top:Math.min($.y,B.y),rx:q,ry:mt})}else P instanceof ae&&P.set({x2:B.x,y2:B.y});F.renderAll()},[]),z=Y(()=>{C.current&&(C.current=!1,R())},[R]);Ft(()=>{if(!s.current)return;const T=s.current;return T.on("mouse:down",M),T.on("mouse:move",j),T.on("mouse:up",z),()=>{T.off("mouse:down",M),T.off("mouse:move",j),T.off("mouse:up",z)}},[M,j,z]);const V=Y(()=>{var dt;if(!s.current)return;const T=s.current,F=T.getZoom(),P=((dt=T.viewportTransform)==null?void 0:dt.slice())||[1,0,0,1,0,0];T.setZoom(1),T.setViewportTransform([1,0,0,1,0,0]),T.renderAll();const B=L.current,$=B?B.width/(T.width||1):1,q=T.toDataURL({format:"png",quality:1,multiplier:$});T.setZoom(F),T.setViewportTransform(P),T.renderAll();const le=T.getObjects().map(Zd=>Zd.toObject());t(q,{objects:le})},[t]),tt=Y(()=>{if(!s.current)return;const T=s.current,F=T.getActiveObjects();F.length>0&&(F.forEach(P=>T.remove(P)),T.discardActiveObject(),T.renderAll(),R())},[R]),N=Y(()=>{if(!s.current)return;const T=s.current,F=Math.min(b*1.2,3),P=new x(T.width/2,T.height/2);T.zoomToPoint(P,F),y(F)},[b]),Ct=Y(()=>{if(!s.current)return;const T=s.current,F=Math.max(b/1.2,.5),P=new x(T.width/2,T.height/2);T.zoomToPoint(P,F),y(F)},[b]),Mt=Y(()=>{if(!s.current)return;const T=s.current;y(1),T.setZoom(1),T.setViewportTransform([1,0,0,1,0,0]),T.renderAll()},[]);Ft(()=>{if(!s.current)return;const T=s.current,F=$=>{const q=$.e;(q.buttons===2||q.buttons===1&&w)&&(q.preventDefault(),A.current=!0,T.selection=!1,D.current={x:q.clientX,y:q.clientY},T.setCursor("grabbing"))},P=$=>{if(A.current&&D.current){const q=$.e,mt=T.viewportTransform;mt[4]+=q.clientX-D.current.x,mt[5]+=q.clientY-D.current.y,T.requestRenderAll(),D.current={x:q.clientX,y:q.clientY}}},B=()=>{A.current&&(A.current=!1,D.current=null,T.setCursor(w?"grab":"default"))};return T.on("mouse:down",F),T.on("mouse:move",P),T.on("mouse:up",B),()=>{T.off("mouse:down",F),T.off("mouse:move",P),T.off("mouse:up",B)}},[w]),Ft(()=>{const T=P=>{if(P.key===" "&&!w&&(P.preventDefault(),O(!0),s.current&&s.current.setCursor("grab")),P.key==="Delete"||P.key==="Backspace"){const B=document.activeElement;(B==null?void 0:B.tagName)!=="INPUT"&&(B==null?void 0:B.tagName)!=="TEXTAREA"&&tt()}(P.ctrlKey||P.metaKey)&&P.key==="z"&&(P.preventDefault(),P.shiftKey?I():H())},F=P=>{P.key===" "&&w&&(O(!1),s.current&&s.current.setCursor("default"))};return window.addEventListener("keydown",T),window.addEventListener("keyup",F),()=>{window.removeEventListener("keydown",T),window.removeEventListener("keyup",F)}},[tt,H,I,w]);const ct=({tool:T,icon:F,label:P})=>_("button",{class:`bugpin-tool-btn ${o===T?"active":""}`,onClick:()=>a(T),title:P,children:_("span",{dangerouslySetInnerHTML:{__html:F}})});return _("div",{class:"bugpin-annotation-container",children:[_("div",{class:"bugpin-annotation-toolbar",children:[_("div",{class:"bugpin-tool-group",children:[_(ct,{tool:"select",label:"Select",icon:'<svg viewBox="0 0 24 24"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z" fill="currentColor"/></svg>'}),_(ct,{tool:"pen",label:"Pen",icon:'<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>'}),_(ct,{tool:"arrow",label:"Arrow",icon:'<svg viewBox="0 0 24 24"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" fill="currentColor"/></svg>'}),_(ct,{tool:"rectangle",label:"Rectangle",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),_(ct,{tool:"circle",label:"Circle",icon:'<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),_(ct,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),_(ct,{tool:"blur",label:"Blur/Mask",icon:'<svg viewBox="0 0 24 24"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z" fill="currentColor"/></svg>'})]}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-color-picker",children:bu.map(T=>_("button",{class:`bugpin-color-btn ${l===T?"active":""}`,style:{backgroundColor:T},onClick:()=>c(T),title:T},T))}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-stroke-picker",children:yu.map(T=>_("button",{class:`bugpin-stroke-btn ${h===T?"active":""}`,onClick:()=>u(T),title:`${T}px`,children:_("span",{style:{height:`${T}px`}})},T))}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-tool-group",children:[_("button",{class:"bugpin-tool-btn",onClick:H,disabled:!d,title:"Undo (Ctrl+Z)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:I,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:tt,title:"Delete selected (Del)",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]}),_("div",{class:"bugpin-tool-divider"}),_("div",{class:"bugpin-tool-group",children:[_("button",{class:"bugpin-tool-btn",onClick:Ct,disabled:b<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:Mt,title:`Reset Zoom (${Math.round(b*100)}%) - Hold Space to pan`,children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z",fill:"currentColor"})})}),_("button",{class:"bugpin-tool-btn",onClick:N,disabled:b>=3,title:"Zoom In - Hold Space to pan when zoomed",children:_("svg",{viewBox:"0 0 24 24",children:_("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z",fill:"currentColor"})})})]})]}),_("div",{class:"bugpin-canvas-wrapper",ref:i,children:_("canvas",{ref:r})}),_("div",{class:"bugpin-annotation-actions",children:[_("button",{class:"bugpin-btn-cancel",onClick:e,children:"Cancel"}),_("button",{class:"bugpin-btn-submit",onClick:V,children:"Done"})]})]})};function xu(n,t){if(n.match(/^[a-z]+:\/\//i))return n;if(n.match(/^\/\//))return window.location.protocol+n;if(n.match(/^[a-z]+:/i))return n;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),i=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(i),t&&(r.href=t),i.href=n,i.href}const wu=(()=>{let n=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(n+=1,`u${t()}${n}`)})();function pe(n){const t=[];for(let e=0,r=n.length;e<r;e++)t.push(n[e]);return t}let Xe=null;function ga(n={}){return Xe||(n.includeStyleProperties?(Xe=n.includeStyleProperties,Xe):(Xe=pe(window.getComputedStyle(document.documentElement)),Xe))}function xi(n,t){const r=(n.ownerDocument.defaultView||window).getComputedStyle(n).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Cu(n){const t=xi(n,"border-left-width"),e=xi(n,"border-right-width");return n.clientWidth+t+e}function Su(n){const t=xi(n,"border-top-width"),e=xi(n,"border-bottom-width");return n.clientHeight+t+e}function fa(n,t={}){const e=t.width||Cu(n),r=t.height||Su(n);return{width:e,height:r}}function Tu(){let n,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(n=parseInt(e,10),Number.isNaN(n)&&(n=1)),n||window.devicePixelRatio||1}const Dt=16384;function ku(n){(n.width>Dt||n.height>Dt)&&(n.width>Dt&&n.height>Dt?n.width>n.height?(n.height*=Dt/n.width,n.width=Dt):(n.width*=Dt/n.height,n.height=Dt):n.width>Dt?(n.height*=Dt/n.width,n.width=Dt):(n.width*=Dt/n.height,n.height=Dt))}function wi(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=n})}async function Ou(n){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(n)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Du(n,t,e){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${e}`),i.setAttribute("viewBox",`0 0 ${t} ${e}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(n),Ou(i)}const wt=(n,t)=>{if(n instanceof t)return!0;const e=Object.getPrototypeOf(n);return e===null?!1:e.constructor.name===t.name||wt(e,t)};function Mu(n){const t=n.getPropertyValue("content");return`${n.cssText} content: '${t.replace(/'|"/g,"")}';`}function Eu(n,t){return ga(t).map(e=>{const r=n.getPropertyValue(e),i=n.getPropertyPriority(e);return`${e}: ${r}${i?" !important":""};`}).join(" ")}function Pu(n,t,e,r){const i=`.${n}:${t}`,s=e.cssText?Mu(e):Eu(e,r);return document.createTextNode(`${i}{${s}}`)}function pa(n,t,e,r){const i=window.getComputedStyle(n,e),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=wu();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Pu(o,e,i,r)),t.appendChild(a)}function Au(n,t,e){pa(n,t,":before",e),pa(n,t,":after",e)}const ma="application/font-woff",va="image/jpeg",ju={woff:ma,woff2:ma,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:va,jpeg:va,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Lu(n){const t=/\.([^./]*?)$/g.exec(n);return t?t[1]:""}function As(n){const t=Lu(n).toLowerCase();return ju[t]||""}function Fu(n){return n.split(/,/)[1]}function js(n){return n.search(/^(data:)/)!==-1}function Ru(n,t){return`data:${t};base64,${n}`}async function ba(n,t,e){const r=await fetch(n,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(i)})}const Ls={};function Bu(n,t,e){let r=n.replace(/\?.*/,"");return e&&(r=n),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Fs(n,t,e){const r=Bu(n,t,e.includeQueryParams);if(Ls[r]!=null)return Ls[r];e.cacheBust&&(n+=(/\?/.test(n)?"&":"?")+new Date().getTime());let i;try{const s=await ba(n,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Fu(a)));i=Ru(s,t)}catch(s){i=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${n}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return Ls[r]=i,i}async function Iu(n){const t=n.toDataURL();return t==="data:,"?n.cloneNode(!1):wi(t)}async function Hu(n,t){if(n.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=n.clientWidth,s.height=n.clientHeight,o==null||o.drawImage(n,0,0,s.width,s.height);const a=s.toDataURL();return wi(a)}const e=n.poster,r=As(e),i=await Fs(e,r,t);return wi(i)}async function zu(n,t){var e;try{if(!((e=n==null?void 0:n.contentDocument)===null||e===void 0)&&e.body)return await Ci(n.contentDocument.body,t,!0)}catch{}return n.cloneNode(!1)}async function Wu(n,t){return wt(n,HTMLCanvasElement)?Iu(n):wt(n,HTMLVideoElement)?Hu(n,t):wt(n,HTMLIFrameElement)?zu(n,t):n.cloneNode(ya(n))}const Vu=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SLOT",ya=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SVG";async function Xu(n,t,e){var r,i;if(ya(t))return t;let s=[];return Vu(n)&&n.assignedNodes?s=pe(n.assignedNodes()):wt(n,HTMLIFrameElement)&&(!((r=n.contentDocument)===null||r===void 0)&&r.body)?s=pe(n.contentDocument.body.childNodes):s=pe(((i=n.shadowRoot)!==null&&i!==void 0?i:n).childNodes),s.length===0||wt(n,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Ci(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function Yu(n,t,e){const r=t.style;if(!r)return;const i=window.getComputedStyle(n);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):ga(e).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),wt(n,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function Uu(n,t){wt(n,HTMLTextAreaElement)&&(t.innerHTML=n.value),wt(n,HTMLInputElement)&&t.setAttribute("value",n.value)}function Gu(n,t){if(wt(n,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(i=>n.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function Nu(n,t,e){return wt(t,Element)&&(Yu(n,t,e),Au(n,t,e),Uu(n,t),Gu(n,t)),t}async function $u(n,t){const e=n.querySelectorAll?n.querySelectorAll("use"):[];if(e.length===0)return n;const r={};for(let s=0;s<e.length;s++){const a=e[s].getAttribute("xlink:href");if(a){const l=n.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await Ci(c,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<i.length;l++)a.appendChild(i[l]);n.appendChild(o)}return n}async function Ci(n,t,e){return!e&&t.filter&&!t.filter(n)?null:Promise.resolve(n).then(r=>Wu(r,t)).then(r=>Xu(n,r,t)).then(r=>Nu(n,r,t)).then(r=>$u(r,t))}const _a=/url\((['"]?)([^'"]+?)\1\)/g,qu=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ku=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Zu(n){const t=n.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ju(n){const t=[];return n.replace(_a,(e,r,i)=>(t.push(i),e)),t.filter(e=>!js(e))}async function Qu(n,t,e,r,i){try{const s=e?xu(t,e):t,o=As(t);let a;return i||(a=await Fs(s,o,r)),n.replace(Zu(t),`$1${a}$3`)}catch{}return n}function td(n,{preferredFontFormat:t}){return t?n.replace(Ku,e=>{for(;;){const[r,,i]=qu.exec(e)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):n}function xa(n){return n.search(_a)!==-1}async function wa(n,t,e){if(!xa(n))return n;const r=td(n,e);return Ju(r).reduce((s,o)=>s.then(a=>Qu(a,o,t,e)),Promise.resolve(r))}async function Ye(n,t,e){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(n);if(i){const s=await wa(i,null,e);return t.style.setProperty(n,s,t.style.getPropertyPriority(n)),!0}return!1}async function ed(n,t){await Ye("background",n,t)||await Ye("background-image",n,t),await Ye("mask",n,t)||await Ye("-webkit-mask",n,t)||await Ye("mask-image",n,t)||await Ye("-webkit-mask-image",n,t)}async function rd(n,t){const e=wt(n,HTMLImageElement);if(!(e&&!js(n.src))&&!(wt(n,SVGImageElement)&&!js(n.href.baseVal)))return;const r=e?n.src:n.href.baseVal,i=await Fs(r,As(r),t);await new Promise((s,o)=>{n.onload=s,n.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=n;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),e?(n.srcset="",n.src=i):n.href.baseVal=i})}async function id(n,t){const r=pe(n.childNodes).map(i=>Ca(i,t));await Promise.all(r).then(()=>n)}async function Ca(n,t){wt(n,Element)&&(await ed(n,t),await rd(n,t),await id(n,t))}function sd(n,t){const{style:e}=n;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{e[i]=r[i]}),n}const Sa={};async function Ta(n){let t=Sa[n];if(t!=null)return t;const r=await(await fetch(n)).text();return t={url:n,cssText:r},Sa[n]=t,t}async function ka(n,t){let e=n.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,n.url).href),ba(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>e)}function Oa(n){if(n==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=n.replace(e,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function nd(n,t){const e=[],r=[];return n.forEach(i=>{if("cssRules"in i)try{pe(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,c=Ta(l).then(h=>ka(h,t)).then(h=>Oa(h).forEach(u=>{try{i.insertRule(u,u.startsWith("@import")?a+=1:i.cssRules.length)}catch(d){console.error("Error inserting rule from remote css",{rule:u,error:d})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(s){const o=n.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(Ta(i.href).then(a=>ka(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",s)}}),Promise.all(r).then(()=>(n.forEach(i=>{if("cssRules"in i)try{pe(i.cssRules||[]).forEach(s=>{e.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),e))}function od(n){return n.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>xa(t.style.getPropertyValue("src")))}async function ad(n,t){if(n.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=pe(n.ownerDocument.styleSheets),r=await nd(e,t);return od(r)}function Da(n){return n.trim().replace(/["']/g,"")}function ld(n){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(Da(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&e(s)})}return e(n),t}async function cd(n,t){const e=await ad(n,t),r=ld(n);return(await Promise.all(e.filter(s=>r.has(Da(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return wa(s.cssText,o,t)}))).join(`
|
|
585
|
-
`)}async function hd(n,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await cd(n,t);if(e){const r=document.createElement("style"),i=document.createTextNode(e);r.appendChild(i),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)}}async function ud(n,t={}){const{width:e,height:r}=fa(n,t),i=await Ci(n,t,!0);return await hd(i,t),await Ca(i,t),sd(i,t),await Du(i,e,r)}async function dd(n,t={}){const{width:e,height:r}=fa(n,t),i=await ud(n,t),s=await wi(i),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Tu(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||ku(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function gd(){try{const n=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1}),t=document.createElement("video");t.srcObject=n,t.autoplay=!0,await new Promise(i=>{t.onloadedmetadata=()=>i()}),await new Promise(i=>setTimeout(i,100));const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;const r=e.getContext("2d");if(!r)throw new Error("Failed to get canvas context");return r.drawImage(t,0,0),n.getTracks().forEach(i=>i.stop()),e.toDataURL("image/png")}catch(n){throw n instanceof Error&&n.name==="NotAllowedError"?new Error("Screen capture permission denied"):n}}async function fd(n="visible",t,e=!1){if(e)return gd();let r;switch(n){case"element":throw new Error("Selector required for element capture");case"fullpage":r=document.documentElement;break;case"visible":default:r=document.documentElement;break}const i=document.getElementById("bugpin-widget");i&&(i.style.display="none");let s={};if(n==="visible"&&r===document.documentElement){const o=document.documentElement,a=window.getComputedStyle(document.body);s={background:o.style.background||void 0,minHeight:o.style.minHeight||void 0,minWidth:o.style.minWidth||void 0},o.style.minWidth="100vw",o.style.minHeight="100vh",o.style.background=a.backgroundColor||a.background||"#ffffff"}try{const a={cacheBust:!0,quality:1,pixelRatio:window.devicePixelRatio||1,skipAutoScale:!0,filter:c=>!(c instanceof HTMLElement&&(c.tagName==="SCRIPT"||c.id==="bugpin-widget"))};return n==="visible"&&(a.width=window.innerWidth,a.height=window.innerHeight,console.log("[BugPin] Capturing element:",r.tagName),console.log("[BugPin] Element dimensions:",{scrollWidth:r.scrollWidth,scrollHeight:r.scrollHeight,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),console.log("[BugPin] Viewport dimensions:",{innerWidth:window.innerWidth,innerHeight:window.innerHeight}),console.log("[BugPin] Capture options:",a)),(await dd(r,a)).toDataURL("image/png")}finally{if(n==="visible"&&r===document.documentElement){const o=document.documentElement;s.background!==void 0?o.style.background=s.background:o.style.removeProperty("background"),s.minHeight!==void 0?o.style.minHeight=s.minHeight:o.style.removeProperty("min-height"),s.minWidth!==void 0?o.style.minWidth=s.minWidth:o.style.removeProperty("min-width")}i&&(i.style.display="")}}function Ma(n){const t=n.split(","),e=t[0].match(/:(.*?);/),r=e?e[1]:"image/png",i=atob(t[1]),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return new Blob([s],{type:r})}function Ea(n){return n.startsWith("data:image/webp")?"webp":n.startsWith("data:image/jpeg")?"jpg":n.startsWith("data:image/gif")?"gif":"png"}const Ue=[];let Pa=!1;function pd(){if(Pa)return;Pa=!0;const n=console.error;console.error=(...r)=>{Ue.push({type:"error",message:r.map(i=>String(i)).join(" "),timestamp:new Date().toISOString()}),n.apply(console,r)};const t=console.warn;console.warn=(...r)=>{Ue.push({type:"warn",message:r.map(i=>String(i)).join(" "),timestamp:new Date().toISOString()}),t.apply(console,r)};const e=window.onerror;window.onerror=(r,i,s,o,a)=>(Ue.push({type:"error",message:String(r),source:i||void 0,line:s||void 0,timestamp:new Date().toISOString()}),e?e.apply(window,[r,i,s,o,a]):!1),window.addEventListener("unhandledrejection",r=>{Ue.push({type:"error",message:`Unhandled Promise Rejection: ${String(r.reason)}`,timestamp:new Date().toISOString()})})}function md(){var r,i,s,o,a;const n=navigator.userAgent;let t="Unknown",e="";return n.includes("Firefox/")?(t="Firefox",e=((r=n.match(/Firefox\/([\d.]+)/))==null?void 0:r[1])||""):n.includes("Edg/")?(t="Edge",e=((i=n.match(/Edg\/([\d.]+)/))==null?void 0:i[1])||""):n.includes("Chrome/")?(t="Chrome",e=((s=n.match(/Chrome\/([\d.]+)/))==null?void 0:s[1])||""):n.includes("Safari/")&&!n.includes("Chrome")?(t="Safari",e=((o=n.match(/Version\/([\d.]+)/))==null?void 0:o[1])||""):(n.includes("Opera/")||n.includes("OPR/"))&&(t="Opera",e=((a=n.match(/(?:Opera|OPR)\/([\d.]+)/))==null?void 0:a[1])||""),{name:t,version:e,userAgent:n}}function vd(){var i,s,o,a,l;const n=navigator.userAgent;let t="desktop",e="Unknown",r;if(/Mobi|Android|iPhone|iPad|iPod/i.test(n)&&(/iPad|Tablet/i.test(n)||window.innerWidth>=768&&/Android/i.test(n)?t="tablet":t="mobile"),n.includes("Windows")){e="Windows";const c=n.match(/Windows NT ([\d.]+)/);if(c){const h=c[1];r={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista"}[h]||h}}else n.includes("Mac OS X")?(e="macOS",r=(s=(i=n.match(/Mac OS X ([\d._]+)/))==null?void 0:i[1])==null?void 0:s.replace(/_/g,".")):n.includes("Linux")?(e=n.includes("Android")?"Android":"Linux",e==="Android"&&(r=(o=n.match(/Android ([\d.]+)/))==null?void 0:o[1])):(n.includes("iPhone")||n.includes("iPad"))&&(e="iOS",r=(l=(a=n.match(/OS ([\d_]+)/))==null?void 0:a[1])==null?void 0:l.replace(/_/g,"."));return{type:t,os:e,osVersion:r}}function bd(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function yd(){try{const n=performance.getEntriesByType("navigation");if(n.length>0){const t=n[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function _d(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:md(),device:vd(),viewport:bd(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:yd(),consoleErrors:Ue.length>0?[...Ue]:void 0}}pd();const Rs=(n,t)=>t.some(e=>n instanceof e);let Aa,ja;function xd(){return Aa||(Aa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function wd(){return ja||(ja=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Bs=new WeakMap,Is=new WeakMap,Si=new WeakMap;function Cd(n){const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",o)},s=()=>{e(Se(n.result)),i()},o=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",o)});return Si.set(t,n),t}function Sd(n){if(Bs.has(n))return;const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",o),n.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",o),n.addEventListener("abort",o)});Bs.set(n,t)}let Hs={get(n,t,e){if(n instanceof IDBTransaction){if(t==="done")return Bs.get(n);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Se(n[t])},set(n,t,e){return n[t]=e,!0},has(n,t){return n instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in n}};function La(n){Hs=n(Hs)}function Td(n){return wd().includes(n)?function(...t){return n.apply(zs(this),t),Se(this.request)}:function(...t){return Se(n.apply(zs(this),t))}}function kd(n){return typeof n=="function"?Td(n):(n instanceof IDBTransaction&&Sd(n),Rs(n,xd())?new Proxy(n,Hs):n)}function Se(n){if(n instanceof IDBRequest)return Cd(n);if(Is.has(n))return Is.get(n);const t=kd(n);return t!==n&&(Is.set(n,t),Si.set(t,n)),t}const zs=n=>Si.get(n);function Od(n,t,{blocked:e,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(n,t),a=Se(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Se(o.result),l.oldVersion,l.newVersion,Se(o.transaction),l)}),e&&o.addEventListener("blocked",l=>e(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),i&&l.addEventListener("versionchange",c=>i(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Dd=["get","getKey","getAll","getAllKeys","count"],Md=["put","add","delete","clear"],Ws=new Map;function Fa(n,t){if(!(n instanceof IDBDatabase&&!(t in n)&&typeof t=="string"))return;if(Ws.get(t))return Ws.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,i=Md.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Dd.includes(e)))return;const s=async function(o,...a){const l=this.transaction(o,i?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[e](...a),i&&l.done]))[0]};return Ws.set(t,s),s}La(n=>({...n,get:(t,e,r)=>Fa(t,e)||n.get(t,e,r),has:(t,e)=>!!Fa(t,e)||n.has(t,e)}));const Ed=["continue","continuePrimaryKey","advance"],Ra={},Vs=new WeakMap,Ba=new WeakMap,Pd={get(n,t){if(!Ed.includes(t))return n[t];let e=Ra[t];return e||(e=Ra[t]=function(...r){Vs.set(this,Ba.get(this)[t](...r))}),e}};async function*Ad(...n){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...n)),!t)return;t=t;const e=new Proxy(t,Pd);for(Ba.set(e,t),Si.set(e,zs(t));t;)yield e,t=await(Vs.get(e)||t.continue()),Vs.delete(e)}function Ia(n,t){return t===Symbol.asyncIterator&&Rs(n,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Rs(n,[IDBIndex,IDBObjectStore])}La(n=>({...n,get(t,e,r){return Ia(t,e)?Ad:n.get(t,e,r)},has(t,e){return Ia(t,e)||n.has(t,e)}}));const jd="bugpin-reports",Ld=2,Ge="pending-reports",Ha=5,Fd=5e3,Rd=3e5,Bd=2;let Ti=null,za=null;function Id(n){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[n]||"bin"}async function ki(){if(Ti)return Ti;try{return Ti=await Od(jd,Ld,{upgrade(n){n.objectStoreNames.contains(Ge)||n.createObjectStore(Ge,{keyPath:"id"}).createIndex("by-created","createdAt")}}),Ti}catch(n){throw console.error("[BugPin] Failed to initialize IndexedDB:",n),n}}function Hd(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function Oi(){return navigator.onLine!==!1}function zd(n){const t=Fd*Math.pow(Bd,n);return Math.min(t,Rd)}async function Wa(n){const t=await ki(),e={...n,id:Hd(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(Ge,e),console.log("[BugPin] Report buffered for later submission:",e.id),Oi()&&Di().catch(console.error),e.id}async function Wd(){try{return await(await ki()).getAllFromIndex(Ge,"by-created")}catch{return[]}}async function Va(n){try{await(await ki()).delete(Ge,n),console.log("[BugPin] Removed buffered report:",n)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function Vd(n){try{await(await ki()).put(Ge,n)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function Xd(n){var t,e;try{const r=new URL("/api/widget/submit",n.serverUrl);r.searchParams.set("apiKey",n.apiKey);const i=new FormData;if(i.append("data",JSON.stringify({title:n.title,description:n.description,priority:n.priority,reporterEmail:n.reporterEmail,reporterName:n.reporterName,metadata:n.metadata,mediaCount:((t=n.media)==null?void 0:t.length)||0,mediaAnnotations:(e=n.media)==null?void 0:e.map(o=>o.annotations).filter(Boolean)})),n.media&&n.media.length>0)for(let o=0;o<n.media.length;o++){const a=n.media[o],l=Ma(a.dataUrl),c=Ea(a.dataUrl)||Id(a.mimeType),u=a.mimeType.startsWith("video/")?"video":"screenshot";i.append("media",l,`${u}-${o}.${c}`)}const s=await fetch(r.toString(),{method:"POST",body:i});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.message||`HTTP ${s.status}`)}return!0}catch(r){throw console.error("[BugPin] Failed to submit buffered report:",r),r}}async function Di(){if(!Oi())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const n=await Wd();if(n.length===0)return{synced:0,failed:0};console.log(`[BugPin] Syncing ${n.length} pending reports...`);let t=0,e=0;for(const r of n){if(r.lastRetryAt){const s=new Date(r.lastRetryAt).getTime()+zd(r.retryCount);if(Date.now()<s)continue}try{await Xd(r),await Va(r.id),t++,console.log("[BugPin] Successfully synced report:",r.id)}catch(i){e++,r.retryCount++,r.lastRetryAt=new Date().toISOString(),r.error=i instanceof Error?i.message:"Unknown error",r.retryCount>=Ha?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await Va(r.id)):(await Vd(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${Ha}):`,r.id))}}return{synced:t,failed:e}}function Yd(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),Di().catch(console.error)}),za||(za=setInterval(()=>{Oi()&&Di().catch(console.error)},3e4)),Oi()&&Di().catch(console.error)}Yd();function Ud(){return navigator.onLine!==!1}function Gd(n){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[n]||"bin"}async function Nd(n){const{apiKey:t,serverUrl:e,media:r,...i}=n;if(!Ud())return console.log("[BugPin] Offline, buffering report for later submission"),await Wa({apiKey:t,serverUrl:e,title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,media:r,metadata:i.metadata}),{success:!0,message:"Report saved. It will be submitted when you're back online."};const s=new URL("/api/widget/submit",e);s.searchParams.set("apiKey",t);const o=new FormData;if(o.append("data",JSON.stringify({title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,metadata:i.metadata,mediaCount:(r==null?void 0:r.length)||0,mediaAnnotations:r==null?void 0:r.map(a=>a.annotations).filter(Boolean)})),r&&r.length>0)for(let a=0;a<r.length;a++){const l=r[a],c=Ma(l.dataUrl),h=Ea(l.dataUrl)||Gd(l.mimeType),d=l.mimeType.startsWith("video/")?"video":"screenshot";console.log(`[BugPin] Media ${a}: dataUrl length=${l.dataUrl.length}, blob size=${c.size}, type=${c.type}`),o.append("media",c,`${d}-${a}.${h}`)}try{const a=await fetch(s.toString(),{method:"POST",body:o}),l=await a.json();if(!a.ok||!l.success)throw new Error(l.message||l.error||"Failed to submit report");return l}catch(a){if(a instanceof TypeError&&a.message.includes("fetch"))return console.log("[BugPin] Network error, buffering report for later submission"),await Wa({apiKey:t,serverUrl:e,title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,media:r,metadata:i.metadata}),{success:!0,message:"Report saved. It will be submitted when the connection is restored."};throw a}}function $d(n){return n==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":n}const Xa={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},qd=({config:n})=>{const t=St(null),[e,r]=rt("closed"),[i,s]=rt(!1),[o,a]=rt(!1),[l,c]=rt([]),[h,u]=rt(null),[d,g]=rt(null),[f,m]=rt("details"),[b,y]=rt(Xa);Ft(()=>{const M=()=>w(),j=()=>O();return document.addEventListener("bugpin:open",M),document.addEventListener("bugpin:close",j),()=>{document.removeEventListener("bugpin:open",M),document.removeEventListener("bugpin:close",j)}},[]),Ft(()=>{const M=t.current;if(!M)return;const j=()=>{$d(n.theme)==="dark"?(M.style.setProperty("--button-color",n.dialogDarkButtonColor),M.style.setProperty("--button-text-color",n.dialogDarkTextColor),M.style.setProperty("--button-hover-color",n.dialogDarkButtonHoverColor),M.style.setProperty("--button-hover-text-color",n.dialogDarkTextHoverColor)):(M.style.setProperty("--button-color",n.dialogLightButtonColor),M.style.setProperty("--button-text-color",n.dialogLightTextColor),M.style.setProperty("--button-hover-color",n.dialogLightButtonHoverColor),M.style.setProperty("--button-hover-text-color",n.dialogLightTextHoverColor))};if(j(),n.theme==="auto"){const z=window.matchMedia("(prefers-color-scheme: dark)"),V=()=>j();return z.addEventListener("change",V),()=>z.removeEventListener("change",V)}},[n.theme,n.dialogLightButtonColor,n.dialogLightTextColor,n.dialogLightButtonHoverColor,n.dialogLightTextHoverColor,n.dialogDarkButtonColor,n.dialogDarkTextColor,n.dialogDarkButtonHoverColor,n.dialogDarkTextHoverColor]);const w=Y(()=>{r("form")},[]),O=Y(()=>{r("closed"),c([]),u(null),m("details"),y(Xa)},[]),k=Y(async()=>{if(n.enableScreenshot){a(!0),r("closed"),await new Promise(M=>setTimeout(M,100));try{const M=await fd(n.captureMethod,void 0,n.useScreenCaptureAPI),j=new Image;j.onload=()=>{console.log(`[BugPin] Captured screenshot: ${j.width}x${j.height}, dataUrl length=${M.length}`);const z={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png",width:j.width,height:j.height};c(V=>[...V,z]),a(!1),m("media"),r("form")},j.onerror=()=>{const z={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png"};c(V=>[...V,z]),a(!1),m("media"),r("form")},j.src=M}catch(M){console.error("[BugPin] Failed to capture screenshot:",M),a(!1),r("form"),g({message:"Failed to capture screenshot",type:"error"})}}},[n]),S=Y(M=>{c(j=>[...j,M])},[]),C=Y(M=>{c(j=>j.filter(z=>z.id!==M))},[]),A=Y(M=>{u(M),r("annotating")},[]),D=Y((M,j)=>{h&&c(z=>z.map(V=>V.id===h?{...V,dataUrl:M,annotated:!0,annotations:j}:V)),u(null),r("form")},[h]),L=Y(()=>{u(null),r("form")},[]),R=Y(async(M,j)=>{s(!0);try{const z=_d();await Nd({apiKey:n.apiKey,serverUrl:n.serverUrl,title:M.title,description:M.description,priority:M.priority,reporterEmail:M.reporterEmail||void 0,reporterName:M.reporterName||void 0,media:j.map(V=>({dataUrl:V.dataUrl,mimeType:V.mimeType,annotations:V.annotations})),metadata:z}),g({message:"Bug report submitted successfully!",type:"success"}),O()}catch(z){console.error("[BugPin] Failed to submit report:",z),g({message:z instanceof Error?z.message:"Failed to submit report",type:"error"})}finally{s(!1)}},[n,O]),H=Y(()=>{g(null)},[]),I=h?l.find(M=>M.id===h):null;return _("div",{ref:t,class:`bugpin-container bugpin-theme-${n.theme}`,children:[_(yl,{position:n.position,buttonText:n.buttonText,buttonShape:n.buttonShape,buttonIcon:n.buttonIcon,buttonIconSize:n.buttonIconSize,buttonIconStroke:n.buttonIconStroke,theme:n.theme,lightButtonColor:n.lightButtonColor,lightTextColor:n.lightTextColor,lightButtonHoverColor:n.lightButtonHoverColor,lightTextHoverColor:n.lightTextHoverColor,darkButtonColor:n.darkButtonColor,darkTextColor:n.darkTextColor,darkButtonHoverColor:n.darkButtonHoverColor,darkTextHoverColor:n.darkTextHoverColor,enableHoverScaleEffect:n.enableHoverScaleEffect,tooltipEnabled:n.tooltipEnabled,tooltipText:n.tooltipText,onClick:w}),e==="annotating"&&I&&_("div",{class:"bugpin-overlay",children:_("div",{class:"bugpin-annotation-modal",children:_(_u,{screenshot:I.dataUrl,onSave:D,onCancel:L})})}),e==="form"&&_(Ol,{onClose:O,onSubmit:R,onCaptureScreenshot:k,onAnnotateMedia:A,media:l,onAddMedia:S,onRemoveMedia:C,isSubmitting:i,isCapturing:o,enableAnnotation:n.enableAnnotation,activeTab:f,onActiveTabChange:m,formData:b,onFormDataChange:y}),d&&_(Dl,{message:d.message,type:d.type,onClose:H})]})},Xs={apiKey:"",serverUrl:window.location.origin,position:"bottom-right",buttonText:null,buttonShape:"rectangle",buttonIcon:"bug",buttonIconSize:18,buttonIconStroke:2,theme:"auto",lightButtonColor:"#6366f1",lightTextColor:"#ffffff",lightButtonHoverColor:"#4f46e5",lightTextHoverColor:"#ffffff",darkButtonColor:"#818cf8",darkTextColor:"#1e1b4b",darkButtonHoverColor:"#a5b4fc",darkTextHoverColor:"#1e1b4b",dialogLightButtonColor:"#ebebeb",dialogLightTextColor:"#575757",dialogLightButtonHoverColor:"#ebebeb",dialogLightTextHoverColor:"#575757",dialogDarkButtonColor:"#3c3c3c",dialogDarkTextColor:"#c3c3c3",dialogDarkButtonHoverColor:"#3c3c3c",dialogDarkTextHoverColor:"#c3c3c3",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024},Kd='*{box-sizing:border-box;margin:0;padding:0}#bugpin-root{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;font-size:14px;line-height:1.5;--background: #ffffff;--foreground: #0a0a0a;--muted: #f5f5f5;--muted-foreground: #737373;--border: #e5e5e5;--input: #e5e5e5;--ring: #a3a3a3;--primary: var(--button-color, #18181b);--primary-foreground: var(--button-text-color, #fafafa);--primary-hover: var(--button-hover-color, #27272a);--primary-hover-foreground: var(--button-hover-text-color, #fafafa);--destructive: #ef4444;--destructive-foreground: #fafafa;--radius: .5rem;--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);color:var(--foreground)}.bugpin-launcher-button{display:flex;align-items:center;justify-content:center;gap:8px;border:none;font-size:14px;font-weight:500;cursor:pointer;box-shadow:0 4px 12px #00000026}.bugpin-launcher-button.hover-scale{transition:transform .3s ease,box-shadow .3s ease}.bugpin-launcher-button.hover-scale:hover{transform:scale(1.1);box-shadow:0 8px 20px #00000040}.bugpin-launcher-button.hover-scale:active{transform:scale(1.05)}.bugpin-launcher-button-container.bottom-right{bottom:20px;right:20px}.bugpin-launcher-button-container.bottom-left{bottom:20px;left:20px}.bugpin-launcher-button-container.top-right{top:20px;right:20px}.bugpin-launcher-button-container.top-left{top:20px;left:20px}.bugpin-launcher-button svg{stroke:currentColor;fill:none}.bugpin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483646;background:#00000080;display:flex;align-items:center;justify-content:center;padding:20px;animation:fadeIn .2s ease-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.bugpin-dialog{position:relative;width:100%;max-width:480px;max-height:90vh;background:var(--background);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg);overflow:hidden;display:flex;flex-direction:column;animation:slideUp .2s ease-out}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.bugpin-header{display:flex;align-items:center;justify-content:space-between;padding:1.5rem;border-bottom:1px solid var(--border)}.bugpin-header h2{font-size:1.125rem;font-weight:600;color:var(--foreground);letter-spacing:-.025em}.bugpin-close{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;border:none;border-radius:calc(var(--radius) - 4px);background:transparent;color:var(--muted-foreground);cursor:pointer;transition:background .15s,color .15s}.bugpin-close:hover{background:var(--muted);color:var(--foreground)}.bugpin-close svg{width:1.25rem;height:1.25rem}.bugpin-body{flex:1;overflow-y:auto;padding:1.5rem}.bugpin-form{display:flex;flex-direction:column;gap:16px}.bugpin-field{display:flex;flex-direction:column;gap:6px}.bugpin-label{font-size:.875rem;font-weight:500;color:var(--foreground)}.bugpin-label.required:after{content:" *";color:var(--destructive)}.bugpin-input,.bugpin-textarea{height:2.5rem;padding:.5rem .75rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);font-size:.875rem;font-family:inherit;color:var(--foreground);background:transparent;transition:border-color .15s,box-shadow .15s}.bugpin-input:focus,.bugpin-textarea:focus{outline:none;border-color:var(--ring);box-shadow:0 0 0 2px var(--background),0 0 0 4px var(--ring)}.bugpin-input::placeholder,.bugpin-textarea::placeholder{color:var(--muted-foreground)}.bugpin-textarea{height:auto;min-height:5rem;resize:vertical}.bugpin-select{height:2.5rem;padding:.5rem .75rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);font-size:.875rem;font-family:inherit;color:var(--foreground);background:transparent;cursor:pointer;transition:border-color .15s,box-shadow .15s}.bugpin-select:focus{outline:none;border-color:var(--ring);box-shadow:0 0 0 2px var(--background),0 0 0 4px var(--ring)}.bugpin-screenshot{margin-top:8px;border-radius:8px;overflow:hidden;background:#f9fafb;border:1px solid #e5e7eb}.bugpin-screenshot img{display:block;width:100%;height:auto;max-height:200px;object-fit:contain}.bugpin-screenshot-actions{display:flex;gap:8px;padding:8px;border-top:1px solid #e5e7eb}.bugpin-btn-secondary{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;border:1px solid #d1d5db;border-radius:6px;background:#fff;color:#374151;font-size:13px;font-weight:500;cursor:pointer;transition:background .15s,border-color .15s}.bugpin-btn-secondary:hover{background:#f9fafb;border-color:#9ca3af}.bugpin-btn-secondary svg{width:16px;height:16px}.bugpin-footer{display:flex;gap:.75rem;padding:1.5rem;border-top:1px solid var(--border);background:var(--muted)}.bugpin-btn-cancel{flex:1;height:2.5rem;padding:0 1rem;border:1px solid var(--input);border-radius:calc(var(--radius) - 2px);background:var(--background);color:var(--foreground);font-size:.875rem;font-weight:500;cursor:pointer;transition:background .15s}.bugpin-btn-cancel:hover{background:var(--muted)}.bugpin-btn-submit{flex:1;height:2.5rem;padding:0 1rem;border:none;border-radius:calc(var(--radius) - 2px);background:var(--primary);color:var(--primary-foreground);font-size:.875rem;font-weight:500;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-submit:hover{background:var(--primary-hover);color:var(--primary-hover-foreground)}.bugpin-btn-submit:disabled{opacity:.5;cursor:not-allowed}.bugpin-toast{position:fixed;bottom:80px;right:20px;z-index:2147483647;display:flex;align-items:center;gap:.75rem;padding:1rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--background);color:var(--foreground);font-size:.875rem;box-shadow:var(--shadow-lg);animation:slideIn .3s ease-out}.bugpin-toast.success{border-color:#22c55e}.bugpin-toast.error{border-color:var(--destructive)}@keyframes slideIn{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}.bugpin-toast svg{width:20px;height:20px;flex-shrink:0}.bugpin-spinner{width:18px;height:18px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.priority-lowest{color:#6b7280}.priority-low{color:#3b82f6}.priority-medium{color:#f59e0b}.priority-high{color:#ef4444}.priority-highest{color:#dc2626}.bugpin-theme-dark,.bugpin-container.bugpin-theme-dark{--background: #0a0a0a;--foreground: #fafafa;--muted: #262626;--muted-foreground: #a3a3a3;--border: #262626;--input: #262626;--ring: #d4d4d4}.bugpin-theme-dark .bugpin-dialog{background:var(--background);color:var(--foreground)}.bugpin-theme-dark .bugpin-header{border-color:var(--border)}.bugpin-theme-dark .bugpin-header h2{color:var(--foreground)}.bugpin-theme-dark .bugpin-close:hover{background:var(--muted);color:var(--foreground)}.bugpin-theme-dark .bugpin-label{color:var(--foreground)}.bugpin-theme-dark .bugpin-input,.bugpin-theme-dark .bugpin-textarea,.bugpin-theme-dark .bugpin-select{background:var(--muted);border-color:var(--input);color:var(--foreground)}.bugpin-theme-dark .bugpin-input::placeholder,.bugpin-theme-dark .bugpin-textarea::placeholder{color:var(--muted-foreground)}.bugpin-theme-dark .bugpin-screenshot{background:var(--muted);border-color:var(--border)}.bugpin-theme-dark .bugpin-screenshot-actions{border-color:var(--border)}.bugpin-theme-dark .bugpin-btn-secondary{background:var(--muted);border-color:var(--border);color:var(--foreground)}.bugpin-theme-dark .bugpin-btn-secondary:hover{background:#3f3f46}.bugpin-theme-dark .bugpin-footer{background:#171717;border-color:var(--border)}.bugpin-theme-dark .bugpin-btn-cancel{background:var(--muted);border-color:var(--border);color:var(--foreground)}.bugpin-theme-dark .bugpin-btn-cancel:hover{background:#3f3f46}.bugpin-error{color:var(--destructive);font-size:.75rem;margin-top:.25rem}.bugpin-annotation-container{display:flex;flex-direction:column;height:100%;background:#1f2937}.bugpin-annotation-toolbar{display:flex;align-items:center;gap:8px;padding:12px 16px;background:#111827;border-bottom:1px solid #374151;flex-wrap:wrap}.bugpin-tool-group{display:flex;gap:4px}.bugpin-tool-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:6px;background:transparent;color:#9ca3af;cursor:pointer;transition:background .15s,color .15s}.bugpin-tool-btn:hover{background:#374151;color:#f3f4f6}.bugpin-tool-btn.active{background:var(--button-color, #6366f1);color:var(--button-text-color, white)}.bugpin-tool-btn:disabled{opacity:.4;cursor:not-allowed}.bugpin-tool-btn svg{width:20px;height:20px}.bugpin-tool-divider{width:1px;height:24px;background:#374151;margin:0 4px}.bugpin-color-picker{display:flex;gap:4px}.bugpin-color-btn{width:24px;height:24px;border:2px solid transparent;border-radius:50%;cursor:pointer;transition:transform .15s,border-color .15s}.bugpin-color-btn:hover{transform:scale(1.1)}.bugpin-color-btn.active{border-color:#fff}.bugpin-stroke-picker{display:flex;gap:4px;align-items:center}.bugpin-stroke-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #4b5563;border-radius:6px;background:#374151;cursor:pointer;transition:border-color .15s}.bugpin-stroke-btn:hover{border-color:#6b7280}.bugpin-stroke-btn.active{border-color:var(--button-color, #6366f1);background:var(--button-color, #6366f1)}.bugpin-stroke-btn span{width:16px;background:#fff;border-radius:2px}.bugpin-canvas-wrapper{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;overflow:auto}.bugpin-canvas-wrapper canvas{border-radius:4px;box-shadow:0 4px 12px #0000004d}.bugpin-annotation-actions{display:flex;gap:12px;padding:12px 16px;background:#111827;border-top:1px solid #374151}.bugpin-annotation-actions .bugpin-btn-cancel,.bugpin-annotation-actions .bugpin-btn-submit{flex:1}.bugpin-annotation-modal{width:90vw;max-width:900px;height:80vh;max-height:700px;background:#1f2937;border-radius:12px;overflow:hidden;box-shadow:0 20px 40px #0006;animation:slideUp .2s ease-out}.bugpin-tabs-container{padding:1rem 1.5rem 0;background:transparent}.bugpin-tabs{display:inline-flex;padding:.25rem;background:var(--muted);border-radius:var(--radius);gap:.25rem}.bugpin-tab{display:flex;align-items:center;gap:.5rem;padding:.375rem .75rem;border:none;border-radius:calc(var(--radius) - 4px);background:transparent;color:var(--muted-foreground);font-size:.875rem;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s,color .15s,box-shadow .15s}.bugpin-tab:hover{color:var(--foreground)}.bugpin-tab.active{background:var(--background);color:var(--foreground);box-shadow:var(--shadow-sm)}.bugpin-tab-icon{display:flex;align-items:center;justify-content:center}.bugpin-tab-icon svg{width:1rem;height:1rem}.bugpin-dialog-tabbed{max-width:560px}.bugpin-theme-dark .bugpin-tabs{background:var(--muted)}.bugpin-theme-dark .bugpin-tab{color:var(--muted-foreground)}.bugpin-theme-dark .bugpin-tab:hover{color:var(--foreground)}.bugpin-theme-dark .bugpin-tab.active{background:var(--background);color:var(--foreground)}.bugpin-screenshot-manager{display:flex;flex-direction:column;gap:16px}.bugpin-media-actions{display:flex;gap:8px}.bugpin-btn-action{flex:1;display:flex;align-items:center;justify-content:center;gap:.5rem;height:2.5rem;padding:0 1rem;border:none;border-radius:calc(var(--radius) - 2px);background:var(--primary);color:var(--primary-foreground);font-size:.875rem;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-action:hover{background:var(--primary-hover);color:var(--primary-hover-foreground)}.bugpin-btn-action:disabled{opacity:.5;cursor:not-allowed}.bugpin-btn-action svg{width:1.125rem;height:1.125rem}.bugpin-btn-action-secondary{background:var(--background);color:var(--foreground);border:1px solid var(--input)}.bugpin-btn-action-secondary:hover{background:var(--muted)}.bugpin-upload-error{display:flex;align-items:center;gap:8px;padding:10px 12px;background:#fef2f2;border:1px solid #fecaca;border-radius:8px;color:#dc2626;font-size:13px}.bugpin-upload-error svg{width:18px;height:18px;flex-shrink:0}.bugpin-drop-zone{min-height:160px;border:2px dashed var(--border);border-radius:var(--radius);background:var(--muted);transition:border-color .15s,background .15s}.bugpin-drop-zone.dragging{border-color:var(--primary);background:color-mix(in srgb,var(--primary) 5%,transparent)}.bugpin-drop-zone.has-media{border-style:solid;border-color:var(--border);background:var(--background);min-height:auto}.bugpin-drop-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 16px;color:#6b7280;text-align:center}.bugpin-drop-placeholder svg{width:48px;height:48px;margin-bottom:12px;color:#9ca3af}.bugpin-drop-placeholder p{font-size:14px;font-weight:500;margin-bottom:4px}.bugpin-drop-placeholder span{font-size:12px;color:#9ca3af}.bugpin-drop-more{display:flex;align-items:center;justify-content:center;padding:12px;margin:8px 12px 12px;border:2px dashed #d1d5db;border-radius:6px;background:#f9fafb;transition:border-color .15s,background .15s}.bugpin-drop-more span{font-size:12px;color:#9ca3af}.bugpin-drop-zone.dragging .bugpin-drop-more{border-color:var(--button-color, #6366f1);background:#6366f10d}.bugpin-media-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;padding:12px}.bugpin-media-card{position:relative;border-radius:var(--radius);overflow:hidden;background:var(--background);border:1px solid var(--border)}.bugpin-media-preview{position:relative;aspect-ratio:16/9;background:#1f2937}.bugpin-media-preview img,.bugpin-media-preview video{width:100%;height:100%;object-fit:contain}.bugpin-media-badges{position:absolute;top:6px;left:6px;display:flex;gap:4px}.bugpin-badge{padding:.125rem .5rem;border-radius:calc(var(--radius) - 4px);font-size:.625rem;font-weight:500;text-transform:uppercase;letter-spacing:.025em}.bugpin-badge.annotated{background:#dbeafe;color:#1d4ed8}.bugpin-badge.video{background:#e5e7eb;color:#374151}.bugpin-media-info{display:flex;justify-content:space-between;padding:6px 8px;font-size:11px;color:#6b7280;border-top:1px solid #e5e7eb}.bugpin-media-item-actions{display:flex;gap:4px;padding:6px 8px;border-top:1px solid #e5e7eb;background:#f9fafb}.bugpin-btn-icon{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:6px;background:#fff;color:#6b7280;cursor:pointer;transition:background .15s,color .15s}.bugpin-btn-icon:hover{background:#e5e7eb;color:#374151}.bugpin-btn-icon svg{width:16px;height:16px}.bugpin-btn-icon-danger:hover{background:#fef2f2;color:#dc2626}.bugpin-helper-text{font-size:12px;color:#9ca3af;text-align:center}.bugpin-theme-dark .bugpin-btn-action-secondary{background:#374151;border-color:#4b5563;color:#d1d5db}.bugpin-theme-dark .bugpin-btn-action-secondary:hover{background:#4b5563}.bugpin-theme-dark .bugpin-upload-error{background:#450a0a;border-color:#7f1d1d;color:#fca5a5}.bugpin-theme-dark .bugpin-drop-zone{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-drop-zone.dragging{background:#6366f11a}.bugpin-theme-dark .bugpin-drop-zone.has-media{border-color:#4b5563;background:#1f2937}.bugpin-theme-dark .bugpin-drop-placeholder{color:#9ca3af}.bugpin-theme-dark .bugpin-drop-placeholder svg{color:#6b7280}.bugpin-theme-dark .bugpin-drop-more{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-drop-more span{color:#6b7280}.bugpin-theme-dark .bugpin-media-card{background:#374151;border-color:#4b5563}.bugpin-theme-dark .bugpin-media-info{border-color:#4b5563;color:#9ca3af}.bugpin-theme-dark .bugpin-media-item-actions{border-color:#4b5563;background:#374151}.bugpin-theme-dark .bugpin-btn-icon{background:#4b5563;color:#9ca3af}.bugpin-theme-dark .bugpin-btn-icon:hover{background:#6b7280;color:#f3f4f6}.bugpin-theme-dark .bugpin-btn-icon-danger:hover{background:#450a0a;color:#fca5a5}.bugpin-theme-dark .bugpin-badge.annotated{background:#1e3a8a;color:#93c5fd}.bugpin-theme-dark .bugpin-badge.video{background:#4b5563;color:#d1d5db}@keyframes bugpin-tooltip-fade-in{0%{opacity:0}to{opacity:1}}';async function Ya(){var o,a,l;const n=document.querySelectorAll('script[src*="widget.js"]'),t=n[n.length-1];if(!t){console.error("[BugPin] Could not find widget script tag");return}const e=t.getAttribute("data-api-key");if(!e){console.error("[BugPin] Missing data-api-key attribute");return}const r=t.getAttribute("data-server-url")||Xs.serverUrl;let i={};try{const c=await fetch(`${r}/api/widget/config/${e}`);if(c.ok){const h=await c.json();h.success&&h.config&&(i={buttonText:h.config.buttonText,buttonShape:h.config.buttonShape,buttonIcon:h.config.buttonIcon,buttonIconSize:h.config.buttonIconSize,buttonIconStroke:h.config.buttonIconStroke,position:h.config.position,theme:h.config.theme,lightButtonColor:h.config.lightButtonColor,lightTextColor:h.config.lightTextColor,lightButtonHoverColor:h.config.lightButtonHoverColor,lightTextHoverColor:h.config.lightTextHoverColor,darkButtonColor:h.config.darkButtonColor,darkTextColor:h.config.darkTextColor,darkButtonHoverColor:h.config.darkButtonHoverColor,darkTextHoverColor:h.config.darkTextHoverColor,dialogLightButtonColor:h.config.dialogLightButtonColor,dialogLightTextColor:h.config.dialogLightTextColor,dialogLightButtonHoverColor:h.config.dialogLightButtonHoverColor,dialogLightTextHoverColor:h.config.dialogLightTextHoverColor,dialogDarkButtonColor:h.config.dialogDarkButtonColor,dialogDarkTextColor:h.config.dialogDarkTextColor,dialogDarkButtonHoverColor:h.config.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:h.config.dialogDarkTextHoverColor,enableHoverScaleEffect:h.config.enableHoverScaleEffect??!0,tooltipEnabled:h.config.tooltipEnabled??!1,tooltipText:h.config.tooltipText??null,enableScreenshot:((o=h.config.features)==null?void 0:o.screenshot)??!0,enableAnnotation:((a=h.config.features)==null?void 0:a.annotation)??!0,enableConsoleCapture:((l=h.config.features)==null?void 0:l.consoleCapture)??!0,captureMethod:h.config.captureMethod||"visible",useScreenCaptureAPI:h.config.useScreenCaptureAPI??!1})}}catch(c){console.warn("[BugPin] Failed to fetch widget config, using defaults",c)}const s={...Xs,...i,apiKey:e,serverUrl:r,...t.getAttribute("data-position")&&{position:t.getAttribute("data-position")},...t.getAttribute("data-button-text")&&{buttonText:t.getAttribute("data-button-text")},...t.getAttribute("data-theme")&&{theme:t.getAttribute("data-theme")}};Ys(s)}function Ys(n){const t=document.createElement("div");t.id="bugpin-widget";const e=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=Kd,e.appendChild(r);const i=document.createElement("div");i.id="bugpin-root",e.appendChild(i),document.body.appendChild(t),Ka(Ke(qd,{config:n}),i)}const Us={init:n=>{const t={...Xs,...n};Ys(t)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};return typeof window<"u"&&(window.BugPin=Us),typeof{url:Ei&&Ei.tagName.toUpperCase()==="SCRIPT"&&Ei.src||new URL("widget.js",document.baseURI).href}<"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ya):Ya()),Ne.BugPin=Us,Ne.createWidget=Ys,Ne.default=Us,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Ne}({});
|
|
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(os,"type","Vibrance"),v(os,"defaults",{vibrance:0}),v(os,"uniformLocations",["uVibrance"]),j.setClass(os);var Tn=Object.freeze({__proto__:null,BaseFilter:yt,BlackWhite:lg,BlendColor:Ur,BlendImage:Gr,Blur:Nr,Brightness:qr,Brownie:rg,ColorMatrix:We,Composed:kn,Contrast:Kr,Convolute:Zr,Gamma:Jr,Grayscale:Qr,HueRotation:si,Invert:ts,Kodachrome:ig,Noise:es,Pixelate:rs,Polaroid:og,RemoveColor:ss,Resize:is,Saturation:ns,Sepia:ag,Technicolor:ng,Vibrance:os,Vintage:sg});ut.ownDefaults.originX="left",ut.ownDefaults.originY="top";const Dl=Symbol.for("bugpin-toObject-patched");if(!ut.prototype[Dl]){const i=ut.prototype.toObject;ut.prototype.toObject=function(t){const e=[...new Set(["data",...t||[]])];return i.call(this,e)},ut.prototype[Dl]=!0}const dg=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],gg=[2,4,6,8];let fg=0;function pg(i,t,e){var T,C,S;const r=t,s=++fg;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 w=b.getContext("2d");if(w){w.drawImage(d,l/g,c/f,h/g,u/f,0,0,h,u);const D=new St(b);D.filters=[new Tn.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 mg=({screenshot:i,onSave:t,onCancel:e})=>{const r=It(null),s=It(null),n=It(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),[w,T]=at(!1),C=It([]),S=It(-1),D=It(!1),A=It(!1),_=It(null),M=It(null);Ht(()=>{if(!r.current)return;const k=new vn(r.current,{isDrawingMode:!1,selection:!0});n.current=k,St.fromURL(i).then(B=>{var it;M.current={width:B.width||800,height:B.height||600};const I=(it=s.current)==null?void 0:it.getBoundingClientRect(),H=I?I.width-32:800,dt=I?I.height-32:600,ht=Math.min(H/(B.width||800),dt/(B.height||600));k.setDimensions({width:(B.width||800)*ht,height:(B.height||600)*ht}),B.scaleToWidth(k.width),k.backgroundImage=B,k.renderAll(),O()}),k.freeDrawingBrush=new Ks(k),k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h,k.on("path:created",()=>{O()}),k.on("object:modified",B=>{var H;const I=B.target;((H=I==null?void 0:I.data)==null?void 0:H.type)==="pixelate"&&I instanceof St&&k.backgroundImage&&(pg(k,I,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]),Ht(()=>{if(!n.current)return;const k=n.current;k.freeDrawingBrush&&(k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h)},[l,h]),Ht(()=>{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 I;if(!n.current||o==="pen"||o==="select"||o==="pan"||k.target||(I=n.current)!=null&&I.findTarget(k.e).target)return;D.current=!0;const P=n.current,E=k.scenePoint;let B=null;switch(o){case"rectangle":B=new Ft({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 Jt({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 Zt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1});break;case"arrow":B=new Zt([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 oe("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 Ft({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,I=E._startPoint;if(E instanceof Ft){const H=B.x-I.x,dt=B.y-I.y;E.set({left:H>0?I.x:B.x,top:dt>0?I.y:B.y,width:Math.abs(H),height:Math.abs(dt)})}else if(E instanceof Jt){const H=Math.abs(B.x-I.x)/2,dt=Math.abs(B.y-I.y)/2;E.set({left:Math.min(I.x,B.x),top:Math.min(I.y,B.y),rx:H,ry:dt})}else E instanceof Zt&&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 Ft&&P.backgroundImage){const I=E,H=P.getZoom(),dt=((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(),I.setCoords();const ht=I.getBoundingRect(),it=ht.left,kt=ht.top,F=ht.width,J=ht.height;if(F>5&&J>5){const et=P.backgroundImage,xt=et.getElement(),ot=et.scaleX||1,ae=et.scaleY||1,te=document.createElement("canvas");te.width=F,te.height=J;const xe=te.getContext("2d");if(xe){xe.drawImage(xt,it/ot,kt/ae,F/ot,J/ae,0,0,F,J);const yr=Math.max(3,Math.round(Math.min(F,J)/20)),Ae=new St(te,{left:it,top:kt,selectable:!0,hasControls:!0,hasBorders:!0});Ae.data={type:"pixelate",blockSize:yr},Ae.filters=[new Tn.Pixelate({blocksize:yr})],Ae.applyFilters(),P.remove(I),P.add(Ae)}}else P.remove(I);P.setZoom(H),P.setViewportTransform(dt),P.renderAll()}else if(E._isArrow&&E instanceof Zt){const I=E,H=I.x1||0,dt=I.y1||0,ht=I.x2||0,it=I.y2||0,kt=ht-H,F=it-dt,J=Math.sqrt(kt*kt+F*F);if(J>10){const et=Math.atan2(F,kt),xt=I.strokeWidth||2,ot=Math.max(xt*5,Math.min(xt*7,J/3)),ae=ot*.35,te=ht-ot*Math.cos(et),xe=it-ot*Math.sin(et),yr=te-ae*Math.cos(et-Math.PI/2),Ae=xe-ae*Math.sin(et-Math.PI/2),le=te-ae*Math.cos(et+Math.PI/2),cs=xe-ae*Math.sin(et+Math.PI/2);I.set({x2:te,y2:xe});const hs=new Yr([{x:ht,y:it},{x:yr,y:Ae},{x:le,y:cs}],{fill:I.stroke,stroke:I.stroke,strokeWidth:1,selectable:!1}),br=new De([I,hs],{selectable:!0,hasControls:!0,hasBorders:!0});P.remove(I),P.add(br)}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]);Ht(()=>{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 K=N(()=>{var kt;if(!n.current)return;const k=n.current,P=k.getZoom(),E=((kt=k.viewportTransform)==null?void 0:kt.slice())||[1,0,0,1,0,0];k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll();const B=M.current,I=B?B.width/(k.width||1):1,H=[];if(k.backgroundImage&&I>1){const F=k.backgroundImage,J=F.getElement(),et=F.scaleX||1,xt=F.scaleY||1;k.getObjects().forEach(ot=>{var te,xe;const ae=ot;if(((te=ae.data)==null?void 0:te.type)==="pixelate"&&ot instanceof St){const yr=ot.getElement(),Ae={width:ot.width||0,height:ot.height||0,scaleX:ot.scaleX||1,scaleY:ot.scaleY||1,left:ot.left||0,top:ot.top||0,angle:ot.angle||0,skewX:ot.skewX||0,skewY:ot.skewY||0,flipX:ot.flipX||!1,flipY:ot.flipY||!1};H.push({obj:ot,originalElement:yr,originalState:Ae}),ot.setCoords();const le=ot.getBoundingRect(),cs=le.width*I,hs=le.height*I,br=document.createElement("canvas");br.width=cs,br.height=hs;const uc=br.getContext("2d");if(uc){uc.drawImage(J,le.left/et,le.top/xt,le.width/et,le.height/xt,0,0,cs,hs);const gp=((xe=ae.data)==null?void 0:xe.blockSize)||Math.max(3,Math.round(Math.min(le.width,le.height)/20)),fp=Math.round(gp*I),Nn=new St(br);Nn.filters=[new Tn.Pixelate({blocksize:fp})],Nn.applyFilters(),ot.setElement(Nn.getElement()),ot.set({width:cs,height:hs,scaleX:1/I,scaleY:1/I})}}}),k.renderAll()}const dt=k.toDataURL({format:"png",quality:1,multiplier:I});H.forEach(({obj:F,originalElement:J,originalState:et})=>{F.setElement(J),F.set(et)}),k.setZoom(P),k.setViewportTransform(E),k.renderAll();const it=k.getObjects().map(F=>F.toObject());t(dt,{objects:it})},[t]),Z=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 x(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),wt=N(()=>{if(!n.current)return;const k=n.current,P=Math.max(y/1.2,.5),E=new x(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),mt=N(()=>{if(!n.current)return;const k=n.current;b(1),k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll()},[]);Ht(()=>{if(!n.current)return;const k=n.current,P=I=>{const H=I.e;(H.buttons===2||H.buttons===1&&w||H.buttons===1&&o==="pan")&&(H.preventDefault(),A.current=!0,k.selection=!1,_.current={x:H.clientX,y:H.clientY},k.setCursor("grabbing"))},E=I=>{if(A.current&&_.current){const H=I.e,dt=k.viewportTransform;dt[4]+=H.clientX-_.current.x,dt[5]+=H.clientY-_.current.y,k.requestRenderAll(),_.current={x:H.clientX,y:H.clientY}}},B=()=>{A.current&&(A.current=!1,_.current=null,k.setCursor(w||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)}},[w,o]),Ht(()=>{const k=E=>{if(E.key===" "&&!w&&(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"&&Z()}(E.ctrlKey||E.metaKey)&&E.key==="z"&&(E.preventDefault(),E.shiftKey?z():V())},P=E=>{E.key===" "&&w&&(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)}},[Z,V,z,w,o]);const lt=({tool:k,icon:P,label:E})=>p("button",{class:Bt("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:dg.map(k=>p("button",{class:Bt("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:gg.map(k=>p("button",{class:Bt("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:Z,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:wt,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:mt,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(ee,{variant:"outline",class:"flex-1",onClick:e,children:"Cancel"}),p(ee,{class:"flex-1",onClick:K,children:"Done"})]})]})};function vg(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 yg=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function Pe(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let dr=null;function Ml(i={}){return dr||(i.includeStyleProperties?(dr=i.includeStyleProperties,dr):(dr=Pe(window.getComputedStyle(document.documentElement)),dr))}function ii(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function bg(i){const t=ii(i,"border-left-width"),e=ii(i,"border-right-width");return i.clientWidth+t+e}function wg(i){const t=ii(i,"border-top-width"),e=ii(i,"border-bottom-width");return i.clientHeight+t+e}function El(i,t={}){const e=t.width||bg(i),r=t.height||wg(i);return{width:e,height:r}}function xg(){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 zt=16384;function _g(i){(i.width>zt||i.height>zt)&&(i.width>zt&&i.height>zt?i.width>i.height?(i.height*=zt/i.width,i.width=zt):(i.width*=zt/i.height,i.height=zt):i.width>zt?(i.height*=zt/i.width,i.width=zt):(i.width*=zt/i.height,i.height=zt))}function ni(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 Cg(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Sg(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),Cg(s)}const jt=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||jt(e,t)};function kg(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function Tg(i,t){return Ml(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function Og(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?kg(e):Tg(e,r);return document.createTextNode(`${s}{${n}}`)}function Pl(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=yg();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Og(o,e,s,r)),t.appendChild(a)}function Dg(i,t,e){Pl(i,t,":before",e),Pl(i,t,":after",e)}const Al="application/font-woff",Ll="image/jpeg",Mg={woff:Al,woff2:Al,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Ll,jpeg:Ll,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Eg(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function On(i){const t=Eg(i).toLowerCase();return Mg[t]||""}function Pg(i){return i.split(/,/)[1]}function Dn(i){return i.search(/^(data:)/)!==-1}function Ag(i,t){return`data:${t};base64,${i}`}async function Fl(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 Mn={};function Lg(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 En(i,t,e){const r=Lg(i,t,e.includeQueryParams);if(Mn[r]!=null)return Mn[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await Fl(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Pg(a)));s=Ag(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 Mn[r]=s,s}async function Fg(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):ni(t)}async function jg(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 ni(a)}const e=i.poster,r=On(e),s=await En(e,r,t);return ni(s)}async function Ig(i,t){var e;try{if(!((e=i==null?void 0:i.contentDocument)===null||e===void 0)&&e.body)return await oi(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function Bg(i,t){return jt(i,HTMLCanvasElement)?Fg(i):jt(i,HTMLVideoElement)?jg(i,t):jt(i,HTMLIFrameElement)?Ig(i,t):i.cloneNode(jl(i))}const Rg=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",jl=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function $g(i,t,e){var r,s;if(jl(t))return t;let n=[];return Rg(i)&&i.assignedNodes?n=Pe(i.assignedNodes()):jt(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=Pe(i.contentDocument.body.childNodes):n=Pe(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||jt(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>oi(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function zg(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):Ml(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`),jt(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 Hg(i,t){jt(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),jt(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function Vg(i,t){if(jt(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Wg(i,t,e){return jt(t,Element)&&(zg(i,t,e),Dg(i,t,e),Hg(i,t),Vg(i,t)),t}async function Xg(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 oi(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 oi(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>Bg(r,t)).then(r=>$g(i,r,t)).then(r=>Wg(i,r,t)).then(r=>Xg(r,t))}const Il=/url\((['"]?)([^'"]+?)\1\)/g,Yg=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ug=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Gg(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ng(i){const t=[];return i.replace(Il,(e,r,s)=>(t.push(s),e)),t.filter(e=>!Dn(e))}async function qg(i,t,e,r,s){try{const n=e?vg(t,e):t,o=On(t);let a;return s||(a=await En(n,o,r)),i.replace(Gg(t),`$1${a}$3`)}catch{}return i}function Kg(i,{preferredFontFormat:t}){return t?i.replace(Ug,e=>{for(;;){const[r,,s]=Yg.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function Bl(i){return i.search(Il)!==-1}async function Rl(i,t,e){if(!Bl(i))return i;const r=Kg(i,e);return Ng(r).reduce((n,o)=>n.then(a=>qg(a,o,t,e)),Promise.resolve(r))}async function gr(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await Rl(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function Zg(i,t){await gr("background",i,t)||await gr("background-image",i,t),await gr("mask",i,t)||await gr("-webkit-mask",i,t)||await gr("mask-image",i,t)||await gr("-webkit-mask-image",i,t)}async function Jg(i,t){const e=jt(i,HTMLImageElement);if(!(e&&!Dn(i.src))&&!(jt(i,SVGImageElement)&&!Dn(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await En(r,On(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 Qg(i,t){const r=Pe(i.childNodes).map(s=>$l(s,t));await Promise.all(r).then(()=>i)}async function $l(i,t){jt(i,Element)&&(await Zg(i,t),await Jg(i,t),await Qg(i,t))}function tf(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 zl={};async function Hl(i){let t=zl[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},zl[i]=t,t}async function Vl(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),Fl(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function Wl(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 ef(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{Pe(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=Hl(l).then(h=>Vl(h,t)).then(h=>Wl(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(Hl(s.href).then(a=>Vl(a,t)).then(a=>Wl(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{Pe(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function rf(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Bl(t.style.getPropertyValue("src")))}async function sf(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=Pe(i.ownerDocument.styleSheets),r=await ef(e,t);return rf(r)}function Xl(i){return i.trim().replace(/["']/g,"")}function nf(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(Xl(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function of(i,t){const e=await sf(i,t),r=nf(i);return(await Promise.all(e.filter(n=>r.has(Xl(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return Rl(n.cssText,o,t)}))).join(`
|
|
540
|
+
`)}async function af(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await of(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}=El(i,t),s=await oi(i,t,!0);return await af(s,t),await $l(s,t),tf(s,t),await Sg(s,e,r)}async function Pn(i,t={}){const{width:e,height:r}=El(i,t),s=await lf(i,t),n=await ni(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||xg(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||_g(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 cf=2,fr=16384,ai=4e7,Yl="data-bugpin-exclude";async function hf(){document.fonts&&document.fonts.ready&&await document.fonts.ready}async function uf(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 An(i,t,e="visible"){const r=Math.ceil(i),s=Math.ceil(t);if(r>fr||s>fr)throw e==="fullpage"?new Error(`Full page dimensions (${r}x${s}) exceed maximum canvas size (${fr}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 (${fr}px). Try capturing a smaller element or use visible viewport mode.`);if(r*s>ai)throw e==="fullpage"?new Error(`Full page total pixels (${r*s}) exceed maximum (${ai}). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot total pixels (${r*s}) exceed maximum (${ai}). Try capturing a smaller element or use visible viewport mode.`);let n=Math.min(window.devicePixelRatio||1,cf),o=r*n,a=s*n,l=o*a;for(;n>1&&(o>fr||a>fr||l>ai);)n-=.5,o=r*n,a=s*n,l=o*a;return Math.max(1,n)}function Ln(i){return!(i instanceof HTMLElement&&(i.tagName==="SCRIPT"||i.hasAttribute(Yl)))}function df(){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 Fn(){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 gf="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAA0lEQVQI12P4z8BQDwAEgAF/QualzQAAAABJRU5ErkJggg==";function ff(){try{for(const i of document.styleSheets)if(i.href)try{i.cssRules}catch{return!0}}catch{return!0}return!1}function jn(){const i=ff();return i&&console.log("[BugPin] Cross-origin stylesheets detected, skipping font embedding"),{skipFonts:i,imagePlaceholder:gf,onImageErrorHandler:()=>{}}}function pf(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}async function mf(){if(!pf())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 vf(i={}){const{method:t="visible",selector:e,useScreenCaptureAPI:r=!1,cacheBust:s}=i;if(r)try{return await mf()}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=df();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(`[${Yl}]`),d=new Map;u.forEach(g=>{g instanceof HTMLElement&&(d.set(g,g.style.visibility),g.style.visibility="hidden")});try{if(await hf(),await uf(n),t==="visible"){const w=An(c,h,"visible"),T=Fn(),C=a+c,S=l+h;console.log("[BugPin] Capture debug:",{scrollX:a,scrollY:l,viewportWidth:c,viewportHeight:h,captureWidth:C,captureHeight:S,dpr:w});const D={...jn(),cacheBust:s??!1,pixelRatio:w,width:C,height:S,backgroundColor:T,filter:Ln},A=await Pn(n,D);console.log("[BugPin] Canvas captured:",{canvasWidth:A.width,canvasHeight:A.height,expectedWidth:C*w,expectedHeight:S*w});const _=document.createElement("canvas");_.width=c*w,_.height=h*w;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*w,l*w,c*w,h*w,0,0,c*w,h*w),_.toDataURL("image/png")}if(t==="fullpage"){const w=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=An(w,T,"fullpage"),S=Fn(),D={...jn(),cacheBust:s??!0,pixelRatio:C,width:w,height:T,backgroundColor:S,filter:Ln};return(await Pn(n,D)).toDataURL("image/png")}const g=n.getBoundingClientRect(),f=An(g.width,g.height,"element"),m=Fn(),y={...jn(),cacheBust:s??!1,pixelRatio:f,backgroundColor:m,filter:Ln};return(await Pn(n,y)).toDataURL("image/png")}finally{u.forEach(g=>{g instanceof HTMLElement&&(g.style.visibility=d.get(g)||"")})}}function Ul(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 Gl(i){return i.startsWith("data:image/webp")?"webp":i.startsWith("data:image/jpeg")?"jpg":i.startsWith("data:image/gif")?"gif":"png"}const pr=[],as=[],ls=[],yf=30;let Nl=!1;function bf(){if(Nl)return;Nl=!0;const i=console.error;console.error=(...o)=>{pr.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)=>{pr.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)=>(pr.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=>{pr.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&&as.push({url:l,method:c,status:h.status,statusText:h.statusText,timestamp:new Date().toISOString()}),h}catch(h){throw as.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&&as.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){ls.push(i),ls.length>yf&&ls.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 _f(){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 Cf(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function Sf(){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 kf(){try{const i=performance.getEntriesByType("navigation");if(i.length>0){const t=i[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function Tf(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:xf(),device:_f(),viewport:Cf(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:kf(),consoleErrors:pr.length>0?[...pr]:void 0,networkErrors:as.length>0?[...as]:void 0,userActivity:ls.length>0?[...ls]:void 0,storageKeys:Sf()}}const In=(i,t)=>t.some(e=>i instanceof e);let ql,Kl;function Of(){return ql||(ql=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Df(){return Kl||(Kl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Bn=new WeakMap,Rn=new WeakMap,li=new WeakMap;function Mf(i){const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("success",n),i.removeEventListener("error",o)},n=()=>{e(Ye(i.result)),s()},o=()=>{r(i.error),s()};i.addEventListener("success",n),i.addEventListener("error",o)});return li.set(t,i),t}function Ef(i){if(Bn.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)});Bn.set(i,t)}let $n={get(i,t,e){if(i instanceof IDBTransaction){if(t==="done")return Bn.get(i);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Ye(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 Zl(i){$n=i($n)}function Pf(i){return Df().includes(i)?function(...t){return i.apply(zn(this),t),Ye(this.request)}:function(...t){return Ye(i.apply(zn(this),t))}}function Af(i){return typeof i=="function"?Pf(i):(i instanceof IDBTransaction&&Ef(i),In(i,Of())?new Proxy(i,$n):i)}function Ye(i){if(i instanceof IDBRequest)return Mf(i);if(Rn.has(i))return Rn.get(i);const t=Af(i);return t!==i&&(Rn.set(i,t),li.set(t,i)),t}const zn=i=>li.get(i);function Jl(i,t,{blocked:e,upgrade:r,blocking:s,terminated:n}={}){const o=indexedDB.open(i,t),a=Ye(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Ye(o.result),l.oldVersion,l.newVersion,Ye(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 Lf=["get","getKey","getAll","getAllKeys","count"],Ff=["put","add","delete","clear"],Hn=new Map;function Ql(i,t){if(!(i instanceof IDBDatabase&&!(t in i)&&typeof t=="string"))return;if(Hn.get(t))return Hn.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=Ff.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Lf.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 Hn.set(t,n),n}Zl(i=>({...i,get:(t,e,r)=>Ql(t,e)||i.get(t,e,r),has:(t,e)=>!!Ql(t,e)||i.has(t,e)}));const jf=["continue","continuePrimaryKey","advance"],tc={},Vn=new WeakMap,ec=new WeakMap,If={get(i,t){if(!jf.includes(t))return i[t];let e=tc[t];return e||(e=tc[t]=function(...r){Vn.set(this,ec.get(this)[t](...r))}),e}};async function*Bf(...i){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...i)),!t)return;t=t;const e=new Proxy(t,If);for(ec.set(e,t),li.set(e,zn(t));t;)yield e,t=await(Vn.get(e)||t.continue()),Vn.delete(e)}function rc(i,t){return t===Symbol.asyncIterator&&In(i,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&In(i,[IDBIndex,IDBObjectStore])}Zl(i=>({...i,get(t,e,r){return rc(t,e)?Bf:i.get(t,e,r)},has(t,e){return rc(t,e)||i.has(t,e)}}));const Rf="bugpin-reports",$f=2,mr="pending-reports",sc=5,zf=5e3,Hf=3e5,Vf=2;let ci=null,ic=null;function Wf(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 hi(){if(ci)return ci;try{return ci=await Jl(Rf,$f,{upgrade(i){i.objectStoreNames.contains(mr)||i.createObjectStore(mr,{keyPath:"id"}).createIndex("by-created","createdAt")}}),ci}catch(i){throw console.error("[BugPin] Failed to initialize IndexedDB:",i),i}}function Xf(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function ui(){return navigator.onLine!==!1}function Yf(i){const t=zf*Math.pow(Vf,i);return Math.min(t,Hf)}async function nc(i){const t=await hi(),e={...i,id:Xf(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(mr,e),console.log("[BugPin] Report buffered for later submission:",e.id),ui()&&di().catch(console.error),e.id}async function Uf(){try{return await(await hi()).getAllFromIndex(mr,"by-created")}catch{return[]}}async function oc(i){try{await(await hi()).delete(mr,i),console.log("[BugPin] Removed buffered report:",i)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function Gf(i){try{await(await hi()).put(mr,i)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function Nf(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=Ul(a.dataUrl),c=Gl(a.dataUrl)||Wf(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 di(){if(!ui())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const i=await Uf();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()+Yf(r.retryCount);if(Date.now()<n)continue}try{await Nf(r),await oc(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>=sc?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await oc(r.id)):(await Gf(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${sc}):`,r.id))}}return{synced:t,failed:e}}function qf(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),di().catch(console.error)}),ic||(ic=setInterval(()=>{ui()&&di().catch(console.error)},3e4)),ui()&&di().catch(console.error)}qf();function Kf(){return navigator.onLine!==!1}function Zf(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 Jf(i){const{apiKey:t,serverUrl:e,media:r,...s}=i;if(!Kf())return console.log("[BugPin] Offline, buffering report for later submission"),await nc({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=Ul(l.dataUrl),h=Gl(l.dataUrl)||Zf(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 nc({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 Qf="bugpin-drafts",tp=1,vr="draft-media",ep="bugpin-draft-";let gi=null;async function fi(){if(gi)return gi;try{return gi=await Jl(Qf,tp,{upgrade(i){i.objectStoreNames.contains(vr)||i.createObjectStore(vr,{keyPath:"apiKey"})}}),gi}catch(i){throw console.error("[BugPin] Failed to initialize draft database:",i),i}}function Wn(i){return`${ep}${i}`}function rp(i,t,e){try{const r={formData:t,activeTab:e,savedAt:new Date().toISOString()};localStorage.setItem(Wn(i),JSON.stringify(r))}catch(r){console.error("[BugPin] Failed to save form draft:",r)}}function ac(i){try{const t=localStorage.getItem(Wn(i));return t?JSON.parse(t):null}catch(t){return console.error("[BugPin] Failed to load form draft:",t),null}}function sp(i){try{localStorage.removeItem(Wn(i))}catch(t){console.error("[BugPin] Failed to clear form draft:",t)}}async function ip(i,t){try{await(await fi()).put(vr,{apiKey:i,media:t,savedAt:new Date().toISOString()})}catch(e){console.error("[BugPin] Failed to save media draft:",e)}}async function np(i){try{const e=await(await fi()).get(vr,i);return(e==null?void 0:e.media)||[]}catch(t){return console.error("[BugPin] Failed to load media draft:",t),[]}}async function lc(i){try{await(await fi()).delete(vr,i)}catch(t){console.error("[BugPin] Failed to clear media draft:",t)}}async function op(i){if(ac(i))return!0;try{const r=await(await fi()).get(vr,i);return r!==void 0&&r.media.length>0}catch{return!1}}async function ap(i,t,e,r){rp(i,t,e),r.length>0?await ip(i,r):await lc(i)}async function lp(i){const t=ac(i),e=await np(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 cp(i){sp(i),await lc(i)}const pi={save:ap,load:lp,clear:cp,has:op},Xn={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},hp=({config:i,deps:t})=>{const e=(t==null?void 0:t.WidgetDialog)??Vh,r=(t==null?void 0:t.AnnotationCanvas)??mg,s=(t==null?void 0:t.captureScreenshot)??vf,n=(t==null?void 0:t.captureContext)??Tf,o=(t==null?void 0:t.submitReport)??Jf,a=It(null),l=Yo(i.theme),[c,h]=at("closed"),[u,d]=at(!1),[g,f]=at(!1),[m,y]=at([]),[b,w]=at(null),[T,C]=at(null),[S,D]=at("details"),[A,_]=at(Xn),[M,O]=at(!1),[V,z]=at(!1),[X,W]=at(!1);Ht(()=>{c==="form"&&!M&&pi.load(i.apiKey).then(F=>{F&&(_(F.formData),D(F.activeTab),y(F.media)),O(!0)})},[c,M,i.apiKey]),Ht(()=>{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")},[]),K=A.title.trim()||A.description.trim()||A.reporterEmail.trim()||A.reporterName.trim()||m.length>0,Z=N(()=>{K?z(!0):(h("closed"),w(null),O(!1))},[K]),L=N(()=>{pi.save(i.apiKey,A,S,m),z(!1),h("closed"),w(null),O(!1)},[i.apiKey,A,S,m]),wt=N(()=>{y([]),D("details"),_(Xn),pi.clear(i.apiKey),z(!1),h("closed"),w(null),O(!1)},[i.apiKey]),mt=N((F=!1)=>{F===!0&&(y([]),D("details"),_(Xn),pi.clear(i.apiKey)),z(!1),h("closed"),w(null),O(!1)},[i.apiKey]);Ht(()=>{const F=()=>G(),J=()=>Z();return document.addEventListener("bugpin:open",F),document.addEventListener("bugpin:close",J),()=>{document.removeEventListener("bugpin:open",F),document.removeEventListener("bugpin:close",J)}},[G,Z]);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 et={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,et]),f(!1),D("media"),h("form")},J.onerror=()=>{const et={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:F,timestamp:new Date,annotated:!1,mimeType:"image/png"};y(xt=>[...xt,et]),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(et=>et.id!==F))},[]),I=N(F=>{w(F),h("annotating")},[]),H=N((F,J)=>{b&&y(et=>et.map(xt=>xt.id===b?{...xt,dataUrl:F,annotated:!0,annotations:J}:xt)),w(null),h("form")},[b]),dt=N(()=>{w(null),h("form")},[]),ht=N(async(F,J)=>{d(!0);try{const et=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:et}),C({message:"Bug report submitted successfully!",type:"success"}),mt(!0)}catch(et){console.error("[BugPin] Failed to submit report:",et),C({message:et instanceof Error?et.message:"Failed to submit report",type:"error"})}finally{d(!1)}},[i,mt,n,o]),it=N(()=>{C(null)},[]),kt=b?m.find(F=>F.id===b):null;return p("div",{ref:a,class:`bugpin-container bugpin-theme-${l}`,children:[p(Oh,{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"&&kt&&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:kt.dataUrl,onSave:H,onCancel:dt})})}),c==="form"&&p(e,{onClose:Z,onSubmit:ht,onCaptureScreenshot:lt,onAnnotateMedia:I,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:wt,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(Lh,{message:T.message,type:T.type,onClose:it})]})},Yn={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},up='/*! 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)}}';bf();let cc=!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(cc){console.warn("[BugPin] Widget already initialized");return}cc=!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=up,e.appendChild(r);const s=document.createElement("div");s.id="bugpin-root",e.appendChild(s),document.body.appendChild(t),vc(Cr(hp,{config:i}),s)}async function dp(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={...Yn,...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||Yn.serverUrl,e=await hc(i.apiKey,t);if(e===null)return;const r={...Yn,...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 mi=document.currentScript;if(mi!=null&&mi.hasAttribute("data-api-key")){const i=()=>dp(mi);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}return wr.BugPin=Gn,wr.createWidget=Un,wr.default=Gn,Object.defineProperties(wr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),wr}({});
|
|
586
541
|
//# sourceMappingURL=widget.js.map
|