@pairbo/ui-kit 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2616 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MyCustomElement={})}(this,(function(t){"use strict";
2
- /**
3
- * @license
4
- * Copyright 2019 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */var e;const i=globalThis,s=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),o=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(s&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&o.set(e,t))}return t}toString(){return this.cssText}};const a=t=>new n("string"==typeof t?t:t+"",void 0,r),l=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new n(i,t,r)},c=s?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return a(e)})(t):t
7
- /**
8
- * @license
9
- * Copyright 2017 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */,{is:h,defineProperty:d,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:g,getPrototypeOf:f}=Object,m=globalThis,b=m.trustedTypes,v=b?b.emptyScript:"",y=m.reactiveElementPolyfillSupport,_=(t,e)=>t,x={toAttribute(t,e){switch(e){case Boolean:t=t?v:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(s){i=null}}return i}},w=(t,e)=>!h(t,e),C={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:w};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=C){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);void 0!==s&&d(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return null==s?void 0:s.call(this)},set(e){const o=null==s?void 0:s.call(this);r.call(this,e),this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??C}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=f(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...p(t),...g(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const t=this._$Eu(e,i);void 0!==t&&this._$Eh.set(t,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(t=this.constructor.l)||t.forEach((t=>t(this)))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),void 0!==this.renderRoot&&this.isConnected&&(null==(e=t.hostConnected)||e.call(t))}removeController(t){var e;null==(e=this._$EO)||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(s)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),r=i.litNonce;void 0!==r&&e.setAttribute("nonce",r),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostConnected)?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostDisconnected)?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var i;const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(void 0!==r&&!0===s.reflect){const o=(void 0!==(null==(i=s.converter)?void 0:i.toAttribute)?s.converter:x).toAttribute(e,s.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,e){var i;const s=this.constructor,r=s._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=s.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null==(i=t.converter)?void 0:i.fromAttribute)?t.converter:x;this._$Em=r,this[r]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??w)(this[t],e))return;this.P(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],i)}let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostUpdate)?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null==(e=this._$EO)||e.forEach((t=>{var e;return null==(e=t.hostUpdated)?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((t=>this._$EC(t,this[t])))),this._$EU()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[_("elementProperties")]=new Map,S[_("finalized")]=new Map,null==y||y({ReactiveElement:S}),(m.reactiveElementVersions??(m.reactiveElementVersions=[])).push("2.0.4");
12
- /**
13
- * @license
14
- * Copyright 2017 Google LLC
15
- * SPDX-License-Identifier: BSD-3-Clause
16
- */
17
- const k=globalThis,T=k.trustedTypes,E=T?T.createPolicy("lit-html",{createHTML:t=>t}):void 0,O="$lit$",D=`lit$${Math.random().toFixed(9).slice(2)}$`,M="?"+D,P=`<${M}>`,A=document,F=()=>A.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,L=Array.isArray,j="[ \t\n\f\r]",B=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,R=/-->/g,z=/>/g,$=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),H=/'/g,N=/"/g,V=/^(?:script|style|textarea|title)$/i,U=(q=1,(t,...e)=>({_$litType$:q,strings:t,values:e})),W=Symbol.for("lit-noChange"),X=Symbol.for("lit-nothing"),G=new WeakMap,Y=A.createTreeWalker(A,129);var q;function K(t,e){if(!L(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}let Z=class t{constructor({strings:e,_$litType$:i},s){let r;this.parts=[];let o=0,n=0;const a=e.length-1,l=this.parts,[c,h]=((t,e)=>{const i=t.length-1,s=[];let r,o=2===e?"<svg>":3===e?"<math>":"",n=B;for(let a=0;a<i;a++){const e=t[a];let i,l,c=-1,h=0;for(;h<e.length&&(n.lastIndex=h,l=n.exec(e),null!==l);)h=n.lastIndex,n===B?"!--"===l[1]?n=R:void 0!==l[1]?n=z:void 0!==l[2]?(V.test(l[2])&&(r=RegExp("</"+l[2],"g")),n=$):void 0!==l[3]&&(n=$):n===$?">"===l[0]?(n=r??B,c=-1):void 0===l[1]?c=-2:(c=n.lastIndex-l[2].length,i=l[1],n=void 0===l[3]?$:'"'===l[3]?N:H):n===N||n===H?n=$:n===R||n===z?n=B:(n=$,r=void 0);const d=n===$&&t[a+1].startsWith("/>")?" ":"";o+=n===B?e+P:c>=0?(s.push(i),e.slice(0,c)+O+e.slice(c)+D+d):e+D+(-2===c?a:d)}return[K(t,o+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]})(e,i);if(this.el=t.createElement(c,s),Y.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=Y.nextNode())&&l.length<a;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(O)){const e=h[n++],i=r.getAttribute(t).split(D),s=/([.?@])?(.*)/.exec(e);l.push({type:1,index:o,name:s[2],strings:i,ctor:"."===s[1]?it:"?"===s[1]?st:"@"===s[1]?rt:et}),r.removeAttribute(t)}else t.startsWith(D)&&(l.push({type:6,index:o}),r.removeAttribute(t));if(V.test(r.tagName)){const t=r.textContent.split(D),e=t.length-1;if(e>0){r.textContent=T?T.emptyScript:"";for(let i=0;i<e;i++)r.append(t[i],F()),Y.nextNode(),l.push({type:2,index:++o});r.append(t[e],F())}}}else if(8===r.nodeType)if(r.data===M)l.push({type:2,index:o});else{let t=-1;for(;-1!==(t=r.data.indexOf(D,t+1));)l.push({type:7,index:o}),t+=D.length-1}o++}}static createElement(t,e){const i=A.createElement("template");return i.innerHTML=t,i}};function J(t,e,i=t,s){var r,o;if(e===W)return e;let n=void 0!==s?null==(r=i._$Co)?void 0:r[s]:i._$Cl;const a=I(e)?void 0:e._$litDirective$;return(null==n?void 0:n.constructor)!==a&&(null==(o=null==n?void 0:n._$AO)||o.call(n,!1),void 0===a?n=void 0:(n=new a(t),n._$AT(t,i,s)),void 0!==s?(i._$Co??(i._$Co=[]))[s]=n:i._$Cl=n),void 0!==n&&(e=J(t,n._$AS(t,e.values),n,s)),e}let Q=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((null==t?void 0:t.creationScope)??A).importNode(e,!0);Y.currentNode=s;let r=Y.nextNode(),o=0,n=0,a=i[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new tt(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new ot(r,this,t)),this._$AV.push(e),a=i[++n]}o!==(null==a?void 0:a.index)&&(r=Y.nextNode(),o++)}return Y.currentNode=A,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},tt=class t{get _$AU(){var t;return(null==(t=this._$AM)?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=X,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(null==s?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=J(this,t,e),I(t)?t===X||null==t||""===t?(this._$AH!==X&&this._$AR(),this._$AH=X):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>L(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==X&&I(this._$AH)?this._$AA.nextSibling.data=t:this.T(A.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Z.createElement(K(s.h,s.h[0]),this.options)),s);if((null==(e=this._$AH)?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new Q(r,this),e=t.u(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Z(t)),e}k(e){L(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,r=0;for(const o of e)r===i.length?i.push(s=new t(this.O(F()),this.O(F()),this,this.options)):s=i[r],s._$AI(o),r++;r<i.length&&(this._$AR(s&&s._$AB.nextSibling,r),i.length=r)}_$AR(t=this._$AA.nextSibling,e){var i;for(null==(i=this._$AP)||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null==(e=this._$AP)||e.call(this,t))}},et=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=X,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=X}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(void 0===r)t=J(this,t,e,0),o=!I(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const s=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=J(this,s[i+n],e,n),a===W&&(a=this._$AH[n]),o||(o=!I(a)||a!==this._$AH[n]),a===X?t=X:t!==X&&(t+=(a??"")+r[n+1]),this._$AH[n]=a}o&&!s&&this.j(t)}j(t){t===X?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},it=class extends et{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===X?void 0:t}},st=class extends et{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==X)}},rt=class extends et{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=J(this,t,e,0)??X)===W)return;const i=this._$AH,s=t===X&&i!==X||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==X&&(i===X||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;"function"==typeof this._$AH?this._$AH.call((null==(e=this.options)?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},ot=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){J(this,t)}};const nt={I:tt},at=k.litHtmlPolyfillSupport;null==at||at(Z,tt),(k.litHtmlVersions??(k.litHtmlVersions=[])).push("3.2.1");const lt=(t,e,i)=>{const s=(null==i?void 0:i.renderBefore)??e;let r=s._$litPart$;if(void 0===r){const t=(null==i?void 0:i.renderBefore)??null;s._$litPart$=r=new tt(e.insertBefore(F(),t),t,void 0,i??{})}return r._$AI(t),r};
18
- /**
19
- * @license
20
- * Copyright 2017 Google LLC
21
- * SPDX-License-Identifier: BSD-3-Clause
22
- */let ct=class extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=lt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null==(t=this._$Do)||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this._$Do)||t.setConnected(!1)}render(){return W}};ct._$litElement$=!0,ct.finalized=!0,null==(e=globalThis.litElementHydrateSupport)||e.call(globalThis,{LitElement:ct});const ht=globalThis.litElementPolyfillSupport;null==ht||ht({LitElement:ct}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");
23
- /**
24
- * @license
25
- * Copyright 2017 Google LLC
26
- * SPDX-License-Identifier: BSD-3-Clause
27
- */
28
- const dt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)}
29
- /**
30
- * @license
31
- * Copyright 2017 Google LLC
32
- * SPDX-License-Identifier: BSD-3-Clause
33
- */,ut={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:w},pt=(t=ut,e,i)=>{const{kind:s,metadata:r}=i;let o=globalThis.litPropertyMetadata.get(r);if(void 0===o&&globalThis.litPropertyMetadata.set(r,o=new Map),o.set(i.name,t),"accessor"===s){const{name:s}=i;return{set(i){const r=e.get.call(this);e.set.call(this,i),this.requestUpdate(s,r,t)},init(e){return void 0!==e&&this.P(s,void 0,t),e}}}if("setter"===s){const{name:s}=i;return function(i){const r=this[s];e.call(this,i),this.requestUpdate(s,r,t)}}throw Error("Unsupported decorator location: "+s)};function gt(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const s=e.hasOwnProperty(i);return e.constructor.createProperty(i,s?{...t,wrapped:!0}:t),s?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}
34
- /**
35
- * @license
36
- * Copyright 2017 Google LLC
37
- * SPDX-License-Identifier: BSD-3-Clause
38
- */function ft(t){return gt({...t,state:!0,attribute:!1})}
39
- /**
40
- * @license
41
- * Copyright 2017 Google LLC
42
- * SPDX-License-Identifier: BSD-3-Clause
43
- */const mt=(t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i)
44
- /**
45
- * @license
46
- * Copyright 2017 Google LLC
47
- * SPDX-License-Identifier: BSD-3-Clause
48
- */;function bt(t,e){return(e,i,s)=>mt(e,i,{get(){return(e=>{var i;return(null==(i=e.renderRoot)?void 0:i.querySelector(t))??null})(this)}})}
49
- /**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */let vt;function yt(t){return(e,i)=>mt(e,i,{get(){return(this.renderRoot??vt??(vt=document.createDocumentFragment())).querySelectorAll(t)}})}const _t=l`
54
- :host {
55
- display: block;
56
- font-family: Arial, sans-serif;
57
- }
58
- .message-selector {
59
- border: 1px solid #ccc;
60
- padding: 1rem;
61
- border-radius: 4px;
62
- background-color: #fff;
63
- color: black;
64
- }
65
- `;var xt=Object.getOwnPropertyDescriptor;function wt(t,e,i){return(e="symbol"==typeof(s=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e,"string"))?s:s+"")in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t;var s}function Ct(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function St(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ct(Object(i),!0).forEach((function(e){wt(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ct(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function kt(t,e){if(null==t)return{};var i,s,r=function(t,e){if(null==t)return{};var i={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(e.indexOf(s)>=0)continue;i[s]=t[s]}return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)i=o[s],e.indexOf(i)>=0||{}.propertyIsEnumerable.call(t,i)&&(r[i]=t[i])}return r}function Tt(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}t.MessageSelector=class extends ct{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".message-selector");e&&e.classList.toggle("message-selector-hidden")}_onGiftChange(t){const e=t.target;this.giftSelected=e.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(t){t.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(t){t.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return U`
66
- <div class="message-selector">
67
- <!-- Gift Checkbox: Always visible -->
68
- <div>
69
- <input
70
- type="checkbox"
71
- id="is-gift"
72
- name="is-gift"
73
- .checked=${this.giftSelected}
74
- @change=${this._onGiftChange}
75
- />
76
- <label for="is-gift">${this.giftLabel}</label>
77
- </div>
78
-
79
- <!-- Premium and Free Message Options: Only visible if gift is selected -->
80
- ${this.giftSelected?U`
81
- <div>
82
- <input
83
- type="checkbox"
84
- id="premium-card"
85
- name="premium-card"
86
- value="premium-card"
87
- .checked=${this.premiumSelected}
88
- @change=${this._onPremiumChange}
89
- />
90
- <label for="premium-card">${this.premiumLabel}</label>
91
- <p class="description">${this.premiumDescription}</p>
92
- </div>
93
- <div>
94
- <input
95
- type="checkbox"
96
- id="free-message"
97
- name="free-message"
98
- value="free-message"
99
- .checked=${this.freeMessageSelected}
100
- @change=${this._onFreeMessageChange}
101
- />
102
- <label for="free-message">${this.noteLabel}</label>
103
- </div>
104
- `:null}
105
-
106
- <!-- Display current selection summary -->
107
- <div class="current-selection">
108
- <strong>Current Selection:</strong>
109
- <ul>
110
- <li>Gift: ${this.giftSelected?"Yes":"No"}</li>
111
- <li>Premium Card: ${this.premiumSelected?"Yes":"No"}</li>
112
- <li>Free Message: ${this.freeMessageSelected?"Yes":"No"}</li>
113
- </ul>
114
- </div>
115
- </div>
116
- `}},t.MessageSelector.styles=[_t,l`
117
- .message-selector {
118
- text-align: left;
119
- }
120
- .message-selector > div {
121
- margin-bottom: 1rem;
122
- }
123
- .message-selector-hidden {
124
- display: none;
125
- }
126
- pre {
127
- background: #f7f7f7;
128
- padding: 1rem;
129
- border: 1px solid #ddd;
130
- border-radius: 4px;
131
- overflow-x: auto;
132
- margin-top: 1rem;
133
- }
134
- code {
135
- font-family: monospace;
136
- }
137
- `],t.MessageSelector.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}},t.MessageSelector=((t,e,i,s)=>{for(var r,o=s>1?void 0:s?xt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=r(o)||o);return o})([dt("pairbo-message-selector")],t.MessageSelector);let Et=class{constructor(){wt(this,"browserShadowBlurConstant",1),wt(this,"DPI",96),wt(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),wt(this,"perfLimitSizeTotal",2097152),wt(this,"maxCacheSideLimit",4096),wt(this,"minCacheSideLimit",256),wt(this,"disableStyleCopyPaste",!1),wt(this,"enableGLFiltering",!0),wt(this,"textureSize",4096),wt(this,"forceGLPutImageData",!1),wt(this,"cachesBoundsOfCurve",!1),wt(this,"fontPaths",{}),wt(this,"NUM_FRACTION_DIGITS",4)}};const Ot=new class extends Et{constructor(t){super(),this.configure(t)}configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,t)}addFonts(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fontPaths=St(St({},this.fontPaths),t)}removeFonts(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>{delete this.fontPaths[t]}))}clearFonts(){this.fontPaths={}}restoreDefaults(t){const e=new Et,i=(null==t?void 0:t.reduce(((t,i)=>(t[i]=e[i],t)),{}))||e;this.configure(i)}},Dt=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return console[t]("fabric",...i)};let Mt=class extends Error{constructor(t,e){super("fabric: ".concat(t),e)}};class Pt extends Mt{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let At=class{},Ft=class extends At{testPrecision(t,e){const i="precision ".concat(e," float;\nvoid main(){}"),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),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((t=>this.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),Dt("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const It={};let Lt;const jt=()=>Lt||(Lt={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Ft,dispose(){},copyPasteData:It}),Bt=()=>jt().document,Rt=()=>jt().window,zt=()=>{var t;return Math.max(null!==(t=Ot.devicePixelRatio)&&void 0!==t?t:Rt().devicePixelRatio,1)},$t=new class{constructor(){wt(this,"charWidthsCache",{}),wt(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:i,fontWeight:s}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],o="".concat(i.toLowerCase(),"_").concat((s+"").toLowerCase());return r[o]||(r[o]={}),r[o]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=Ot,i=Math.sqrt(e*t);return[Math.floor(i),Math.floor(e/i)]}},Ht="6.5.4";function Nt(){}const Vt=Math.PI/2,Ut=2*Math.PI,Wt=Math.PI/180,Xt=Object.freeze([1,0,0,1,0,0]),Gt=16,Yt=.4477152502,qt="center",Kt="left",Zt="top",Jt="bottom",Qt="right",te="none",ee=/\r?\n/,ie="moving",se="scaling",re="rotating",oe="rotate",ne="skewing",ae="resizing",le="modifyPoly",ce="modifyPath",he="changed",de="scale",ue="scaleX",pe="scaleY",ge="skewX",fe="skewY",me="fill",be="stroke",ve="modified",ye="json",_e="svg",xe=new class{constructor(){this[ye]=new Map,this[_e]=new Map}has(t){return this[ye].has(t)}getClass(t){const e=this[ye].get(t);if(!e)throw new Mt("No class registered for ".concat(t));return e}setClass(t,e){e?this[ye].set(e,t):(this[ye].set(t.type,t),this[ye].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[_e].get(t)}setSVGClass(t,e){this[_e].set(null!=e?e:t.type.toLowerCase(),t)}},we=new class extends Array{remove(t){const e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){const t=this.splice(0);return t.forEach((t=>t.abort())),t}cancelByCanvas(t){if(!t)return[];const e=this.filter((e=>{var i;return e.target===t||"object"==typeof e.target&&(null===(i=e.target)||void 0===i?void 0:i.canvas)===t}));return e.forEach((t=>t.abort())),e}cancelByTarget(t){if(!t)return[];const e=this.filter((e=>e.target===t));return e.forEach((t=>t.abort())),e}};class Ce{constructor(){wt(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)return Object.entries(t).forEach((t=>{let[e,i]=t;this.on(e,i)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if("object"==typeof t){const e=[];return Object.entries(t).forEach((t=>{let[i,s]=t;e.push(this.once(i,s))})),()=>e.forEach((t=>t()))}if(e){const i=this.on(t,(function(){for(var t=arguments.length,s=new Array(t),r=0;r<t;r++)s[r]=arguments[r];e.call(this,...s),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(void 0===t)for(const i in this.__eventListeners)this._removeEventListener(i);else"object"==typeof t?Object.entries(t).forEach((t=>{let[e,i]=t;this._removeEventListener(e,i)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=null===(i=this.__eventListeners[t])||void 0===i?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Se=(t,e)=>{const i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},ke=t=>{if(0===t)return 1;switch(Math.abs(t)/Vt){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},Te=t=>{if(0===t)return 0;const e=t/Vt,i=Math.sign(t);switch(e){case 1:return i;case 2:return 0;case 3:return-i}return Math.sin(t)};class Ee{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new Ee(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new Ee(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new Ee(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new Ee(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new Ee(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new Ee(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new Ee(this.x/t.x,this.y/t.y)}scalarDivide(t){return new Ee(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&&void 0!==arguments[1]?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new Ee(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new Ee(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new Ee(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,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new Ee(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe;const i=Te(t),s=ke(t),r=this.subtract(e);return new Ee(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Ee(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 Oe=new Ee(0,0),De=t=>!!t&&Array.isArray(t._objects);function Me(t){class e extends t{constructor(){super(...arguments),wt(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._objects.push(...e);return e.forEach((t=>this._onObjectAdded(t))),s}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return this._objects.splice(t,0,...i),i.forEach((t=>this._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.forEach((i=>{const s=t.indexOf(i);-1!==s&&(t.splice(s,1),e.push(i),this._onObjectRemoved(i))})),e}forEachObject(t){this.getObjects().forEach(((e,i,s)=>t(e,i,s)))}getObjects(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?[...this._objects]:this._objects.filter((t=>t.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,i){return!!this._objects.includes(t)||!!i&&this._objects.some((i=>i instanceof e&&i.contains(t,!0)))}complexity(){return this._objects.reduce(((t,e)=>t+(e.complexity?e.complexity():0)),0)}sendObjectToBack(t){return!(!t||t===this._objects[0]||(Se(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),0))}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1]||(Se(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),0))}sendObjectBackwards(t,e){if(!t)return!1;const i=this._objects.indexOf(t);if(0!==i){const s=this.findNewLowerIndex(t,i,e);return Se(this._objects,t),this._objects.splice(s,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;const i=this._objects.indexOf(t);if(i!==this._objects.length-1){const s=this.findNewUpperIndex(t,i,e);return Se(this._objects,t),this._objects.splice(s,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(Se(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,i){let s;if(i){s=e;for(let i=e-1;i>=0;--i)if(t.isOverlapping(this._objects[i])){s=i;break}}else s=e-1;return s}findNewUpperIndex(t,e,i){let s;if(i){s=e;for(let i=e+1;i<this._objects.length;++i)if(t.isOverlapping(this._objects[i])){s=i;break}}else s=e+1;return s}collectObjects(t){let{left:e,top:i,width:s,height:r}=t,{includeIntersecting:o=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=[],a=new Ee(e,i),l=a.add(new Ee(s,r));for(let c=this._objects.length-1;c>=0;c--){const t=this._objects[c];t.selectable&&t.visible&&(o&&t.intersectsWithRect(a,l)||t.isContainedWithinRect(a,l)||o&&t.containsPoint(a)||o&&t.containsPoint(l))&&n.push(t)}return n}}return e}class Pe extends Ce{_setOptions(){let t=arguments.length>0&&void 0!==arguments[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"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}}function Ae(t){return Rt().requestAnimationFrame(t)}let Fe=0;const Ie=()=>Fe++,Le=()=>{const t=Bt().createElement("canvas");if(!t||void 0===t.getContext)throw new Mt("Failed to create `canvas` element");return t},je=t=>{const e=Le();return e.width=t.width,e.height=t.height,e},Be=(t,e,i)=>t.toDataURL("image/".concat(e),i),Re=t=>t*Wt,ze=t=>t/Wt,$e=(t,e,i)=>new Ee(t).transform(e,i),He=t=>{const e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:s,y:r}=new Ee(t[4],t[5]).transform(i,!0);return i[4]=-s,i[5]=-r,i},Ne=(t,e,i)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]],Ve=(t,e)=>t.reduceRight(((t,i)=>i&&t?Ne(i,t,e):i||t),void 0)||Xt.concat(),Ue=t=>{let[e,i]=t;return Math.atan2(i,e)},We=t=>{const e=Ue(t),i=Math.pow(t[0],2)+Math.pow(t[1],2),s=Math.sqrt(i),r=(t[0]*t[3]-t[2]*t[1])/s,o=Math.atan2(t[0]*t[2]+t[1]*t[3],i);return{angle:ze(e),scaleX:s,scaleY:r,skewX:ze(o),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Xe=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Ge(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:e=0,y:i=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=Re(t),r=ke(s),o=Te(s);return[r,o,-o,r,e?e-(r*e-o*i):0,i?i-(o*e+r*i):0]}const Ye=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},qe=t=>Math.tan(Re(t)),Ke=t=>[1,0,qe(t),1,0,0],Ze=t=>[1,qe(t),0,1,0,0],Je=t=>{let{scaleX:e=1,scaleY:i=1,flipX:s=!1,flipY:r=!1,skewX:o=0,skewY:n=0}=t,a=Ye(s?-e:e,r?-i:i);return o&&(a=Ne(a,Ke(o),!0)),n&&(a=Ne(a,Ze(n),!0)),a},Qe=t=>{const{translateX:e=0,translateY:i=0,angle:s=0}=t;let r=Xe(e,i);s&&(r=Ne(r,Ge({angle:s})));const o=Je(t);return(t=>t.every(((t,e)=>t===Xt[e])))(o)||(r=Ne(r,o)),r},ti=function(t){let{signal:e,crossOrigin:i=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(s,r){if(e&&e.aborted)return r(new Pt("loadImage"));const o=Bt().createElement("img");let n;e&&(n=function(t){o.src="",r(t)},e.addEventListener("abort",n,{once:!0}));const a=function(){o.onload=o.onerror=null,n&&(null==e||e.removeEventListener("abort",n)),s(o)};t?(o.onload=a,o.onerror=function(){n&&(null==e||e.removeEventListener("abort",n)),r(new Mt("Error loading ".concat(o.src)))},i&&(o.crossOrigin=i),o.src=t):a()}))},ei=function(t){let{signal:e,reviver:i=Nt}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((s,r)=>{const o=[];e&&e.addEventListener("abort",r,{once:!0}),Promise.all(t.map((t=>xe.getClass(t.type).fromObject(t,{signal:e}).then((e=>(i(t,e),o.push(e),e)))))).then(s).catch((t=>{o.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},ii=function(t){let{signal:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{const r=[];e&&e.addEventListener("abort",s,{once:!0});const o=Object.values(t).map((t=>t&&t.type&&xe.has(t.type)?ei([t],{signal:e}).then((t=>{let[e]=t;return r.push(e),e})):t)),n=Object.keys(t);Promise.all(o).then((t=>t.reduce(((t,e,i)=>(t[n[i]]=e,t)),{}))).then(i).catch((t=>{r.forEach((t=>{t.dispose&&t.dispose()})),s(t)})).finally((()=>{e&&e.removeEventListener("abort",s)}))}))},si=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,i)=>(i in t&&(e[i]=t[i]),e)),{})},ri=(t,e)=>Object.keys(t).reduce(((i,s)=>(e(t[s],s,t)&&(i[s]=t[s]),i)),{}),oi={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"},ni=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),ai=(t,e,i,s)=>{t/=255,e/=255,i/=255;const r=Math.max(t,e,i),o=Math.min(t,e,i);let n,a;const l=(r+o)/2;if(r===o)n=a=0;else{const s=r-o;switch(a=l>.5?s/(2-r-o):s/(r+o),r){case t:n=(e-i)/s+(e<i?6:0);break;case e:n=(i-t)/s+2;break;case i:n=(t-e)/s+4}n/=6}return[Math.round(360*n),Math.round(100*a),Math.round(100*l),s]},li=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},ci=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),hi=t=>{let[e,i,s,r=1]=t;const o=Math.round(.3*e+.59*i+.11*s);return[o,o,o,r]};class di{constructor(t){if(wt(this,"isUnrecognised",!1),t)if(t instanceof di)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in oi&&(t=oi[t]),"transparent"===t?[255,255,255,0]:di.sourceFromHex(t)||di.sourceFromRgb(t)||di.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=ai(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=ai(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(ci(t)).concat(ci(e)).concat(ci(i)).concat(ci(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(hi(this.getSource())),this}toBlackWhite(t){const[e,,,i]=hi(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof di||(t=new di(t));const e=this.getSource(),i=t.getSource(),[s,r,o]=e.map(((t,e)=>Math.round(.5*t+.5*i[e])));return this.setSource([s,r,o,e[3]]),this}static fromRgb(t){return di.fromRgba(t)}static fromRgba(t){return new di(di.sourceFromRgb(t))}static sourceFromRgb(t){const e=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[t,i,s]=e.slice(1,4).map((t=>{const e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e}));return[t,i,s,li(e[4])]}}static fromHsl(t){return di.fromHsla(t)}static fromHsla(t){return new di(di.sourceFromHsl(t))}static sourceFromHsl(t){const e=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 i=(di.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let o,n,a;if(0===s)o=n=a=r;else{const t=r<=.5?r*(s+1):r+s-r*s,e=2*r-t;o=ni(e,t,i+1/3),n=ni(e,t,i),a=ni(e,t,i-1/3)}return[Math.round(255*o),Math.round(255*n),Math.round(255*a),li(e[4])]}static fromHex(t){return new di(di.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 i;i=e.length<=4?e.split("").map((t=>t+t)):e.match(/.{2}/g);const[s,r,o,n=255]=i.map((t=>parseInt(t,16)));return[s,r,o,n/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ze(i):e.includes("turn")?360*i:i}}const ui=(t,e)=>parseFloat(Number(t).toFixed(e)),pi=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;const i=/\D{0,2}$/.exec(t),s=parseFloat(t),r=Ot.DPI;switch(null==i?void 0:i[0]){case"mm":return s*r/25.4;case"cm":return s*r/2.54;case"in":return s*r;case"pt":return s*r/72;case"pc":return s*r/72*12;case"em":return s*e;default:return s}},gi=t=>"matrix("+t.map((t=>ui(t,Ot.NUM_FRACTION_DIGITS))).join(" ")+")",fi=function(t,e){let i,s,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(e.toLive)i="url(#SVGID_".concat(e.id,")");else{const t=new di(e),r=t.getAlpha();i=t.toRgb(),1!==r&&(s=r.toString())}else i="none";return r?"".concat(t,": ").concat(i,"; ").concat(s?"".concat(t,"-opacity: ").concat(s,"; "):""):"".concat(t,'="').concat(i,'" ').concat(s?"".concat(t,'-opacity="').concat(s,'" '):"")},mi=t=>!!t&&void 0!==t.toLive,bi=t=>!!t&&"function"==typeof t.toObject,vi=t=>!!t&&void 0!==t.offsetX&&"source"in t,yi=t=>!!t&&"multiSelectionStacking"in t;function _i(t){const e=t&&xi(t);let i=0,s=0;if(!t||!e)return{left:i,top:s};let r=t;const o=e.documentElement,n=e.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===e?(i=n.scrollLeft||o.scrollLeft||0,s=n.scrollTop||o.scrollTop||0):(i+=r.scrollLeft||0,s+=r.scrollTop||0),1!==r.nodeType||"fixed"!==r.style.position););return{left:i,top:s}}const xi=t=>t.ownerDocument||null,wi=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},Ci=function(t,e,i){let{width:s,height:r}=i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=s,t.height=r,o>1&&(t.setAttribute("width",(s*o).toString()),t.setAttribute("height",(r*o).toString()),e.scale(o,o))},Si=(t,e)=>{let{width:i,height:s}=e;i&&(t.style.width="number"==typeof i?"".concat(i,"px"):i),s&&(t.style.height="number"==typeof s?"".concat(s,"px"):s)};function ki(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=te,t}class Ti{constructor(t){wt(this,"_originalCanvasStyle",void 0),wt(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&void 0!==i.getContext?t:t&&Bt().getElementById(t)||Le();var i;if(e.hasAttribute("data-fabric"))throw new Mt("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:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Ci(i,s,t,e)}setCSSDimensions(t){Si(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&xi(t),s={left:0,top:0};if(!i)return s;const r=(null===(e=wi(t))||void 0===e?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let o={left:0,top:0};const n=i.documentElement;void 0!==t.getBoundingClientRect&&(o=t.getBoundingClientRect());const a=_i(t);return{left:o.left+a.left-(n.clientLeft||0)+s.left,top:o.top+a.top-(n.clientTop||0)+s.top}}(this.lower.el)}dispose(){jt().dispose(this.lower.el),delete this.lower}}const Ei={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Xt]};class Oi extends(Me(Pe)){get lowerCanvasEl(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.el}get contextContainer(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.ctx}static getDefaults(){return Oi.ownDefaults}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?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 Ti(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(Dt("warn","Canvas is trying to add an object that belongs to a different canvas.\nResulting 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?zt():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:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e=St({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}i||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 i=t,s=[...this.viewportTransform],r=$e(t,He(s));s[0]=e,s[3]=e;const o=$e(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new Ee(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 Ee(-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=Ae((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=He(this.viewportTransform),s=$e({x:0,y:0},i),r=$e({x:t,y:e},i),o=s.min(r),n=s.max(r);return this.vptCoords={tl:o,tr:new Ee(n.x,o.y),bl:new Ee(o.x,n.y),br:n}}cancelRequestedRender(){this.nextRenderHandle&&(function(t){Rt().cancelAnimationFrame(t)}(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[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 i=this.viewportTransform;t.save(),t.transform(...i),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 i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],r=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const n=mi(i);if(i){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=n?i.toLive(t):i,o&&t.transform(...r),n){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const e=i.gradientTransform||i.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:e}=this;this.skipOffscreen=o,o&&t.transform(...r),s.render(t),this.skipOffscreen=e,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 Ee(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new Ee(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new Ee(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 Ee(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new Ee(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return $e(this.getCenterPoint(),He(this.viewportTransform))}_centerObject(t,e){t.setXY(e,qt,qt),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 i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return St(St(St({version:Ht},si(this,e)),{},{objects:this._objects.filter((t=>!t.excludeFromExport)).map((i=>this._toObject(i,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,o=this.backgroundColor,n=this.overlayColor;return mi(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),mi(n)?n.excludeFromExport||(i.overlay=n.toObject(e)):n&&(i.overlay=n),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i}toSVG(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,')" >\n')),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("</g>\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=Ot.NUM_FRACTION_DIGITS,o=e.viewBox;let n;if(o)n='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const t=this.viewportTransform;n='viewBox="'.concat(ui(-t[4]/t[0],r)," ").concat(ui(-t[5]/t[3],r)," ").concat(ui(this.width/t[0],r)," ").concat(ui(this.height/t[3],r),'" ')}else n='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',n,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",Ht,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Ie()),'<clipPath id="'.concat(e.clipPathId,'" >\n').concat(e.toClipPathSVG(t.reviver),"</clipPath>\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if(mi(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(r,{additionalTransform:i?gi(s):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=Ot.fontPaths;this._objects.forEach((function e(i){t.push(i),De(i)&&i._objects.forEach(e)})),t.forEach((t=>{if(!(s=t)||"function"!=typeof s._renderText)return;var s;const{styles:r,fontFamily:o}=t;!e[o]&&i[o]&&(e[o]=!0,r&&Object.values(r).forEach((t=>{Object.values(t).forEach((t=>{let{fontFamily:s=""}=t;!e[s]&&i[s]&&(e[s]=!0)}))})))}));const s=Object.keys(e).map((t=>"\t\t@font-face {\n\t\t\tfont-family: '".concat(t,"';\n\t\t\tsrc: url('").concat(i[t],"');\n\t\t}\n"))).join("");return s?'\t<style type="text/css"><![CDATA[\n'.concat(s,"]]></style>\n"):""}_setSVGObjects(t,e){this.forEachObject((i=>{i.excludeFromExport||this._setSVGObject(t,i,e)}))}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(mi(i)){const s=i.repeat||"",r=this.width,o=this.height,n=this["".concat(e,"Vpt")]?gi(He(this.viewportTransform)):"";t.push('<rect transform="'.concat(n," translate(").concat(r/2,",").concat(o/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-o/2,'" width="').concat("repeat-y"!==s&&"no-repeat"!==s||!vi(i)?r:i.source.width,'" height="').concat("repeat-x"!==s&&"no-repeat"!==s||!vi(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,')"></rect>\n'))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',"></rect>\n")}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new Mt("`json` is undefined"));const s="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:o,background:n,overlayImage:a,overlay:l,clipPath:c}=s,h=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([ei(r,{reviver:e,signal:i}),ii({backgroundImage:o,backgroundColor:n,overlayImage:a,overlayColor:l,clipPath:c},{signal:i})]).then((t=>{let[e,i]=t;return this.clear(),this.add(...e),this.set(s),this.set(i),this.renderOnAddRemove=h,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=je(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return Be(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(e||this.width)*t,a=(i||this.height)*t,l=this.getZoom(),c=this.width,h=this.height,d=this.skipControlsDrawing,u=l*t,p=this.viewportTransform,g=[u,0,0,u,(p[4]-(s||0))*t,(p[5]-(r||0))*t],f=this.enableRetinaScaling,m=je({width:n,height:a}),b=o?this._objects.filter((t=>o(t))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=n,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),b),this.viewportTransform=p,this.width=c,this.height=h,this.calcViewportBoundaries(),this.enableRetinaScaling=f,this.skipControlsDrawing=d,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),we.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}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," }>")}}wt(Oi,"ownDefaults",Ei);const Di=["touchstart","touchmove","touchend"],Mi=t=>Di.includes(t.type)||"touch"===t.pointerType,Pi=t=>{t.preventDefault(),t.stopPropagation()},Ai=t=>{let e=0,i=0,s=0,r=0;for(let o=0,n=t.length;o<n;o++){const{x:n,y:a}=t[o];(n>s||!o)&&(s=n),(n<e||!o)&&(e=n),(a>r||!o)&&(r=a),(a<i||!o)&&(i=a)}return{left:e,top:i,width:s-e,height:r-i}},Fi=["translateX","translateY","scaleX","scaleY"],Ii=(t,e)=>{const i=We(e),{translateX:s,translateY:r,scaleX:o,scaleY:n}=i,a=kt(i,Fi),l=new Ee(s,r);t.flipX=!1,t.flipY=!1,Object.assign(t,a),t.set({scaleX:o,scaleY:n}),t.setPositionByOrigin(l,qt,qt)},Li=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),ji=(t,e,i)=>{const s=t/2,r=e/2,o=[new Ee(-s,-r),new Ee(s,-r),new Ee(-s,r),new Ee(s,r)].map((t=>t.transform(i))),n=Ai(o);return new Ee(n.width,n.height)},Bi=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xt;return Ne(He(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xt),t)},Ri=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xt,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xt;return t.transform(Bi(e,i))},zi=(t,e)=>{var i;const{transform:{target:s}}=e;null===(i=s.canvas)||void 0===i||i.fire("object:".concat(t),St(St({},e),{},{target:s})),s.fire(t,e)},$i={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Hi=t=>"string"==typeof t?$i[t]:t-.5,Ni="not-allowed";function Vi(t){return Hi(t.originX)===Hi(qt)&&Hi(t.originY)===Hi(qt)}function Ui(t){return.5-Hi(t)}const Wi=(t,e)=>t[e],Xi=(t,e,i,s)=>({e:t,transform:e,pointer:new Ee(i,s)});function Gi(t,e){const i=t.getTotalAngle()+ze(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function Yi(t,e,i,s,r){var o;let{target:n,corner:a}=t;const l=n.controls[a],c=(null===(o=n.canvas)||void 0===o?void 0:o.getZoom())||1,h=n.padding/c,d=function(t,e,i,s){const r=t.getRelativeCenterPoint(),o=void 0!==i&&void 0!==s?t.translateToGivenOrigin(r,qt,qt,i,s):new Ee(t.left,t.top);return(t.angle?e.rotate(-Re(t.angle),r):e).subtract(o)}(n,new Ee(s,r),e,i);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const qi=(t,e,i,s)=>{const{target:r,offsetX:o,offsetY:n}=e,a=i-o,l=s-n,c=!Wi(r,"lockMovementX")&&r.left!==a,h=!Wi(r,"lockMovementY")&&r.top!==l;return c&&r.set(Kt,a),h&&r.set(Zt,l),(c||h)&&zi(ie,Xi(t,e,i,s)),c||h};class Ki{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):te,r=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",n=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0!==this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",h=t?"":this.getSvgFilter(),d=fi(me,this.fill);return[fi(be,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",n,"; ","stroke-miterlimit: ",a,"; ",d,"fill-rule: ",e,"; ","opacity: ",l,";",h,c].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&&void 0!==arguments[1]?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(gi(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),n=s?'style="'.concat(this.getSvgFilter(),'" '):"",a=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=a&&a.absolutePositioned,h=this.stroke,d=this.fill,u=this.shadow,p=[],g=t.indexOf("COMMON_PARTS");let f;a&&(a.clipPathId="CLIPPATH_".concat(Ie()),f='<clipPath id="'.concat(a.clipPathId,'" >\n').concat(a.toClipPathSVG(i),"</clipPath>\n")),c&&p.push("<g ",n,this.getSvgCommons()," >\n"),p.push("<g ",this.getSvgTransform(!1),c?"":n+this.getSvgCommons()," >\n");const m=[o,l,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[g]=m,mi(d)&&p.push(d.toSVG(this)),mi(h)&&p.push(h.toSVG(this)),u&&p.push(u.toSVG(this)),a&&p.push(f),p.push(t.join("")),p.push("</g>\n"),c&&p.push("</g>\n"),i?i(p.join("")):p.join("")}addPaintOrder(){return this.paintFirst!==me?' paint-order="'.concat(this.paintFirst,'" '):""}}function Zi(t){return new RegExp("^("+t.join("|")+")\\b","i")}var Ji;const Qi=String.raw(Ji||(Ji=Tt(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),ts=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Qi+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Qi+"))?\\s+(.*)"),es={cx:Kt,x:Kt,r:"radius",cy:Zt,y:Zt,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"},is="font-size",ss="clip-path";Zi(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Zi(["symbol","image","marker","pattern","view","svg"]);const rs=Zi(["symbol","g","a","svg","clipPath","defs"]),os=new Ee(1,0),ns=new Ee,as=(t,e)=>t.rotate(e),ls=(t,e)=>new Ee(e).subtract(t),cs=t=>t.distanceFrom(ns),hs=(t,e)=>Math.atan2(ps(t,e),gs(t,e)),ds=t=>t.eq(ns)?t:t.scalarDivide(cs(t)),us=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ds(new Ee(-t.y,t.x).scalarMultiply(e?1:-1))},ps=(t,e)=>t.x*e.y-t.y*e.x,gs=(t,e)=>t.x*e.x+t.y*e.y,fs=(t,e,i)=>{if(t.eq(e)||t.eq(i))return!0;const s=ps(e,i),r=ps(e,t),o=ps(i,t);return s>=0?r>=0&&o<=0:!(r<=0&&o>=0)},ms="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",bs=new RegExp("(?:\\s|^)"+ms+ms+"("+Qi+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class vs{constructor(t){const e="string"==typeof t?vs.parseShadow(t):t;Object.assign(this,vs.ownDefaults,e),this.id=Ie()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(bs.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(bs,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=as(new Ee(this.offsetX,this.offsetY),Re(-t.angle)),i=new di(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*ui((Math.abs(e.x)+this.blur)/t.width,Ot.NUM_FRACTION_DIGITS)+20,r=100*ui((Math.abs(e.y)+this.blur)/t.height,Ot.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="').concat(ui(this.blur?this.blur/2:0,Ot.NUM_FRACTION_DIGITS),'"></feGaussianBlur>\n\t<feOffset dx="').concat(ui(e.x,Ot.NUM_FRACTION_DIGITS),'" dy="').concat(ui(e.y,Ot.NUM_FRACTION_DIGITS),'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="').concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n')}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=vs.ownDefaults;return this.includeDefaultValues?t:ri(t,((t,i)=>t!==e[i]))}static async fromObject(t){return new this(t)}}wt(vs,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),wt(vs,"type","shadow"),xe.setClass(vs,"shadow");const ys=(t,e,i)=>Math.max(t,Math.min(e,i)),_s=[Zt,Kt,ue,pe,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",ge,fe],xs=[me,be,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ws={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:Kt,originY:Zt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:me,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},Cs=(t,e,i,s)=>-i*Math.cos(t/s*Vt)+i+e,Ss=()=>!1;class ks{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=Cs,onStart:n=Nt,onChange:a=Nt,onComplete:l=Nt,abort:c=Ss,target:h}=t;wt(this,"_state","pending"),wt(this,"durationProgress",0),wt(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=o,this._onStart=n,this._onChange=a,this._onComplete=l,this._abort=c,this.target=h,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return"aborted"===this._state||"completed"===this._state}start(){const t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>Ae(t)),this.delay):Ae(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,"aborted"!==this._state&&(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),Ae(this.tick)))}register(){we.push(this)}unregister(){we.remove(this)}abort(){this._state="aborted",this.unregister()}}const Ts=["startValue","endValue"];class Es extends ks{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(St(St({},kt(t,Ts)),{},{startValue:e,byValue:i-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 Os=["startValue","endValue"];class Ds extends ks{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(St(St({},kt(t,Os)),{},{startValue:e,byValue:i.map(((t,i)=>t-e[i]))}))}calculate(t){const e=this.startValue.map(((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Ms=["startValue","endValue","easing","onChange","onComplete","abort"],Ps=(t,e,i,s)=>e+i*(1-Math.cos(t/s*Vt)),As=t=>t&&((e,i,s)=>t(new di(e).toRgba(),i,s));class Fs extends ks{constructor(t){let{startValue:e,endValue:i,easing:s=Ps,onChange:r,onComplete:o,abort:n}=t,a=kt(t,Ms);const l=new di(e).getSource(),c=new di(i).getSource();super(St(St({},a),{},{startValue:l,byValue:c.map(((t,e)=>t-l[e])),easing:s,onChange:As(r),onComplete:As(o),abort:As(n)}))}calculate(t){const[e,i,s,r]=this.startValue.map(((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i))),o=[...[e,i,s].map(Math.round),ys(0,r,1)];return{value:o,valueProgress:o.map(((t,e)=>0!==this.byValue[e]?Math.abs((t-this.startValue[e])/this.byValue[e]):0)).find((t=>0!==t))||0}}}function Is(t){const e=(i=t,Array.isArray(i.startValue)||Array.isArray(i.endValue)?new Ds(t):new Es(t));var i;return e.start(),e}class Ls{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),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((t=>!this.includes(t)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const r=ls(e,i),o=ls(e,t).divide(r);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 i=new Ee(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let s=0;for(let r=0;r<e.length;r++){const o=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(o.includes(t))return!0;s+=Number("Intersection"===o.status)}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];const n=e.x-t.x,a=e.y-t.y,l=s.x-i.x,c=s.y-i.y,h=t.x-i.x,d=t.y-i.y,u=l*d-c*h,p=n*d-a*h,g=c*n-l*a;if(0!==g){const e=u/g,i=p/g;return(r||0<=e&&e<=1)&&(o||0<=i&&i<=1)?new Ls("Intersection").append(new Ee(t.x+e*n,t.y+e*a)):new Ls}if(0===u||0===p){const n=r||o||Ls.isPointContained(t,i,s)||Ls.isPointContained(e,i,s)||Ls.isPointContained(i,t,e)||Ls.isPointContained(s,t,e);return new Ls(n?"Coincident":void 0)}return new Ls("Parallel")}static intersectSegmentLine(t,e,i,s){return Ls.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return Ls.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const r=new Ls,o=i.length;for(let n,a,l,c=0;c<o;c++){if(n=i[c],a=i[(c+1)%o],l=Ls.intersectLineLine(t,e,n,a,s,!1),"Coincident"===l.status)return l;r.append(...l.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return Ls.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new Ls,s=t.length,r=[];for(let o=0;o<s;o++){const n=t[o],a=t[(o+1)%s],l=Ls.intersectSegmentPolygon(n,a,e);"Coincident"===l.status?(r.push(l),i.append(n,a)):i.append(...l.points)}return r.length>0&&r.length===t.length?new Ls("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),o=new Ee(r.x,s.y),n=new Ee(s.x,r.y);return Ls.intersectPolygonPolygon(t,[s,o,r,n])}}class js extends Pe{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?$e(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=$e(t,He(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new Ee(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.originX,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,i,s];if(this.group){const t=this.group.calcTransformMatrix();return r.map((e=>$e(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Ls.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Ls.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:o}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return Ls.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.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)||this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Ai(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ue,t),this._set(pe,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(null===(t=this.canvas)||void 0===t?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?ze(Ue(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||Xt.concat()}calcACoords(){const t=Ge({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Xe(e,i),r=Ne(s,t),o=this._getTransformedDimensions(),n=o.x/2,a=o.y/2;return{tl:$e({x:-n,y:-a},r),tr:$e({x:n,y:-a},r),bl:$e({x:-n,y:a},r),br:$e({x:n,y:a},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&void 0!==arguments[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,Hi(this.originX),Hi(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((t,e)=>t===i[e]))?s.value:(this.group&&(e=Ne(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=Qe(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new Ee(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&&void 0!==arguments[0]?arguments[0]:{};const e=St({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const o=e.width+s,n=e.height+s;let a;return a=0===e.skewX&&0===e.skewY?new Ee(o*e.scaleX,n*e.scaleY):ji(o,n,Je(e)),a.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,n=t.y;const a=Hi(s)-Hi(e),l=Hi(r)-Hi(i);if(a||l){const t=this._getTransformedDimensions();o+=a*t.x,n+=l*t.y}return new Ee(o,n)}translateToCenterPoint(t,e,i){if(e===qt&&i===qt)return t;const s=this.translateToGivenOrigin(t,e,i,qt,qt);return this.angle?s.rotate(Re(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,qt,qt,e,i);return this.angle?s.rotate(Re(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?$e(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new Ee(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Kt,Zt)}}const Bs=["type"],Rs=["extraParam"];let zs=class t extends js{static getDefaults(){return t.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){Dt("warn","Setting type has no effect",t)}constructor(e){super(),wt(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=Le(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=Ot.maxCacheSideLimit,r=Ot.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=Ot.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const o=e/i,[n,a]=$t.limitDimsByArea(o),l=ys(r,n,s),c=ys(r,a,s);return e>l&&(t.zoomX/=e/l,t.width=l,t.capped=!0),i>c&&(t.zoomY/=i/c,t.height=c,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:r,zoomY:o,x:n,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),l=i!==t.width||s!==t.height,c=this.zoomX!==r||this.zoomY!==o;if(!t||!e)return!1;if(l||c){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const l=n/2,c=a/2;return this.cacheTranslationX=Math.round(t.width/2-l)+l,this.cacheTranslationY=Math.round(t.height/2-c)+c,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,o),this.zoomX=r,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new Ee(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=We(this.calcTransformMatrix());return new Ee(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}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:0===t?1e-4:t}_set(t,e){t!==ue&&t!==pe||(e=this._constrainScale(e)),t===ue&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof vs||(e=new vs(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!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:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:o,height:n}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:o,height:n,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!(this.paintFirst===be&&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&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=r}createClipPathLayer(t,e){const i=je(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((t=>{t.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=He(this.calcTransformMatrix());s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);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&&void 0!==arguments[0]&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.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 i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,mi(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(mi(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,o]=(null==i?void 0:i.viewportTransform)||Xt,n=r*s,a=o*s,l=e.nonScaling?new Ee(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Ot.browserShadowBlurConstant*(n+a)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*n*l.x,t.shadowOffsetY=e.offsetY*a*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!mi(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===be?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){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 i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/r,n=s.y/this.scaleY/r,a=je({width:Math.ceil(o),height:Math.ceil(n)}),l=a.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(o,0),l.lineTo(o,n),l.lineTo(0,n),l.closePath(),l.translate(o/2,n/2),l.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=null!==(i=l.createPattern(a,"no-repeat"))&&void 0!==i?i:"")}_findCenterFromElement(){return new Ee(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(xe.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Li(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?zt():1,n=(t.multiplier||1)*o,a=t.canvasProvider||(t=>new Oi(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&(t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)})(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&((t,e,i)=>{const s=Bi(e,i);Ii(t,Ne(s,t.calcOwnMatrix()))})(this,this.getViewportTransform()),this.setCoords();const l=Le(),c=this.getBoundingRect(),h=this.shadow,d=new Ee;if(h){const t=h.blur,e=h.nonScaling?new Ee(1,1):this.getObjectScaling();d.x=2*Math.round(r(h.offsetX)+t)*r(e.x),d.y=2*Math.round(r(h.offsetY)+t)*r(e.y)}const u=c.width+d.x,p=c.height+d.y;l.width=Math.ceil(u),l.height=Math.ceil(p);const g=a(l);"jpeg"===t.format&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new Ee(g.width/2,g.height/2),qt,qt);const f=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const m=g.toCanvasElement(n||1,t);return this.set("canvas",f),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),g._objects=[],g.destroy(),m}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Be(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:t,y:e}=this.getRelativeCenterPoint();this.originX=qt,this.originY=qt,this.left=t,this.top=e}if(this.set("angle",t),e){const{x:t,y:e}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=t,this.top=e,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){we.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&jt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((t,i)=>{let[s,r]=i;return t[s]=this._animate(s,r,e),t}),{})}_animate(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:n,onChange:a,onComplete:l}=i,c=St(St({},i),{},{target:this,startValue:null!=n?n:s.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==o?void 0:o.bind(this),onChange:(t,e,i)=>{s.reduce(((e,i,r)=>(r===s.length-1&&(e[i]=t),e[i])),this),a&&a(t,e,i)},onComplete:(t,e,i)=>{this.setCoords(),l&&l(t,e,i)}});return r?function(t){const e=new Fs(t);return e.start(),e}(c):Is(c)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.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(),i=t.getAncestors();if(0===e.length&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,o)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...i],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 i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),r=e.otherFork.pop(),o=i._objects.indexOf(s),n=i._objects.indexOf(r);return o>-1&&o>n}toObject(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]);let i;const s=Ot.NUM_FRACTION_DIGITS,{clipPath:r,fill:o,stroke:n,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:v,strokeUniform:y,strokeMiterLimit:_,scaleX:x,scaleY:w,angle:C,flipX:S,flipY:k,opacity:T,visible:E,backgroundColor:O,fillRule:D,paintFirst:M,globalCompositeOperation:P,skewX:A,skewY:F}=this;r&&!r.excludeFromExport&&(i=r.toObject(e.concat("inverted","absolutePositioned")));const I=t=>ui(t,s),L=St(St({},si(this,e)),{},{type:this.constructor.type,version:Ht,originX:d,originY:u,left:I(c),top:I(h),width:I(p),height:I(g),fill:bi(o)?o.toObject():o,stroke:bi(n)?n.toObject():n,strokeWidth:I(f),strokeDashArray:l?l.concat():l,strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:v,strokeUniform:y,strokeMiterLimit:I(_),scaleX:I(x),scaleY:I(w),angle:I(C),flipX:S,flipY:k,opacity:I(T),shadow:a?a.toObject():a,visible:E,backgroundColor:O,fillRule:D,paintFirst:M,globalCompositeOperation:P,skewX:I(A),skewY:I(F)},i?{clipPath:i}:null);return this.includeDefaultValues?L:this._removeDefaultValues(L)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return ri(t,((t,e)=>{if(e===Kt||e===Zt||"type"===e)return!0;const s=i[e];return t!==s&&!(Array.isArray(t)&&Array.isArray(s)&&0===t.length&&0===s.length)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=kt(t,Bs),i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:s}=i,r=kt(i,Rs);return ii(e,r).then((t=>s?(delete t[s],new this(e[s],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};wt(zs,"stateProperties",_s),wt(zs,"cacheProperties",xs),wt(zs,"ownDefaults",ws),wt(zs,"type","FabricObject"),wt(zs,"colorProperties",[me,be,"backgroundColor"]),wt(zs,"customProperties",[]),xe.setClass(zs),xe.setClass(zs,"object");const $s=(t,e,i)=>(s,r,o,n)=>{const a=e(s,r,o,n);return a&&zi(t,St(St({},Xi(s,r,o,n)),i)),a};function Hs(t){return(e,i,s,r)=>{const{target:o,originX:n,originY:a}=i,l=o.getRelativeCenterPoint(),c=o.translateToOriginPoint(l,n,a),h=t(e,i,s,r);return o.setPositionByOrigin(c,i.originX,i.originY),h}}const Ns=$s(ae,Hs(((t,e,i,s)=>{const r=Yi(e,e.originX,e.originY,i,s);if(Hi(e.originX)===Hi(qt)||Hi(e.originX)===Hi(Qt)&&r.x<0||Hi(e.originX)===Hi(Kt)&&r.x>0){const{target:t}=e,i=t.strokeWidth/(t.strokeUniform?t.scaleX:1),s=Vi(e)?2:1,o=t.width,n=Math.abs(r.x*s/t.scaleX)-i;return t.set("width",Math.max(n,1)),o!==t.width}return!1})));function Vs(t,e,i,s,r){s=s||{};const o=this.sizeX||s.cornerSize||r.cornerSize,n=this.sizeY||s.cornerSize||r.cornerSize,a=void 0!==s.transparentCorners?s.transparentCorners:r.transparentCorners,l=a?be:me,c=!a&&(s.cornerStrokeColor||r.cornerStrokeColor);let h,d=e,u=i;t.save(),t.fillStyle=s.cornerColor||r.cornerColor||"",t.strokeStyle=s.cornerStrokeColor||r.cornerStrokeColor||"",o>n?(h=o,t.scale(1,n/o),u=i*o/n):n>o?(h=n,t.scale(o/n,1),d=e*n/o):h=o,t.beginPath(),t.arc(d,u,h/2,0,Ut,!1),t[l](),c&&t.stroke(),t.restore()}function Us(t,e,i,s,r){s=s||{};const o=this.sizeX||s.cornerSize||r.cornerSize,n=this.sizeY||s.cornerSize||r.cornerSize,a=void 0!==s.transparentCorners?s.transparentCorners:r.transparentCorners,l=a?be:me,c=!a&&(s.cornerStrokeColor||r.cornerStrokeColor),h=o/2,d=n/2;t.save(),t.fillStyle=s.cornerColor||r.cornerColor||"",t.strokeStyle=s.cornerStrokeColor||r.cornerStrokeColor||"",t.translate(e,i);const u=r.getTotalAngle();t.rotate(Re(u)),t["".concat(l,"Rect")](-h,-d,o,n),c&&t.strokeRect(-h,-d,o,n),t.restore()}class Ws{constructor(t){wt(this,"visible",!0),wt(this,"actionName",de),wt(this,"angle",0),wt(this,"x",0),wt(this,"y",0),wt(this,"offsetX",0),wt(this,"offsetY",0),wt(this,"sizeX",0),wt(this,"sizeY",0),wt(this,"touchSizeX",0),wt(this,"touchSizeY",0),wt(this,"cursorStyle","crosshair"),wt(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:o,tr:n,br:a,bl:l}=s;return(null===(r=e.canvas)||void 0===r?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&Ls.isPointInPolygon(i,[o,n,a,l])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return null!==(i=null===(s=t._controlsVisibility)||void 0===s?void 0:s[e])&&void 0!==i?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new Ee(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const n=Ve([Xe(i,s),Ge({angle:t}),Ye((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new Ee(-.5,-.5).transform(n),tr:new Ee(.5,-.5).transform(n),br:new Ee(.5,.5).transform(n),bl:new Ee(-.5,.5).transform(n)}}render(t,e,i,s,r){"circle"===((s=s||{}).cornerStyle||r.cornerStyle)?Vs.call(this,t,e,i,s,r):Us.call(this,t,e,i,s,r)}}const Xs=(t,e,i)=>i.lockRotation?Ni:e.cursorStyle,Gs=$s(re,Hs(((t,e,i,s)=>{let{target:r,ex:o,ey:n,theta:a,originX:l,originY:c}=e;const h=r.translateToOriginPoint(r.getRelativeCenterPoint(),l,c);if(Wi(r,"lockRotation"))return!1;const d=Math.atan2(n-h.y,o-h.x),u=Math.atan2(s-h.y,i-h.x);let p=ze(u-d+a);if(r.snapAngle&&r.snapAngle>0){const t=r.snapAngle,e=r.snapThreshold||t,i=Math.ceil(p/t)*t,s=Math.floor(p/t)*t;Math.abs(p-s)<e?p=s:Math.abs(p-i)<e&&(p=i)}p<0&&(p=360+p),p%=360;const g=r.angle!==p;return r.angle=p,g})));function Ys(t,e){const i=e.canvas,s=t[i.uniScaleKey];return i.uniformScaling&&!s||!i.uniformScaling&&s}function qs(t,e,i){const s=Wi(t,"lockScalingX"),r=Wi(t,"lockScalingY");if(s&&r)return!0;if(!e&&(s||r)&&i)return!0;if(s&&"x"===e)return!0;if(r&&"y"===e)return!0;const{width:o,height:n,strokeWidth:a}=t;return 0===o&&0===a&&"y"!==e||0===n&&0===a&&"x"!==e}const Ks=["e","se","s","sw","w","nw","n","ne","e"],Zs=(t,e,i)=>{const s=Ys(t,i);if(qs(i,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",s))return Ni;const r=Gi(i,e);return"".concat(Ks[r],"-resize")};function Js(t,e,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const o=e.target,n=r.by,a=Ys(t,o);let l,c,h,d,u,p;if(qs(o,n,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,h=e.scaleY*e.gestureScale;else{if(l=Yi(e,e.originX,e.originY,i,s),u="y"!==n?Math.sign(l.x||e.signX||1):1,p="x"!==n?Math.sign(l.y||e.signY||1):1,e.signX||(e.signX=u),e.signY||(e.signY=p),Wi(o,"lockScalingFlip")&&(e.signX!==u||e.signY!==p))return!1;if(d=o._getTransformedDimensions(),a&&!n){const t=Math.abs(l.x)+Math.abs(l.y),{original:i}=e,s=t/(Math.abs(d.x*i.scaleX/o.scaleX)+Math.abs(d.y*i.scaleY/o.scaleY));c=i.scaleX*s,h=i.scaleY*s}else c=Math.abs(l.x*o.scaleX/d.x),h=Math.abs(l.y*o.scaleY/d.y);Vi(e)&&(c*=2,h*=2),e.signX!==u&&"y"!==n&&(e.originX=Ui(e.originX),c*=-1,e.signX=u),e.signY!==p&&"x"!==n&&(e.originY=Ui(e.originY),h*=-1,e.signY=p)}const g=o.scaleX,f=o.scaleY;return n?("x"===n&&o.set(ue,c),"y"===n&&o.set(pe,h)):(!Wi(o,"lockScalingX")&&o.set(ue,c),!Wi(o,"lockScalingY")&&o.set(pe,h)),g!==o.scaleX||f!==o.scaleY}const Qs=$s(se,Hs(((t,e,i,s)=>Js(t,e,i,s)))),tr=$s(se,Hs(((t,e,i,s)=>Js(t,e,i,s,{by:"x"})))),er=$s(se,Hs(((t,e,i,s)=>Js(t,e,i,s,{by:"y"})))),ir=["target","ex","ey","skewingSide"],sr={x:{counterAxis:"y",scale:ue,skew:ge,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:pe,skew:fe,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},rr=["ns","nesw","ew","nwse"];function or(t,e,i,s,r){const{target:o}=i,{counterAxis:n,origin:a,lockSkewing:l,skew:c,flip:h}=sr[t];if(Wi(o,l))return!1;const{origin:d,flip:u}=sr[n],p=Hi(i[d])*(o[u]?-1:1),g=-Math.sign(p)*(o[h]?-1:1),f=-(0===o[c]&&Yi(i,qt,qt,s,r)[t]>0||o[c]>0?1:-1)*g*.5+.5;return $s(ne,Hs(((e,i,s,r)=>function(t,e,i){let{target:s,ex:r,ey:o,skewingSide:n}=e,a=kt(e,ir);const{skew:l}=sr[t],c=i.subtract(new Ee(r,o)).divide(new Ee(s.scaleX,s.scaleY))[t],h=s[l],d=a[l],u=Math.tan(Re(d)),p="y"===t?s._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:s._getTransformedDimensions({scaleX:1,scaleY:1}).y,g=2*c*n/Math.max(p,1)+u,f=ze(Math.atan(g));s.set(l,f);const m=h!==s[l];if(m&&"y"===t){const{skewX:t,scaleX:e}=s,i=s._getTransformedDimensions({skewY:h}),r=s._getTransformedDimensions(),o=0!==t?i.x/r.x:1;1!==o&&s.set(ue,o*e)}return m}(t,i,new Ee(s,r)))))(e,St(St({},i),{},{[a]:f,skewingSide:g}),s,r)}function nr(t,e){return t[e.canvas.altActionKey]}const ar=(t,e,i)=>{const s=nr(t,i);return 0===e.x?s?ge:pe:0===e.y?s?fe:ue:""},lr=(t,e,i)=>nr(t,i)?((t,e,i)=>{if(0!==e.x&&Wi(i,"lockSkewingY"))return Ni;if(0!==e.y&&Wi(i,"lockSkewingX"))return Ni;const s=Gi(i,e)%4;return"".concat(rr[s],"-resize")})(0,e,i):Zs(t,e,i),cr=(t,e,i,s)=>nr(t,e.target)?((t,e,i,s)=>or("y",t,e,i,s))(t,e,i,s):tr(t,e,i,s),hr=(t,e,i,s)=>nr(t,e.target)?((t,e,i,s)=>or("x",t,e,i,s))(t,e,i,s):er(t,e,i,s),dr=()=>({ml:new Ws({x:-.5,y:0,cursorStyleHandler:lr,actionHandler:cr,getActionName:ar}),mr:new Ws({x:.5,y:0,cursorStyleHandler:lr,actionHandler:cr,getActionName:ar}),mb:new Ws({x:0,y:.5,cursorStyleHandler:lr,actionHandler:hr,getActionName:ar}),mt:new Ws({x:0,y:-.5,cursorStyleHandler:lr,actionHandler:hr,getActionName:ar}),tl:new Ws({x:-.5,y:-.5,cursorStyleHandler:Zs,actionHandler:Qs}),tr:new Ws({x:.5,y:-.5,cursorStyleHandler:Zs,actionHandler:Qs}),bl:new Ws({x:-.5,y:.5,cursorStyleHandler:Zs,actionHandler:Qs}),br:new Ws({x:.5,y:.5,cursorStyleHandler:Zs,actionHandler:Qs}),mtr:new Ws({x:0,y:-.5,actionHandler:Gs,cursorStyleHandler:Xs,offsetY:-40,withConnection:!0,actionName:oe})}),ur=()=>St(St({},dr()),{mr:new Ws({x:.5,y:0,actionHandler:Ns,cursorStyleHandler:lr,actionName:ae}),ml:new Ws({x:-.5,y:0,actionHandler:Ns,cursorStyleHandler:lr,actionName:ae})});class pr extends zs{static getDefaults(){return St(St({},super.getDefaults()),pr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),pr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:dr()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(de))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&&void 0!==arguments[1]&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,o]=i[s],n=this.controls[r];if(n.shouldActivate(r,this,t,e?o.touchCorner:o.corner))return this.__corner=r,{key:r,control:n,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Xe(e.x,e.y),s=Ge({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Ne(i,s),o=Ne(t,r),n=Ne(o,[1/t[0],0,0,1/t[3],0,0]),a=this.group?We(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));const l=this._calculateCurrentDimensions(a),c={};return this.forEachControl(((t,e)=>{const i=t.positionHandler(l,n,this,t);c[e]=Object.assign(i,this._calcCornerCoords(t,i))})),c}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,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(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(Re(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=St({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);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&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=St({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),n=r.hasBorders,a=r.hasControls,l=Ne(o,this.calcTransformMatrix()),c=We(l);t.save(),t.translate(c.translateX,c.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180),t.rotate(Re(this.group?c.angle:this.angle)),n&&this.drawBorders(t,c,e),a&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const t=ji(this.width,this.height,Je(e)),i=this.isStrokeAccountedForInDimensions()?Oe:(this.strokeUniform?(new Ee).scalarAdd(this.canvas?this.canvas.getZoom():1):new Ee(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=t.add(i).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,r)=>{s.withConnection&&s.getVisibility(this,r)&&(i=!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))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:o}=this,n=St({cornerStrokeColor:s,cornerDashArray:r,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=n.cornerColor,this.transparentCorners||(t.strokeStyle=n.cornerStrokeColor),this._setLineDash(t,n.cornerDashArray),this.forEachControl(((e,i)=>{if(e.getVisibility(this,i)){const s=this.oCoords[i];e.render(t,s.x,s.y,n,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&&void 0!==arguments[0]?arguments[0]:{};Object.entries(t).forEach((t=>{let[e,i]=t;return this.setControlVisible(e,i)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),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 gr(t,e){return e.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),t}wt(pr,"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 fr extends pr{}gr(fr,[Ki]),xe.setClass(fr),xe.setClass(fr,"object");class mr{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new Ee(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new Ee(1/this.options.scaleX,1/this.options.scaleY):new Ee(1,1)}createSideVector(t,e){const i=ls(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){const e=new Ee(t);return e.y+=e.x*Math.tan(Re(this.options.skewY)),e.x+=e.y*Math.tan(Re(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const br=new Ee;class vr extends mr{static getOrthogonalRotationFactor(t,e){const i=e?hs(t,e):(t=>hs(os,t))(t);return Math.abs(i)<Vt?-1:1}constructor(t,e,i,s){super(s),wt(this,"AB",void 0),wt(this,"AC",void 0),wt(this,"alpha",void 0),wt(this,"bisector",void 0),this.A=new Ee(t),this.B=new Ee(e),this.C=new Ee(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=hs(this.AB,this.AC),this.bisector=ds(as(this.AB.eq(br)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=us(s),o=vr.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%Ut==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),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?cs(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return cs(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new Ee(vr.getOrthogonalRotationFactor(this.bisector),vr.getOrthogonalRotationFactor(new Ee(this.bisector.y,this.bisector.x)));return[new Ee(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new Ee(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((s=>{fs(s,t,e)&&i.push(this.A.add(s))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:o,scaleY:n,strokeUniform:a}=this.options,l=new Ee(Math.tan(Re(s)),Math.tan(Re(r))),c=this.strokeProjectionMagnitude,h=a?c/n/Math.sqrt(1/n**2+1/o**2*l.y**2):c/Math.sqrt(1+l.y**2),d=new Ee(Math.sqrt(Math.max(c**2-h**2,0)),h),u=a?c/Math.sqrt(1+l.x**2*(1/n)**2/(1/o+1/o*l.x*l.y)**2):c/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),p=new Ee(u,Math.sqrt(Math.max(c**2-u**2,0)));return[p,p.scalarMultiply(-1),d,d.scalarMultiply(-1)].map((t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t))).forEach((s=>{fs(s,t,e)&&i.push(this.applySkew(this.A).add(s))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Ut==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),n=ps(s,o)>0,a=n?s:r,l=n?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(a,l)):t.push(...this.projectRoundNoSkew(a,l)),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 yr extends mr{constructor(t,e,i){super(i),this.A=new Ee(t),this.T=new Ee(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(us(s),i)}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 Ee(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 vr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new Ee(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),i=this.scaleUnitVector(ds(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((t=>this.applySkew(t)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const _r=t=>{const e={};return Object.keys(t).forEach((i=>{e[i]={},Object.keys(t[i]).forEach((s=>{e[i][s]=St({},t[i][s])}))})),e},xr=t=>{const e=[];for(let i,s=0;s<t.length;s++)!1!==(i=wr(t,s))&&e.push(i);return e},wr=(t,e)=>{const i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";const i=t.charCodeAt(e+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";const s=t.charCodeAt(e-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1},Cr=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||i&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Sr=(t,e)=>{const i=e.split("\n"),s=[];let r=-1,o={};t=_r(t);for(let n=0;n<i.length;n++){const e=xr(i[n]);if(t[n])for(let i=0;i<e.length;i++){r++;const e=t[n][i];e&&Object.keys(e).length>0&&(Cr(o,e,!0)?s.push({start:r,end:r+1,style:e}):s[s.length-1].end++),o=e||{}}else r+=e.length,o={}}return s},kr=(t,e)=>{if(!Array.isArray(t))return _r(t);const i=e.split(ee),s={};let r=-1,o=0;for(let n=0;n<i.length;n++){const e=xr(i[n]);for(let i=0;i<e.length;i++)r++,t[o]&&t[o].start<=r&&r<t[o].end&&(s[n]=s[n]||{},s[n][i]=St({},t[o].style),r===t[o].end-1&&o++)}return s},Tr=["display","transform",me,"fill-opacity","fill-rule","opacity",be,"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 Er(t,e){const i=t.nodeName,s=t.getAttribute("class"),r=t.getAttribute("id"),o="(?![a-zA-Z\\-]+)";let n;if(n=new RegExp("^"+i,"i"),e=e.replace(n,""),r&&e.length&&(n=new RegExp("#"+r+o,"i"),e=e.replace(n,"")),s&&e.length){const t=s.split(" ");for(let i=t.length;i--;)n=new RegExp("\\."+t[i]+o,"i"),e=e.replace(n,"")}return 0===e.length}function Or(t,e){let i=!0;const s=Er(t,e.pop());return s&&e.length&&(i=function(t,e){let i,s=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)s&&(i=e.pop()),s=Er(t=t.parentElement,i);return 0===e.length}(t,e)),s&&i&&0===e.length}const Dr=t=>{var e;return null!==(e=es[t])&&void 0!==e?e:t},Mr=new RegExp("(".concat(Qi,")"),"gi");var Pr,Ar,Fr,Ir,Lr,jr,Br;const Rr="(".concat(Qi,")"),zr=String.raw(Pr||(Pr=Tt(["(skewX)(",")"],["(skewX)\\(","\\)"])),Rr),$r=String.raw(Ar||(Ar=Tt(["(skewY)(",")"],["(skewY)\\(","\\)"])),Rr),Hr=String.raw(Fr||(Fr=Tt(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Rr,Rr,Rr),Nr=String.raw(Ir||(Ir=Tt(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Rr,Rr),Vr=String.raw(Lr||(Lr=Tt(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Rr,Rr),Ur=String.raw(jr||(jr=Tt(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Rr,Rr,Rr,Rr,Rr,Rr),Wr="(?:".concat(Ur,"|").concat(Vr,"|").concat(Hr,"|").concat(Nr,"|").concat(zr,"|").concat($r,")"),Xr="(?:".concat(Wr,"*)"),Gr=String.raw(Br||(Br=Tt(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Xr),Yr=new RegExp(Gr),qr=new RegExp(Wr),Kr=new RegExp(Wr,"g");function Zr(t){const e=[];if(!(t=(t=>t.replace(Mr," $1 ").replace(/,/gi," ").replace(/\s+/gi," "))(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!Yr.test(t))return[...Xt];for(const i of t.matchAll(Kr)){const t=qr.exec(i[0]);if(!t)continue;let s=Xt;const r=t.filter((t=>!!t)),[,o,...n]=r,[a,l,c,h,d,u]=n.map((t=>parseFloat(t)));switch(o){case"translate":s=Xe(a,l);break;case oe:s=Ge({angle:a},{x:l,y:c});break;case de:s=Ye(a,l);break;case ge:s=Ke(a);break;case fe:s=Ze(a);break;case"matrix":s=[a,l,c,h,d,u]}e.push(s)}return Ve(e)}function Jr(t,e,i,s){const r=Array.isArray(e);let o,n=e;if(t!==me&&t!==be||e!==te){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)n=e===te?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)n=i&&i.transformMatrix?Ne(i.transformMatrix,Zr(e)):Zr(e);else if("visible"===t)n=e!==te&&"hidden"!==e,i&&!1===i.visible&&(n=!1);else if("opacity"===t)n=parseFloat(e),i&&void 0!==i.opacity&&(n*=i.opacity);else if("textAnchor"===t)n="start"===e?Kt:"end"===e?Qt:qt;else if("charSpacing"===t)o=pi(e,s)/s*1e3;else if("paintFirst"===t){const t=e.indexOf(me),i=e.indexOf(be);n=me,(t>-1&&i>-1&&i<t||-1===t&&i>-1)&&(n=be)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;o=r?e.map(pi):pi(e,s)}}else n="";return!r&&isNaN(o)?n:o}const Qr={stroke:"strokeOpacity",fill:"fillOpacity"};function to(t,e,i){if(!t)return{};let s,r={},o=Gt;t.parentNode&&rs.test(t.parentNode.nodeName)&&(r=to(t.parentElement,e,i),r.fontSize&&(s=o=pi(r.fontSize)));const n=St(St(St({},e.reduce(((e,i)=>{const s=t.getAttribute(i);return s&&(e[i]=s),e}),{})),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};for(const s in e)Or(t,s.split(" "))&&(i=St(St({},i),e[s]));return i}(t,i)),function(t){const e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[i,s]=t.split(":");e[i.trim().toLowerCase()]=s.trim()}))}(i,e):(s=i,r=e,Object.entries(s).forEach((t=>{let[e,i]=t;void 0!==i&&(r[e.toLowerCase()]=i)}))),e):e;var s,r}(t));n[ss]&&t.setAttribute(ss,n[ss]),n[is]&&(s=pi(n[is],o),n[is]="".concat(s));const a={};for(const c in n){const t=Dr(c),e=Jr(t,n[c],r,s);a[t]=e}a&&a.font&&function(t,e){const i=t.match(ts);if(!i)return;const s=i[1],r=i[3],o=i[4],n=i[5],a=i[6];s&&(e.fontStyle=s),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),o&&(e.fontSize=pi(o)),a&&(e.fontFamily=a),n&&(e.lineHeight="normal"===n?1:n)}(a.font,a);const l=St(St({},r),a);return rs.test(t.nodeName)?l:function(t){const e=fr.getDefaults();return Object.entries(Qr).forEach((i=>{let[s,r]=i;if(void 0===t[r]||""===t[s])return;if(void 0===t[s]){if(!e[s])return;t[s]=e[s]}if(0===t[s].indexOf("url("))return;const o=new di(t[s]);t[s]=o.setAlpha(ui(o.getAlpha()*t[r],2)).toRgba()})),t}(l)}const eo=["left","top","width","height","visible"],io=["rx","ry"];class so extends fr{static getDefaults(){return St(St({},super.getDefaults()),so.ownDefaults)}constructor(t){super(),Object.assign(this,so.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:i}=this,s=-e/2,r=-i/2,o=this.rx?Math.min(this.rx,e/2):0,n=this.ry?Math.min(this.ry,i/2):0,a=0!==o||0!==n;t.beginPath(),t.moveTo(s+o,r),t.lineTo(s+e-o,r),a&&t.bezierCurveTo(s+e-Yt*o,r,s+e,r+Yt*n,s+e,r+n),t.lineTo(s+e,r+i-n),a&&t.bezierCurveTo(s+e,r+i-Yt*n,s+e-Yt*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),a&&t.bezierCurveTo(s+Yt*o,r+i,s,r+i-Yt*n,s,r+i-n),t.lineTo(s,r+n),a&&t.bezierCurveTo(s,r+Yt*n,s+Yt*o,r,s+o,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...io,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,'" />\n')]}static async fromElement(t,e,i){const s=to(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:n=0,height:a=0,visible:l=!0}=s,c=kt(s,eo);return new this(St(St(St({},e),c),{},{left:r,top:o,width:n,height:a,visible:Boolean(l&&n&&a)}))}}wt(so,"type","Rect"),wt(so,"cacheProperties",[...xs,...io]),wt(so,"ownDefaults",{rx:0,ry:0}),wt(so,"ATTRIBUTE_NAMES",[...Tr,"x","y","rx","ry","width","height"]),xe.setClass(so),xe.setSVGClass(so);const ro="initialization",oo="added",no="removed",ao="imperative",lo=(t,e)=>{const{strokeUniform:i,strokeWidth:s,width:r,height:o,group:n}=e,a=n&&n!==t?Bi(n.calcTransformMatrix(),t.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),h=i&&c?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xt,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xt;return t.transform(Bi(e,i),!0)}(new Ee(s,s),void 0,t.calcTransformMatrix()):Oe,d=!i&&c?s:0,u=ji(r+d,o+d,Ve([a,e.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class co{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===ro||e===ao||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==ro&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===ao&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:o,width:n,height:a}=Ai(t.map((t=>lo(s,t))).reduce(((t,e)=>t.concat(e)),[])),l=new Ee(n,a),c=new Ee(r,o).add(l.scalarDivide(2));if(i===ro){const t=this.getInitialSize(e,{size:l,center:c});return{center:c,relativeCorrection:new Ee(0,0),size:t}}return{center:c.transform(s.calcOwnMatrix()),size:l}}}wt(co,"type","strategy");class ho extends co{shouldPerformLayout(t){return!0}}wt(ho,"type","fit-content"),xe.setClass(ho);const uo=["strategy"],po=["target","strategy","bubbles","prevStrategy"],go="layoutManager";class fo{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ho;wt(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=St(St({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[ve,ie,ae,re,se,ne,he,le,ce].map((e=>t.on(e,(t=>this.performLayout(e===ve?{type:"object_modified",trigger:e,e:t,target:i}:{type:"object_modifying",trigger:e,e:t,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((t=>t())),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:i}=t,{canvas:s}=e;if(i===ro||i===oo?this.subscribeTargets(t):i===no&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===ao&&t.deep){const i=kt(t,uo);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(St(St({},i),{},{bubbles:!1,target:t}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const o=s===ro?new Ee:e.getRelativeCenterPoint(),{center:n,correction:a=new Ee,relativeCorrection:l=new Ee}=r,c=o.subtract(n).add(a).transform(s===ro?Xt:He(e.calcOwnMatrix()),!0).add(l);return{result:r,prevCenter:o,nextCenter:n,offset:c}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var o,n;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===ro?i.set({left:null!==(o=t.x)&&void 0!==o?o:r.x+s.x*Hi(i.originX),top:null!==(n=t.y)&&void 0!==n?n:r.y+s.y*Hi(i.originY)}):(i.setPositionByOrigin(r,qt,qt),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:r,prevStrategy:o}=t,n=kt(t,po),{canvas:a}=i;i.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:i});const l=i.parent;r&&null!=l&&l.layoutManager&&((n.path||(n.path=[])).push(i),l.layoutManager.performLayout(St(St({},n),{},{target:l}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:go,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}xe.setClass(fo,go);const mo=["type","objects","layoutManager"];class bo extends fo{performLayout(){}}class vo extends(Me(fr)){static getDefaults(){return St(St({},super.getDefaults()),vo.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),wt(this,"_activeObjects",[]),wt(this,"__objectSelectionTracker",void 0),wt(this,"__objectSelectionDisposer",void 0),Object.assign(this,vo.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((t=>{this.enterGroup(t,!1)})),this.layoutManager=null!==(i=e.layoutManager)&&void 0!==i?i:new fo,this.layoutManager.performLayout({type:ro,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Dt("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(Dt("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((t,e,i)=>this.canEnterGroup(t)&&i.indexOf(t)===e))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...s);return this._onAfterObjectsChange(oo,s),r}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...r);return this._onAfterObjectsChange(oo,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(no,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 i=this[t];return super._set(t,e),"canvas"===t&&i!==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:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const t=s.indexOf(i);t>-1&&(s.splice(t,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Ii(t,Ne(He(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Ii(t,Ne(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=fr.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,i){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var s;const e=this._objects[r];null!==(s=this.canvas)&&void 0!==s&&s.preserveObjectStacking&&e.group!==this?(t.save(),t.transform(...He(this.calcTransformMatrix())),e.render(t),t.restore()):e.group===this&&e.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(St({target:this,type:ao},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(t){return!t.excludeFromExport})).map((function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=r,o}))}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.layoutManager.toObject();return St(St(St({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||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=so.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS"," >\n"],i=this._createSVGBgRect(t);i&&e.push("\t\t",i);for(let s=0;s<this._objects.length;s++)e.push("\t\t",this._objects[s].toSVG(t));return e.push("</g>\n"),e}getSvgStyles(){const t=void 0!==this.opacity&&1!==this.opacity?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push("\t",i);for(let s=0;s<this._objects.length;s++)e.push("\t",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,o=kt(t,mo);return Promise.all([ei(s,e),ii(o,e)]).then((t=>{let[e,i]=t;const s=new this(e,St(St(St({},o),i),{},{layoutManager:new bo}));if(r){const t=xe.getClass(r.type),e=xe.getClass(r.strategy);s.layoutManager=new t(new e)}else s.layoutManager=new fo;return s.layoutManager.subscribeTargets({type:ro,target:s,targets:s.getObjects()}),s.setCoords(),s}))}}wt(vo,"type","Group"),wt(vo,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),xe.setClass(vo);const yo="\\s*,?\\s*",_o="".concat(yo,"(").concat(Qi,")"),xo="".concat(_o).concat(_o).concat(_o).concat(yo,"([01])").concat(yo,"([01])").concat(_o).concat(_o),wo={m:"l",M:"L"},Co=(t,e,i,s,r,o,n,a,l,c,h)=>{const d=ke(t),u=Te(t),p=ke(e),g=Te(e),f=i*r*p-s*o*g+n,m=s*r*p+i*o*g+a;return["C",c+l*(-i*r*u-s*o*d),h+l*(-s*r*u+i*o*d),f+l*(i*r*g+s*o*p),m+l*(s*r*g-i*o*p),f,m]},So=(t,e,i,s)=>{const r=Math.atan2(e,t),o=Math.atan2(s,i);return o>=r?o-r:2*Math.PI-(r-o)};function ko(t,e,i,s,r,o,n,a){let l;if(Ot.cachesBoundsOfCurve&&(l=[...arguments].join(),$t.boundsOfCurveCache[l]))return $t.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*n,f=3*i-3*t;for(let _=0;_<2;++_){if(_>0&&(p=6*e-12*s+6*o,g=-3*e+9*s-9*o+3*a,f=3*s-3*e),h(g)<1e-12){if(h(p)<1e-12)continue;const t=-f/p;0<t&&t<1&&d.push(t);continue}const t=p*p-4*f*g;if(t<0)continue;const i=c(t),r=(-p+i)/(2*g);0<r&&r<1&&d.push(r);const n=(-p-i)/(2*g);0<n&&n<1&&d.push(n)}let m=d.length;const b=m,v=Oo(t,e,i,s,r,o,n,a);for(;m--;){const{x:t,y:e}=v(d[m]);u[0][m]=t,u[1][m]=e}u[0][b]=t,u[1][b]=e,u[0][b+1]=n,u[1][b+1]=a;const y=[new Ee(Math.min(...u[0]),Math.min(...u[1])),new Ee(Math.max(...u[0]),Math.max(...u[1]))];return Ot.cachesBoundsOfCurve&&($t.boundsOfCurveCache[l]=y),y}const To=(t,e,i)=>{let[s,r,o,n,a,l,c,h]=i;const d=((t,e,i,s,r,o,n)=>{if(0===i||0===s)return[];let a=0,l=0,c=0;const h=Math.PI,d=n*Wt,u=Te(d),p=ke(d),g=.5*(-p*t-u*e),f=.5*(-p*e+u*t),m=i**2,b=s**2,v=f**2,y=g**2,_=m*b-m*v-b*y;let x=Math.abs(i),w=Math.abs(s);if(_<0){const t=Math.sqrt(1-_/(m*b));x*=t,w*=t}else c=(r===o?-1:1)*Math.sqrt(_/(m*v+b*y));const C=c*x*f/w,S=-c*w*g/x,k=p*C-u*S+.5*t,T=u*C+p*S+.5*e;let E=So(1,0,(g-C)/x,(f-S)/w),O=So((g-C)/x,(f-S)/w,(-g-C)/x,(-f-S)/w);0===o&&O>0?O-=2*h:1===o&&O<0&&(O+=2*h);const D=Math.ceil(Math.abs(O/h*2)),M=[],P=O/D,A=8/3*Math.sin(P/4)*Math.sin(P/4)/Math.sin(P/2);let F=E+P;for(let I=0;I<D;I++)M[I]=Co(E,F,p,u,x,w,k,T,A,a,l),a=M[I][5],l=M[I][6],E=F,F+=P;return M})(c-t,h-e,r,o,a,l,n);for(let u=0,p=d.length;u<p;u++)d[u][1]+=t,d[u][2]+=e,d[u][3]+=t,d[u][4]+=e,d[u][5]+=t,d[u][6]+=e;return d},Eo=(t,e,i,s)=>Math.sqrt((i-t)**2+(s-e)**2),Oo=(t,e,i,s,r,o,n,a)=>l=>{const c=l**3,h=3*(p=l)**2*(1-p),d=(t=>3*t*(1-t)**2)(l),u=(t=>(1-t)**3)(l);var p;return new Ee(n*c+r*h+i*d+t*u,a*c+o*h+s*d+e*u)},Do=t=>t**2,Mo=t=>2*t*(1-t),Po=t=>(1-t)**2,Ao=(t,e,i,s,r,o,n,a)=>l=>{const c=Do(l),h=Mo(l),d=Po(l),u=3*(d*(i-t)+h*(r-i)+c*(n-r)),p=3*(d*(s-e)+h*(o-s)+c*(a-o));return Math.atan2(p,u)},Fo=(t,e,i,s,r,o)=>n=>{const a=Do(n),l=Mo(n),c=Po(n);return new Ee(r*a+i*l+t*c,o*a+s*l+e*c)},Io=(t,e,i,s,r,o)=>n=>{const a=1-n,l=2*(a*(i-t)+n*(r-i)),c=2*(a*(s-e)+n*(o-s));return Math.atan2(c,l)},Lo=(t,e,i)=>{let s=new Ee(e,i),r=0;for(let o=1;o<=100;o+=1){const e=t(o/100);r+=Eo(s.x,s.y,e.x,e.y),s=e}return r},jo=t=>{let e,i,s=0,r=0,o=0,n=0,a=0;const l=[];for(const c of t){const t={x:r,y:o,command:c[0],length:0};switch(c[0]){case"M":i=t,i.x=n=r=c[1],i.y=a=o=c[2];break;case"L":i=t,i.length=Eo(r,o,c[1],c[2]),r=c[1],o=c[2];break;case"C":e=Oo(r,o,c[1],c[2],c[3],c[4],c[5],c[6]),i=t,i.iterator=e,i.angleFinder=Ao(r,o,c[1],c[2],c[3],c[4],c[5],c[6]),i.length=Lo(e,r,o),r=c[5],o=c[6];break;case"Q":e=Fo(r,o,c[1],c[2],c[3],c[4]),i=t,i.iterator=e,i.angleFinder=Io(r,o,c[1],c[2],c[3],c[4]),i.length=Lo(e,r,o),r=c[3],o=c[4];break;case"Z":i=t,i.destX=n,i.destY=a,i.length=Eo(r,o,n,a),r=n,o=a}s+=i.length,l.push(i)}return l.push({length:s,x:r,y:o}),l},Bo=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:jo(t),s=0;for(;e-i[s].length>0&&s<i.length-2;)e-=i[s].length,s++;const r=i[s],o=e/r.length,n=t[s];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return St(St({},new Ee(r.x,r.y).lerp(new Ee(r.destX,r.destY),o)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return St(St({},new Ee(r.x,r.y).lerp(new Ee(n[1],n[2]),o)),{},{angle:Math.atan2(n[2]-r.y,n[1]-r.x)});case"C":case"Q":return((t,e)=>{let i,s=0,r=0,o={x:t.x,y:t.y},n=St({},o),a=.01,l=0;const c=t.iterator,h=t.angleFinder;for(;r<e&&a>1e-4;)n=c(s),l=s,i=Eo(o.x,o.y,n.x,n.y),i+r>e?(s-=a,a/=2):(o=n,s+=a,r+=i);return St(St({},n),{},{angle:h(l)})})(r,e)}},Ro=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),zo=new RegExp(xo,"g"),$o=new RegExp(Qi,"gi"),Ho={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7};function No(t,e){const i=t.style;i&&e&&("string"==typeof e?i.cssText+=";"+e:Object.entries(e).forEach((t=>{let[e,s]=t;return i.setProperty(e,s)})))}class Vo extends Ti{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),wt(this,"upper",void 0),wt(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,r),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Le();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=Bt().createElement("div");return t.setAttribute("data-fabric","wrapper"),No(t,{position:"relative"}),ki(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;No(t,St(St({},i),{},{"touch-action":s?"manipulation":te})),ki(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Ci(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Si(this.upper.el,t),Si(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),jt().dispose(this.upper.el),delete this.upper,delete this.container}}class Uo extends Oi{constructor(){super(...arguments),wt(this,"targets",[]),wt(this,"_hoveredTargets",[]),wt(this,"_objectsToRender",void 0),wt(this,"_currentTransform",null),wt(this,"_groupSelector",null),wt(this,"contextTopDirty",!1)}static getDefaults(){return St(St({},super.getDefaults()),Uo.ownDefaults)}get upperCanvasEl(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.el}get contextTop(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Vo(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(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=o,r.restore();const n=Math.round(s*this.getRetinaScaling());return((t,e,i,s)=>{const r=2*(s=Math.round(s))+1,{data:o}=t.getImageData(e-s,i-s,r,r);for(let n=3;n<o.length;n+=4)if(o[n]>0)return!1;return!0})(r,n,n,n)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((e=>!!e&&!0===t[e])):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&-1===i.indexOf(e)&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===de||e===ue||e===pe||e===ae?s=this.centeredScaling||t.centeredScaling:e===oe&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e?(["ml","tl","bl"].includes(e)?i.x=Qt:["mr","tr","br"].includes(e)&&(i.x=Kt),["tl","mt","tr"].includes(e)?i.y=Jt:["bl","mb","br"].includes(e)&&(i.y=Zt),i):i}_setupCurrentTransform(t,e,i){var s;const r=e.group?Ri(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:n}=e.getActiveControl()||{},a=i&&n?null===(s=n.getActionHandler(t,e,n))||void 0===s?void 0:s.bind(n):qi,l=((t,e,i,s)=>{if(!e||!t)return"drag";const r=s.controls[e];return r.getActionName(i,r,s)})(i,o,t,e),c=t[this.centeredKey],h=this._shouldCenterTransform(e,l,c)?{x:qt,y:qt}:this._getOriginFromCorner(e,o),d={target:e,action:l,actionHandler:a,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:Re(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:c,original:St(St({},Li(e)),{},{originX:h.x,originY:h.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:i,deltaX:s,deltaY:r}=this._groupSelector,o=new Ee(e,i).transform(this.viewportTransform),n=new Ee(e+s,i+r).transform(this.viewportTransform),a=this.selectionLineWidth/2;let l=Math.min(o.x,n.x),c=Math.min(o.y,n.y),h=Math.max(o.x,n.x),d=Math.max(o.y,n.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(l,c,h-l,d-c)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,l+=a,c+=a,h-=a,d-=a,fr.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(l,c,h-l,d-c))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,Mi(t)))return i;if(s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const r=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&r&&r!==i?(this.targets=s,i):r}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[t,e,s,o]=i,n=Math.atan2(e.y-t.y,e.x-t.x),a=ke(n)*r,l=Te(n)*r,c=a+l,h=a-l;i=[new Ee(t.x-h,t.y-c),new Ee(e.x+c,e.y-h),new Ee(s.x+h,s.y+c),new Ee(o.x-c,o.y+h)]}return Ls.isPointInPolygon(e,i)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Ri(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!this.isTargetTransparent(t,e.x,e.y))return!0}return!1}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(De(s)&&s.subTargetCheck){const t=this._searchPossibleTargets(s._objects,e);t&&this.targets.push(t)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&De(i)&&i.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const i=t[e];if(!De(i)||!i.interactive)return i}return t[0]}return i}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&&void 0!==arguments[1]&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=(t=>{const e=_i(t.target),i=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new Ee(i.clientX+e.left,i.clientY+e.top)})(t),o=s.width||0,n=s.height||0;o&&n||(Zt in s&&Jt in s&&(n=Math.abs(s.top-s.bottom)),Qt in s&&Kt in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=Ri(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const l=0===o||0===n?new Ee(1,1):new Ee(i.width/o,i.height/n);return r.multiply(l)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Le(),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 yi(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),o=[],n=[];t.forEach((t=>{r.includes(t)||(i=!0,t.fire("deselected",{e:e,target:t}),n.push(t))})),r.forEach((s=>{t.includes(s)||(i=!0,s.fire("selected",{e:e,target:s}),o.push(s))})),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e:e,selected:o,deselected:n})):r.length>0?(s=!0,this.fire("selection:created",{e:e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e:e,deselected:n})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return!(i===t||!this._discardActiveObject(e,t)&&this._activeObject||t.onSelect({e:e})||(this._activeObject=t,yi(t)&&i!==t&&t.set("canvas",this),t.setCoords(),0))}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),yi(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});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,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(ve,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;yi(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,i){const s=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&yi(e)&&this._activeObject===e){const i=si(t,["angle","flipX","flipY",Kt,ue,pe,ge,fe,Zt]);return((t,e)=>{Ii(t,Ne(e,t.calcOwnMatrix()))})(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}wt(Uo,"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 Wo{constructor(t){wt(this,"targets",[]),wt(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.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),Se(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;(null===(e=this.target)||void 0===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 Xo=["target","oldTarget","fireCanvas","e"],Go={passive:!1},Yo=(t,e)=>{const i=t.getViewportPoint(e),s=t.getScenePoint(e);return{viewportPoint:i,scenePoint:s,pointer:i,absolutePointer:s}},qo=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return t.addEventListener(...i)},Ko=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return t.removeEventListener(...i)},Zo={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 Jo extends Uo{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),wt(this,"_isClick",void 0),wt(this,"textEditingManager",new Wo(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(qo,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(wi(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,Go),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,Go)}removeListeners(){this.addOrRemove(Ko,"remove");const t=this._getEventPrefix(),e=xi(this.upperCanvasEl);Ko(e,"".concat(t,"up"),this._onMouseUp),Ko(e,"touchend",this._onTouchEnd,Go),Ko(e,"".concat(t,"move"),this._onMouseMove,Go),Ko(e,"touchmove",this._onMouseMove,Go),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=St({e:t},Yo(this,t));this.fire("mouse:out",St(St({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",St({},i)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",St(St({},i),{},{target:t})),t&&t.fire("mouseout",St({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",St({e:t},Yo(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 i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void qo(this.upperCanvasEl,"drag",this._onDragProgress)}Pi(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),null==e||e.clearContextTop(),i!==e&&(null==i||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==te,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};Ko(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),r=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let n;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(n=i),i.fire(e,o));for(let a=0;a<s.length;a++){const i=s[a];i.canDrop(t)&&(n=i),i.fire(e,o)}this._renderDragEffects(t,r,n),this._dropTarget=n}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",St({e:t,target:e,subTargets:i,dragSource:this._dragSource},Yo(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&Pi(t),this._basicEventHandler("contextmenu",s),!1}_onDoubleClick(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData()}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,r=this._getEventPrefix(),o=xi(s);qo(o,"touchend",this._onTouchEnd,Go),e&&qo(o,"touchmove",this._onMouseMove,Go),Ko(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();Ko(e,"".concat(i,"move"),this._onMouseMove,Go);const s=xi(e);qo(s,"".concat(i,"up"),this._onMouseUp),qo(s,"".concat(i,"move"),this._onMouseMove,Go)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=xi(this.upperCanvasEl);Ko(i,"touchend",this._onTouchEnd,Go),Ko(i,"touchmove",this._onMouseMove,Go),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{qo(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const t=xi(this.upperCanvasEl);Ko(t,"".concat(i,"up"),this._onMouseUp),Ko(t,"".concat(i,"move"),this._onMouseMove,Go),qo(e,"".concat(i,"move"),this._onMouseMove,Go)}}_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 i=this._currentTransform,s=this._isClick,r=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&1===o||this.fireRightClick&&2===o)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let n,a,l=!1;if(i&&(this._finalizeCurrentTransform(t),l=i.actionPerformed),!s){const e=r===this._activeObject;this.handleSelection(t),l||(l=this._shouldRender(r)||!e&&r===this._activeObject)}if(r){const e=r.findControl(this.getViewportPoint(t),Mi(t)),{key:s,control:o}=e||{};if(a=s,r.selectable&&r!==this._activeObject&&"up"===r.activeOn)this.setActiveObject(r,t),l=!0;else if(o){const e=o.getMouseUpHandler(t,r,o);e&&(n=this.getScenePoint(t),e.call(o,t,i,n.x,n.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==a)){const e=i.target&&i.target.controls[i.corner],s=e&&e.getMouseUpHandler(t,i.target,e);n=n||this.getScenePoint(t),s&&s.call(e,t,i,n.x,n.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),l?this.requestRenderAll():s||null!==(e=this._activeObject)&&void 0!==e&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e){const i=this._target,s=this.targets||[],r=St(St({e:t,target:i,subTargets:s},Yo(this,t)),{},{transform:this._currentTransform},"up:before"===e||"up"===e?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{});this.fire("mouse:".concat(e),r),i&&i.fire("mouse".concat(e),r);for(let o=0;o<s.length;o++)s[o]!==i&&s[o].fire("mouse".concat(e),r)}_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")}_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;const{button:i}=t;if(i)return(this.fireMiddleClick&&1===i||this.fireRightClick&&2===i)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t))return;if(this._currentTransform)return;let s=this._shouldRender(e),r=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,r=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(e){const i=e===this._activeObject;e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);const s=e.findControl(this.getViewportPoint(t),Mi(t));if(e===this._activeObject&&(s||!r)){this._setupCurrentTransform(t,e,i);const r=s?s.control:void 0,o=this.getScenePoint(t),n=r&&r.getMouseDownHandler(t,e,r);n&&n.call(r,t,this._currentTransform,o.x,o.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Ri(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 i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const e=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let n=0;n<o;n++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[n],oldTarget:s[n]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",St(St({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let n=0;n<o;n++)this.fireSyntheticInOutEvents("drag",St(St({},e),{},{target:r[n],oldTarget:s[n]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,n=kt(e,Xo);const{targetIn:a,targetOut:l,canvasIn:c,canvasOut:h}=Zo[t],d=s!==i;if(s&&d){const t=St(St({},n),{},{e:o,target:s,nextTarget:i},Yo(this,o));r&&this.fire(h,t),s.fire(l,t)}if(i&&d){const t=St(St({},n),{},{e:o,target:i,previousTarget:s},Yo(this,o));r&&this.fire(c,t),i.fire(a,t)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,r=s.group?Ri(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:o}=e,n=!!r&&r(t,e,i.x,i.y);n&&o.setCoords(),"drag"===s&&n&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||n}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=yi(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const i=r.control;this.setCursor(i.cursorStyleHandler(t,i,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((t=>{i=t.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=yi(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const s=i.getObjects();if(e===i){const i=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,i)||this.searchPossibleTargets(this._objects,i))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],1===i.size()&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(s,t)}else{i.isEditing&&i.exitEditing();const s=new(xe.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(i,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new Ee(e,i),n=o.add(new Ee(s,r)),a=o.min(n),l=o.max(n).subtract(a),c=this.collectObjects({left:a.x,top:a.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),h=o.eq(n)?c[0]?[c[0]]:[]:c.length>1?c.filter((e=>!e.onSelect({e:t}))).reverse():c;if(1===h.length)this.setActiveObject(h[0],t);else if(h.length>1){const e=xe.getClass("ActiveSelection");this.setActiveObject(new e(h,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Qo={x1:0,y1:0,x2:0,y2:0},tn=St(St({},Qo),{},{r1:0,r2:0}),en=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,sn=/^(\d+\.\d+)%|(\d+)%$/;function rn(t){return t&&sn.test(t)}function on(t,e){const i="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(rn(t)?100:1):NaN;return ys(0,en(i,e),1)}const nn=/\s*;\s*/,an=/\s*:\s*/;function ln(t,e){let i,s;const r=t.getAttribute("style");if(r){const t=r.split(nn);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,o]=t[e].split(an).map((t=>t.trim()));"stop-color"===r?i=o:"stop-opacity"===r&&(s=o)}}const o=new di(i||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:on(t.getAttribute("offset"),0),color:o.toRgb(),opacity:en(parseFloat(s||t.getAttribute("stop-opacity")||""),1)*o.getAlpha()*e}}function cn(t,e){const i=[],s=t.getElementsByTagName("stop"),r=on(e,1);for(let o=s.length;o--;)i.push(ln(s[o],r));return i}function hn(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function dn(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function un(t,e){return t.getAttribute(e)}function pn(t,e){return function(t,e){let i,{width:s,height:r,gradientUnits:o}=e;return Object.keys(t).reduce(((e,n)=>{const a=t[n];return"Infinity"===a?i=1:"-Infinity"===a?i=0:(i="string"==typeof a?parseFloat(a):a,"string"==typeof a&&rn(a)&&(i*=.01,"pixels"===o&&("x1"!==n&&"x2"!==n&&"r2"!==n||(i*=s),"y1"!==n&&"y2"!==n||(i*=r)))),e[n]=i,e}),{})}("linear"===hn(t)?{x1:un(i=t,"x1")||0,y1:un(i,"y1")||0,x2:un(i,"x2")||"100%",y2:un(i,"y2")||0}:function(t){return{x1:un(t,"fx")||un(t,"cx")||"50%",y1:un(t,"fy")||un(t,"cy")||"50%",r1:0,x2:un(t,"cx")||"50%",y2:un(t,"cy")||"50%",r2:un(t,"r")||"50%"}}(t),St(St({},e),{},{gradientUnits:dn(t)}));var i}class gn{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:o=0,offsetY:n=0,gradientTransform:a,id:l}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:St(St({},"radial"===e?tn:Qo),s),colorStops:r,offsetX:o,offsetY:n,gradientTransform:a,id:l?"".concat(l,"_").concat(Ie()):Ie()})}addColorStop(t){for(const e in t){const i=new di(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return St(St({},si(this,t)),{},{type:this.type,coords:St({},this.coords),colorStops:this.colorStops.map((t=>St({},t))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Xt.concat(),r="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((t=>St({},t))).sort(((t,e)=>t.offset-e.offset));let n=-this.offsetX,a=-this.offsetY;var l;"objectBoundingBox"===r?(n/=t.width,a/=t.height):(n+=t.width/2,a+=t.height/2),(l=t)&&"function"==typeof l._renderPathCommands&&"percentage"!==this.gradientUnits&&(n-=t.pathOffset.x,a-=t.pathOffset.y),s[4]-=n,s[5]-=a;const c=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(gi(s),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:s,y2:r}=this.coords;i.push("<linearGradient ",c,' x1="',t,'" y1="',e,'" x2="',s,'" y2="',r,'">\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:s,y2:r,r1:n,r2:a}=this.coords,l=n>a;i.push("<radialGradient ",c,' cx="',l?t:s,'" cy="',l?e:r,'" r="',l?n:a,'" fx="',l?s:t,'" fy="',l?r:e,'">\n'),l&&(o.reverse(),o.forEach((t=>{t.offset=1-t.offset})));const h=Math.min(n,a);if(h>0){const t=h/Math.max(n,a);o.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return o.forEach((t=>{let{color:e,offset:s,opacity:r}=t;i.push("<stop ",'offset="',100*s+"%",'" style="stop-color:',e,void 0!==r?";stop-opacity: "+r:";",'"/>\n')})),i.push("linear"===this.type?"</linearGradient>":"</radialGradient>","\n"),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:o,r2:n}=this.coords,a="linear"===this.type?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,o,s,r,n);return this.colorStops.forEach((t=>{let{color:e,opacity:i,offset:s}=t;a.addColorStop(s,void 0!==i?new di(e).setAlpha(i).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(St(St({},t),{},{colorStops:e?e.map((t=>St({},t))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=dn(t),r=e._findCenterFromElement();return new this(St({id:t.getAttribute("id")||void 0,type:hn(t),coords:pn(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:cn(t,i.opacity),gradientUnits:s,gradientTransform:Zr(t.getAttribute("gradientTransform")||"")},"pixels"===s?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}wt(gn,"type","Gradient"),xe.setClass(gn,"gradient"),xe.setClass(gn,"linear"),xe.setClass(gn,"radial");const fn=["type","source","patternTransform"];class mn{get type(){return"pattern"}set type(t){Dt("warn","Setting type has no effect",t)}constructor(t){wt(this,"repeat","repeat"),wt(this,"offsetX",0),wt(this,"offsetY",0),wt(this,"crossOrigin",""),this.id=Ie(),Object.assign(this,t)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}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&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return St(St({},si(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:ui(this.offsetX,Ot.NUM_FRACTION_DIGITS),offsetY:ui(this.offsetY,Ot.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:o}=this,n=en(this.offsetX/e,0),a=en(this.offsetY/i,0),l="repeat-y"===r||"no-repeat"===r?1+Math.abs(n||0):en(s.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):en(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(n,'" y="').concat(a,'" width="').concat(l,'" height="').concat(c,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join("\n")}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=kt(t,fn);const n=await ti(s,St(St({},e),{},{crossOrigin:o.crossOrigin}));return new this(St(St({},o),{},{patternTransform:r&&r.slice(0),source:n}))}}wt(mn,"type","Pattern"),xe.setClass(mn),xe.setClass(mn,"pattern");const bn=["path","left","top"],vn=["d"];class yn extends fr{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:i,left:s,top:r}=e,o=kt(e,bn);super(),Object.assign(this,yn.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),"number"==typeof s&&this.set(Kt,s),"number"==typeof r&&this.set(Zt,r)}_setPath(t,e){this.path=(t=>{let e=0,i=0,s=0,r=0;const o=[];let n,a=0,l=0;for(const c of t){const t=[...c];let h;switch(t[0]){case"l":t[1]+=e,t[2]+=i;case"L":e=t[1],i=t[2],h=["L",e,i];break;case"h":t[1]+=e;case"H":e=t[1],h=["L",e,i];break;case"v":t[1]+=i;case"V":i=t[1],h=["L",e,i];break;case"m":t[1]+=e,t[2]+=i;case"M":e=t[1],i=t[2],s=t[1],r=t[2],h=["M",e,i];break;case"c":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i,t[5]+=e,t[6]+=i;case"C":a=t[3],l=t[4],e=t[5],i=t[6],h=["C",t[1],t[2],a,l,e,i];break;case"s":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"S":"C"===n?(a=2*e-a,l=2*i-l):(a=e,l=i),e=t[3],i=t[4],h=["C",a,l,t[1],t[2],e,i],a=h[3],l=h[4];break;case"q":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"Q":a=t[1],l=t[2],e=t[3],i=t[4],h=["Q",a,l,e,i];break;case"t":t[1]+=e,t[2]+=i;case"T":"Q"===n?(a=2*e-a,l=2*i-l):(a=e,l=i),e=t[1],i=t[2],h=["Q",a,l,e,i];break;case"a":t[6]+=e,t[7]+=i;case"A":To(e,i,t).forEach((t=>o.push(t))),e=t[6],i=t[7];break;case"z":case"Z":e=s,i=r,h=["Z"]}h?(o.push(h),n=h[0]):n=""}return o})(Array.isArray(t)?t:(t=>{var e;const i=[],s=null!==(e=t.match(Ro))&&void 0!==e?e:[];for(const r of s){const t=r[0];if("z"===t||"Z"===t){i.push([t]);continue}const e=Ho[t.toLowerCase()];let s=[];if("a"===t||"A"===t){zo.lastIndex=0;for(let t=null;t=zo.exec(r);)s.push(...t.slice(1))}else s=r.match($o)||[];for(let r=0;r<s.length;r+=e){const o=new Array(e),n=wo[t];o[0]=r>0&&n?n:t;for(let t=0;t<e;t++)o[t+1]=parseFloat(s[r+t]);i.push(o)}}return i})(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new Ee(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return St(St({},super.toObject(t)),{},{path:this.path.map((t=>t.slice()))})}toDatalessObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=((t,e)=>t.map((t=>t.map(((t,i)=>0===i||void 0===e?t:ui(t,e))).join(" "))).join(" "))(this.path,Ot.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,'" stroke-linecap="round" />\n')]}_getOffsetTransform(){const t=Ot.NUM_FRACTION_DIGITS;return" translate(".concat(ui(-this.pathOffset.x,t),", ").concat(ui(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return"\t"+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:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,qt,qt)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],r=o[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=o[1],r=o[2],e=s,i=r;break;case"C":t.push(...ko(s,r,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],r=o[6];break;case"Q":t.push(...ko(s,r,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],r=o[4];break;case"Z":s=e,r=i}return Ai(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return St(St({},t),{},{pathOffset:new Ee(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=to(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,St(St(St({},kt(s,vn)),e),{},{left:void 0,top:void 0}))}}wt(yn,"type","Path"),wt(yn,"cacheProperties",[...xs,"path","fillRule"]),wt(yn,"ATTRIBUTE_NAMES",[...Tr,"d"]),xe.setClass(yn),xe.setSVGClass(yn);const _n=["left","top","radius"],xn=["radius","startAngle","endAngle","counterClockwise"];class wn extends fr{static getDefaults(){return St(St({},super.getDefaults()),wn.ownDefaults)}constructor(t){super(),Object.assign(this,wn.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,Re(this.startAngle),Re(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ue)}getRadiusY(){return this.get("radius")*this.get(pe)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...xn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),'" />\n'];{const{radius:e}=this,i=Re(this.startAngle),s=Re(this.endAngle),r=ke(i)*e,o=Te(i)*e,n=ke(s)*e,a=Te(s)*e,l=t>180?1:0,c=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(l," ").concat(c," ").concat(n," ").concat(a,'" '),"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,i){const s=to(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:n=0}=s;return new this(St(St({},kt(s,_n)),{},{radius:n,left:r-n,top:o-n}))}static fromObject(t){return super._fromObject(t)}}wt(wn,"type","Circle"),wt(wn,"cacheProperties",[...xs,...xn]),wt(wn,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),wt(wn,"ATTRIBUTE_NAMES",["cx","cy","r",...Tr]),xe.setClass(wn),xe.setSVGClass(wn);const Cn=["x1","y1","x2","y2"],Sn=["x1","y1","x2","y2"],kn=["x1","x2","y1","y2"];class Tn extends fr{constructor(){let[t,e,i,s]=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,Tn.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:n}=r;"number"==typeof o&&this.set(Kt,o),"number"==typeof n&&this.set(Zt,n)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:r,top:o,width:n,height:a}=Ai([{x:t,y:e},{x:i,y:s}]),l=new Ee(r+n/2,o+a/2);this.setPositionByOrigin(l,qt,qt)}_set(t,e){return super._set(t,e),kn.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 i=t.strokeStyle;var s;mi(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null!==(s=this.stroke)&&void 0!==s?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new Ee((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return St(St({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:o}=this,n=t<=e?-1:1,a=i<=s?-1:1;return{x1:n*r/2,x2:n*-r/2,y1:a*o/2,y2:a*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,'" />\n')]}static async fromElement(t,e,i){const s=to(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:o=0,x2:n=0,y2:a=0}=s;return new this([r,o,n,a],kt(s,Cn))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=kt(t,Sn);return this._fromObject(St(St({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}wt(Tn,"type","Line"),wt(Tn,"cacheProperties",[...xs,...kn]),wt(Tn,"ATTRIBUTE_NAMES",Tr.concat(kn)),xe.setClass(Tn),xe.setSVGClass(Tn);class En extends fr{static getDefaults(){return St(St({},super.getDefaults()),En.ownDefaults)}constructor(t){super(),Object.assign(this,En.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}wt(En,"type","Triangle"),wt(En,"ownDefaults",{width:100,height:100}),xe.setClass(En),xe.setSVGClass(En);const On=["rx","ry"];class Dn extends fr{static getDefaults(){return St(St({},super.getDefaults()),Dn.ownDefaults)}constructor(t){super(),Object.assign(this,Dn.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(ue)}getRy(){return this.get("ry")*this.get(pe)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...On,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,'" />\n')]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Ut,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=to(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}wt(Dn,"type","Ellipse"),wt(Dn,"cacheProperties",[...xs,...On]),wt(Dn,"ownDefaults",{rx:0,ry:0}),wt(Dn,"ATTRIBUTE_NAMES",[...Tr,"cx","cy","rx","ry"]),xe.setClass(Dn),xe.setSVGClass(Dn);const Mn=["left","top"],Pn={exactBoundingBox:!1};class An extends fr{static getDefaults(){return St(St({},super.getDefaults()),An.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),wt(this,"strokeDiff",void 0),Object.assign(this,An.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(Kt,i),"number"==typeof s&&this.set(Zt,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=[];if(0===t.length)return s;const r=t.reduce(((t,e)=>(t[t.length-1].eq(e)||t.push(new Ee(e)),t)),[new Ee(t[0])]);if(1===r.length)i=!0;else if(!i){const t=r[0],e=((t,e)=>{for(let i=t.length-1;i>=0;i--)if(e(t[i]))return i;return-1})(r,(e=>!e.eq(t)));r.splice(e+1)}return r.forEach(((t,r,o)=>{let n,a;0===r?(a=o[1],n=i?t:o[o.length-1]):r===o.length-1?(n=o[r-1],a=i?t:o[0]):(n=o[r-1],a=o[r+1]),i&&1===o.length?s.push(...new yr(t,t,e).project()):!i||0!==r&&r!==o.length-1?s.push(...new vr(t,n,a,e).project()):s.push(...new yr(t,0===r?a:n,e).project())})),s}(this.points,t,this.isOpen())}_calcDimensions(t){t=St({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((t=>t.projectedPoint)):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new Ee,strokeOffset:new Ee,strokeDiff:new Ee};const i=Ai(e),s=Je(St(St({},t),{},{scaleX:1,scaleY:1})),r=Ai(this.points.map((t=>$e(t,s,!0)))),o=new Ee(this.scaleX,this.scaleY);let n=i.left+i.width/2,a=i.top+i.height/2;return this.exactBoundingBox&&(n-=a*Math.tan(Re(this.skewX)),a-=n*Math.tan(Re(this.skewY))),St(St({},i),{},{pathOffset:new Ee(n,a),strokeOffset:new Ee(r.left,r.top).subtract(new Ee(i.left,i.top)).multiply(o),strokeDiff:new Ee(i.width,i.height).subtract(new Ee(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=Ai(this.points);return new Ee(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:o,strokeOffset:n,strokeDiff:a}=this._calcDimensions();this.set({width:s,height:r,pathOffset:o,strokeOffset:n,strokeDiff:a}),t&&this.setPositionByOrigin(new Ee(e+s/2,i+r/2),qt,qt)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new Ee(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((t=>this.strokeUniform||this.constructor.layoutProperties.includes(t)))){var e,i;const{width:s,height:r}=this._calcDimensions(t);o=new Ee(null!==(e=t.width)&&void 0!==e?e:s,null!==(i=t.height)&&void 0!==i?i:r)}else{var s,r;o=new Ee(null!==(s=t.width)&&void 0!==s?s:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return o.multiply(new Ee(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===ue||t===pe)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return St(St({},super.toObject(t)),{},{points:this.points.map((t=>{let{x:e,y:i}=t;return{x:e,y:i}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=Ot.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(ui(this.points[r].x-e,s),",",ui(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),'" />\n')]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let r=0;r<e;r++){const e=this.points[r];t.lineTo(e.x-i,e.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(function(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),i=[];for(let s=0;s<e.length;s+=2)i.push({x:parseFloat(e[s]),y:parseFloat(e[s+1])});return i}(t.getAttribute("points")),St(St({},kt(to(t,this.ATTRIBUTE_NAMES,i),Mn)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}wt(An,"ownDefaults",Pn),wt(An,"type","Polyline"),wt(An,"layoutProperties",[ge,fe,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),wt(An,"cacheProperties",[...xs,"points"]),wt(An,"ATTRIBUTE_NAMES",[...Tr]),xe.setClass(An),xe.setSVGClass(An);class Fn extends An{isOpen(){return!1}}wt(Fn,"ownDefaults",Pn),wt(Fn,"type","Polygon"),xe.setClass(Fn),xe.setSVGClass(Fn);const In=["fontSize","fontWeight","fontFamily","fontStyle"],Ln=["underline","overline","linethrough"],jn=[...In,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Bn=[...jn,...Ln,"textBackgroundColor","direction"],Rn=[...In,...Ln,be,"strokeWidth",me,"deltaY","textBackgroundColor"],zn={_reNewline:ee,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Kt,fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Kt,pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2},$n="justify",Hn="justify-left",Nn="justify-right",Vn="justify-center";class Un extends fr{isEmptyStyles(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;const e=void 0===t?this.styles:{line:this.styles[t]};for(const i in e)for(const t in e[i])for(const s in e[i][t])return!1;return!0}styleHas(t,e){if(!this.styles)return!1;if(void 0!==e&&!this.styles[e])return!1;const i=void 0===e?this.styles:{0:this.styles[e]};for(const s in i)for(const e in i[s])if(void 0!==i[s][e][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,o=!0,n=0;for(const a in e){i=0;for(const n in e[a]){const l=e[a][n]||{};r++,void 0!==l[t]?(s?l[t]!==s&&(o=!1):s=l[t],l[t]===this[t]&&delete l[t]):o=!1,0!==Object.keys(l).length?i++:delete e[a][n]}0===i&&delete e[a]}for(let a=0;a<this._textLines.length;a++)n+=this._textLines[a].length;o&&r===n&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],0===Object.keys(i[r]).length&&delete i[r];0===Object.keys(i).length&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=ri(St(St({},this._getStyleDeclaration(i,s)),e),(t=>void 0!==t));this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&null!==(i=s[e])&&void 0!==i?i:{}}getCompleteStyleDeclaration(t,e){return St(St({},si(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_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]}}wt(Un,"_styleProperties",Rn);const Wn=/ +/g,Xn=/"/g;function Gn(t,e,i,s,r){return"\t\t".concat(function(t,e){let{left:i,top:s,width:r,height:o}=e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ot.NUM_FRACTION_DIGITS;const a=fi(me,t,!1),[l,c,h,d]=[i,s,r,o].map((t=>ui(t,n)));return"<rect ".concat(a,' x="').concat(l,'" y="').concat(c,'" width="').concat(h,'" height="').concat(d,'"></rect>')}(t,{left:e,top:i,width:s,height:r}),"\n")}const Yn=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let qn;class Kn extends Un{static getDefaults(){return St(St({},super.getDefaults()),Kn.ownDefaults)}constructor(t,e){super(),wt(this,"__charBounds",[]),Object.assign(this,Kn.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=jo(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($n)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,o,n;for(let a=0,l=this._textLines.length;a<l;a++)if((this.textAlign===$n||a!==l-1&&!this.isEndOfWrapping(a))&&(s=0,r=this._textLines[a],e=this.getLineWidth(a),e<this.width&&(n=this.textLines[a].match(this._reSpacesAndTabs)))){i=n.length,t=(this.width-e)/i;for(let e=0;e<=r.length;e++)o=this.__charBounds[a][e],this._reSpaceAndTab.test(r[e])?(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 i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===be?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case qt:t.textBaseline="middle";break;case"ascender":t.textBaseline=Zt;break;case"descender":t.textBaseline=Jt}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,i,s,r,o){this._renderChars(t,e,i,s,r,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,o=this._textLines.length;r<o;r++){const e=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=e;continue}const o=this._textLines[r].length,n=this._getLineLeftOffset(r);let a,l,c=0,h=0,d=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let u=0;u<o;u++){const o=this.__charBounds[r][u];l=this.getValueOfPropertyAt(r,u,"textBackgroundColor"),this.path?(t.save(),t.translate(o.renderLeft,o.renderTop),t.rotate(o.angle),t.fillStyle=l,l&&t.fillRect(-o.width/2,-e/this.lineHeight*(1-this._fontSizeFraction),o.width,e/this.lineHeight),t.restore()):l!==d?(a=i+n+h,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=d,d&&t.fillRect(a,s,c,e/this.lineHeight),h=o.left,c=o.width,d=l):c+=o.kernedWidth}l&&!this.path&&(a=i+n+h,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=l,t.fillRect(a,s,c,e/this.lineHeight)),s+=e}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=$t.getFontCache(e),o=this._getFontDeclaration(e),n=i+t,a=i&&o===this._getFontDeclaration(s),l=e.fontSize/this.CACHE_FONT_SIZE;let c,h,d,u;if(i&&void 0!==r[i]&&(d=r[i]),void 0!==r[t]&&(u=c=r[t]),a&&void 0!==r[n]&&(h=r[n],u=h-d),void 0===c||void 0===d||void 0===h){const s=function(){if(!qn){const t=je({width:0,height:0});qn=t.getContext("2d")}return qn}();this._setTextStyles(s,e,!0),void 0===c&&(u=c=s.measureText(t).width,r[t]=c),void 0===d&&a&&i&&(d=s.measureText(i).width,r[i]=d),a&&void 0===h&&(h=s.measureText(n).width,r[n]=h,u=h-d)}return{width:c*l,kernedWidth:u*l}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===Qt,o=this.path,n=this._textLines[t],a=n.length,l=new Array(a);this.__charBounds[t]=l;for(let c=0;c<a;c++){const r=n[c];i=this._getGraphemeBox(r,t,c,e),l[c]=i,s+=i.kernedWidth,e=r}if(l[a]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let t=0;const e=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Kt:t=r?e-s:0;break;case qt:t=(e-s)/2;break;case Qt:t=r?0:e-s}t+=this.pathStartOffset*(r?-1:1);for(let s=r?a-1:0;r?s>=0:s<a;r?s--:s++)i=l[s],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,i),t+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=Bo(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===Qt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const o=this.getCompleteStyleDeclaration(e,i),n=s?this.getCompleteStyleDeclaration(e,i-1):{},a=this._measureChar(t,o,s,n);let l,c=a.kernedWidth,h=a.width;0!==this.charSpacing&&(l=this._getWidthOfCharSpacing(),h+=l,c+=l);const d={width:h,left:0,height:o.fontSize,kernedWidth:c,deltaY:o.deltaY};if(i>0&&!r){const t=this.__charBounds[e][i-1];d.left=t.left+t.width+a.kernedWidth-a.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)e=Math.max(this.getHeightOfChar(t,i),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let i=0,s=this._textLines.length;i<s;i++)t=this.getHeightOfLine(i),e+=i===s-1?t/this.lineHeight:t;return e}_getLeftOffset(){return"ltr"===this.direction?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),r=this._getTopOffset();for(let o=0,n=this._textLines.length;o<n;o++){const n=this.getHeightOfLine(o),a=n/this.lineHeight,l=this._getLineLeftOffset(o);this._renderTextLine(e,t,this._textLines[o],s+l,r+i+a,o),i+=n}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(me))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!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,i,s,r,o){const n=this.getHeightOfLine(o),a=this.textAlign.includes($n),l=this.path,c=!a&&0===this.charSpacing&&this.isEmptyStyles(o)&&!l,h="ltr"===this.direction,d="ltr"===this.direction?1:-1,u=e.direction;let p,g,f,m,b,v="",y=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Kt:Qt),r-=n*this._fontSizeFraction/this.lineHeight,c)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let _=0,x=i.length-1;_<=x;_++)m=_===x||this.charSpacing||l,v+=i[_],f=this.__charBounds[o][_],0===y?(s+=d*(f.kernedWidth-f.width),y+=f.width):y+=f.kernedWidth,a&&!m&&this._reSpaceAndTab.test(i[_])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(o,_),g=this.getCompleteStyleDeclaration(o,_+1),m=Cr(p,g,!1)),m&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,_,v,-y/2,0),e.restore()):(b=s,this._renderChar(t,e,o,_,v,b,r)),v="",p=g,s+=d*y,y=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=je({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return mi(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,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",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,r,o,n){const a=this._getStyleDeclaration(i,s),l=this.getCompleteStyleDeclaration(i,s),c="fillText"===t&&l.fill,h="strokeText"===t&&l.stroke&&l.strokeWidth;if(h||c){if(e.save(),e.font=this._getFontDeclaration(l),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(n+=a.deltaY),c){const t=this._setFillStyles(e,l);e.fillText(r,o-t.offsetX,n-t.offsetY)}if(h){const t=this._setStrokeStyles(e,l);e.strokeText(r,o-t.offsetX,n-t.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),n={fontSize:r*i.size,deltaY:o+r*i.baseline};this.setSelectionStyles(n,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,o=this.isEndOfWrapping(t);let n=0;return s===$n||s===Vn&&!o||s===Nn&&!o||s===Hn&&!o?0:(s===qt&&(n=i/2),s===Qt&&(n=i),s===Vn&&(n=i/2),s===Nn&&(n=i),"rtl"===r&&(s===Qt||s===$n||s===Nn?n=0:s===Kt||s===Hn?n=-i:s!==qt&&s!==Vn||(n=-i/2)),n)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return null!==(s=this._getStyleDeclaration(t,e)[i])&&void 0!==s?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,o=this._getWidthOfCharSpacing(),n=this.offsets[e];for(let a=0,l=this._textLines.length;a<l;a++){const l=this.getHeightOfLine(a);if(!this[e]&&!this.styleHas(e,a)){i+=l;continue}const c=this._textLines[a],h=l/this.lineHeight,d=this._getLineLeftOffset(a);let u,p,g=0,f=0,m=this.getValueOfPropertyAt(a,0,e),b=this.getValueOfPropertyAt(a,0,me);const v=i+h*(1-this._fontSizeFraction);let y=this.getHeightOfChar(a,0),_=this.getValueOfPropertyAt(a,0,"deltaY");for(let i=0,o=c.length;i<o;i++){const o=this.__charBounds[a][i];u=this.getValueOfPropertyAt(a,i,e),p=this.getValueOfPropertyAt(a,i,me);const l=this.getHeightOfChar(a,i),c=this.getValueOfPropertyAt(a,i,"deltaY");if(r&&u&&p)t.save(),t.fillStyle=b,t.translate(o.renderLeft,o.renderTop),t.rotate(o.angle),t.fillRect(-o.kernedWidth/2,n*l+c,o.kernedWidth,this.fontSize/15),t.restore();else if((u!==m||p!==b||l!==y||c!==_)&&f>0){let e=s+d+g;"rtl"===this.direction&&(e=this.width-e-f),m&&b&&(t.fillStyle=b,t.fillRect(e,v+n*y+_,f,this.fontSize/15)),g=o.left,f=o.width,m=u,b=p,y=l,_=c}else f+=o.kernedWidth}let x=s+d+g;"rtl"===this.direction&&(x=this.width-x-f),t.fillStyle=p,u&&p&&t.fillRect(x,v+n*y+_,f-o,this.fontSize/15),i+=l}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Kn.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?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 xr(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=["\n"];let r=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),r=r.concat(i[o],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return St(St({},super.toObject([...Bn,...t])),{},{styles:Sr(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,r=!1;if("object"==typeof t)for(const o in t)"path"===o&&this.setPathInfo(),s=s||i.includes(o),r=r||"path"===o;else s=i.includes(t),r="path"===t;return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=to(t,Kn.ATTRIBUTE_NAMES,i),r=St(St({},e),s),{textAnchor:o=Kt,textDecoration:n="",dx:a=0,dy:l=0,top:c=0,left:h=0,fontSize:d=Gt,strokeWidth:u=1}=r,p=kt(r,Yn),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),St({left:h+a,top:c+l,underline:n.includes("underline"),overline:n.includes("overline"),linethrough:n.includes("line-through"),strokeWidth:0,fontSize:d},p)),f=g.getScaledHeight()/g.height,m=((g.height+g.strokeWidth)*g.lineHeight-g.height)*f,b=g.getScaledHeight()+m;let v=0;return o===qt&&(v=g.getScaledWidth()/2),o===Qt&&(v=g.getScaledWidth()),g.set({left:g.left-v,top:g.top-(b-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:u}),g}static fromObject(t){return this._fromObject(St(St({},t),{},{styles:kr(t.styles||{},t.text)}),{extraParam:"text"})}}wt(Kn,"textLayoutProperties",jn),wt(Kn,"cacheProperties",[...xs,...Bn]),wt(Kn,"ownDefaults",zn),wt(Kn,"type","Text"),wt(Kn,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),wt(Kn,"ATTRIBUTE_NAMES",Tr.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),gr(Kn,[class extends Ki{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(t){let{textBgRects:e,textSpans:i}=t;const s=this.getSvgTextDecoration(this);return[e.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(Xn,"'"),'" '):"",this.fontSize?'font-size="'.concat(this.fontSize,'" '):"",this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",s?'text-decoration="'.concat(s,'" '):"","rtl"===this.direction?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",i.join(""),"</text>\n"]}_getSVGTextAndBg(t,e){const i=[],s=[];let r,o=t;this.backgroundColor&&s.push(...Gn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let n=0,a=this._textLines.length;n<a;n++)r=this._getLineLeftOffset(n),"rtl"===this.direction&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",n))&&this._setSVGTextLineBg(s,n,e+r,o),this._setSVGTextLineText(i,n,e+r,o),o+=this.getHeightOfLine(n);return{textSpans:i,textBgRects:s}}_createTextCharSpan(t,e,i,s){const r=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(Wn)),o=r?'style="'.concat(r,'"'):"",n=e.deltaY,a=n?' dy="'.concat(ui(n,Ot.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(ui(i,Ot.NUM_FRACTION_DIGITS),'" y="').concat(ui(s,Ot.NUM_FRACTION_DIGITS),'" ').concat(a).concat(o,">").concat((t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))(t),"</tspan>")}_setSVGTextLineText(t,e,i,s){const r=this.getHeightOfLine(e),o=this.textAlign.includes($n),n=this._textLines[e];let a,l,c,h,d,u="",p=0;s+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=n.length-1;g<=f;g++)d=g===f||this.charSpacing,u+=n[g],c=this.__charBounds[e][g],0===p?(i+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,o&&!d&&this._reSpaceAndTab.test(n[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(e,g),l=this.getCompleteStyleDeclaration(e,g+1),d=Cr(a,l,!0)),d&&(h=this._getStyleDeclaration(e,g),t.push(this._createTextCharSpan(u,h,i,s)),u="",a=l,"rtl"===this.direction?i-=p:i+=p,p=0)}_setSVGTextLineBg(t,e,i,s){const r=this._textLines[e],o=this.getHeightOfLine(e)/this.lineHeight;let n,a=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let h=0;h<r.length;h++){const{left:r,width:d,kernedWidth:u}=this.__charBounds[e][h];n=this.getValueOfPropertyAt(e,h,"textBackgroundColor"),n!==c?(c&&t.push(...Gn(c,i+l,s,a,o)),l=r,a=d,c=n):a+=u}n&&t.push(...Gn(c,i+l,s,a,o))}_getSVGLineTopOffset(t){let e,i=0;for(e=0;e<t;e++)i+=this.getHeightOfLine(e);const s=this.getHeightOfLine(e);return{lineTop:i,offset:(this._fontSizeMult-this._fontSizeFraction)*s/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(t){return"".concat(super.getSvgStyles(t)," white-space: pre;")}getSvgSpanStyles(t,e){const{fontFamily:i,strokeWidth:s,stroke:r,fill:o,fontSize:n,fontStyle:a,fontWeight:l,deltaY:c}=t,h=this.getSvgTextDecoration(t);return[r?fi(be,r):"",s?"stroke-width: ".concat(s,"; "):"",i?"font-family: ".concat(i.includes("'")||i.includes('"')?i:"'".concat(i,"'"),"; "):"",n?"font-size: ".concat(n,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h?"text-decoration: ".concat(h,"; "):h,o?fi(me,o):"",c?"baseline-shift: ".concat(-c,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter((e=>t[e.replace("-","")])).join(" ")}}]),xe.setClass(Kn),xe.setSVGClass(Kn);class Zn{constructor(t){wt(this,"target",void 0),wt(this,"__mouseDownInPlace",!1),wt(this,"__dragStartFired",!1),wt(this,"__isDraggingOver",!1),wt(this,"__dragStartSelection",void 0),wt(this,"__dragImageDisposer",void 0),wt(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((t=>t())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=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 i;let{selectionStart:s,selectionEnd:r}=e;const o=this.target,n=o.canvas,a=new Ee(o.flipX?-1:1,o.flipY?-1:1),l=o._getCursorBoundaries(s),c=new Ee(l.left+l.leftOffset,l.top+l.topOffset).multiply(a).transform(o.calcTransformMatrix()),h=n.getScenePoint(t).subtract(c),d=o.getCanvasRetinaScaling(),u=o.getBoundingRect(),p=c.subtract(new Ee(u.left,u.top)),g=n.viewportTransform,f=p.add(h).transform(g,!0),m=o.backgroundColor,b=_r(o.styles);o.backgroundColor="";const v={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(v,0,s),o.setSelectionStyles(v,r,o.text.length),o.dirty=!0;const y=o.toCanvasElement({enableRetinaScaling:n.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=m,o.styles=b,o.dirty=!0,No(y,{position:"fixed",left:"".concat(-y.width,"px"),border:te,width:"".concat(y.width/d,"px"),height:"".concat(y.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{y.remove()},xi(t.target||this.target.hiddenTextarea).body.appendChild(y),null===(i=t.dataTransfer)||void 0===i||i.setDragImage(y,f.x,f.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(i.selectionStart,i.selectionEnd).join(""),r=St({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,r)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e:e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e:e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(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:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let r=null===(e=i.dataTransfer)||void 0===e?void 0:e.getData("text/plain");if(r&&!s){const e=this.target,s=e.canvas;let o=e.getSelectionStartFromPointer(i);const{styles:n}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},a=r[Math.max(0,r.length-1)],l=0;if(this.__dragStartSelection){const t=this.__dragStartSelection.selectionStart,i=this.__dragStartSelection.selectionEnd;o>t&&o<=i?o=t:o>i&&(o-=i-t),e.removeChars(t,i),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[o])||o===e._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(r,n,o),s.setActiveObject(e),e.enterEditing(i),e.selectionStart=Math.min(o+l,e._text.length),e.selectionEnd=Math.min(e.selectionStart+r.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(he,{index:o+l,action:"drop"}),s.fire("text:changed",{target:e}),s.contextTopDirty=!0,s.requestRenderAll()}}dragEndHandler(t){let{e:e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const t=this.target,s=this.target.canvas,{selectionStart:r,selectionEnd:o}=this.__dragStartSelection,n=(null===(i=e.dataTransfer)||void 0===i?void 0:i.dropEffect)||te;n===te?(t.selectionStart=r,t.selectionEnd=o,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===n&&(t.removeChars(r,o),t.selectionStart=t.selectionEnd=r,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(he,{index:r,action:"dragend"}),s.fire("text:changed",{target:t}),s.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Jn=/[ \n\.,;!\?\-]/;class Qn extends Kn{constructor(){super(...arguments),wt(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:i,delay:s,onComplete:r}=t;return Is({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,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;null===(t=this._currentTickCompleteState)||void 0===t||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}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(-1===e||!ee.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!Jn.test(r);)s+=e,r=i[s];return-1===e&&Jn.test(r)&&s++,s}selectWord(t){t=t||this.selectionStart;const e=this.searchWordBoundary(t,-1),i=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t||this.selectionStart;const e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this}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;xi(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(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,i){const s=i.slice(0,t),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.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),i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex,o=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,n=e.leftOffset,a=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,c=l.width/a,h=l.height/a,d=c-o,u=h-o,p=new Ee(e.left+n,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new Ee(l.clientWidth/c,l.clientHeight/h));return p.x<0&&(p.x=0),p.x>d&&(p.x=d),p.y<0&&(p.y=0),p.y>u&&(p.y=u),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:"".concat(p.x,"px"),top:"".concat(p.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(ve),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:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let t=s;t<this._unwrappedTextLines[i].length;t++)delete this.styles[i][t];if(this.styles[r])for(let t=o;t<this._unwrappedTextLines[r].length;t++){const e=this.styles[r][t];e&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+t-o]=e)}for(let t=i+1;t<=r;t++)delete this.styles[t];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const t=this.styles[i],e=o-s;for(let i=s;i<o;i++)delete t[i];for(const s in this.styles[i]){const i=parseInt(s,10);i>=o&&(t[i-e]=t[s],delete t[s])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},o=this._unwrappedTextLines[t].length,n=o===e;let a=!1;i||(i=1),this.shiftLineStyles(t,i);const l=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const h in this.styles[t]){const i=parseInt(h,10);i>=e&&(a=!0,r[i-e]=this.styles[t][h],n&&0===e||delete this.styles[t][h])}let c=!1;for(a&&!n&&(this.styles[t+i]=r,c=!0),(c||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:St({},s[i-1])}:l?this.styles[t+i]={0:St({},l)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],o=r?St({},r):{};i||(i=1);for(const a in o){const t=parseInt(a,10);t>=e&&(r[t+i]=o[t],o[t-i]||delete r[t])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=St({},s[i]));return}if(!r)return;const n=r[e?e-1:1];for(;n&&i--;)this.styles[t][e+i]=St({},n)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let o,n=0;for(let a=0;a<t.length;a++)"\n"===t[a]?(n++,r[n]=0):r[n]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),n&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],n),o=1;o<n;o++)r[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,r[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,r[o],i)}removeChars(t){let e=arguments.length>1&&void 0!==arguments[1]?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,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Kt:this._selectionDirection===Qt&&(this._selectionDirection=Kt,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===Qt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=Qt:this._selectionDirection===Kt&&(this._selectionDirection=Qt,this.selectionStart=e),this.selectionEnd=i)}}class ta extends Qn{initHiddenTextarea(){const t=this.canvas&&xi(this.canvas.getElement())||Bt(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map((t=>{let[i,s]=t;return e.setAttribute(i,s)}));const{top:i,left:s,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(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((t=>{let[i,s]=t;return e.addEventListener(i,this[s].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e="rtl"===this.direction?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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(he),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void i();const s=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,o=s.length,n=this.selectionStart,a=this.selectionEnd,l=n!==a;let c,h,d,u,p=o-r;const g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),f=n>g.selectionStart;l?(h=this._text.slice(n,a),p+=a-n):o<r&&(h=f?this._text.slice(a+p,a):this._text.slice(n,n-p));const m=s.slice(g.selectionEnd-p,g.selectionEnd);if(h&&h.length&&(m.length&&(c=this.getSelectionStyles(n,n+1,!1),c=m.map((()=>c[0]))),l?(d=n,u=a):f?(d=a-h.length,u=a):(d=a,u=a+h.length),this.removeStyleFromTo(d,u)),m.length){const{copyPasteData:t}=jt();e&&m.join("")===t.copiedText&&!Ot.disableStyleCopyPaste&&(c=t.copiedTextStyle),this.insertNewStyleBlock(m,n,c)}i()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=jt();t.copiedText=this.getSelectedText(),Ot.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 i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;const o=s.charIndex,n=this._getWidthBeforeCursor(r,o),a=this._getIndexOnLine(r+1,n);return this._textLines[r].slice(o).length+a+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;const o=s.charIndex,n=this._getWidthBeforeCursor(r,o),a=this._getIndexOnLine(r-1,n),l=this._textLines[r].slice(0,o),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-l.length+(1-c)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,o=this._getLineLeftOffset(t),n=0;for(let a=0,l=i.length;a<l;a++)if(s=this.__charBounds[t][a].width,o+=s,o>e){r=!0;const t=o-s,i=o,l=Math.abs(t-e);n=Math.abs(i-e)<l?a:a-1;break}return r||(n=i.length-1),n}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===Qt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i){const t=this.text.length;this.selectionStart=ys(0,this.selectionStart,t),this.selectionEnd=ys(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Kt?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return void 0!==s&&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=Kt,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Qt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=Kt,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 i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Kt&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Qt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Qt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const ea=t=>!!t.button;class ia extends ta{constructor(){super(...arguments),wt(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new Zn(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),Pi(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!ea(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!ea(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e:e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||ea(e)||s||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(He(this.calcTransformMatrix())).add(new Ee(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let l=0;l<this._textLines.length&&i<=e.y;l++)i+=this.getHeightOfLine(l),r=l,l>0&&(s+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));let o=Math.abs(this._getLineLeftOffset(r));const n=this._textLines[r].length,a=this.__charBounds[r];for(let l=0;l<n;l++){const t=o+a[l].kernedWidth;if(e.x<=t){Math.abs(e.x-t)<=Math.abs(e.x-o)&&s++;break}o=t,s++}return Math.min(this.flipX?n-s:s,this._text.length)}}const sa="moveCursorUp",ra="moveCursorDown",oa="moveCursorLeft",na="moveCursorRight",aa="exitEditing",la=St({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:aa,27:aa,33:sa,34:ra,35:na,36:oa,37:oa,38:sa,39:na,40:ra},keysMapRtl:{9:aa,27:aa,33:sa,34:ra,35:oa,36:na,37:na,38:sa,39:oa,40:ra},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ca extends ia{static getDefaults(){return St(St({},super.getDefaults()),ca.ownDefaults)}get type(){const t=super.type;return"itext"===t?"i-text":t}constructor(t,e){super(t,St(St({},ca.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof Jo&&this.canvas.textEditingManager.remove(this),e instanceof Jo&&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&&void 0!==arguments[0]?arguments[0]:this.selectionStart||0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionStart||0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&void 0!==arguments[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 i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_getCursorBoundaries(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.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,i=0;const{charIndex:s,lineIndex:r}=this.get2DCursorLocation(t);for(let l=0;l<r;l++)e+=this.getHeightOfLine(l);const o=this._getLineLeftOffset(r),n=this.__charBounds[r][s];n&&(i=n.left),0!==this.charSpacing&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const a={top:e,left:o+(i>0?i:0)};return"rtl"===this.direction&&(this.textAlign===Qt||this.textAlign===$n||this.textAlign===Nn?a.left*=-1:this.textAlign===Kt||this.textAlign===Hn?a.left=o-(i>0?i:0):this.textAlign!==qt&&this.textAlign!==Vn||(a.left=o-(i>0?i:0))),a}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&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,r,"fontSize"),n=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/n,l=this.getValueOfPropertyAt(s,r,"deltaY"),c=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:c+e.top+l,width:a,height:o}}_renderCursor(t,e,i){const{color:s,opacity:r,left:o,top:n,width:a,height:l}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(o,n,a,l)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,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,i){const s=e.selectionStart,r=e.selectionEnd,o=this.textAlign.includes($n),n=this.get2DCursorLocation(s),a=this.get2DCursorLocation(r),l=n.lineIndex,c=a.lineIndex,h=n.charIndex<0?0:n.charIndex,d=a.charIndex<0?0:a.charIndex;for(let u=l;u<=c;u++){const e=this._getLineLeftOffset(u)||0;let s=this.getHeightOfLine(u),r=0,n=0,a=0;if(u===l&&(n=this.__charBounds[l][h].left),u>=l&&u<c)a=o&&!this.isEndOfWrapping(u)?this.width:this.getLineWidth(u)||5;else if(u===c)if(0===d)a=this.__charBounds[c][d].left;else{const t=this._getWidthOfCharSpacing();a=this.__charBounds[c][d-1].left+this.__charBounds[c][d-1].width-t}r=s,(this.lineHeight<1||u===c&&this.lineHeight>1)&&(s/=this.lineHeight);let p=i.left+e+n,g=s,f=0;const m=a-n;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",g=1,f=s):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===Qt||this.textAlign===$n||this.textAlign===Nn?p=this.width-p-m:this.textAlign===Kt||this.textAlign===Hn?p=i.left+e-a:this.textAlign!==qt&&this.textAlign!==Vn||(p=i.left+e-a)),t.fillRect(p,i.top+i.topOffset+f,m,g),i.topOffset+=r}}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,me)}_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()}}wt(ca,"ownDefaults",la),wt(ca,"type","IText"),xe.setClass(ca),xe.setClass(ca,"i-text");class ha extends ca{static getDefaults(){return St(St({},super.getDefaults()),ha.ownDefaults)}constructor(t,e){super(t,St(St({},ha.ownDefaults),e))}static createControls(){return{controls:ur()}}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($n)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let o=0;o<t.graphemeLines.length;o++)"\n"===t.graphemeText[s]&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),r[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const o=this._styleMap[t],n=this._styleMap[t+1];o&&(t=o.line,i=o.offset),n&&(s=n.line,r=s===t,e=n.offset);const a=void 0===t?this.styles:{line:this.styles[t]};for(const l in a)for(const t in a[l]){const s=parseInt(t,10);if(s>=i&&(!r||s<e))for(const e in a[l][t])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.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 i=this.getGraphemeDataForRender(t),s=[];for(let r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((t,r)=>{let o=0;const n=e?this.graphemeSplit(t):this.wordSplit(t);return 0===n.length?[{word:[],width:0}]:n.map((t=>{const n=e?[t]:this.graphemeSplit(t),a=this._measureWord(n,r,o);return s=Math.max(a,s),o+=n.length+i.length,{word:n,width:a}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=0;for(let o=0,n=t.length;o<n;o++)r+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const n=this._getWidthOfCharSpacing(),a=this.splitByGrapheme,l=[],c=a?"":" ";let h=0,d=[],u=0,p=0,g=!0;e-=o;const f=Math.max(e,s,this.dynamicMinWidth),m=r[t];let b;for(u=0,b=0;b<m.length;b++){const{word:e,width:i}=m[b];u+=e.length,h+=p+i-n,h>f&&!g?(l.push(d),d=[],h=i,g=!0):h+=n,g||a||d.push(c),d=d.concat(e),p=a?0:this._measureWord([c],t,u),u++,g=!1}return b&&l.push(d),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-n+o),l}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),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=i[r].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){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&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}wt(ha,"type","Textbox"),wt(ha,"textLayoutProperties",[...ca.textLayoutProperties,"width"]),wt(ha,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),xe.setClass(ha);class da extends co{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:n}=Ai(lo(i,s)),a=new Ee(o,n);if(s.absolutePositioned)return{center:Ri(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:a};{const r=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:i=new Ee,correction:s=new Ee}=this.calcBoundingBox(e,t)||{};return{center:i.add(r),correction:s.subtract(r),size:a}}return{center:i.getRelativeCenterPoint().add(r),size:a}}}}wt(da,"type","clip-path"),xe.setClass(da);class ua extends co{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new Ee(i.width||s.x,i.height||s.y)}}wt(ua,"type","fixed"),xe.setClass(ua);class pa extends fo{subscribeTargets(t){const e=t.target;t.targets.reduce(((t,e)=>(e.parent&&t.add(e.parent),t)),new Set).forEach((t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((t,e)=>(e.parent&&t.add(e.parent),t)),new Set).forEach((t=>{!i.some((e=>e.parent===t))&&t.layoutManager.unsubscribeTargets({target:t,targets:[e]})}))}}class ga extends vo{static getDefaults(){return St(St({},super.getDefaults()),ga.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,ga.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:null!=r?r:new pa})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];"selection-order"===this.multiSelectionStacking?this.add(...e):e.forEach((t=>{const e=this._objects.findIndex((e=>e.isInFrontOf(t))),i=-1===e?this.size():e;this.insertAt(i,t)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(Dt("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 i=new Set;e.forEach((t=>{const{parent:e}=t;e&&i.add(e)})),t===no?i.forEach((t=>{t._onAfterObjectsChange(oo,e)})):i.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=St(St({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}wt(ga,"type","ActiveSelection"),wt(ga,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),xe.setClass(ga),xe.setClass(ga,"activeSelection");class fa{constructor(){wt(this,"resources",{})}applyFilters(t,e,i,s,r){const o=r.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const n={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:r,ctx:o,filterBackend:this};t.forEach((t=>{t.applyTo(n)}));const{imageData:a}=n;return a.width===i&&a.height===s||(r.width=a.width,r.height=a.height),o.putImageData(a,0,0),n}}class ma{constructor(){let{tileSize:t=Ot.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};wt(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),wt(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=je({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,r,o){const n=this.gl,a=r.getContext("2d");if(!n||!a)return;let l;o&&(l=this.getCachedTexture(o,e));const c={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:n,sourceTexture:this.createTexture(n,i,s,l?void 0:e),targetTexture:this.createTexture(n,i,s),originalTexture:l||this.createTexture(n,i,s,l?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=n.createFramebuffer();return n.bindFramebuffer(n.FRAMEBUFFER,h),t.forEach((t=>{t&&t.applyTo(c)})),function(t){const e=t.targetCanvas,i=e.width,s=e.height,r=t.destinationWidth,o=t.destinationHeight;i===r&&s===o||(e.width=r,e.height=o)}(c),this.copyGLTo2D(n,c),n.bindTexture(n.TEXTURE_2D,null),n.deleteTexture(c.sourceTexture),n.deleteTexture(c.targetTexture),n.deleteFramebuffer(h),a.setTransform(1,0,0,1,0,0),c}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:o,TEXTURE_2D:n,RGBA:a,UNSIGNED_BYTE:l,CLAMP_TO_EDGE:c,TEXTURE_MAG_FILTER:h,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:u,TEXTURE_WRAP_T:p}=t,g=t.createTexture();return t.bindTexture(n,g),t.texParameteri(n,h,r||o),t.texParameteri(n,d,r||o),t.texParameteri(n,u,c),t.texParameteri(n,p,c),s?t.texImage2D(n,0,a,a,l,s):t.texImage2D(n,0,a,e,i,0,a,l,null),g}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const o=i.height-s.height;r.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,r=e.destinationHeight,o=s*r*4;if(!i)return;const n=new Uint8Array(this.imageBuffer,0,o),a=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,n);const l=new ImageData(a,s,r);i.putImageData(l,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let ba;function va(){return!ba&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(ba=function(){const{WebGLProbe:t}=jt();return t.queryWebGL(Le()),Ot.enableGLFiltering&&t.isSupported(Ot.textureSize)?new ma({tileSize:Ot.textureSize}):new fa}()),ba}const ya=["filters","resizeFilter","src","crossOrigin","type"],_a=["cropX","cropY"];class xa extends fr{static getDefaults(){return St(St({},super.getDefaults()),xa.ownDefaults)}constructor(t,e){super(),wt(this,"_lastScaleX",1),wt(this,"_lastScaleY",1),wt(this,"_filterScalingX",1),wt(this,"_filterScalingY",1),this.filters=[],Object.assign(this,xa.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ie()),this.setElement("string"==typeof t?(this.canvas&&xi(this.canvas.getElement())||Bt()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(e),t.classList.add(xa.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=va(!1);e instanceof ma&&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&&jt().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||0===this.strokeWidth)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=[];return this.filters.forEach((t=>{t&&e.push(t.toObject())})),St(St({},super.toObject([..._a,...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,i=-this.width/2,s=-this.height/2;let r=[],o=[],n="",a="";if(!e)return[];if(this.hasCrop()){const t=Ie();r.push('<clipPath id="imageCrop_'+t+'">\n','\t<rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),n=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t<image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(a).concat(n,"></image>\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,o=['\t<rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),'" />\n')],this.fill=t}return r=this.paintFirst!==me?r.concat(o,t):r.concat(t,o),r}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:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ti(t,{crossOrigin:e,signal:i}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const n=je(o),{width:a,height:l}=o;this._element=n,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,va().applyFilters([t],o,a,l,this._element),this._filterScalingX=n.width/this._originalElement.width,this._filterScalingY=n.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.filters||[];if(t=t.filter((t=>t&&!t.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const t=je({width:i,height:s});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);va().applyFilters(t,this._originalElement,i,s,this._element),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,!0!==this.isMoving&&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 i=this._filterScalingX,s=this._filterScalingY,r=this.width,o=this.height,n=Math.max(this.cropX,0),a=Math.max(this.cropY,0),l=e.naturalWidth||e.width,c=e.naturalHeight||e.height,h=n*i,d=a*s,u=Math.min(r*i,l-h),p=Math.min(o*s,c-d),g=-r/2,f=-o/2,m=Math.min(r,l/i-n),b=Math.min(o,c/s-a);e&&t.drawImage(e,h,d,u,p,g,f,m,b)}_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&&void 0!==arguments[0]?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=(t=>{const[e,i]=t.trim().split(" "),[s,r]=(o=e)&&o!==te?[o.slice(1,4),o.slice(5,8)]:o===te?[o,o]:["Mid","Mid"];var o;return{meetOrSlice:i||"meet",alignX:s,alignY:r}})(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,o=this._element.width,n=this._element.height,a=1,l=1,c=0,h=0,d=0,u=0;return!t||t.alignX===te&&t.alignY===te?(a=e/o,l=i/n):("meet"===t.meetOrSlice&&(a=l=((t,e)=>Math.min(e.width/t.width,e.height/t.height))(this._element,s),r=(e-o*a)/2,"Min"===t.alignX&&(c=-r),"Max"===t.alignX&&(c=r),r=(i-n*l)/2,"Min"===t.alignY&&(h=-r),"Max"===t.alignY&&(h=r)),"slice"===t.meetOrSlice&&(a=l=((t,e)=>Math.max(e.width/t.width,e.height/t.height))(this._element,s),r=o-e/a,"Mid"===t.alignX&&(d=r/2),"Max"===t.alignX&&(d=r),r=n-i/l,"Mid"===t.alignY&&(u=r/2),"Max"===t.alignY&&(u=r),o=e/a,n=i/l)),{width:o,height:n,scaleX:a,scaleY:l,offsetLeft:c,offsetTop:h,cropX:d,cropY:u}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:n}=t,a=kt(t,ya);return Promise.all([ti(r,St(St({},e),{},{crossOrigin:o})),i&&ei(i,e),s&&ei([s],e),ii(a,e)]).then((t=>{let[e,i=[],[s]=[],o={}]=t;return new this(e,St(St({},a),{},{src:r,filters:i,resizeFilter:s},o))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return ti(t,{crossOrigin:e,signal:i}).then((t=>new this(t,s)))}static async fromElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=to(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch((t=>(Dt("log","Unable to parse Image",t),null)))}}wt(xa,"type","Image"),wt(xa,"cacheProperties",[...xs,..._a]),wt(xa,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),wt(xa,"CSS_CANVAS","canvas-img"),wt(xa,"ATTRIBUTE_NAMES",[...Tr,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),xe.setClass(xa),xe.setSVGClass(xa),Zi(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const wa=t=>void 0!==t.webgl,Ca="precision highp float",Sa="\n ".concat(Ca,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),ka=["type"],Ta=["type"],Ea=new RegExp(Ca,"g");class Oa{get type(){return this.constructor.type}constructor(){let t=kt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},ka);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Sa}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }"}createProgram(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=jt();"highp"!==s&&(e=e.replace(Ea,Ca.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),n=t.createProgram();if(!r||!o||!n)throw new Mt("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Mt("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Mt("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(n,r),t.attachShader(n,o),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS))throw new Mt('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(n)));const a=this.getUniformLocations(t,n)||{};return a.uStepW=t.getUniformLocation(n,"uStepW"),a.uStepH=t.getUniformLocation(n,"uStepH"),{program:n,attributeLocations:this.getAttributeLocations(t,n),uniformLocations:a}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,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){wa(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,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),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:i}=t,s=je({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return St({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(kt(t,Ta))}}wt(Oa,"type","BaseFilter"),wt(Oa,"uniformLocations",[]);const Da={multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",difference:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"\n if (uColor.r < 0.5) {\n gl_FragColor.r *= 2.0 * uColor.r;\n } else {\n gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n }\n if (uColor.g < 0.5) {\n gl_FragColor.g *= 2.0 * uColor.g;\n } else {\n gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n }\n if (uColor.b < 0.5) {\n gl_FragColor.b *= 2.0 * uColor.b;\n } else {\n gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n }\n ",tint:"\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n "};class Ma extends Oa{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n gl_FragColor = color;\n if (color.a > 0.0) {\n ".concat(Da[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const i=new di(this.color).getSource(),s=this.alpha,r=i[0]*s,o=i[1]*s,n=i[2]*s,a=1-s;for(let l=0;l<e.length;l+=4){const t=e[l],i=e[l+1],s=e[l+2];let c,h,d;switch(this.mode){case"multiply":c=t*r/255,h=i*o/255,d=s*n/255;break;case"screen":c=255-(255-t)*(255-r)/255,h=255-(255-i)*(255-o)/255,d=255-(255-s)*(255-n)/255;break;case"add":c=t+r,h=i+o,d=s+n;break;case"difference":c=Math.abs(t-r),h=Math.abs(i-o),d=Math.abs(s-n);break;case"subtract":c=t-r,h=i-o,d=s-n;break;case"darken":c=Math.min(t,r),h=Math.min(i,o),d=Math.min(s,n);break;case"lighten":c=Math.max(t,r),h=Math.max(i,o),d=Math.max(s,n);break;case"overlay":c=r<128?2*t*r/255:255-2*(255-t)*(255-r)/255,h=o<128?2*i*o/255:255-2*(255-i)*(255-o)/255,d=n<128?2*s*n/255:255-2*(255-s)*(255-n)/255;break;case"exclusion":c=r+t-2*r*t/255,h=o+i-2*o*i/255,d=n+s-2*n*s/255;break;case"tint":c=r+t*a,h=o+i*a,d=n+s*a}e[l]=c,e[l+1]=h,e[l+2]=d}}sendUniformData(t,e){const i=new di(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}wt(Ma,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),wt(Ma,"type","BlendColor"),wt(Ma,"uniformLocations",["uColor"]),xe.setClass(Ma);const Pa={multiply:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.rgba *= color2.rgba;\n gl_FragColor = color;\n }\n ",mask:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.a = color2.a;\n gl_FragColor = color;\n }\n "},Aa=["type","image"];class Fa extends Oa{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Pa[this.mode]}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n "}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,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:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const o=this.image;r.blendImage||(r.blendImage=Le());const n=r.blendImage,a=n.getContext("2d");n.width!==i||n.height!==s?(n.width=i,n.height=s):a.clearRect(0,0,i,s),a.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),a.drawImage(o.getElement(),0,0,i,s);const l=a.getImageData(0,0,i,s).data;for(let c=0;c<e.length;c+=4){const t=e[c],i=e[c+1],s=e[c+2],r=e[c+3],o=l[c],n=l[c+1],a=l[c+2],h=l[c+3];switch(this.mode){case"multiply":e[c]=t*o/255,e[c+1]=i*n/255,e[c+2]=s*a/255,e[c+3]=r*h/255;break;case"mask":e[c+3]=h}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return St(St({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=kt(t,Aa);return xa.fromObject(s,e).then((t=>new this(St(St({},r),{},{image:t}))))}}wt(Fa,"type","BlendImage"),wt(Fa,"defaults",{mode:"multiply",alpha:1}),wt(Fa,"uniformLocations",["uTransformMatrix","uImage"]),xe.setClass(Fa);class Ia extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){wa(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){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:i,filterBackend:{resources:s}}=t;const{width:r,height:o}=i;s.blurLayer1||(s.blurLayer1=Le(),s.blurLayer2=Le());const n=s.blurLayer1,a=s.blurLayer2;n.width===r&&n.height===o||(a.width=n.width=r,a.height=n.height=o);const l=n.getContext("2d"),c=a.getContext("2d"),h=.06*this.blur*.5;let d,u,p,g;for(l.putImageData(i,0,0),c.clearRect(0,0,r,o),g=-15;g<=15;g++)d=(Math.random()-.5)/4,u=g/15,p=h*u*r+d,c.globalAlpha=1-Math.abs(u),c.drawImage(n,p,d),l.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(g=-15;g<=15;g++)d=(Math.random()-.5)/4,u=g/15,p=h*u*o+d,c.globalAlpha=1-Math.abs(u),c.drawImage(n,d,p),l.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(n,0,0);const f=e.getImageData(0,0,n.width,n.height);return l.globalAlpha=1,l.clearRect(0,0,n.width,n.height),f}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const i=t*this.blur*.12;return this.horizontal?e[0]=i:e[1]=i,e}}wt(Ia,"type","Blur"),wt(Ia,"defaults",{blur:0}),wt(Ia,"uniformLocations",["uDelta"]),xe.setClass(Ia);class La extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBrightness;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += uBrightness;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=i,e[s+1]+=i,e[s+2]+=i}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}wt(La,"type","Brightness"),wt(La,"defaults",{brightness:0}),wt(La,"uniformLocations",["uBrightness"]),xe.setClass(La);const ja={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ba extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n uniform mat4 uColorMatrix;\n uniform vec4 uConstants;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color *= uColorMatrix;\n color += uConstants;\n gl_FragColor = color;\n }"}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const t=e[r],o=e[r+1],n=e[r+2];if(e[r]=t*i[0]+o*i[1]+n*i[2]+255*i[4],e[r+1]=t*i[5]+o*i[6]+n*i[7]+255*i[9],e[r+2]=t*i[10]+o*i[11]+n*i[12]+255*i[14],!s){const s=e[r+3];e[r]+=s*i[3],e[r+1]+=s*i[8],e[r+2]+=s*i[13],e[r+3]=t*i[15]+o*i[16]+n*i[17]+s*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return St(St({},super.toObject()),{},{matrix:[...this.matrix]})}}function Ra(t,e){var i;const s=(wt(i=class extends Ba{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),wt(i,"defaults",{colorsOnly:!1,matrix:e}),i);return xe.setClass(s,t),s}wt(Ba,"type","ColorMatrix"),wt(Ba,"defaults",ja),wt(Ba,"uniformLocations",["uColorMatrix","uConstants"]),xe.setClass(Ba),Ra("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Ra("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Ra("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Ra("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Ra("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Ra("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Ra("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 za extends Oa{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){wa(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((t=>xe.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}wt(za,"type","Composed"),xe.setClass(za);class $a extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uContrast;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n gl_FragColor = color;\n }"}isNeutralState(){return 0===this.contrast}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}wt($a,"type","Contrast"),wt($a,"defaults",{contrast:0}),wt($a,"uniformLocations",["uContrast"]),xe.setClass($a);const Ha={Convolute_3_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_3_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_5_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_5_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_7_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_7_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_9_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_9_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n "};class Na extends Oa{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Ha[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),o=Math.floor(r/2),n=e.width,a=e.height,l=t.ctx.createImageData(n,a),c=l.data,h=this.opaque?1:0;let d,u,p,g,f,m,b,v,y,_,x,w,C;for(x=0;x<a;x++)for(_=0;_<n;_++){for(f=4*(x*n+_),d=0,u=0,p=0,g=0,C=0;C<r;C++)for(w=0;w<r;w++)b=x+C-o,m=_+w-o,b<0||b>=a||m<0||m>=n||(v=4*(b*n+m),y=s[C*r+w],d+=i[v]*y,u+=i[v+1]*y,p+=i[v+2]*y,h||(g+=i[v+3]*y));c[f]=d,c[f+1]=u,c[f+2]=p,c[f+3]=h?i[f+3]:g}t.imageData=l}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return St(St({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}wt(Na,"type","Convolute"),wt(Na,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),wt(Na,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),xe.setClass(Na);const Va="Gamma";class Ua extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec3 uGamma;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec3 correction = (1.0 / uGamma);\n color.r = pow(color.r, correction.r);\n color.g = pow(color.g, correction.g);\n color.b = pow(color.b, correction.b);\n gl_FragColor = color;\n gl_FragColor.rgb *= color.a;\n }\n"}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],r=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const n=this.rgbValues;for(let a=0;a<256;a++)n.r[a]=255*Math.pow(a/255,s),n.g[a]=255*Math.pow(a/255,r),n.b[a]=255*Math.pow(a/255,o);for(let a=0;a<e.length;a+=4)e[a]=n.r[e[a]],e[a+1]=n.g[e[a+1]],e[a+2]=n.b[e[a+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:Va,gamma:this.gamma.concat()}}}wt(Ua,"type",Va),wt(Ua,"defaults",{gamma:[1,1,1]}),wt(Ua,"uniformLocations",["uGamma"]),xe.setClass(Ua);const Wa={average:"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float average = (color.r + color.b + color.g) / 3.0;\n gl_FragColor = vec4(average, average, average, color.a);\n }\n ",lightness:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n ",luminosity:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n "};class Xa extends Oa{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],o=e[s+2];switch(this.mode){case"average":i=(t+r+o)/3;break;case"lightness":i=(Math.min(t,r,o)+Math.max(t,r,o))/2;break;case"luminosity":i=.21*t+.72*r+.07*o}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Wa[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}wt(Xa,"type","Grayscale"),wt(Xa,"defaults",{mode:"average"}),wt(Xa,"uniformLocations",["uMode"]),xe.setClass(Xa);const Ga=St(St({},ja),{},{rotation:0});class Ya extends Ba{calculateMatrix(){const t=this.rotation*Math.PI,e=ke(t),i=Te(t),s=1/3,r=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-r,s*o+r,0,0,s*o+r,e+s*o,s*o-r,0,0,s*o-r,s*o+r,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}wt(Ya,"type","HueRotation"),wt(Ya,"defaults",Ga),xe.setClass(Ya);class qa extends Oa{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uInvert;\n uniform int uAlpha;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n if (uInvert == 1) {\n if (uAlpha == 1) {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);\n } else {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n }\n } else {\n gl_FragColor = color;\n }\n }\n"}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}wt(qa,"type","Invert"),wt(qa,"defaults",{alpha:!1,invert:!0}),wt(qa,"uniformLocations",["uInvert","uAlpha"]),xe.setClass(qa);class Ka extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uStepH;\n uniform float uNoise;\n uniform float uSeed;\n varying vec2 vTexCoord;\n float rand(vec2 co, float seed, float vScale) {\n return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n }\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const t=(.5-Math.random())*i;e[s]+=t,e[s+1]+=t,e[s+2]+=t}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}}wt(Ka,"type","Noise"),wt(Ka,"defaults",{noise:0}),wt(Ka,"uniformLocations",["uNoise","uSeed"]),xe.setClass(Ka);class Za extends Oa{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let t=0;t<i;t+=this.blocksize){const o=4*r*i+4*t,n=e[o],a=e[o+1],l=e[o+2],c=e[o+3];for(let h=r;h<Math.min(r+this.blocksize,s);h++)for(let s=t;s<Math.min(t+this.blocksize,i);s++){const t=4*h*i+4*s;e[t]=n,e[t+1]=a,e[t+2]=l,e[t+3]=c}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBlocksize;\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n float blockW = uBlocksize * uStepW;\n float blockH = uBlocksize * uStepH;\n int posX = int(vTexCoord.x / blockW);\n int posY = int(vTexCoord.y / blockH);\n float fposX = float(posX);\n float fposY = float(posY);\n vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n vec4 color = texture2D(uTexture, squareCoords);\n gl_FragColor = color;\n }\n"}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}wt(Za,"type","Pixelate"),wt(Za,"defaults",{blocksize:4}),wt(Za,"uniformLocations",["uBlocksize"]),xe.setClass(Za);class Ja extends Oa{getFragmentSource(){return"\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n gl_FragColor.a = 0.0;\n }\n}\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new di(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],o=[s[0]+i,s[1]+i,s[2]+i];for(let n=0;n<e.length;n+=4){const t=e[n],i=e[n+1],s=e[n+2];t>r[0]&&i>r[1]&&s>r[2]&&t<o[0]&&i<o[1]&&s<o[2]&&(e[n+3]=0)}}sendUniformData(t,e){const i=new di(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],o=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,o)}}wt(Ja,"type","RemoveColor"),wt(Ja,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),wt(Ja,"uniformLocations",["uLow","uHigh"]),xe.setClass(Ja);class Qa extends Oa{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),s=new Array(i);for(let r=1;r<=i;r++)s[r-1]=t(r*e);return s}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[".concat(t,"];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ").concat(e.map(((t,e)=>"\n color += texture2D(uTexture, vTexCoord + ".concat(t,") * uTaps[").concat(e,"] + texture2D(uTexture, vTexCoord - ").concat(t,") * uTaps[").concat(e,"];\n sum += 2.0 * uTaps[").concat(e,"];\n "))).join("\n"),"\n gl_FragColor = color / sum;\n }\n ")}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){wa(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,o=e.height,n=Math.round(r*i),a=Math.round(o*s);let l;l="sliceHack"===this.resizeType?this.sliceByTwo(t,r,o,n,a):"hermite"===this.resizeType?this.hermiteFastResize(t,r,o,n,a):"bilinear"===this.resizeType?this.bilinearFiltering(t,r,o,n,a):"lanczos"===this.resizeType?this.lanczosResize(t,r,o,n,a):new ImageData(n,a),t.imageData=l}sliceByTwo(t,e,i,s,r){const o=t.imageData,n=.5;let a=!1,l=!1,c=e*n,h=i*n;const d=t.filterBackend.resources;let u=0,p=0;const g=e;let f=0;d.sliceByTwo||(d.sliceByTwo=Le());const m=d.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const b=m.getContext("2d");for(b.clearRect(0,0,1.5*e,i),b.putImageData(o,0,0),s=Math.floor(s),r=Math.floor(r);!a||!l;)e=c,i=h,s<Math.floor(c*n)?c=Math.floor(c*n):(c=s,a=!0),r<Math.floor(h*n)?h=Math.floor(h*n):(h=r,l=!0),b.drawImage(m,u,p,e,i,g,f,c,h),u=g,p=f,f+=h;return b.getImageData(u,p,s,r)}lanczosResize(t,e,i,s,r){const o=t.imageData.data,n=t.ctx.createImageData(s,r),a=n.data,l=this.lanczosCreate(this.lanczosLobes),c=this.rcpScaleX,h=this.rcpScaleY,d=2/this.rcpScaleX,u=2/this.rcpScaleY,p=Math.ceil(c*this.lanczosLobes/2),g=Math.ceil(h*this.lanczosLobes/2),f={},m={x:0,y:0},b={x:0,y:0};return function t(v){let y,_,x,w,C,S,k,T,E,O,D;for(m.x=(v+.5)*c,b.x=Math.floor(m.x),y=0;y<r;y++){for(m.y=(y+.5)*h,b.y=Math.floor(m.y),C=0,S=0,k=0,T=0,E=0,_=b.x-p;_<=b.x+p;_++)if(!(_<0||_>=e)){O=Math.floor(1e3*Math.abs(_-m.x)),f[O]||(f[O]={});for(let t=b.y-g;t<=b.y+g;t++)t<0||t>=i||(D=Math.floor(1e3*Math.abs(t-m.y)),f[O][D]||(f[O][D]=l(Math.sqrt(Math.pow(O*d,2)+Math.pow(D*u,2))/1e3)),x=f[O][D],x>0&&(w=4*(t*e+_),C+=x,S+=x*o[w],k+=x*o[w+1],T+=x*o[w+2],E+=x*o[w+3]))}w=4*(y*s+v),a[w]=S/C,a[w+1]=k/C,a[w+2]=T/C,a[w+3]=E/C}return++v<s?t(v):n}(0)}bilinearFiltering(t,e,i,s,r){let o,n,a,l,c,h,d,u,p,g,f,m,b,v=0;const y=this.rcpScaleX,_=this.rcpScaleY,x=4*(e-1),w=t.imageData.data,C=t.ctx.createImageData(s,r),S=C.data;for(d=0;d<r;d++)for(u=0;u<s;u++)for(c=Math.floor(y*u),h=Math.floor(_*d),p=y*u-c,g=_*d-h,b=4*(h*e+c),f=0;f<4;f++)o=w[b+f],n=w[b+4+f],a=w[b+x+f],l=w[b+x+4+f],m=o*(1-p)*(1-g)+n*p*(1-g)+a*g*(1-p)+l*p*g,S[v++]=m;return C}hermiteFastResize(t,e,i,s,r){const o=this.rcpScaleX,n=this.rcpScaleY,a=Math.ceil(o/2),l=Math.ceil(n/2),c=t.imageData.data,h=t.ctx.createImageData(s,r),d=h.data;for(let u=0;u<r;u++)for(let t=0;t<s;t++){const i=4*(t+u*s);let r=0,h=0,p=0,g=0,f=0,m=0,b=0;const v=(u+.5)*n;for(let s=Math.floor(u*n);s<(u+1)*n;s++){const i=Math.abs(v-(s+.5))/l,n=(t+.5)*o,d=i*i;for(let l=Math.floor(t*o);l<(t+1)*o;l++){let t=Math.abs(n-(l+.5))/a;const i=Math.sqrt(d+t*t);i>1&&i<-1||(r=2*i*i*i-3*i*i+1,r>0&&(t=4*(l+s*e),b+=r*c[t+3],p+=r,c[t+3]<255&&(r=r*c[t+3]/250),g+=r*c[t],f+=r*c[t+1],m+=r*c[t+2],h+=r))}}d[i]=g/h,d[i+1]=f/h,d[i+2]=m/h,d[i+3]=b/p}return h}}wt(Qa,"type","Resize"),wt(Qa,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),wt(Qa,"uniformLocations",["uDelta","uTaps"]),xe.setClass(Qa);class tl extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uSaturation;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float rgMax = max(color.r, color.g);\n float rgbMax = max(rgMax, color.b);\n color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],o=e[s+2],n=Math.max(t,r,o);e[s]+=n!==t?(n-t)*i:0,e[s+1]+=n!==r?(n-r)*i:0,e[s+2]+=n!==o?(n-o)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}wt(tl,"type","Saturation"),wt(tl,"defaults",{saturation:0}),wt(tl,"uniformLocations",["uSaturation"]),xe.setClass(tl);class el extends Oa{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uVibrance;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float max = max(color.r, max(color.g, color.b));\n float avg = (color.r + color.g + color.b) / 3.0;\n float amt = (abs(max - avg) * 2.0) * uVibrance;\n color.r += max != color.r ? (max - color.r) * amt : 0.00;\n color.g += max != color.g ? (max - color.g) * amt : 0.00;\n color.b += max != color.b ? (max - color.b) * amt : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],o=e[s+2],n=Math.max(t,r,o),a=(t+r+o)/3,l=2*Math.abs(n-a)/255*i;e[s]+=n!==t?(n-t)*l:0,e[s+1]+=n!==r?(n-r)*l:0,e[s+2]+=n!==o?(n-o)*l:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}function il(t,e){const i={waitUntilFirstUpdate:!1,...e};return function(e,s){const r=Array.isArray(t)?t:[t],{update:o}=e;e.update=function(t){r.forEach((e=>{const r=e;if(t.has(r)){const e=t.get(r),o=this[r];e!==o&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](e,o))}})),o.call(this,t)}}}wt(el,"type","Vibrance"),wt(el,"defaults",{vibrance:0}),wt(el,"uniformLocations",["uVibrance"]),xe.setClass(el);const sl=l`
138
- :host {
139
- box-sizing: border-box;
140
- }
141
-
142
- :host *,
143
- :host *::before,
144
- :host *::after {
145
- box-sizing: inherit;
146
- }
147
-
148
- [hidden] {
149
- display: none !important;
150
- }
151
- `,rl=l`
152
- :host {
153
- display: block;
154
- }
155
-
156
- .fabric-container {
157
- max-width: 24rem;
158
- width: 100% !important;
159
- height: auto !important;
160
- object-fit: contain;
161
- display: block;
162
- margin-left: auto;
163
- margin-right: auto;
164
- }
165
-
166
- .fabric-container canvas {
167
- max-width: 24rem;
168
- width: 100% !important;
169
- height: auto !important;
170
- display: block;
171
- object-fit: contain;
172
- }
173
- `;var ol=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,al=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?nl(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&ol(e,i,o),o};t.FabricExample=class extends ct{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message="Dear fridends,\n\nMy name is xxxxx. sadf;lkasdf\ngood aklsdfja",this.alignment="left",this.fontFamily="Arial",this.color="#000",this._backgroundImg=new Image,this._natureSize={width:0,height:0},this._scale=1,this._lineHeight=0,this._fontSize=0,this._backgroundImg=new Image}connectedCallback(){super.connectedCallback();new ResizeObserver((()=>{this.adjustCanvasElements()})).observe(this),this._backgroundImg.src="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this._backgroundImg.onload=()=>{this._natureSize={width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}},this._canvasElement=document.createElement("canvas")}disconnectedCallback(){super.disconnectedCallback()}formatTextbox(t){var e;let i=t.textLines;if(i.length>12){const s=i.slice(0,12);t.set("text",s.join("\n")),t.setSelectionStart(t.text.length),t.setSelectionEnd(t.text.length),null==(e=this._canvas)||e.renderAll()}}firstUpdated(){var t;const e=document.createElement("canvas");null==(t=this.shadowRoot)||t.appendChild(e),this._backgroundImg.onload=()=>{const t=new xa(this._backgroundImg);this._canvas=new Jo(e,{backgroundImage:t,containerClass:"fabric-container"}),this._canvas.setDimensions({width:this._backgroundImg.width,height:this._backgroundImg.height}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:(this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width)/12*.8,left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0};this._textbox=new ha(this.message,i),this._textbox.set("fill",this.color),this._textbox.on("changed",(()=>{var t;if(!this._textbox)return;let e=this._textbox.text.split("\n"),i=[];e.forEach((t=>{if(t.length>20){const e=t.split(" ");let s="",r=0;e.forEach((t=>{r+t.length>20?(i.push(s.trim()),s=t+" ",r=t.length+1):(s+=t+" ",r+=t.length+1)})),s.trim().length>0&&i.push(s.trim())}else i.push(t)})),i.length>12&&(i=i.slice(0,12)),this._textbox.text=i.join("\n"),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),null==(t=this._canvas)||t.renderAll()})),this._rect=new so({left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,fill:"red",selectable:!1}),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.add(this._rect),this._canvas.renderAll()},window.addEventListener("resize",(()=>{var t;e.width=this._fabricContainer.clientWidth,e.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),null==(t=this._canvas)||t.renderAll()})),setTimeout((()=>this.adjustCanvasElements()),100)}adjustCanvasElements(){var t,e;if(!(this._canvas&&this._textbox&&this._backgroundImg&&this._backgroundImg.complete))return;const i=null==(t=this.shadowRoot)?void 0:t.querySelector(".fabric-container");if(!i)return;const s=i.clientWidth,r=i.clientHeight,o=this._backgroundImg.naturalWidth,n=this._backgroundImg.naturalHeight;let a;a=0===r||0===s?s/o:s/r>o/n?r/n:s/o;const l=o*a,c=n*a;this._canvas.setDimensions({width:l,height:c}),this._canvas.backgroundImage&&(this._canvas.backgroundImage.scaleToWidth(l),this._canvas.backgroundImage.scaleToHeight(c)),this._textbox.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l,fontSize:(c-.4874*c-.084*l)/12*.8,lineHeight:this._lineHeight*a}),null==(e=this._rect)||e.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l}),this._canvas.renderAll()}handleMessageChange(t,e){var i;this._textbox&&(this._textbox.set("text",e),this.formatTextbox(this._textbox),null==(i=this._canvas)||i.renderAll())}handleAlignmentChange(t,e){var i,s;this._textbox&&(null==(i=this._textbox)||i.set("textAlign",e),null==(s=this._canvas)||s.renderAll())}handleFontFamilyChange(t,e){var i,s;this._textbox&&(null==(i=this._textbox)||i.set("fontFamily",e),null==(s=this._canvas)||s.renderAll())}handleColorChange(t,e){var i,s;this._textbox&&(null==(i=this._textbox)||i.set("fill",e),null==(s=this._canvas)||s.renderAll())}render(){var t,e,i,s;return U` <div
174
- style="position: fixed; top: 0; left: 0; padding: 1rem; z-index: 1000; background: rgba(255, 255, 255, 0.5); color: rgba(0, 0, 0, 0.5);"
175
- >
176
- background image url: ${this.backgroundUrl} <br />
177
- Nature font size: ${this._fontSize} <br />
178
- Nature line height: ${this._lineHeight} <br />
179
- Line height: ${null==(t=this._textbox)?void 0:t.get("lineHeight")} <br />
180
- Font size: ${null==(e=this._textbox)?void 0:e.get("fontSize")} <br />
181
- real textbox width: ${.382*this._backgroundImg.width} <br />
182
- real textbox height: ${.45*this._backgroundImg.height} <br />
183
- Textbox width: ${null==(i=this._textbox)?void 0:i.width} <br />
184
- Textbox height: ${null==(s=this._textbox)?void 0:s.height} <br />
185
- </div>`}},t.FabricExample.styles=[sl,rl],al([gt()],t.FabricExample.prototype,"backgroundUrl",2),al([gt()],t.FabricExample.prototype,"message",2),al([gt({type:String,reflect:!0})],t.FabricExample.prototype,"alignment",2),al([gt({type:String})],t.FabricExample.prototype,"fontFamily",2),al([gt({type:String})],t.FabricExample.prototype,"color",2),al([bt(".fabric-container")],t.FabricExample.prototype,"_fabricContainer",2),al([ft()],t.FabricExample.prototype,"_canvas",2),al([ft()],t.FabricExample.prototype,"_canvasElement",2),al([ft()],t.FabricExample.prototype,"_textbox",2),al([ft()],t.FabricExample.prototype,"_backgroundImg",2),al([ft()],t.FabricExample.prototype,"_natureSize",2),al([ft()],t.FabricExample.prototype,"_scale",2),al([ft()],t.FabricExample.prototype,"_lineHeight",2),al([ft()],t.FabricExample.prototype,"_fontSize",2),al([ft()],t.FabricExample.prototype,"_rect",2),al([il("message")],t.FabricExample.prototype,"handleMessageChange",1),al([il("alignment")],t.FabricExample.prototype,"handleAlignmentChange",1),al([il("fontFamily")],t.FabricExample.prototype,"handleFontFamilyChange",1),al([il("color")],t.FabricExample.prototype,"handleColorChange",1),t.FabricExample=al([dt("fabric-example")],t.FabricExample);const ll=l`
186
- :host {
187
- display: block;
188
- }
189
- .is-open {
190
- background-color: red;
191
- }
192
- .choices__item {
193
- font-size: 1rem;
194
- }
195
- `
196
- /*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */;var cl=function(t,e){return(cl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function hl(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}cl(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var dl=function(){return dl=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},dl.apply(this,arguments)};function ul(t,e,i){for(var s,r=0,o=e.length;r<o;r++)!s&&r in e||(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var pl,gl="ADD_CHOICE",fl="REMOVE_CHOICE",ml="FILTER_CHOICES",bl="ACTIVATE_CHOICES",vl="CLEAR_CHOICES",yl="ADD_GROUP",_l="ADD_ITEM",xl="REMOVE_ITEM",wl="HIGHLIGHT_ITEM",Cl="showDropdown",Sl="hideDropdown",kl="change",Tl="choice",El="search",Ol="addItem",Dl="removeItem",Ml="highlightItem",Pl="highlightChoice",Al="unhighlightItem",Fl=9,Il=16,Ll=46,jl=8,Bl=13,Rl=65,zl=27,$l=38,Hl=40,Nl=33,Vl=34,Ul=["fuseOptions","classNames"],Wl="text",Xl="select-one",Gl="select-multiple",Yl=function(t){return{type:fl,choice:t}},ql=function(t){return{type:xl,item:t}},Kl=function(t,e){return{type:wl,item:t,highlighted:e}},Zl=function(t){return Array.from({length:t},(function(){return(t=0,e=36,Math.floor(Math.random()*(e-t)+t)).toString(36);var t,e})).join("")},Jl=function(t){if("string"!=typeof t){if(null==t)return"";if("object"==typeof t){if("raw"in t)return Jl(t.raw);if("trusted"in t)return t.trusted}return t}return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},Ql=(pl=document.createElement("div"),function(t){pl.innerHTML=t.trim();for(var e=pl.children[0];pl.firstChild;)pl.removeChild(pl.firstChild);return e}),tc=function(t,e){return"function"==typeof t?t(Jl(e),e):t},ec=function(t){return"function"==typeof t?t():t},ic=function(t){if("string"==typeof t)return t;if("object"==typeof t){if("trusted"in t)return t.trusted;if("raw"in t)return t.raw}return""},sc=function(t,e){return t?function(t){if("string"==typeof t)return t;if("object"==typeof t){if("escaped"in t)return t.escaped;if("trusted"in t)return t.trusted}return""}(e):Jl(e)},rc=function(t,e,i){t.innerHTML=sc(e,i)},oc=function(t,e){return t.rank-e.rank},nc=function(t){return Array.isArray(t)?t:[t]},ac=function(t){return t&&Array.isArray(t)?t.map((function(t){return".".concat(t)})).join(""):".".concat(t)},lc=function(t,e){var i;(i=t.classList).add.apply(i,nc(e))},cc=function(t,e){var i;(i=t.classList).remove.apply(i,nc(e))},hc=function(t){if(void 0!==t)try{return JSON.parse(t)}catch(e){return t}return{}},dc=function(){function t(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return t.prototype.show=function(){return lc(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},t.prototype.hide=function(){return cc(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},t}(),uc=function(){function t(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return t.prototype.shouldFlip=function(t,e){var i=!1;return"auto"===this.position?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:"top"===this.position&&(i=!0),i},t.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},t.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},t.prototype.open=function(t,e){lc(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(lc(this.element,this.classNames.flippedState),this.isFlipped=!0)},t.prototype.close=function(){cc(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(cc(this.element,this.classNames.flippedState),this.isFlipped=!1)},t.prototype.addFocusState=function(){lc(this.element,this.classNames.focusState)},t.prototype.removeFocusState=function(){cc(this.element,this.classNames.focusState)},t.prototype.enable=function(){cc(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===Xl&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},t.prototype.disable=function(){lc(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===Xl&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},t.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},t.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},t.prototype.addLoadingState=function(){lc(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},t.prototype.removeLoadingState=function(){cc(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},t}(),pc=function(){function t(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(t.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),t.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},t.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},t.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},t.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},t.prototype.focus=function(){this.isFocussed||this.element.focus()},t.prototype.blur=function(){this.isFocussed&&this.element.blur()},t.prototype.clear=function(t){return void 0===t&&(t=!0),this.element.value="",t&&this.setWidth(),this},t.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},t.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},t.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},t.prototype._onInput=function(){this.type!==Xl&&this.setWidth()},t.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},t.prototype._onFocus=function(){this.isFocussed=!0},t.prototype._onBlur=function(){this.isFocussed=!1},t}(),gc=function(){function t(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return t.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},t.prototype.scrollToTop=function(){this.element.scrollTop=0},t.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,o=t.offsetHeight,n=t.offsetTop+o,a=e>0?this.element.scrollTop+n-r:t.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,e)}))}},t.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},t.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},t.prototype._animateScroll=function(t,e){var i=this,s=this.element.scrollTop,r=!1;e>0?(this._scrollDown(s,4,t),s<t&&(r=!0)):(this._scrollUp(s,4,t),s>t&&(r=!0)),r&&requestAnimationFrame((function(){i._animateScroll(t,e)}))},t}(),fc=function(){function t(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(t.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),t.prototype.conceal=function(){var t=this.element;lc(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},t.prototype.reveal=function(){var t=this.element;cc(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},t.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},t.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},t.prototype.triggerEvent=function(t,e){!function(t,e,i){void 0===i&&(i=null);var s=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});t.dispatchEvent(s)}(this.element,t,e||{})},t}(),mc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return hl(e,t),e}(fc),bc=function(t,e){return void 0===e&&(e=!0),void 0===t?e:!!t},vc=function(t){if("string"==typeof t&&(t=t.split(" ").filter((function(t){return t.length}))),Array.isArray(t)&&t.length)return t},yc=function(t,e,i){if(void 0===i&&(i=!0),"string"==typeof t){var s=Jl(t);return yc({value:t,label:i||s===t?t:{escaped:s,raw:t},selected:!0},!1)}var r=t;if("choices"in r){if(!e)throw new TypeError("optGroup is not allowed");var o=r,n=o.choices.map((function(t){return yc(t,!1)}));return{id:0,label:ic(o.label)||o.value,active:!!n.length,disabled:!!o.disabled,choices:n}}var a=r;return{id:0,group:null,score:0,rank:0,value:a.value,label:a.label||a.value,active:bc(a.active),selected:bc(a.selected,!1),disabled:bc(a.disabled,!1),placeholder:bc(a.placeholder,!1),highlighted:!1,labelClass:vc(a.labelClass),labelDescription:a.labelDescription,customProperties:a.customProperties}},_c=function(t){return"SELECT"===t.tagName},xc=function(t){function e(e){var i=e.element,s=e.classNames,r=e.template,o=e.extractPlaceholder,n=t.call(this,{element:i,classNames:s})||this;return n.template=r,n.extractPlaceholder=o,n}return hl(e,t),Object.defineProperty(e.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),e.prototype.addOptions=function(t){var e=this,i=document.createDocumentFragment();t.forEach((function(t){var s=t;if(!s.element){var r=e.template(s);i.appendChild(r),s.element=r}})),this.element.appendChild(i)},e.prototype.optionsAsChoices=function(){var t=this,e=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(t){return"OPTION"===t.tagName}(i)?function(t){return"OPTGROUP"===t.tagName}(i)&&e.push(t._optgroupToChoice(i)):e.push(t._optionToChoice(i))})),e},e.prototype._optionToChoice=function(t){return!t.hasAttribute("value")&&t.hasAttribute("placeholder")&&(t.setAttribute("value",""),t.value=""),{id:0,group:null,score:0,rank:0,value:t.value,label:t.innerText,element:t,active:!0,selected:this.extractPlaceholder?t.selected:t.hasAttribute("selected"),disabled:t.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!t.value||t.hasAttribute("placeholder")),labelClass:void 0!==t.dataset.labelClass?vc(t.dataset.labelClass):void 0,labelDescription:void 0!==t.dataset.labelDescription?t.dataset.labelDescription:void 0,customProperties:hc(t.dataset.customProperties)}},e.prototype._optgroupToChoice=function(t){var e=this,i=t.querySelectorAll("option"),s=Array.from(i).map((function(t){return e._optionToChoice(t)}));return{id:0,label:t.label||"",element:t,active:!!s.length,disabled:t.disabled,choices:s}},e}(fc),wc={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(t){return!!t&&""!==t},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(t,e){var i=t.value,s=t.label,r=void 0===s?i:s,o=e.value,n=e.label,a=void 0===n?o:n;return ic(r).localeCompare(ic(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(t){return'Press Enter to add <b>"'.concat(t,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(t){return"Remove item: ".concat(t)},maxItemText:function(t){return"Only ".concat(t," values can be added")},valueComparer:function(t,e){return t===e},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Cc=function(t){var e=t.itemEl;e&&(e.remove(),t.itemEl=void 0)};var Sc={groups:function(t,e){var i=t,s=!0;switch(e.type){case yl:i.push(e.group);break;case vl:i=[];break;default:s=!1}return{state:i,update:s}},items:function(t,e,i){var s=t,r=!0;switch(e.type){case _l:e.item.selected=!0,(o=e.item.element)&&(o.selected=!0,o.setAttribute("selected","")),s.push(e.item);break;case xl:var o;if(e.item.selected=!1,o=e.item.element){o.selected=!1,o.removeAttribute("selected");var n=o.parentElement;n&&_c(n)&&n.type===Xl&&(n.value="")}Cc(e.item),s=s.filter((function(t){return t.id!==e.item.id}));break;case fl:Cc(e.choice),s=s.filter((function(t){return t.id!==e.choice.id}));break;case wl:var a=e.highlighted,l=s.find((function(t){return t.id===e.item.id}));l&&l.highlighted!==a&&(l.highlighted=a,i&&function(t,e,i){var s=t.itemEl;s&&(cc(s,i),lc(s,e))}(l,a?i.classNames.highlightedState:i.classNames.selectedState,a?i.classNames.selectedState:i.classNames.highlightedState));break;default:r=!1}return{state:s,update:r}},choices:function(t,e,i){var s=t,r=!0;switch(e.type){case gl:s.push(e.choice);break;case fl:e.choice.choiceEl=void 0,e.choice.group&&(e.choice.group.choices=e.choice.group.choices.filter((function(t){return t.id!==e.choice.id}))),s=s.filter((function(t){return t.id!==e.choice.id}));break;case _l:case xl:e.item.choiceEl=void 0;break;case ml:var o=[];e.results.forEach((function(t){o[t.item.id]=t})),s.forEach((function(t){var e=o[t.id];void 0!==e?(t.score=e.score,t.rank=e.rank,t.active=!0):(t.score=0,t.rank=0,t.active=!1),i&&i.appendGroupInSearch&&(t.choiceEl=void 0)}));break;case bl:s.forEach((function(t){t.active=e.active,i&&i.appendGroupInSearch&&(t.choiceEl=void 0)}));break;case vl:s=[];break;default:r=!1}return{state:s,update:r}}},kc=function(){function t(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(t.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),t.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},t.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach((function(e){return e(t)}))},t.prototype.subscribe=function(t){return this._listeners.push(t),this},t.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(Sc).forEach((function(o){var n=Sc[o](i[o],t,e._context);n.update&&(s=!0,r[o]=!0,i[o]=n.state)})),s&&(this._txn?this._changeSet=r:this._listeners.forEach((function(t){return t(r)})))},t.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach((function(t){return t(e)})))}}},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(t){return!t.disabled&&t.active&&t.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeChoices",{get:function(){return this.choices.filter((function(t){return t.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(t){return!t.disabled&&!t.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter((function(e){var i=e.active&&!e.disabled,s=t.state.choices.some((function(t){return t.active&&!t.disabled}));return i&&s}),[])},enumerable:!1,configurable:!0}),t.prototype.inTxn=function(){return this._txn>0},t.prototype.getChoiceById=function(t){return this.activeChoices.find((function(e){return e.id===t}))},t.prototype.getGroupById=function(t){return this.groups.find((function(e){return e.id===t}))},t}(),Tc="no-choices",Ec="no-results",Oc="add-choice",Dc="";function Mc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Pc(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function Ac(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Pc(Object(i),!0).forEach((function(e){Mc(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Pc(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function Fc(t){return Array.isArray?Array.isArray(t):"[object Array]"===$c(t)}function Ic(t){return"string"==typeof t}function Lc(t){return"number"==typeof t}function jc(t){return!0===t||!1===t||function(t){return Bc(t)&&null!==t}(t)&&"[object Boolean]"==$c(t)}function Bc(t){return"object"==typeof t}function Rc(t){return null!=t}function zc(t){return!t.trim().length}function $c(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Hc=Object.prototype.hasOwnProperty;class Nc{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{let i=Vc(t);this._keys.push(i),this._keyMap[i.id]=i,e+=i.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vc(t){let e=null,i=null,s=null,r=1,o=null;if(Ic(t)||Fc(t))s=t,e=Uc(t),i=Wc(t);else{if(!Hc.call(t,"name"))throw new Error((t=>`Missing ${t} property in key`)("name"));const n=t.name;if(s=n,Hc.call(t,"weight")&&(r=t.weight,r<=0))throw new Error((t=>`Property 'weight' in key '${t}' must be a positive integer`)(n));e=Uc(n),i=Wc(n),o=t.getFn}return{path:e,id:i,weight:r,src:s,getFn:o}}function Uc(t){return Fc(t)?t:t.split(".")}function Wc(t){return Fc(t)?t.join("."):t}const Xc={useExtendedSearch:!1,getFn:function(t,e){let i=[],s=!1;const r=(t,e,o)=>{if(Rc(t))if(e[o]){const n=t[e[o]];if(!Rc(n))return;if(o===e.length-1&&(Ic(n)||Lc(n)||jc(n)))i.push(function(t){return null==t?"":function(t){if("string"==typeof t)return t;let e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}(n));else if(Fc(n)){s=!0;for(let t=0,i=n.length;t<i;t+=1)r(n[t],e,o+1)}else e.length&&r(n,e,o+1)}else i.push(t)};return r(t,Ic(e)?e.split("."):e,0),s?i:i[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Gc=Ac(Ac(Ac(Ac({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),Xc);const Yc=/[^ ]+/g;class qc{constructor({getFn:t=Gc.getFn,fieldNormWeight:e=Gc.fieldNormWeight}={}){this.norm=function(t=1,e=3){const i=new Map,s=Math.pow(10,e);return{get(e){const r=e.match(Yc).length;if(i.has(r))return i.get(r);const o=1/Math.pow(r,.5*t),n=parseFloat(Math.round(o*s)/s);return i.set(r,n),n},clear(){i.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,Ic(this.docs[0])?this.docs.forEach(((t,e)=>{this._addString(t,e)})):this.docs.forEach(((t,e)=>{this._addObject(t,e)})),this.norm.clear())}add(t){const e=this.size();Ic(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!Rc(t)||zc(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach(((e,s)=>{let r=e.getFn?e.getFn(t):this.getFn(t,e.path);if(Rc(r))if(Fc(r)){let t=[];const e=[{nestedArrIndex:-1,value:r}];for(;e.length;){const{nestedArrIndex:i,value:s}=e.pop();if(Rc(s))if(Ic(s)&&!zc(s)){let e={v:s,i:i,n:this.norm.get(s)};t.push(e)}else Fc(s)&&s.forEach(((t,i)=>{e.push({nestedArrIndex:i,value:t})}))}i.$[s]=t}else if(Ic(r)&&!zc(r)){let t={v:r,n:this.norm.get(r)};i.$[s]=t}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Kc(t,e,{getFn:i=Gc.getFn,fieldNormWeight:s=Gc.fieldNormWeight}={}){const r=new qc({getFn:i,fieldNormWeight:s});return r.setKeys(t.map(Vc)),r.setSources(e),r.create(),r}function Zc(t,{errors:e=0,currentLocation:i=0,expectedLocation:s=0,distance:r=Gc.distance,ignoreLocation:o=Gc.ignoreLocation}={}){const n=e/t.length;if(o)return n;const a=Math.abs(s-i);return r?n+a/r:a?1:n}const Jc=32;function Qc(t,e,i,{location:s=Gc.location,distance:r=Gc.distance,threshold:o=Gc.threshold,findAllMatches:n=Gc.findAllMatches,minMatchCharLength:a=Gc.minMatchCharLength,includeMatches:l=Gc.includeMatches,ignoreLocation:c=Gc.ignoreLocation}={}){if(e.length>Jc)throw new Error(`Pattern length exceeds max of ${Jc}.`);const h=e.length,d=t.length,u=Math.max(0,Math.min(s,d));let p=o,g=u;const f=a>1||l,m=f?Array(d):[];let b;for(;(b=t.indexOf(e,g))>-1;){let t=Zc(e,{currentLocation:b,expectedLocation:u,distance:r,ignoreLocation:c});if(p=Math.min(t,p),g=b+h,f){let t=0;for(;t<h;)m[b+t]=1,t+=1}}g=-1;let v=[],y=1,_=h+d;const x=1<<h-1;for(let C=0;C<h;C+=1){let s=0,o=_;for(;s<o;){Zc(e,{errors:C,currentLocation:u+o,expectedLocation:u,distance:r,ignoreLocation:c})<=p?s=o:_=o,o=Math.floor((_-s)/2+s)}_=o;let a=Math.max(1,u-o+1),l=n?d:Math.min(u+o,d)+h,b=Array(l+2);b[l+1]=(1<<C)-1;for(let n=l;n>=a;n-=1){let s=n-1,o=i[t.charAt(s)];if(f&&(m[s]=+!!o),b[n]=(b[n+1]<<1|1)&o,C&&(b[n]|=(v[n+1]|v[n])<<1|1|v[n+1]),b[n]&x&&(y=Zc(e,{errors:C,currentLocation:s,expectedLocation:u,distance:r,ignoreLocation:c}),y<=p)){if(p=y,g=s,g<=u)break;a=Math.max(1,2*u-g)}}if(Zc(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:c})>p)break;v=b}const w={isMatch:g>=0,score:Math.max(.001,y)};if(f){const t=function(t=[],e=Gc.minMatchCharLength){let i=[],s=-1,r=-1,o=0;for(let n=t.length;o<n;o+=1){let n=t[o];n&&-1===s?s=o:n||-1===s||(r=o-1,r-s+1>=e&&i.push([s,r]),s=-1)}return t[o-1]&&o-s>=e&&i.push([s,o-1]),i}(m,a);t.length?l&&(w.indices=t):w.isMatch=!1}return w}function th(t){let e={};for(let i=0,s=t.length;i<s;i+=1){const r=t.charAt(i);e[r]=(e[r]||0)|1<<s-i-1}return e}class eh{constructor(t,{location:e=Gc.location,threshold:i=Gc.threshold,distance:s=Gc.distance,includeMatches:r=Gc.includeMatches,findAllMatches:o=Gc.findAllMatches,minMatchCharLength:n=Gc.minMatchCharLength,isCaseSensitive:a=Gc.isCaseSensitive,ignoreLocation:l=Gc.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:n,isCaseSensitive:a,ignoreLocation:l},this.pattern=a?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const c=(t,e)=>{this.chunks.push({pattern:t,alphabet:th(t),startIndex:e})},h=this.pattern.length;if(h>Jc){let t=0;const e=h%Jc,i=h-e;for(;t<i;)c(this.pattern.substr(t,Jc),t),t+=Jc;if(e){const t=h-Jc;c(this.pattern.substr(t),t)}}else c(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let e={isMatch:!0,score:0};return i&&(e.indices=[[0,t.length-1]]),e}const{location:s,distance:r,threshold:o,findAllMatches:n,minMatchCharLength:a,ignoreLocation:l}=this.options;let c=[],h=0,d=!1;this.chunks.forEach((({pattern:e,alphabet:u,startIndex:p})=>{const{isMatch:g,score:f,indices:m}=Qc(t,e,u,{location:s+p,distance:r,threshold:o,findAllMatches:n,minMatchCharLength:a,includeMatches:i,ignoreLocation:l});g&&(d=!0),h+=f,g&&m&&(c=[...c,...m])}));let u={isMatch:d,score:d?h/this.chunks.length:1};return d&&i&&(u.indices=c),u}}class ih{constructor(t){this.pattern=t}static isMultiMatch(t){return sh(t,this.multiRegex)}static isSingleMatch(t){return sh(t,this.singleRegex)}search(){}}function sh(t,e){const i=t.match(e);return i?i[1]:null}class rh extends ih{constructor(t,{location:e=Gc.location,threshold:i=Gc.threshold,distance:s=Gc.distance,includeMatches:r=Gc.includeMatches,findAllMatches:o=Gc.findAllMatches,minMatchCharLength:n=Gc.minMatchCharLength,isCaseSensitive:a=Gc.isCaseSensitive,ignoreLocation:l=Gc.ignoreLocation}={}){super(t),this._bitapSearch=new eh(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:n,isCaseSensitive:a,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class oh extends ih{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e,i=0;const s=[],r=this.pattern.length;for(;(e=t.indexOf(this.pattern,i))>-1;)i=e+r,s.push([e,i-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const nh=[class extends ih{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},oh,class extends ih{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},class extends ih{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends ih{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends ih{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},class extends ih{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},rh],ah=nh.length,lh=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const ch=new Set([rh.type,oh.type]);class hh{constructor(t,{isCaseSensitive:e=Gc.isCaseSensitive,includeMatches:i=Gc.includeMatches,minMatchCharLength:s=Gc.minMatchCharLength,ignoreLocation:r=Gc.ignoreLocation,findAllMatches:o=Gc.findAllMatches,location:n=Gc.location,threshold:a=Gc.threshold,distance:l=Gc.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:r,location:n,threshold:a,distance:l},this.pattern=e?t:t.toLowerCase(),this.query=function(t,e={}){return t.split("|").map((t=>{let i=t.trim().split(lh).filter((t=>t&&!!t.trim())),s=[];for(let r=0,o=i.length;r<o;r+=1){const t=i[r];let o=!1,n=-1;for(;!o&&++n<ah;){const i=nh[n];let r=i.isMultiMatch(t);r&&(s.push(new i(r,e)),o=!0)}if(!o)for(n=-1;++n<ah;){const i=nh[n];let r=i.isSingleMatch(t);if(r){s.push(new i(r,e));break}}}return s}))}(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let r=0,o=[],n=0;for(let a=0,l=e.length;a<l;a+=1){const s=e[a];o.length=0,r=0;for(let e=0,a=s.length;e<a;e+=1){const a=s[e],{isMatch:l,indices:c,score:h}=a.search(t);if(!l){n=0,r=0,o.length=0;break}if(r+=1,n+=h,i){const t=a.constructor.type;ch.has(t)?o=[...o,...c]:o.push(c)}}if(r){let t={isMatch:!0,score:n/r};return i&&(t.indices=o),t}}return{isMatch:!1,score:1}}}const dh=[];function uh(t,e){for(let i=0,s=dh.length;i<s;i+=1){let s=dh[i];if(s.condition(t,e))return new s(t,e)}return new eh(t,e)}const ph="$and",gh="$or",fh="$path",mh="$val",bh=t=>!(!t[ph]&&!t[gh]),vh=t=>({[ph]:Object.keys(t).map((e=>({[e]:t[e]})))});function yh(t,e,{auto:i=!0}={}){const s=t=>{let r=Object.keys(t);const o=(t=>!!t[fh])(t);if(!o&&r.length>1&&!bh(t))return s(vh(t));if((t=>!Fc(t)&&Bc(t)&&!bh(t))(t)){const s=o?t[fh]:r[0],n=o?t[mh]:t[s];if(!Ic(n))throw new Error((t=>`Invalid value for key ${t}`)(s));const a={keyId:Wc(s),pattern:n};return i&&(a.searcher=uh(n,e)),a}let n={children:[],operator:r[0]};return r.forEach((e=>{const i=t[e];Fc(i)&&i.forEach((t=>{n.children.push(s(t))}))})),n};return bh(t)||(t=vh(t)),s(t)}function _h(t,e){const i=t.matches;e.matches=[],Rc(i)&&i.forEach((t=>{if(!Rc(t.indices)||!t.indices.length)return;const{indices:i,value:s}=t;let r={indices:i,value:s};t.key&&(r.key=t.key.src),t.idx>-1&&(r.refIndex=t.idx),e.matches.push(r)}))}function xh(t,e){e.score=t.score}class wh{constructor(t,e={},i){this.options=Ac(Ac({},Gc),e),this.options.useExtendedSearch,this._keyStore=new Nc(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof qc))throw new Error("Incorrect 'index' type");this._myIndex=e||Kc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Rc(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:r,sortFn:o,ignoreFieldNorm:n}=this.options;let a=Ic(t)?Ic(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return function(t,{ignoreFieldNorm:e=Gc.ignoreFieldNorm}){t.forEach((t=>{let i=1;t.matches.forEach((({key:t,norm:s,score:r})=>{const o=t?t.weight:null;i*=Math.pow(0===r&&o?Number.EPSILON:r,(o||1)*(e?1:s))})),t.score=i}))}(a,{ignoreFieldNorm:n}),r&&a.sort(o),Lc(e)&&e>-1&&(a=a.slice(0,e)),function(t,e,{includeMatches:i=Gc.includeMatches,includeScore:s=Gc.includeScore}={}){const r=[];return i&&r.push(_h),s&&r.push(xh),t.map((t=>{const{idx:i}=t,s={item:e[i],refIndex:i};return r.length&&r.forEach((e=>{e(t,s)})),s}))}(a,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=uh(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach((({v:t,i:i,n:r})=>{if(!Rc(t))return;const{isMatch:o,score:n,indices:a}=e.searchIn(t);o&&s.push({item:t,idx:i,matches:[{score:n,value:t,norm:r,indices:a}]})})),s}_searchLogical(t){const e=yh(t,this.options),i=(t,e,s)=>{if(!t.children){const{keyId:i,searcher:r}=t,o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(e,i),searcher:r});return o&&o.length?[{idx:s,item:e,matches:o}]:[]}const r=[];for(let o=0,n=t.children.length;o<n;o+=1){const n=t.children[o],a=i(n,e,s);if(a.length)r.push(...a);else if(t.operator===ph)return[]}return r},s=this._myIndex.records,r={},o=[];return s.forEach((({$:t,i:s})=>{if(Rc(t)){let n=i(e,t,s);n.length&&(r[s]||(r[s]={idx:s,item:t,matches:[]},o.push(r[s])),n.forEach((({matches:t})=>{r[s].matches.push(...t)})))}})),o}_searchObjectList(t){const e=uh(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach((({$:t,i:s})=>{if(!Rc(t))return;let o=[];i.forEach(((i,s)=>{o.push(...this._findMatches({key:i,value:t[s],searcher:e}))})),o.length&&r.push({idx:s,item:t,matches:o})})),r}_findMatches({key:t,value:e,searcher:i}){if(!Rc(e))return[];let s=[];if(Fc(e))e.forEach((({v:e,i:r,n:o})=>{if(!Rc(e))return;const{isMatch:n,score:a,indices:l}=i.searchIn(e);n&&s.push({score:a,key:t,value:e,idx:r,norm:o,indices:l})}));else{const{v:r,n:o}=e,{isMatch:n,score:a,indices:l}=i.searchIn(r);n&&s.push({score:a,key:t,value:r,norm:o,indices:l})}return s}}wh.version="7.0.0",wh.createIndex=Kc,wh.parseIndex=function(t,{getFn:e=Gc.getFn,fieldNormWeight:i=Gc.fieldNormWeight}={}){const{keys:s,records:r}=t,o=new qc({getFn:e,fieldNormWeight:i});return o.setKeys(s),o.setIndexRecords(r),o},wh.config=Gc,wh.parseQuery=yh,function(...t){dh.push(...t)}(hh);var Ch=function(){function t(t){this._haystack=[],this._fuseOptions=dl(dl({},t.fuseOptions),{keys:ul([],t.searchFields),includeMatches:!0})}return t.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},t.prototype.reset=function(){this._haystack=[],this._fuse=void 0},t.prototype.isEmptyIndex=function(){return!this._haystack.length},t.prototype.search=function(t){return this._fuse||(this._fuse=new wh(this._haystack,this._fuseOptions)),this._fuse.search(t).map((function(t,e){return{item:t.item,score:t.score||0,rank:e+1}}))},t}();var Sh=function(t,e,i){var s=t.dataset,r=e.customProperties,o=e.labelClass,n=e.labelDescription;o&&(s.labelClass=nc(o).join(" ")),n&&(s.labelDescription=n),i&&r&&("string"==typeof r?s.customProperties=r:"object"!=typeof r||function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(r)||(s.customProperties=JSON.stringify(r)))},kh=function(t,e,i){var s=e&&t.querySelector("label[for='".concat(e,"']")),r=s&&s.innerText;r&&i.setAttribute("aria-label",r)},Th={containerOuter:function(t,e,i,s,r,o,n){var a=t.classNames.containerOuter,l=document.createElement("div");return lc(l,a),l.dataset.type=o,e&&(l.dir=e),s&&(l.tabIndex=0),i&&(l.setAttribute("role",r?"combobox":"listbox"),r?l.setAttribute("aria-autocomplete","list"):n||kh(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),n&&l.setAttribute("aria-labelledby",n),l},containerInner:function(t){var e=t.classNames.containerInner,i=document.createElement("div");return lc(i,e),i},itemList:function(t,e){var i=t.searchEnabled,s=t.classNames,r=s.list,o=s.listSingle,n=s.listItems,a=document.createElement("div");return lc(a,r),lc(a,e?o:n),this._isSelectElement&&i&&a.setAttribute("role","listbox"),a},placeholder:function(t,e){var i=t.allowHTML,s=t.classNames.placeholder,r=document.createElement("div");return lc(r,s),rc(r,i,e),r},item:function(t,e,i){var s=t.allowHTML,r=t.removeItemButtonAlignLeft,o=t.removeItemIconText,n=t.removeItemLabelText,a=t.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=ic(e.value),g=document.createElement("div");if(lc(g,l),e.labelClass){var f=document.createElement("span");rc(f,s,e.label),lc(f,e.labelClass),g.appendChild(f)}else rc(g,s,e.label);if(g.dataset.item="",g.dataset.id=e.id,g.dataset.value=p,Sh(g,e,!0),(e.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),e.placeholder&&(lc(g,u),g.dataset.placeholder=""),lc(g,e.highlighted?h:d),i){e.disabled&&cc(g,d),g.dataset.deletable="";var m=document.createElement("button");m.type="button",lc(m,c),rc(m,!0,tc(o,e.value));var b=tc(n,e.value);b&&m.setAttribute("aria-label",b),m.dataset.button="",r?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(t,e){var i=t.classNames.list,s=document.createElement("div");return lc(s,i),e||s.setAttribute("aria-multiselectable","true"),s.setAttribute("role","listbox"),s},choiceGroup:function(t,e){var i=t.allowHTML,s=t.classNames,r=s.group,o=s.groupHeading,n=s.itemDisabled,a=e.id,l=e.label,c=e.disabled,h=ic(l),d=document.createElement("div");lc(d,r),c&&lc(d,n),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return lc(u,o),rc(u,i,l||""),d.appendChild(u),d},choice:function(t,e,i,s){var r=t.allowHTML,o=t.classNames,n=o.item,a=o.itemChoice,l=o.itemSelectable,c=o.selectedState,h=o.itemDisabled,d=o.description,u=o.placeholder,p=e.label,g=ic(e.value),f=document.createElement("div");f.id=e.elementId,lc(f,n),lc(f,a),s&&"string"==typeof p&&(p=sc(r,p),p={trusted:p+=" (".concat(s,")")});var m=f;if(e.labelClass){var b=document.createElement("span");rc(b,r,p),lc(b,e.labelClass),m=b,f.appendChild(b)}else rc(f,r,p);if(e.labelDescription){var v="".concat(e.elementId,"-description");m.setAttribute("aria-describedby",v);var y=document.createElement("span");rc(y,r,e.labelDescription),y.id=v,lc(y,d),f.appendChild(y)}return e.selected&&lc(f,c),e.placeholder&&lc(f,u),f.setAttribute("role",e.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=e.id,f.dataset.value=g,i&&(f.dataset.selectText=i),e.group&&(f.dataset.groupId="".concat(e.group.id)),Sh(f,e,!1),e.disabled?(lc(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(lc(f,l),f.dataset.choiceSelectable=""),f},input:function(t,e){var i=t.classNames,s=i.input,r=i.inputCloned,o=t.labelId,n=document.createElement("input");return n.type="search",lc(n,s),lc(n,r),n.autocomplete="off",n.autocapitalize="off",n.spellcheck=!1,n.setAttribute("role","textbox"),n.setAttribute("aria-autocomplete","list"),e?n.setAttribute("aria-label",e):o||kh(this._docRoot,this.passedElement.element.id,n),n},dropdown:function(t){var e=t.classNames,i=e.list,s=e.listDropdown,r=document.createElement("div");return lc(r,i),lc(r,s),r.setAttribute("aria-expanded","false"),r},notice:function(t,e,i){var s=t.classNames,r=s.item,o=s.itemChoice,n=s.addChoice,a=s.noResults,l=s.noChoices,c=s.notice;void 0===i&&(i=Dc);var h=document.createElement("div");switch(rc(h,!0,e),lc(h,r),lc(h,o),lc(h,c),i){case Oc:lc(h,n);break;case Ec:lc(h,a);break;case Tc:lc(h,l)}return i===Oc&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(t){var e=ic(t.label),i=new Option(e,t.value,!1,t.selected);return Sh(i,t,!0),i.disabled=t.disabled,t.selected&&i.setAttribute("selected",""),i}},Eh="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Oh={},Dh=function(t){if(t)return t.dataset.id?parseInt(t.dataset.id,10):void 0},Mh="[data-choice-selectable]",Ph=function(){function t(e,i){void 0===e&&(e="[data-choice]"),void 0===i&&(i={});var s=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var r=t.defaults;this.config=dl(dl(dl({},r.allOptions),r.options),i),Ul.forEach((function(t){s.config[t]=dl(dl(dl({},r.allOptions[t]),r.options[t]),i[t])}));var o=this.config;o.silent||this._validateConfig();var n=o.shadowRoot||document.documentElement;this._docRoot=n;var a="string"==typeof e?n.querySelector(e):e;if(!a||"object"!=typeof a||"INPUT"!==a.tagName&&!_c(a)){if(!a&&"string"==typeof e)throw TypeError("Selector ".concat(e," failed to find an element"));throw TypeError("Expected one of the following types text|select-one|select-multiple")}var l=a.type,c=l===Wl;(c||1!==o.maxItemCount)&&(o.singleModeForMultiSelect=!1),o.singleModeForMultiSelect&&(l=Gl);var h=l===Xl,d=l===Gl,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&o.addItems||u&&o.addChoices,"boolean"!=typeof o.renderSelectedChoices&&(o.renderSelectedChoices="always"===o.renderSelectedChoices||h),"auto"===o.closeDropdownOnSelect?o.closeDropdownOnSelect=c||h||o.singleModeForMultiSelect:o.closeDropdownOnSelect=bc(o.closeDropdownOnSelect),o.placeholder&&(o.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,o.placeholderValue=a.dataset.placeholder)),i.addItemFilter&&"function"!=typeof i.addItemFilter){var p=i.addItemFilter instanceof RegExp?i.addItemFilter:new RegExp(i.addItemFilter);o.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new mc({element:a,classNames:o.classNames});else{var g=a;this.passedElement=new xc({element:g,classNames:o.classNames,template:function(t){return s._templates.option(t)},extractPlaceholder:o.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new kc(o),this._currentValue="",o.searchEnabled=!c&&o.searchEnabled||d,this._canSearch=o.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=function(t,e){var i=t.id||t.name&&"".concat(t.name,"-").concat(Zl(2))||Zl(4);return i=i.replace(/(:|\.|\[|\]|,)/g,""),"".concat(e,"-").concat(i)}(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction;f!==window.getComputedStyle(document.documentElement).direction&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=r.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive)return o.silent||console.warn("Trying to initialise Choices on element already initialised",{element:e}),this.initialised=!0,void(this.initialisedOK=!1);this.init(),this._initialItems=this._store.items.map((function(t){return t.value}))}return Object.defineProperty(t,"defaults",{get:function(){return Object.preventExtensions({get options(){return Oh},get allOptions(){return wc},get templates(){return Th}})},enumerable:!1,configurable:!0}),t.prototype.init=function(){if(!this.initialised&&void 0===this.initialisedOK){var t;this._searcher=(t=this.config,new Ch(t)),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var e=this.config.callbackOnInit;"function"==typeof e&&e.call(this)}},t.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=t.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},t.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},t.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},t.prototype.highlightItem=function(t,e){if(void 0===e&&(e=!0),!t||!t.id)return this;var i=this._store.items.find((function(e){return e.id===t.id}));return!i||i.highlighted||(this._store.dispatch(Kl(i,!0)),e&&this.passedElement.triggerEvent(Ml,this._getChoiceForOutput(i))),this},t.prototype.unhighlightItem=function(t,e){if(void 0===e&&(e=!0),!t||!t.id)return this;var i=this._store.items.find((function(e){return e.id===t.id}));return i&&i.highlighted?(this._store.dispatch(Kl(i,!1)),e&&this.passedElement.triggerEvent(Al,this._getChoiceForOutput(i)),this):this},t.prototype.highlightAll=function(){var t=this;return this._store.withTxn((function(){t._store.items.forEach((function(e){e.highlighted||(t._store.dispatch(Kl(e,!0)),t.passedElement.triggerEvent(Ml,t._getChoiceForOutput(e)))}))})),this},t.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn((function(){t._store.items.forEach((function(e){e.highlighted&&(t._store.dispatch(Kl(e,!1)),t.passedElement.triggerEvent(Ml,t._getChoiceForOutput(e)))}))})),this},t.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn((function(){e._store.items.filter((function(e){return e.value===t})).forEach((function(t){return e._removeItem(t)}))})),this},t.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn((function(){e._store.items.filter((function(e){return e.id!==t})).forEach((function(t){return e._removeItem(t)}))})),this},t.prototype.removeHighlightedItems=function(t){var e=this;return void 0===t&&(t=!1),this._store.withTxn((function(){e._store.highlightedActiveItems.forEach((function(i){e._removeItem(i),t&&e._triggerChange(i.value)}))})),this},t.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive||(void 0===t&&(t=!this._canSearch),requestAnimationFrame((function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Cl)}))),this},t.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame((function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Sl)})),this):this},t.prototype.getValue=function(t){var e=this,i=this._store.items.map((function(i){return t?i.value:e._getChoiceForOutput(i)}));return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},t.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn((function(){t.forEach((function(t){t&&e._addChoice(yc(t,!1))}))})),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},t.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?(this._isTextElement||(this._store.withTxn((function(){(Array.isArray(t)?t:[t]).forEach((function(t){return e._findAndSelectChoiceByValue(t)})),e.unhighlightAll()})),this._searcher.reset()),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},t.prototype.setChoices=function(t,e,i,s,r){var o=this;if(void 0===t&&(t=[]),void 0===e&&(e="value"),void 0===i&&(i="label"),void 0===s&&(s=!1),void 0===r&&(r=!0),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof e||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(s&&this.clearChoices(),"function"==typeof t){var n=t(this);if("function"==typeof Promise&&n instanceof Promise)return new Promise((function(t){return requestAnimationFrame(t)})).then((function(){return o._handleLoadingState(!0)})).then((function(){return n})).then((function(t){return o.setChoices(t,e,i,s)})).catch((function(t){o.config.silent||console.error(t)})).then((function(){return o._handleLoadingState(!1)})).then((function(){return o}));if(!Array.isArray(n))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof n));return this.setChoices(n,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn((function(){r&&(o._isSearching=!1);var s="value"===e,n="label"===i;t.forEach((function(t){if("choices"in t){var r=t;n||(r=dl(dl({},r),{label:r[i]})),o._addGroup(yc(r,!0))}else{var a=t;n&&s||(a=dl(dl({},a),{value:a[e],label:a[i]})),o._addChoice(yc(a,!1))}})),o.unhighlightAll()})),this._searcher.reset(),this},t.prototype.refresh=function(t,e,i){var s=this;return void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),this._isSelectElement?(this._store.withTxn((function(){var r=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach((function(t){t.id&&t.active&&t.selected&&!t.disabled&&(o[t.value]=!0)})),s.clearStore(!1);var n=function(t){i?s._store.dispatch(ql(t)):o[t.value]&&(t.selected=!0)};r.forEach((function(t){"choices"in t?t.choices.forEach(n):n(t)})),s._addPredefinedChoices(r,e,t),s._isSearching&&s._searchChoices(s.input.value)})),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},t.prototype.removeChoice=function(t){var e=this._store.choices.find((function(e){return e.value===t}));return e?(this._clearNotice(),this._store.dispatch(Yl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Dl,this._getChoiceForOutput(e)),this):this},t.prototype.clearChoices=function(){var t=this;return this._store.withTxn((function(){t._store.choices.forEach((function(e){e.selected||t._store.dispatch(Yl(e))}))})),this._searcher.reset(),this},t.prototype.clearStore=function(t){return void 0===t&&(t=!0),this._stopSearch(),t&&this.passedElement.element.replaceChildren(""),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.reset(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this._searcher.reset(),this},t.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},t.prototype._validateConfig=function(){var t,e,i,s,r=this.config,o=(t=r,e=wc,i=Object.keys(t).sort(),s=Object.keys(e).sort(),i.filter((function(t){return s.indexOf(t)<0})));o.length&&console.warn("Unknown config option(s) passed",o.join(", ")),r.allowHTML&&r.allowHtmlUserInput&&(r.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),r.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},t.prototype._render=function(t){void 0===t&&(t={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},t.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this.config,i=this._isSearching,s=this._store,r=s.activeGroups,o=s.activeChoices,n=0;if(i&&e.searchResultLimit>0?n=e.searchResultLimit:e.renderChoiceLimit>0&&(n=e.renderChoiceLimit),this._isSelectElement){var a=o.filter((function(t){return!t.element}));a.length&&this.passedElement.addOptions(a)}var l=document.createDocumentFragment(),c=function(t){return t.filter((function(t){return!t.placeholder&&(i?!!t.rank:e.renderSelectedChoices||!t.selected)}))},h=!1,d=function(s,r,o){i?s.sort(oc):e.shouldSort&&s.sort(e.sorter);var a=s.length;a=!r&&n&&a>n?n:a,a--,s.every((function(s,r){var n=s.choiceEl||t._templates.choice(e,s,e.itemSelectText,o);return s.choiceEl=n,l.appendChild(n),s.disabled||!i&&s.selected||(h=!0),r<a}))};o.length&&(e.resetScrollPosition&&requestAnimationFrame((function(){return t.choiceList.scrollToTop()})),this._hasNonChoicePlaceholder||i||!this._isSelectOneElement||d(o.filter((function(t){return t.placeholder&&!t.group})),!1,void 0),r.length&&!i?(e.shouldSort&&r.sort(e.sorter),d(o.filter((function(t){return!t.placeholder&&!t.group})),!1,void 0),r.forEach((function(s){var r=c(s.choices);if(r.length){if(s.label){var o=s.groupEl||t._templates.choiceGroup(t.config,s);s.groupEl=o,o.remove(),l.appendChild(o)}d(r,!0,e.appendGroupInSearch&&i?s.label:void 0)}}))):d(c(o),!1,void 0)),h||(this._notice||(this._notice={text:ec(i?e.noResultsText:e.noChoicesText),type:i?Ec:Tc}),l.replaceChildren("")),this._renderNotice(l),this.choiceList.element.replaceChildren(l),h&&this._highlightChoice()}},t.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),o=function(t){return i.querySelector('[data-item][data-id="'.concat(t.id,'"]'))},n=function(e){var i=e.itemEl;i&&i.parentElement||(i=o(e)||t._templates.item(s,e,s.removeItemButton),e.itemEl=i,r.appendChild(i))};e.forEach(n);var a=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var l=i.children.length;if(a||l>1){var c=i.querySelector(ac(s.classNames.placeholder));c&&c.remove()}else l||(a=!0,n(yc({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}a&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach((function(t){var e=o(t);e&&(e.remove(),r.append(e))})),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map((function(t){return t.value})).join(s.delimiter))},t.prototype._displayNotice=function(t,e,i){void 0===i&&(i=!0);var s=this._notice;s&&(s.type===e&&s.text===t||s.type===Oc&&(e===Ec||e===Tc))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0))},t.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ac(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},t.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},t.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},t.prototype._triggerChange=function(t){null!=t&&this.passedElement.triggerEvent(kl,{value:t})},t.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var s=t&&Dh(t.parentElement),r=s&&i.find((function(t){return t.id===s}));r&&this._store.withTxn((function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var t=e._store.choices.reverse().find((function(t){return!t.disabled&&t.placeholder}));t&&(e._addItem(t),e.unhighlightAll(),t.value&&e._triggerChange(t.value))}}))}},t.prototype._handleItemAction=function(t,e){var i=this;void 0===e&&(e=!1);var s=this._store.items;if(s.length&&this.config.removeItems&&!this._isSelectOneElement){var r=Dh(t);r&&(s.forEach((function(t){t.id!==r||t.highlighted?!e&&t.highlighted&&i.unhighlightItem(t):i.highlightItem(t)})),this.input.focus())}},t.prototype._handleChoiceAction=function(t){var e=this,i=Dh(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()})),this._triggerChange(s.value)}return r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},t.prototype._handleBackspace=function(t){var e=this.config;if(e.removeItems&&t.length){var i=t[t.length-1],s=t.some((function(t){return t.highlighted}));e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},t.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(t){return yc(t,!1)})),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map((function(t){return yc(t,!1,e.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach((function(t){t.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(t){return yc(t,!0)}));var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},t.prototype._handleLoadingState=function(t){void 0===t&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},t.prototype._handleSearch=function(t){if(this.input.isFocussed)if(null!=t&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;null!==e&&this.passedElement.triggerEvent(El,{value:t,resultCount:e})}else this._store.choices.some((function(t){return!t.active}))&&this._stopSearch()},t.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!(!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length)||(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(e):i,Oc),!1)},t.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&"function"==typeof e.addItemFilter&&!e.addItemFilter(t)&&(i=!1,s=tc(e.customAddItemText,t)),i){var r=this._store.choices.find((function(i){return e.valueComparer(i.value,t)}));if(this._isSelectElement){if(r)return this._displayNotice("",Oc),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=tc(e.uniqueItemText,t))}return i&&(s=tc(e.addItemText,t)),s&&this._displayNotice(s,Oc),i},t.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var r=this._notice;return(r&&r.type)!==Oc&&(s.length?this._clearNotice():this._displayNotice(ec(this.config.noResultsText),Ec)),this._store.dispatch(function(t){return{type:ml,results:t}}(s)),s.length},t.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:bl,active:!0}),this.passedElement.triggerEvent(El,{value:"",resultCount:0}))},t.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},t.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},t.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=1===t.key.length||2===t.key.length&&t.key.charCodeAt(0)>=55296||"Unidentified"===t.key;switch(this._isTextElement||i||e===zl||e===Fl||e===Il||(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key," "===t.key&&t.preventDefault())),e){case Rl:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Bl:return this._onEnterKey(t,i);case zl:return this._onEscapeKey(t,i);case $l:case Nl:case Hl:case Vl:return this._onDirectionKey(t,i);case jl:case Ll:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},t.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},t.prototype._onInput=function(){var t=this.input.value;t?this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},t.prototype._onSelectKey=function(t,e){(t.ctrlKey||t.metaKey)&&e&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},t.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button"))this._handleButtonAction(r);else if(e){var o=this.dropdown.element.querySelector(ac(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(r&&s){if(this._canAddItems()){var n=!1;this._store.withTxn((function(){if(!(n=i._findAndSelectChoiceByValue(s,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(s))return;i._addChoice(yc(s,!1,i.config.allowHtmlUserInput),!0,!0),n=!0}i.clearInput(),i.unhighlightAll()})),n&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},t.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},t.prototype._onDirectionKey=function(t,e){var i,s,r,o=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var n=o===Hl||o===Vl?1:-1,a=void 0;if(t.metaKey||o===Vl||o===Nl)a=n>0?this.dropdown.element.querySelector("".concat(Mh,":last-of-type")):this.dropdown.element.querySelector(Mh);else{var l=this.dropdown.element.querySelector(ac(this.config.classNames.highlightedState));a=l?function(t,e,i){void 0===i&&(i=1);for(var s="".concat(i>0?"next":"previous","ElementSibling"),r=t[s];r;){if(r.matches(e))return r;r=r[s]}return null}(l,Mh,n):this.dropdown.element.querySelector(Mh)}a&&(i=a,s=this.choiceList.element,void 0===(r=n)&&(r=1),(r>0?s.scrollTop+s.offsetHeight>=i.offsetTop+i.offsetHeight:i.offsetTop>=s.scrollTop)||this.choiceList.scrollToChildElement(a,n),this._highlightChoice(a)),t.preventDefault()}},t.prototype._onDeleteKey=function(t,e,i){this._isSelectOneElement||t.target.value||!i||(this._handleBackspace(e),t.preventDefault())},t.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},t.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(e)&&((e===this.containerOuter.element||e===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation());this._wasTap=!0},t.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(Eh&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},t.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},t.prototype._onClick=function(t){var e=t.target,i=this.containerOuter;i.element.contains(e)?this.dropdown.isActive||i.isDisabled?this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},t.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter;if(e&&i.element.contains(e)){var s=e===this.input.element;this._isTextElement?s&&i.addFocusState():this._isSelectMultipleElement?s&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),s&&this.showDropdown(!0))}},t.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter;e&&i.element.contains(e)&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&i.removeFocusState():(this._isScrollingOnIe=!1,this.input.element.focus())},t.prototype._onFormReset=function(){var t=this;this._store.withTxn((function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)}))},t.prototype._highlightChoice=function(t){void 0===t&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Mh));if(e.length){var i=t,s=this.config.classNames.highlightedState;Array.from(this.dropdown.element.querySelectorAll(ac(s))).forEach((function(t){cc(t,s),t.setAttribute("aria-selected","false")})),i?this._highlightPosition=e.indexOf(i):(i=e.length>this._highlightPosition?e[this._highlightPosition]:e[e.length-1])||(i=e[0]),lc(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Pl,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},t.prototype._addItem=function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(function(t){return{type:_l,item:t}}(t)),e&&(this.passedElement.triggerEvent(Ol,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Tl,this._getChoiceForOutput(t)))},t.prototype._removeItem=function(t){if(t.id){this._store.dispatch(ql(t));var e=this._notice;e&&e.type===Tc&&this._clearNotice(),this.passedElement.triggerEvent(Dl,this._getChoiceForOutput(t))}},t.prototype._addChoice=function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!this._isSelectElement&&s.duplicateItemsAllowed||!this._store.choices.find((function(e){return s.valueComparer(e.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var r=s.prependValue,o=s.appendValue;r&&(t.value=r+t.value),o&&(t.value+=o.toString()),(r||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(function(t){return{type:gl,choice:t}}(t)),t.selected&&this._addItem(t,e,i)}},t.prototype._addGroup=function(t,e){var i=this;if(void 0===e&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(t){return{type:yl,group:t}}(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach((function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)})))},t.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};"function"==typeof e&&(i=e.call(this,Ql,sc,nc));var s={};Object.keys(this._templates).forEach((function(e){s[e]=e in i?i[e].bind(t):t._templates[e].bind(t)})),this._templates=s},t.prototype._createElements=function(){var t=this._templates,e=this.config,i=this._isSelectOneElement,s=e.position,r=e.classNames,o=this._elementType;this.containerOuter=new uc({element:t.containerOuter(e,this._direction,this._isSelectElement,i,e.searchEnabled,o,e.labelId),classNames:r,type:o,position:s}),this.containerInner=new uc({element:t.containerInner(e),classNames:r,type:o,position:s}),this.input=new pc({element:t.input(e,this._placeholderValue),classNames:r,type:o,preventPaste:!e.paste}),this.choiceList=new gc({element:t.choiceList(e,i)}),this.itemList=new gc({element:t.itemList(e,i)}),this.dropdown=new dc({element:t.dropdown(e),classNames:r,type:o})},t.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},t.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn((function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},t.prototype._addPredefinedChoices=function(t,e,i){var s=this;(void 0===e&&(e=!1),void 0===i&&(i=!0),e)&&(-1===t.findIndex((function(t){return t.selected}))&&t.some((function(t){return!t.disabled&&!("choices"in t)&&(t.selected=!0,!0)})));t.forEach((function(t){"choices"in t?s._isSelectElement&&s._addGroup(t,i):s._addChoice(t,i)}))},t.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;void 0===e&&(e=!1);var s=this._store.choices.find((function(e){return i.config.valueComparer(e.value,t)}));return!(!s||s.disabled||s.selected)&&(this._addItem(s,!0,e),!0)},t.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},t.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(t," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}},t.version="11.0.3",t}();const Ah='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width: 640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}';class Fh{constructor(t,...e){this.slotNames=[],this.handleSlotChange=t=>{const e=t.target;(this.slotNames.includes("[default]")&&!e.name||e.name&&this.slotNames.includes(e.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some((t=>{var e;if(t.nodeType===t.TEXT_NODE&&""!==(null==(e=t.textContent)?void 0:e.trim()))return!0;if(t.nodeType===t.ELEMENT_NODE){const e=t;if("pbo-visually-hidden"===e.tagName.toLowerCase())return!1;if(!e.hasAttribute("slot"))return!0}return!1}))}hasNamedSlot(t){return null!==this.host.querySelector(`:scope > [slot="${t}"]`)}test(t){return"[default]"===t?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}
197
- /**
198
- * @license
199
- * Copyright 2017 Google LLC
200
- * SPDX-License-Identifier: BSD-3-Clause
201
- */const Ih=1,Lh=3,jh=4,Bh=t=>(...e)=>({_$litDirective$:t,values:e});let Rh=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
202
- /**
203
- * @license
204
- * Copyright 2018 Google LLC
205
- * SPDX-License-Identifier: BSD-3-Clause
206
- */const zh=Bh(class extends Rh{constructor(t){var e;if(super(t),t.type!==Ih||"class"!==t.name||(null==(e=t.strings)?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var i,s;if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null==(i=this.nt)?void 0:i.has(t))&&this.st.add(t);return this.render(e)}const r=t.element.classList;for(const o of this.st)o in e||(r.remove(o),this.st.delete(o));for(const o in e){const t=!!e[o];t===this.st.has(o)||(null==(s=this.nt)?void 0:s.has(o))||(t?(r.add(o),this.st.add(o)):(r.remove(o),this.st.delete(o)))}return W}}),$h=l`
207
- .form-control .form-control__label {
208
- display: none;
209
- }
210
-
211
- .form-control .form-control__help-text {
212
- display: none;
213
- }
214
-
215
- /* Label */
216
- .form-control--has-label .form-control__label {
217
- display: inline-block;
218
- color: var(--pbo-input-label-color);
219
- margin-bottom: var(--pbo-spacing-2x-small);
220
- }
221
-
222
- .form-control--has-label.form-control--small .form-control__label {
223
- font-size: var(--pbo-input-label-font-size-small);
224
- }
225
-
226
- .form-control--has-label.form-control--medium .form-control__label {
227
- font-size: var(--pbo-input-label-font-size-medium);
228
- }
229
-
230
- .form-control--has-label.form-control--large .form-control__label {
231
- font-size: var(--pbo-input-label-font-size-large);
232
- }
233
-
234
- :host([required]) .form-control--has-label .form-control__label::after {
235
- content: var(--pbo-input-required-content);
236
- margin-inline-start: var(--pbo-input-required-content-offset);
237
- color: var(--pbo-input-required-content-color);
238
- }
239
-
240
- /* Help text */
241
- .form-control--has-help-text .form-control__help-text {
242
- display: block;
243
- color: var(--pbo-input-help-text-color);
244
- margin-top: var(--pbo-spacing-3x-small);
245
- }
246
-
247
- .form-control--has-help-text.form-control--small .form-control__help-text {
248
- font-size: var(--pbo-input-help-text-font-size-small);
249
- }
250
-
251
- .form-control--has-help-text.form-control--medium .form-control__help-text {
252
- font-size: var(--pbo-input-help-text-font-size-medium);
253
- }
254
-
255
- .form-control--has-help-text.form-control--large .form-control__help-text {
256
- font-size: var(--pbo-input-help-text-font-size-large);
257
- }
258
-
259
- .form-control--has-help-text.form-control--radio-group .form-control__help-text {
260
- margin-top: var(--pbo-spacing-2x);
261
- }
262
- `;var Hh=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,Vh=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Nh(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Hh(e,i,o),o};t.PboSelector=class extends ct{constructor(){super(...arguments),this.hasSlotController=new Fh(this,"help-text","label"),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.disabled=!1,this.size="medium",this.label=""}get value(){var t;return null==(t=this._choices)?void 0:t.getValue().value}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():null==(t=this._choices)||t.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var t;null==(t=this._choices)||t.destroy(),this._choices=new Ph(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:this.fonts.map(((t,e)=>({value:t.value,label:t.label,customProperties:{font:t.font},selected:0===e}))),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},r)=>{var o;const n=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`\n <div \n class="${n}"\n data-item \n data-id="${r.id}" \n data-value="${e(r.value)}" \n ${r.active?'aria-selected="true"':""} \n ${r.disabled?'aria-disabled="true"':""}\n style="font-family: ${(null==(o=r.customProperties)?void 0:o.font)||"inherit"}"\n >\n ${r.label}\n </div>\n `)},choice:({classNames:s},r)=>{var o;const n=[i(s.item).join(" "),i(s.itemChoice).join(" "),i(r.disabled?s.itemDisabled:s.itemSelectable).join(" ")].join(" ");return t(`\n <div class="${n}"\n data-select-text="${this.config.itemSelectText}" \n data-choice ${r.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable"} \n data-id="${r.id}" \n data-value="${e(r.value)}" \n ${r.groupId>0?'role="treeitem"':'role="option"'}\n style="font-family: ${(null==(o=r.customProperties)?void 0:o.font)||"inherit"}"\n >\n ${r.label}\n </div>\n `)}}}}),this.choiceEl.addEventListener("change",(t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))}))}render(){const t=this.hasSlotController.test("label"),e=!!this.label||!!t;return U` <div
263
- class=${zh({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--radio-group":!0,"form-control--has-label":e})}
264
- >
265
- <label
266
- part="form-control-label"
267
- id="label"
268
- class="form-control__label"
269
- aria-hidden=${e?"false":"true"}
270
- >
271
- <slot name="label">${this.label}</slot>
272
- </label>
273
- </div>
274
- <select part="base" class="js-choice"></select>`}},t.PboSelector.styles=[sl,ll,$h,a(Ah)],Vh([gt({type:Array})],t.PboSelector.prototype,"fonts",2),Vh([gt({type:Boolean,reflect:!0})],t.PboSelector.prototype,"disabled",2),Vh([gt()],t.PboSelector.prototype,"size",2),Vh([gt()],t.PboSelector.prototype,"label",2),Vh([bt(".js-choice")],t.PboSelector.prototype,"choiceEl",2),Vh([il("disabled",{waitUntilFirstUpdate:!0})],t.PboSelector.prototype,"handleDisabledChanged",1),t.PboSelector=Vh([dt("pbo-selector")],t.PboSelector);const Uh=l`
275
- :host {
276
- display: inline-block;
277
- position: relative;
278
- width: auto;
279
- cursor: pointer;
280
- }
281
-
282
- .button {
283
- display: inline-flex;
284
- align-items: stretch;
285
- justify-content: center;
286
- width: 100%;
287
- border-style: solid;
288
- border-width: var(--pbo-input-border-width);
289
- font-family: var(--pbo-input-font-family);
290
- font-weight: var(--pbo-font-weight-semibold);
291
- text-decoration: none;
292
- user-select: none;
293
- -webkit-user-select: none;
294
- white-space: nowrap;
295
- vertical-align: middle;
296
- padding: 0;
297
- transition:
298
- var(--pbo-transition-x-fast) background-color,
299
- var(--pbo-transition-x-fast) color,
300
- var(--pbo-transition-x-fast) border,
301
- var(--pbo-transition-x-fast) box-shadow;
302
- cursor: inherit;
303
- }
304
-
305
- .button::-moz-focus-inner {
306
- border: 0;
307
- }
308
-
309
- .button:focus {
310
- outline: none;
311
- }
312
-
313
- .button:focus-visible {
314
- outline: var(--pbo-focus-ring);
315
- outline-offset: var(--pbo-focus-ring-offset);
316
- }
317
-
318
- .button--disabled {
319
- opacity: 0.5;
320
- cursor: not-allowed;
321
- }
322
-
323
- /* When disabled, prevent mouse events from bubbling up from children */
324
- .button--disabled * {
325
- pointer-events: none;
326
- }
327
-
328
- .button__prefix,
329
- .button__suffix {
330
- flex: 0 0 auto;
331
- display: flex;
332
- align-items: center;
333
- pointer-events: none;
334
- }
335
-
336
- .button__label {
337
- display: inline-block;
338
- }
339
-
340
- /*
341
- * Standard buttons
342
- */
343
-
344
- /* Default */
345
- .button--standard.button--default {
346
- background-color: var(--pbo-color-neutral-0);
347
- border-color: var(--pbo-input-border-color);
348
- color: var(--pbo-color-neutral-700);
349
- }
350
-
351
- .button--standard.button--default:hover:not(.button--disabled) {
352
- background-color: var(--pbo-color-primary-50);
353
- border-color: var(--pbo-color-primary-300);
354
- color: var(--pbo-color-primary-700);
355
- }
356
-
357
- .button--standard.button--default:active:not(.button--disabled) {
358
- background-color: var(--pbo-color-primary-100);
359
- border-color: var(--pbo-color-primary-400);
360
- color: var(--pbo-color-primary-700);
361
- }
362
-
363
- /* Primary */
364
- .button--standard.button--primary {
365
- background-color: #0d6efd;
366
- border-color: #0d6efd;
367
- color: var(--pbo-color-neutral-0);
368
- }
369
-
370
- .button--standard.button--primary:hover:not(.button--disabled) {
371
- background-color: #0b5ed7;
372
- border-color: #0b5ed7;
373
- color: var(--pbo-color-neutral-0);
374
- }
375
-
376
- .button--standard.button--primary:active:not(.button--disabled) {
377
- background-color: var(--pbo-color-primary-600);
378
- border-color: var(--pbo-color-primary-600);
379
- color: var(--pbo-color-neutral-0);
380
- }
381
-
382
- /* Success */
383
- .button--standard.button--success {
384
- background-color: var(--pbo-color-success-600);
385
- border-color: var(--pbo-color-success-600);
386
- color: var(--pbo-color-neutral-0);
387
- }
388
-
389
- .button--standard.button--success:hover:not(.button--disabled) {
390
- background-color: var(--pbo-color-success-500);
391
- border-color: var(--pbo-color-success-500);
392
- color: var(--pbo-color-neutral-0);
393
- }
394
-
395
- .button--standard.button--success:active:not(.button--disabled) {
396
- background-color: var(--pbo-color-success-600);
397
- border-color: var(--pbo-color-success-600);
398
- color: var(--pbo-color-neutral-0);
399
- }
400
-
401
- /* Neutral */
402
- .button--standard.button--neutral {
403
- background-color: var(--pbo-color-neutral-600);
404
- border-color: var(--pbo-color-neutral-600);
405
- color: var(--pbo-color-neutral-0);
406
- }
407
-
408
- .button--standard.button--neutral:hover:not(.button--disabled) {
409
- background-color: var(--pbo-color-neutral-500);
410
- border-color: var(--pbo-color-neutral-500);
411
- color: var(--pbo-color-neutral-0);
412
- }
413
-
414
- .button--standard.button--neutral:active:not(.button--disabled) {
415
- background-color: var(--pbo-color-neutral-600);
416
- border-color: var(--pbo-color-neutral-600);
417
- color: var(--pbo-color-neutral-0);
418
- }
419
-
420
- /* Warning */
421
- .button--standard.button--warning {
422
- background-color: var(--pbo-color-warning-600);
423
- border-color: var(--pbo-color-warning-600);
424
- color: var(--pbo-color-neutral-0);
425
- }
426
- .button--standard.button--warning:hover:not(.button--disabled) {
427
- background-color: var(--pbo-color-warning-500);
428
- border-color: var(--pbo-color-warning-500);
429
- color: var(--pbo-color-neutral-0);
430
- }
431
-
432
- .button--standard.button--warning:active:not(.button--disabled) {
433
- background-color: var(--pbo-color-warning-600);
434
- border-color: var(--pbo-color-warning-600);
435
- color: var(--pbo-color-neutral-0);
436
- }
437
-
438
- /* Danger */
439
- .button--standard.button--danger {
440
- background-color: #fb2c36;
441
- border-color: #fb2c36;
442
- color: var(--pbo-color-neutral-0);
443
- }
444
-
445
- .button--standard.button--danger:hover:not(.button--disabled) {
446
- background-color: #e7000b;
447
- border-color: #e7000b;
448
- color: var(--pbo-color-neutral-0);
449
- }
450
-
451
- .button--standard.button--danger:active:not(.button--disabled) {
452
- background-color: #e7000b;
453
- border-color: #e7000b;
454
- color: var(--pbo-color-neutral-0);
455
- }
456
-
457
- /*
458
- * Outline buttons
459
- */
460
-
461
- .button--outline {
462
- background: none;
463
- border: solid 1px;
464
- }
465
-
466
- /* Default */
467
- .button--outline.button--default {
468
- border-color: var(--pbo-input-border-color);
469
- color: var(--pbo-color-neutral-700);
470
- }
471
-
472
- .button--outline.button--default:hover:not(.button--disabled),
473
- .button--outline.button--default.button--checked:not(.button--disabled) {
474
- border-color: var(--pbo-color-primary-600);
475
- background-color: var(--pbo-color-primary-600);
476
- color: var(--pbo-color-neutral-0);
477
- }
478
-
479
- .button--outline.button--default:active:not(.button--disabled) {
480
- border-color: var(--pbo-color-primary-700);
481
- background-color: var(--pbo-color-primary-700);
482
- color: var(--pbo-color-neutral-0);
483
- }
484
-
485
- /* Primary */
486
- .button--outline.button--primary {
487
- border-color: var(--pbo-color-primary-600);
488
- color: var(--pbo-color-primary-600);
489
- }
490
-
491
- .button--outline.button--primary:hover:not(.button--disabled),
492
- .button--outline.button--primary.button--checked:not(.button--disabled) {
493
- background-color: var(--pbo-color-primary-600);
494
- color: var(--pbo-color-neutral-0);
495
- }
496
-
497
- .button--outline.button--primary:active:not(.button--disabled) {
498
- border-color: var(--pbo-color-primary-700);
499
- background-color: var(--pbo-color-primary-700);
500
- color: var(--pbo-color-neutral-0);
501
- }
502
-
503
- /* Success */
504
- .button--outline.button--success {
505
- border-color: var(--pbo-color-success-600);
506
- color: var(--pbo-color-success-600);
507
- }
508
-
509
- .button--outline.button--success:hover:not(.button--disabled),
510
- .button--outline.button--success.button--checked:not(.button--disabled) {
511
- background-color: var(--pbo-color-success-600);
512
- color: var(--pbo-color-neutral-0);
513
- }
514
-
515
- .button--outline.button--success:active:not(.button--disabled) {
516
- border-color: var(--pbo-color-success-700);
517
- background-color: var(--pbo-color-success-700);
518
- color: var(--pbo-color-neutral-0);
519
- }
520
-
521
- /* Neutral */
522
- .button--outline.button--neutral {
523
- border-color: var(--pbo-color-neutral-600);
524
- color: var(--pbo-color-neutral-600);
525
- }
526
-
527
- .button--outline.button--neutral:hover:not(.button--disabled),
528
- .button--outline.button--neutral.button--checked:not(.button--disabled) {
529
- background-color: var(--pbo-color-neutral-600);
530
- color: var(--pbo-color-neutral-0);
531
- }
532
-
533
- .button--outline.button--neutral:active:not(.button--disabled) {
534
- border-color: var(--pbo-color-neutral-700);
535
- background-color: var(--pbo-color-neutral-700);
536
- color: var(--pbo-color-neutral-0);
537
- }
538
-
539
- /* Warning */
540
- .button--outline.button--warning {
541
- border-color: var(--pbo-color-warning-600);
542
- color: var(--pbo-color-warning-600);
543
- }
544
-
545
- .button--outline.button--warning:hover:not(.button--disabled),
546
- .button--outline.button--warning.button--checked:not(.button--disabled) {
547
- background-color: var(--pbo-color-warning-600);
548
- color: var(--pbo-color-neutral-0);
549
- }
550
-
551
- .button--outline.button--warning:active:not(.button--disabled) {
552
- border-color: var(--pbo-color-warning-700);
553
- background-color: var(--pbo-color-warning-700);
554
- color: var(--pbo-color-neutral-0);
555
- }
556
-
557
- /* Danger */
558
- .button--outline.button--danger {
559
- border-color: var(--pbo-color-danger-600);
560
- color: var(--pbo-color-danger-600);
561
- }
562
-
563
- .button--outline.button--danger:hover:not(.button--disabled),
564
- .button--outline.button--danger.button--checked:not(.button--disabled) {
565
- background-color: var(--pbo-color-danger-600);
566
- color: var(--pbo-color-neutral-0);
567
- }
568
-
569
- .button--outline.button--danger:active:not(.button--disabled) {
570
- border-color: var(--pbo-color-danger-700);
571
- background-color: var(--pbo-color-danger-700);
572
- color: var(--pbo-color-neutral-0);
573
- }
574
-
575
- @media (forced-colors: active) {
576
- .button.button--outline.button--checked:not(.button--disabled) {
577
- outline: solid 2px transparent;
578
- }
579
- }
580
-
581
- /*
582
- * Text buttons
583
- */
584
-
585
- .button--text {
586
- background-color: transparent;
587
- border-color: transparent;
588
- color: var(--pbo-color-primary-600);
589
- }
590
-
591
- .button--text:hover:not(.button--disabled) {
592
- background-color: transparent;
593
- border-color: transparent;
594
- color: var(--pbo-color-primary-500);
595
- }
596
-
597
- .button--text:focus-visible:not(.button--disabled) {
598
- background-color: transparent;
599
- border-color: transparent;
600
- color: var(--pbo-color-primary-500);
601
- }
602
-
603
- .button--text:active:not(.button--disabled) {
604
- background-color: transparent;
605
- border-color: transparent;
606
- color: var(--pbo-color-primary-700);
607
- }
608
-
609
- /*
610
- * Size modifiers
611
- */
612
-
613
- .button--small {
614
- height: auto;
615
- min-height: var(--pbo-input-height-small);
616
- font-size: var(--pbo-button-font-size-small);
617
- line-height: calc(var(--pbo-input-height-small) - var(--pbo-input-border-width) * 2);
618
- border-radius: var(--pbo-input-border-radius-small);
619
- }
620
-
621
- .button--medium {
622
- height: auto;
623
- min-height: var(--pbo-input-height-medium);
624
- font-size: var(--pbo-button-font-size-medium);
625
- line-height: calc(var(--pbo-input-height-medium) - var(--pbo-input-border-width) * 2);
626
- border-radius: var(--pbo-input-border-radius-medium);
627
- }
628
-
629
- .button--large {
630
- height: auto;
631
- min-height: var(--pbo-input-height-large);
632
- font-size: var(--pbo-button-font-size-large);
633
- line-height: calc(var(--pbo-input-height-large) - var(--pbo-input-border-width) * 2);
634
- border-radius: var(--pbo-input-border-radius-large);
635
- }
636
-
637
- /*
638
- * Pill modifier
639
- */
640
-
641
- .button--pill.button--small {
642
- border-radius: var(--pbo-input-height-small);
643
- }
644
-
645
- .button--pill.button--medium {
646
- border-radius: var(--pbo-input-height-medium);
647
- }
648
-
649
- .button--pill.button--large {
650
- border-radius: var(--pbo-input-height-large);
651
- }
652
-
653
- /*
654
- * Circle modifier
655
- */
656
-
657
- .button--circle {
658
- padding-left: 0;
659
- padding-right: 0;
660
- border-radius: 100%;
661
- }
662
-
663
- .button--circle.button--small {
664
- width: var(--pbo-input-height-small);
665
- }
666
-
667
- .button--circle.button--medium {
668
- width: var(--pbo-input-height-medium);
669
- }
670
-
671
- .button--circle.button--large {
672
- width: var(--pbo-input-height-large);
673
- }
674
-
675
- .button--circle .button__prefix,
676
- .button--circle .button__suffix,
677
- .button--circle .button__caret {
678
- display: none;
679
- }
680
-
681
- /*
682
- * Color block modifier
683
- */
684
-
685
- .button--outline.button--default.button--color-block {
686
- border-color: var(--pbo-color-gray-300);
687
- }
688
-
689
- .button--outline.button--default:hover:not(.button--disabled).button--color-block,
690
- .button--outline.button--default.button--checked:not(.button--disabled).button--color-block {
691
- border-color: var(--pbo-color-gray-300);
692
- }
693
-
694
- .button--color-block {
695
- padding-left: 0;
696
- padding-right: 0;
697
- border-radius: 5px;
698
- border-width: 1.5px;
699
- height: 22px !important;
700
- width: 22px !important;
701
- min-height: 22px;
702
- min-width: 22px;
703
- }
704
-
705
- .button--color-block.button--small {
706
- width: var(--pbo-input-height-small);
707
- }
708
-
709
- .button--color-block.button--medium {
710
- width: var(--pbo-input-height-medium);
711
- }
712
-
713
- .button--color-block.button--large {
714
- width: var(--pbo-input-height-large);
715
- }
716
-
717
- .button--color-block .button__prefix,
718
- .button--color-block .button__suffix,
719
- .button--color-block .button__caret {
720
- display: none;
721
- }
722
-
723
- /*
724
- * Caret modifier
725
- */
726
-
727
- .button--caret .button__suffix {
728
- display: none;
729
- }
730
-
731
- .button--caret .button__caret {
732
- height: auto;
733
- }
734
-
735
- /*
736
- * Loading modifier
737
- */
738
-
739
- .button--loading {
740
- position: relative;
741
- cursor: wait;
742
- }
743
-
744
- .button--loading .button__prefix,
745
- .button--loading .button__label,
746
- .button--loading .button__suffix,
747
- .button--loading .button__caret {
748
- visibility: hidden;
749
- }
750
- .button--loading pbo-spinner {
751
- --indicator-color: currentColor;
752
- position: absolute;
753
- font-size: 1em;
754
- height: 1em;
755
- width: 1em;
756
- top: calc(50% - 0.5em);
757
- left: calc(50% - 0.5em);
758
- }
759
-
760
- /*
761
- * Badges
762
- */
763
-
764
- .button ::slotted(pbo-badge) {
765
- position: absolute;
766
- top: 0;
767
- right: 0;
768
- translate: 50% -50%;
769
- pointer-events: none;
770
- }
771
-
772
- .button--rtl ::slotted(pbo-badge) {
773
- right: auto;
774
- left: 0;
775
- translate: -50% -50%;
776
- }
777
-
778
- /*
779
- * Button spacing
780
- */
781
-
782
- .button--has-label.button--small .button__label {
783
- padding: 0 var(--pbo-spacing-small);
784
- }
785
-
786
- .button--has-label.button--medium .button__label {
787
- padding: 0 var(--pbo-spacing-medium);
788
- }
789
-
790
- .button--has-label.button--large .button__label {
791
- padding: 0 var(--pbo-spacing-large);
792
- }
793
-
794
- .button--has-prefix.button--small {
795
- padding-inline-start: var(--pbo-spacing-x-small);
796
- }
797
-
798
- .button--has-prefix.button--small .button__label {
799
- padding-inline-start: var(--pbo-spacing-x-small);
800
- }
801
-
802
- .button--has-prefix.button--medium {
803
- padding-inline-start: var(--pbo-spacing-small);
804
- }
805
-
806
- .button--has-prefix.button--medium .button__label {
807
- padding-inline-start: var(--pbo-spacing-small);
808
- }
809
-
810
- .button--has-prefix.button--large {
811
- padding-inline-start: var(--pbo-spacing-small);
812
- }
813
-
814
- .button--has-prefix.button--large .button__label {
815
- padding-inline-start: var(--pbo-spacing-small);
816
- }
817
-
818
- .button--has-suffix.button--small,
819
- .button--caret.button--small {
820
- padding-inline-end: var(--pbo-spacing-x-small);
821
- }
822
-
823
- .button--has-suffix.button--small .button__label,
824
- .button--caret.button--small .button__label {
825
- padding-inline-end: var(--pbo-spacing-x-small);
826
- }
827
-
828
- .button--has-suffix.button--medium,
829
- .button--caret.button--medium {
830
- padding-inline-end: var(--pbo-spacing-small);
831
- }
832
-
833
- .button--has-suffix.button--medium .button__label,
834
- .button--caret.button--medium .button__label {
835
- padding-inline-end: var(--pbo-spacing-small);
836
- }
837
-
838
- .button--has-suffix.button--large,
839
- .button--caret.button--large {
840
- padding-inline-end: var(--pbo-spacing-small);
841
- }
842
-
843
- .button--has-suffix.button--large .button__label,
844
- .button--caret.button--large .button__label {
845
- padding-inline-end: var(--pbo-spacing-small);
846
- }
847
-
848
- /*
849
- * Button groups support a variety of button types (e.g. buttons with tooltips, buttons as dropdown triggers, etc.).
850
- * This means buttons aren't always direct descendants of the button group, thus we can't target them with the
851
- * ::slotted selector. To work around this, the button group component does some magic to add these special classes to
852
- * buttons and we style them here instead.
853
- */
854
-
855
- :host([data-pbo-button-group__button--first]:not([data-pbo-button-group__button--last]))
856
- .button:not(.button--circle) {
857
- border-start-end-radius: 0;
858
- border-end-end-radius: 0;
859
- }
860
-
861
- :host([data-pbo-button-group__button--inner]) .button {
862
- border-radius: 0;
863
- }
864
-
865
- :host([data-pbo-button-group__button--last]:not([data-pbo-button-group__button--first]))
866
- .button:not(.button--circle) {
867
- border-start-start-radius: 0;
868
- border-end-start-radius: 0;
869
- }
870
-
871
- /* All except the first */
872
- :host([data-pbo-button-group__button]:not([data-pbo-button-group__button--first])) {
873
- margin-inline-start: calc(-1 * var(--pbo-input-border-width));
874
- }
875
-
876
- :host([data-pbo-button-group__button]:not([data-pbo-button-group__button--last])) .button--circle {
877
- margin-right: var(--pbo-spacing-x-small);
878
- }
879
-
880
- /* Add a visual separator between solid buttons */
881
- :host(
882
- [data-pbo-button-group__button]:not(
883
- [data-pbo-button-group__button--first],
884
- [data-pbo-button-group__button--radio],
885
- [variant="default"]
886
- ):not(:hover)
887
- )
888
- .button:after {
889
- content: "";
890
- position: absolute;
891
- top: 0;
892
- inset-inline-start: 0;
893
- bottom: 0;
894
- border-left: solid 1px rgb(128 128 128 / 33%);
895
- mix-blend-mode: multiply;
896
- }
897
-
898
- /*Icon button*/
899
- .button--icon {
900
- background-color: transparent;
901
- border-color: transparent;
902
- outline: none !important;
903
- min-height: auto;
904
- padding: 0.4rem 0.4rem;
905
- }
906
- .button--icon:hover {
907
- background-color: #e2e8f0 !important;
908
- border-color: transparent;
909
- outline: none !important;
910
- }
911
- .button--icon .button__label {
912
- padding: 0 !important;
913
- }
914
-
915
- /*Button group for icon buttons*/
916
- :host([data-pbo-button-group__button]) .button--icon {
917
- height: auto;
918
- border-radius: 0.625rem !important;
919
- border-color: transparent !important;
920
- margin-inline-start: 0 !important;
921
- }
922
-
923
- :host([data-pbo-button-group__button]) .button--icon.button--checked {
924
- border-color: #cbd5e1;
925
- background-color: #cbd5e1;
926
- }
927
-
928
- /* Bump hovered, focused, and checked buttons up so their focus ring isn't clipped */
929
- :host([data-pbo-button-group__button--hover]) {
930
- z-index: 1;
931
- }
932
- `
933
- /**
934
- * @license
935
- * Copyright 2020 Google LLC
936
- * SPDX-License-Identifier: BSD-3-Clause
937
- */,Wh=Symbol.for(""),Xh=t=>{if((null==t?void 0:t.r)===Wh)return null==t?void 0:t._$litStatic$},Gh=(t,...e)=>({_$litStatic$:e.reduce(((e,i,s)=>e+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[s+1]),t[0]),r:Wh}),Yh=new Map,qh=(t=>(e,...i)=>{const s=i.length;let r,o;const n=[],a=[];let l,c=0,h=!1;for(;c<s;){for(l=e[c];c<s&&void 0!==(o=i[c],r=Xh(o));)l+=r+e[++c],h=!0;c!==s&&a.push(o),n.push(l),c++}if(c===s&&n.push(e[s]),h){const t=n.join("$$lit$$");void 0===(e=Yh.get(t))&&(n.raw=n,Yh.set(t,e=n)),i=a}return t(e,...i)})(U);class Kh extends ct{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const Zh=new WeakMap,Jh=new WeakMap,Qh=new WeakMap,td=new WeakSet,ed=new WeakMap;class id{constructor(t,e){this.handleFormData=t=>{const e=this.options.disabled(this.host),i=this.options.name(this.host),s=this.options.value(this.host),r="pbo-button"===this.host.tagName.toLowerCase();this.host.isConnected&&!e&&!r&&"string"==typeof i&&i.length>0&&void 0!==s&&(Array.isArray(s)?s.forEach((e=>{t.formData.append(i,e.toString())})):t.formData.append(i,s.toString()))},this.handleFormSubmit=t=>{var e;const i=this.options.disabled(this.host),s=this.options.reportValidity;this.form&&!this.form.noValidate&&(null==(e=Zh.get(this.form))||e.forEach((t=>{this.setUserInteracted(t,!0)}))),!this.form||this.form.noValidate||i||s(this.host)||(null==t||t.preventDefault(),null==t||t.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),ed.set(this.host,[])},this.handleInteraction=t=>{const e=ed.get(this.host);e.includes(t.type)||e.push(t.type),e.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if("function"==typeof e.checkValidity&&!e.checkValidity())return!1}return!0},this.doAction=(t,e)=>{if(this.form){const i=document.createElement("button");i.type=t,i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.clipPath="inset(50%)",i.style.overflow="hidden",i.style.whiteSpace="nowrap",e&&(i.name=e.name,i.value=e.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{e.hasAttribute(t)&&i.setAttribute(t,e.getAttribute(t))}))),this.form.append(i),i.click(),i.remove()}},(this.host=t).addController(this),this.options={form:t=>{const e=t.form;if(e){const i=t.getRootNode().querySelector(`#${e}`);if(i)return i}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),checkValidity:t=>"function"!=typeof t.checkValidity||t.checkValidity(),setValue:(t,e)=>t.value=e,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),ed.set(this.host,[]),this.options.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),ed.delete(this.host),this.options.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(t){t?(this.form=t,Zh.has(this.form)?Zh.get(this.form).add(this.host):Zh.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Jh.has(this.form)||(Jh.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Qh.has(this.form)||(Qh.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=Zh.get(this.form);t&&(t.delete(this.host),t.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Jh.has(this.form)&&(this.form.reportValidity=Jh.get(this.form),Jh.delete(this.form)),Qh.has(this.form)&&(this.form.checkValidity=Qh.get(this.form),Qh.delete(this.form)),this.form=void 0))}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if("function"==typeof e.reportValidity&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?td.add(t):td.delete(t),t.requestUpdate()}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const e=this.host,i=Boolean(td.has(e)),s=Boolean(e.required);e.toggleAttribute("data-required",s),e.toggleAttribute("data-optional",!s),e.toggleAttribute("data-invalid",!t),e.toggleAttribute("data-valid",t),e.toggleAttribute("data-user-invalid",i&&!t),e.toggleAttribute("data-user-valid",i&&t)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("pbo-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||null==t||t.preventDefault()}}const sd=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),rd=Object.freeze({...sd,valid:!1,valueMissing:!1}),od=Object.freeze({...sd,valid:!1,customError:!0}),nd=t=>t??X,ad=l`
938
- :host {
939
- --track-width: 2px;
940
- --track-color: rgb(128 128 128 / 25%);
941
- --indicator-color: var(--pbo-color-primary-600);
942
- --speed: 2s;
943
-
944
- display: inline-flex;
945
- width: 1em;
946
- height: 1em;
947
- flex: none;
948
- }
949
-
950
- .spinner {
951
- flex: 1 1 auto;
952
- height: 100%;
953
- width: 100%;
954
- }
955
-
956
- .spinner__track,
957
- .spinner__indicator {
958
- fill: none;
959
- stroke-width: var(--track-width);
960
- r: calc(0.5em - var(--track-width) / 2);
961
- cx: 0.5em;
962
- cy: 0.5em;
963
- transform-origin: 50% 50%;
964
- }
965
-
966
- .spinner__track {
967
- stroke: var(--track-color);
968
- transform-origin: 0% 0%;
969
- }
970
-
971
- .spinner__indicator {
972
- stroke: var(--indicator-color);
973
- stroke-linecap: round;
974
- stroke-dasharray: 150% 75%;
975
- animation: spin var(--speed) linear infinite;
976
- }
977
-
978
- @keyframes spin {
979
- 0% {
980
- transform: rotate(0deg);
981
- stroke-dasharray: 0.05em, 3em;
982
- }
983
-
984
- 50% {
985
- transform: rotate(450deg);
986
- stroke-dasharray: 1.375em, 1.375em;
987
- }
988
-
989
- 100% {
990
- transform: rotate(1080deg);
991
- stroke-dasharray: 0.05em, 3em;
992
- }
993
- }
994
- `;var ld=Object.getOwnPropertyDescriptor;let cd=class extends Kh{render(){return U`
995
- <svg part="base" class="spinner" role="progressbar" aria-label="loading">
996
- <circle class="spinner__track"></circle>
997
- <circle class="spinner__indicator"></circle>
998
- </svg>
999
- `}};cd.styles=[sl,ad],cd=((t,e,i,s)=>{for(var r,o=s>1?void 0:s?ld(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=r(o)||o);return o})([dt("pbo-spinner")],cd);var hd=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,ud=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?dd(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&hd(e,i,o),o};let pd=class extends Kh{constructor(){super(...arguments),this.formControlController=new id(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new Fh(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:sd}get validationMessage(){return this.isButton()?this.button.validationMessage:""}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInvalid(){}handleClick(){"submit"===this.type&&this.formControlController.submit(this),"reset"===this.type&&this.formControlController.reset(this)}isButton(){return!this.href}isLink(){return!!this.href}doAction(t,e){}click(){this.button.click()}focus(){this.button.focus()}blur(){this.button.blur()}checkValidity(){return!this.isButton()||this.button.checkValidity()}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?Gh`a`:Gh`button`;return qh`
1000
- <${e}
1001
- part="base"
1002
- class= ${zh({button:!0,"button--default":"default"===this.variant,"button--primary":"primary"===this.variant,"button--success":"success"===this.variant,"button--neutral":"neutral"===this.variant,"button--warning":"warning"===this.variant,"button--danger":"danger"===this.variant,"button--text":"text"===this.variant,"button--small":"small"===this.size,"button--medium":"medium"===this.size,"button--large":"large"===this.size,"button--standard":!this.outline,"button--outline":this.outline,"button--focused":this.hasFocus,"button--loading":this.loading,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--disabled":this.disabled})}
1003
- ?disabled=${nd(t?void 0:this.disabled)}
1004
- tabindex=${this.disabled?"-1":"0"}
1005
- href="${this.href}"
1006
- name=${nd(t?void 0:this.name)}
1007
- @blur=${this.handleBlur}
1008
- @focus=${this.handleFocus}
1009
- @invalid=${this.isButton()?this.handleInvalid:null}
1010
- @click=${this.handleClick}
1011
- >
1012
- <slot name="prefix" part="prefix" class="button__prefix"></slot>
1013
- <slot part="label" class="button__label"></slot>
1014
- <slot name="suffix" part="suffix" class="button__suffix"></slot>
1015
- ${this.loading?qh`<pbo-spinner part="spinner"></pbo-spinner>`:""}
1016
- </${e}>`}};pd.styles=[sl,Uh],pd.dependencies={"pbo-spinner":cd},ud([bt(".button")],pd.prototype,"button",2),ud([bt(".button--loading pbo-spinner")],pd.prototype,"spinner",2),ud([gt({type:Boolean,reflect:!0})],pd.prototype,"disabled",2),ud([gt()],pd.prototype,"href",2),ud([gt()],pd.prototype,"name",2),ud([gt()],pd.prototype,"value",2),ud([gt({reflect:!0})],pd.prototype,"variant",2),ud([gt({type:Boolean,reflect:!0})],pd.prototype,"outline",2),ud([gt({reflect:!0})],pd.prototype,"size",2),ud([gt({type:Boolean,reflect:!0})],pd.prototype,"circle",2),ud([gt({reflect:!0})],pd.prototype,"type",2),ud([gt({type:Boolean,reflect:!0,attribute:"color-block"})],pd.prototype,"colorBlock",2),ud([gt({type:Boolean,reflect:!0})],pd.prototype,"loading",2),ud([ft()],pd.prototype,"isIconButton",2),ud([ft()],pd.prototype,"hasFocus",2),pd=ud([dt("pbo-button")],pd);const gd=pd,fd=l`
1017
- :host {
1018
- display: inline-block;
1019
- }
1020
-
1021
- .button-group {
1022
- /* display: flex; */
1023
- /* flex-wrap: nowrap; */
1024
- }
1025
- `;var md=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,vd=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?bd(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&md(e,i,o),o};let yd=class extends Kh{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=_d(t.target);null==e||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=_d(t.target);null==e||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=_d(t.target);null==e||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=_d(t.target);null==e||e.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach((e=>{const i=t.indexOf(e),s=_d(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",0===i),s.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),s.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),s.toggleAttribute("data-pbo-button-group__button--radio","pbo-radio-button"===s.tagName.toLowerCase()))}))}render(){return U`
1026
- <div
1027
- part="base"
1028
- class=${zh({"button-group":!0})}
1029
- role="${this.disableRole?"presentation":"group"}"
1030
- aria-label=${this.label}
1031
- @focusout=${this.handleBlur}
1032
- @focusin=${this.handleFocus}
1033
- @mouseover=${this.handleMouseOver}
1034
- @mouseout=${this.handleMouseOut}
1035
- >
1036
- <slot @slotchange=${this.handleSlotChange}></slot>
1037
- </div>
1038
- `}};function _d(t){const e="pbo-button, pbo-radio-button";return t.closest(e)??t.querySelector(e)}yd.styles=[sl,fd],vd([bt("slot")],yd.prototype,"defaultSlot",2),vd([ft()],yd.prototype,"disableRole",2),vd([gt()],yd.prototype,"label",2),yd=vd([dt("pbo-button-group")],yd);const xd=yd,wd=l`
1039
- ${Uh}
1040
-
1041
- .button__prefix,
1042
- .button__suffix,
1043
- .button__label {
1044
- display: inline-flex;
1045
- position: relative;
1046
- align-items: center;
1047
- }
1048
-
1049
- .button--checked.button--circle {
1050
- /* border-width: 5px; */
1051
- /* border-color: rgb(13, 110, 253, 0.5) !important; */
1052
- outline: 3px solid rgb(13, 110, 253, 0.5);
1053
- padding: 2px;
1054
- }
1055
- `
1056
- /**
1057
- * @license
1058
- * Copyright 2018 Google LLC
1059
- * SPDX-License-Identifier: BSD-3-Clause
1060
- */,Cd="important",Sd=" !"+Cd,kd=Bh(class extends Rh{constructor(t){var e;if(super(t),t.type!==Ih||"style"!==t.name||(null==(e=t.strings)?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return null==s?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const s of this.ft)null==e[s]&&(this.ft.delete(s),s.includes("-")?i.removeProperty(s):i[s]=null);for(const s in e){const t=e[s];if(null!=t){this.ft.add(s);const e="string"==typeof t&&t.endsWith(Sd);s.includes("-")||e?i.setProperty(s,e?t.slice(0,-11):t,e?Cd:""):i[s]=t}}return W}});var Td=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,Od=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Ed(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Td(e,i,o),o};let Dd=class extends Kh{constructor(){super(...arguments),this.hasSlotController=new Fh(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled)return t.preventDefault(),void t.stopPropagation();this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=(new Option).style;return e.color=t,""!==e.color}render(){return U`
1061
- <div part="base" role="presentation">
1062
- <button
1063
- part="${"button"+(this.checked?"button--checked":"")}"
1064
- role="radio"
1065
- aria-checked="${this.checked}"
1066
- class=${zh({button:!0,"button--default":!0,"button--color-block":!!this.isColorString(this.value),"button--small":"small"===this.size,"button--medium":"medium"===this.size,"button--large":"large"===this.size,"button--checked":this.checked,"button--disabled":this.disabled,"button--outline":!0,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--icon":this.iconOnly})}
1067
- type="button"
1068
- value=${nd(this.value)}
1069
- @blur=${this.handleBlur}
1070
- @click=${this.handleClick}
1071
- @focus=${this.handleFocus}
1072
- style=${kd({backgroundColor:this.isColorString(this.value)?this.value:""})}
1073
- >
1074
- <slot name="prefix" part="prefix" class="button__prefix"></slot>
1075
- <slot part="label" class="button__label"></slot>
1076
- <slot name="suffix" part="suffix" class="button__suffix"></slot>
1077
- </button>
1078
- </div>
1079
- `}};Dd.styles=[sl,wd],Od([bt(".button")],Dd.prototype,"input",2),Od([bt(".hidden-input")],Dd.prototype,"hiddenInput",2),Od([gt({type:Boolean,reflect:!0})],Dd.prototype,"checked",2),Od([gt()],Dd.prototype,"value",2),Od([gt({type:Boolean,reflect:!0})],Dd.prototype,"disabled",2),Od([gt({reflect:!0})],Dd.prototype,"size",2),Od([gt({type:Boolean,reflect:!0})],Dd.prototype,"circle",2),Od([gt({type:Boolean,reflect:!0,attribute:"icon-only"})],Dd.prototype,"iconOnly",2),Od([ft()],Dd.prototype,"hasFocus",2),Dd=Od([dt("pbo-radio-button")],Dd);const Md=Dd,Pd=l`
1080
- :host {
1081
- display: block;
1082
- }
1083
- .form-control {
1084
- position: relative;
1085
- border: none;
1086
- padding: 0;
1087
- margin: 0;
1088
- }
1089
-
1090
- .visually-hidden {
1091
- position: absolute;
1092
- width: 1px;
1093
- height: 1px;
1094
- padding: 0;
1095
- margin: -1px;
1096
- overflow: hidden;
1097
- clip: rect(0, 0, 0, 0);
1098
- white-space: nowrap;
1099
- border: 0;
1100
- }
1101
-
1102
- .form-control-input pbo-button-group {
1103
- padding: 0.25rem;
1104
- }
1105
-
1106
- .radio-icon-group .form-control-input pbo-button-group {
1107
- background-color: #f3f4f6;
1108
- padding: 0.25rem;
1109
- border-radius: 1rem;
1110
- }
1111
- `;var Ad=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,Id=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Fd(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Ad(e,i,o),o};let Ld=class extends Kh{constructor(){super(...arguments),this.formControlController=new id(this),this.hasSlotController=new Fh(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?od:t?rd:sd}get validationMessage(){const t=this.required&&!this.value;return""!==this.customValidityMessage?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}checkValidity(){const t=this.required&&!this.value,e=""!==this.customValidityMessage;return!t&&!e||(this.formControlController.emitInvalidEvent(),!1)}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout((()=>this.validationInput.hidden=!0),1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach((t=>t.checked=t.value===this.value)),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;e&&!e.disabled&&(this.value=e.value,i.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){}syncRadios(){customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")||customElements.get("pbo-radio")?this.syncRadioElements():(customElements.whenDefined("pbo-radio").then((()=>{this.syncRadios()})),customElements.get("pbo-radio-button")?this.syncRadioElements():customElements.whenDefined("pbo-radio-button").then((()=>{this.syncRadios()})))}async syncRadioElements(){var t;const e=this.getAllRadios();if(await Promise.all(e.map((async t=>{await t.updateComplete,t.checked=t.value===this.value}))),this.hasButtonGroup=e.some((t=>"pbo-radio-button"===t.tagName.toLowerCase())),e.length>0&&!e.some((t=>t.checked)))if(this.hasButtonGroup){const i=null==(t=e[0].shadowRoot)?void 0:t.querySelector("button");i&&i.setAttribute("tabindex","0")}else e[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=!!this.helpText||!!e,s=!!this.label||!!t;return U`
1112
- <fieldset
1113
- role="radiogroup"
1114
- part="form-control"
1115
- class=${zh({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--radio-group":!0,"form-control--has-label":s,"form-control--has-help-text":i,"radio-icon-group":this.iconGroup})}
1116
- role="radiogroup"
1117
- aria-labelledby="label"
1118
- aria-describedby="help-text"
1119
- aria-errormessage="error-message"
1120
- >
1121
- <label
1122
- part="form-control-label"
1123
- id="label"
1124
- class="form-control__label"
1125
- aria-hidden=${s?"false":"true"}
1126
- @click=${this.handleLabelClick}
1127
- >
1128
- <slot name="label">${this.label}</slot>
1129
- </label>
1130
-
1131
- <div part="form-control-input" class="form-control-input">
1132
- <div class="visually-hidden">
1133
- <div id="error-message" aria-live="assertive">${this.errorMessage}</div>
1134
- <label class="radio-group__validation">
1135
- <input
1136
- type="text"
1137
- class="radio-group__validation-input"
1138
- ?required=${this.required}
1139
- tabindex="-1"
1140
- hidden
1141
- @invalid=${this.handleInvalid}
1142
- />
1143
- </label>
1144
- </div>
1145
- <pbo-button-group part="button-group" exportparts="base:button-group__base" role="presentation">
1146
- <slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
1147
- </pbo-button-group>
1148
- </div>
1149
- <div
1150
- part="form-control-help-text"
1151
- id="help-text"
1152
- class="form-control__help-text"
1153
- aria-hidden=${i?"false":"true"}
1154
- >
1155
- <slot name="help-text">${this.helpText}</slot>
1156
- </div>
1157
- </fieldset>
1158
- `}};Ld.styles=[sl,Pd,$h],Ld.dependencies={"pbo-button-group":yd},Id([bt("slot:not([name])")],Ld.prototype,"defaultSlot",2),Id([bt(".radio-group__validation-input")],Ld.prototype,"validationInput",2),Id([ft()],Ld.prototype,"hasButtonGroup",2),Id([ft()],Ld.prototype,"errorMessage",2),Id([ft()],Ld.prototype,"defaultValue",2),Id([gt({type:Boolean,reflect:!0})],Ld.prototype,"required",2),Id([gt()],Ld.prototype,"name",2),Id([gt({reflect:!0})],Ld.prototype,"value",2),Id([gt({attribute:"help-text"})],Ld.prototype,"helpText",2),Id([gt()],Ld.prototype,"label",2),Id([gt({type:Boolean,reflect:!0,attribute:"icon-group"})],Ld.prototype,"iconGroup",2),Id([gt()],Ld.prototype,"size",2),Id([gt({type:Boolean,reflect:!0})],Ld.prototype,"disabled",2),Id([gt({reflect:!0})],Ld.prototype,"form",2),Id([il("value")],Ld.prototype,"handleValueChange",1),Ld=Id([dt("pbo-radio-group")],Ld);const jd=Ld,Bd=l`
1159
- :host {
1160
- display: block;
1161
- position: relative;
1162
- }
1163
- .form-control__help-text {
1164
- position: absolute;
1165
- right: 0px;
1166
- }
1167
- .textarea {
1168
- display: grid;
1169
- align-items: center;
1170
- position: relative;
1171
- width: 100%;
1172
- font-family: var(--pbo-input-font-family);
1173
- font-weight: var(--pbo-input-font-weight);
1174
- line-height: var(--pbo-line-height-normal);
1175
- letter-spacing: var(--pbo-input-letter-spacing);
1176
- vertical-align: middle;
1177
- transition:
1178
- var(--pbo-transition-fast) color,
1179
- var(--pbo-transition-fast) border,
1180
- var(--pbo-transition-fast) box-shadow,
1181
- var(--pbo-transition-fast) background-color;
1182
- cursor: text;
1183
- }
1184
-
1185
- /* Standard textareas */
1186
- .textarea--standard {
1187
- background-color: var(--pbo-input-background-color);
1188
- border: solid var(--pbo-input-border-width) var(--pbo-input-border-color);
1189
- }
1190
-
1191
- .textarea--standard:hover:not(.textarea--disabled) {
1192
- background-color: var(--pbo-input-background-color-hover);
1193
- border-color: var(--pbo-input-border-color-hover);
1194
- }
1195
- .textarea--standard:hover:not(.textarea--disabled) .textarea__control {
1196
- color: var(--pbo-input-color-hover);
1197
- }
1198
-
1199
- .textarea--standard.textarea--focused:not(.textarea--disabled) {
1200
- background-color: var(--pbo-input-background-color-focus);
1201
- border-color: var(--pbo-input-border-color-focus);
1202
- color: var(--pbo-input-color-focus);
1203
- box-shadow: 0 0 0 var(--pbo-focus-ring-width) var(--pbo-input-focus-ring-color);
1204
- }
1205
-
1206
- .textarea--standard.textarea--focused:not(.textarea--disabled) .textarea__control {
1207
- color: var(--pbo-input-color-focus);
1208
- }
1209
-
1210
- .textarea--standard.textarea--disabled {
1211
- background-color: var(--pbo-input-background-color-disabled);
1212
- border-color: var(--pbo-input-border-color-disabled);
1213
- opacity: 0.5;
1214
- cursor: not-allowed;
1215
- }
1216
-
1217
- .textarea__control,
1218
- .textarea__size-adjuster {
1219
- grid-area: 1 / 1 / 2 / 2;
1220
- }
1221
-
1222
- .textarea__size-adjuster {
1223
- visibility: hidden;
1224
- pointer-events: none;
1225
- opacity: 0;
1226
- }
1227
-
1228
- .textarea--standard.textarea--disabled .textarea__control {
1229
- color: var(--pbo-input-color-disabled);
1230
- }
1231
-
1232
- .textarea--standard.textarea--disabled .textarea__control::placeholder {
1233
- color: var(--pbo-input-placeholder-color-disabled);
1234
- }
1235
-
1236
- /* Filled textareas */
1237
- .textarea--filled {
1238
- border: none;
1239
- background-color: var(--pbo-input-filled-background-color);
1240
- color: var(--pbo-input-color);
1241
- }
1242
-
1243
- .textarea--filled:hover:not(.textarea--disabled) {
1244
- background-color: var(--pbo-input-filled-background-color-hover);
1245
- }
1246
-
1247
- .textarea--filled.textarea--focused:not(.textarea--disabled) {
1248
- background-color: var(--pbo-input-filled-background-color-focus);
1249
- outline: var(--pbo-focus-ring);
1250
- outline-offset: var(--pbo-focus-ring-offset);
1251
- }
1252
-
1253
- .textarea--filled.textarea--disabled {
1254
- background-color: var(--pbo-input-filled-background-color-disabled);
1255
- opacity: 0.5;
1256
- cursor: not-allowed;
1257
- }
1258
-
1259
- .textarea__control {
1260
- font-family: inherit;
1261
- font-size: inherit;
1262
- font-weight: inherit;
1263
- line-height: 1.4;
1264
- color: var(--pbo-input-color);
1265
- border: none;
1266
- background: none;
1267
- box-shadow: none;
1268
- cursor: inherit;
1269
- -webkit-appearance: none;
1270
- }
1271
-
1272
- .textarea__control::-webkit-search-decoration,
1273
- .textarea__control::-webkit-search-cancel-button,
1274
- .textarea__control::-webkit-search-results-button,
1275
- .textarea__control::-webkit-search-results-decoration {
1276
- -webkit-appearance: none;
1277
- }
1278
-
1279
- .textarea__control::placeholder {
1280
- color: var(--pbo-input-placeholder-color);
1281
- user-select: none;
1282
- -webkit-user-select: none;
1283
- }
1284
-
1285
- .textarea__control:focus {
1286
- outline: none;
1287
- }
1288
-
1289
- /*
1290
- * Size modifiers
1291
- */
1292
-
1293
- .textarea--small {
1294
- border-radius: var(--pbo-input-border-radius-small);
1295
- font-size: var(--pbo-input-font-size-small);
1296
- }
1297
-
1298
- .textarea--small .textarea__control {
1299
- padding: 0.5em var(--pbo-input-spacing-small);
1300
- }
1301
-
1302
- .textarea--medium {
1303
- border-radius: var(--pbo-input-border-radius-medium);
1304
- font-size: var(--pbo-input-font-size-medium);
1305
- }
1306
-
1307
- .textarea--medium .textarea__control {
1308
- padding: 0.5em 11.5px;
1309
- }
1310
-
1311
- .textarea--large {
1312
- border-radius: var(--pbo-input-border-radius-large);
1313
- font-size: var(--pbo-input-font-size-large);
1314
- }
1315
-
1316
- .textarea--large .textarea__control {
1317
- padding: 0.5em var(--pbo-input-spacing-large);
1318
- }
1319
-
1320
- /*
1321
- * Resize types
1322
- */
1323
-
1324
- .textarea--resize-none .textarea__control {
1325
- resize: none;
1326
- }
1327
-
1328
- .textarea--resize-vertical .textarea__control {
1329
- resize: vertical;
1330
- }
1331
-
1332
- .textarea--resize-auto .textarea__control {
1333
- height: auto;
1334
- resize: none;
1335
- overflow-y: hidden;
1336
- }
1337
-
1338
- .form-control__help-text {
1339
- margin-top: var(--pbo-spacing-2x-small) !important;
1340
- display: flex !important;
1341
- justify-content: end !important;
1342
- }
1343
- `
1344
- /**
1345
- * @license
1346
- * Copyright 2020 Google LLC
1347
- * SPDX-License-Identifier: BSD-3-Clause
1348
- */,{I:Rd}=nt,zd=(t,e)=>void 0!==(null==t?void 0:t._$litType$),$d=()=>document.createComment(""),Hd=(t,e,i)=>{var s;const r=t._$AA.parentNode,o=t._$AB;if(void 0===i){const e=r.insertBefore($d(),o),s=r.insertBefore($d(),o);i=new Rd(e,s,t,t.options)}else{const e=i._$AB.nextSibling,n=i._$AM,a=n!==t;if(a){let e;null==(s=i._$AQ)||s.call(i,t),i._$AM=t,void 0!==i._$AP&&(e=t._$AU)!==n._$AU&&i._$AP(e)}if(e!==o||a){let t=i._$AA;for(;t!==e;){const e=t.nextSibling;r.insertBefore(t,o),t=e}}}return i},Nd={},Vd=(t,e=Nd)=>t._$AH=e,Ud=t=>t._$AH,Wd=Bh(class extends Rh{constructor(t){if(super(t),t.type!==Lh&&t.type!==Ih&&t.type!==jh)throw Error("The `live` directive is not allowed on child or event bindings");if(void 0!==t.strings)throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===W||e===X)return e;const i=t.element,s=t.name;if(t.type===Lh){if(e===i[s])return W}else if(t.type===jh){if(!!e===i.hasAttribute(s))return W}else if(t.type===Ih&&i.getAttribute(s)===e+"")return W;return Vd(t),e}});var Xd=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Yd=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Gd(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Xd(e,i,o),o};let qd=class extends Kh{constructor(){super(...arguments),this.formControlController=new id(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new Fh(this,"help-text"),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,this.placeholder="",this.rows=4,this.resize="vertical",this.disabled=!1,this.readonly=!1,this.form="",this.required=!1,this.helpText=""}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleChange(){this.value=this.input.value,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){this.value=this.input.value,this.emit("pbo-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(t){return t?("number"==typeof t.top&&(this.input.scrollTop=t.top),void("number"==typeof t.left&&(this.input.scrollLeft=t.left))):{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(t,e,i="none"){this.input.setSelectionRange(t,e,i)}setRangeText(t,e,i,s="preserve"){const r=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,r,o,s),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("help-text"),e=!!this.helpText||!!t;return U` <div
1349
- part="form-control"
1350
- class=${zh({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-help-text":e,invalid:!0})}
1351
- >
1352
- <div part="form-control-input" class="form-control-input">
1353
- <div
1354
- part="base"
1355
- class=${zh({textarea:!0,"textarea--small":"small"===this.size,"textarea--medium":"medium"===this.size,"textarea--large":"large"===this.size,"textarea--standard":!this.filled,"textarea--filled":this.filled,"textarea--disabled":this.disabled,"textarea--focused":this.hasFocus,"textarea--empty":!this.value,"textarea--resize-none":"none"===this.resize,"textarea--resize-vertical":"vertical"===this.resize,"textarea--resize-auto":"auto"===this.resize})}
1356
- >
1357
- <textarea
1358
- part="textarea"
1359
- id="input"
1360
- class="textarea__control"
1361
- title=${this.title}
1362
- name=${nd(this.name)}
1363
- .value=${Wd(this.value)}
1364
- ?disabled=${this.disabled}
1365
- ?readonly=${this.readonly}
1366
- ?required=${this.required}
1367
- placeholder=${nd(this.placeholder)}
1368
- rows=${nd(this.rows)}
1369
- minlength=${nd(this.minlength)}
1370
- maxlength=${nd(this.maxlength)}
1371
- aria-describedby="help-text"
1372
- @change=${this.handleChange}
1373
- @input=${this.handleInput}
1374
- @invalid=${this.handleInvalid}
1375
- @focus=${this.handleFocus}
1376
- @blur=${this.handleBlur}
1377
- ></textarea>
1378
- <!-- This "adjuster" exists to prevent layout shifting. https://github.com/shoelace-style/shoelace/issues/2180 -->
1379
- <div part="textarea-adjuster" class="textarea__size-adjuster" ?hidden=${"auto"!==this.resize}></div>
1380
- </div>
1381
- </div>
1382
- <div
1383
- part="form-control-help-text"
1384
- id="help-text"
1385
- class="form-control__help-text"
1386
- aria-hidden=${e?"false":"true"}
1387
- >
1388
- <slot name="help-text">${this.helpText}</slot>
1389
- </div>
1390
- </div>`}};qd.styles=[sl,Bd,$h],Yd([bt(".textarea__control")],qd.prototype,"input",2),Yd([bt(".textarea__size-adjuster")],qd.prototype,"sizeAdjuster",2),Yd([ft()],qd.prototype,"hasFocus",2),Yd([gt()],qd.prototype,"name",2),Yd([gt()],qd.prototype,"value",2),Yd([gt({reflect:!0})],qd.prototype,"size",2),Yd([gt({type:Boolean,reflect:!0})],qd.prototype,"filled",2),Yd([gt()],qd.prototype,"placeholder",2),Yd([gt({type:Number})],qd.prototype,"rows",2),Yd([gt()],qd.prototype,"resize",2),Yd([gt({type:Boolean,reflect:!0})],qd.prototype,"disabled",2),Yd([gt({type:Boolean,reflect:!0})],qd.prototype,"readonly",2),Yd([gt({reflect:!0})],qd.prototype,"form",2),Yd([gt({type:Boolean,reflect:!0})],qd.prototype,"required",2),Yd([gt({type:Number})],qd.prototype,"minlength",2),Yd([gt({type:Number})],qd.prototype,"maxlength",2),Yd([gt({attribute:"help-text"})],qd.prototype,"helpText",2),qd=Yd([dt("pbo-textarea")],qd);const Kd=qd,Zd=l`
1391
- :host {
1392
- display: block;
1393
- width: 100%;
1394
- height: 100%;
1395
- }
1396
- @media screen and (min-width: 640px) {
1397
- :host {
1398
- display: block;
1399
- height: 100%;
1400
- width: 100%;
1401
- }
1402
- }
1403
-
1404
- .editor {
1405
- height: 100%;
1406
- width: 100%;
1407
- display: flex;
1408
- flex-direction: column;
1409
- gap: var(--pbo-spacing-large);
1410
- }
1411
-
1412
- .editor__form {
1413
- display: flex;
1414
- flex-direction: column;
1415
- gap: var(--pbo-spacing-x-small);
1416
- }
1417
-
1418
- @media screen and (min-width: 640px) {
1419
- .editor {
1420
- width: 100%;
1421
- height: 100%;
1422
- display: grid;
1423
- grid-template-columns: repeat(12, 1fr);
1424
- gap: 1rem;
1425
- }
1426
-
1427
- .editor__card {
1428
- grid-column: 1 / 7;
1429
- }
1430
-
1431
- .editor__form {
1432
- grid-column: 7 / 13;
1433
- }
1434
- }
1435
-
1436
- @media screen and (min-width: 768px) {
1437
- .editor__card {
1438
- grid-column: 2 / 7;
1439
- }
1440
- .editor__form {
1441
- grid-column: 7 / 12;
1442
- }
1443
- }
1444
-
1445
- @media screen and (min-width: 1536px) {
1446
- .editor__card {
1447
- grid-column: 3 / 7;
1448
- }
1449
- .editor__form {
1450
- grid-column: 7 / 11;
1451
- }
1452
- }
1453
- `,Jd=l`
1454
- :host {
1455
- display: block;
1456
- }
1457
- .typing-form {
1458
- display: flex;
1459
- flex-direction: column;
1460
- gap: var(--pbo-spacing-medium);
1461
- }
1462
-
1463
- .color-alignment-container {
1464
- display: grid;
1465
- grid-template-columns: repeat(2, 1fr);
1466
- }
1467
-
1468
- .cta-buttons {
1469
- display: flex;
1470
- flex-direction: column;
1471
- }
1472
-
1473
- .cta-buttons pbo-button::part(base) {
1474
- font-size: var(--pbo-font-size-medium);
1475
- }
1476
- `,Qd=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),tu=t=>null!=t,eu=t=>Object.entries(t).reduce(((t,[e,i])=>(null==i||(t[e]=i),t)),{});var iu=Object.defineProperty,su=Object.getOwnPropertyDescriptor,ru=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?su(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&iu(e,i,o),o};let ou=class extends Kh{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=ou.CTA_STATES.primary,this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout((()=>{this.windowHeight=window.innerHeight}),50)}}isLoadingChanged(){this.ctaButtons.forEach((t=>{t.loading=this.loading}))}disabledChanged(){this.greetingText.disabled=this.disabled,this.fontSelector.disabled=this.disabled,this.textColor.childNodes.forEach((t=>{t.disabled=this.disabled})),this.textAlignment.childNodes.forEach((t=>{t.disabled=this.disabled})),this.ctaButtons.forEach((t=>{t.disabled=this.disabled}))}firstUpdated(){this.disabledChanged(),this.isLoadingChanged(),this.textArea.addEventListener("invalid",(()=>{alert("Please add a message to continue")}))}get formData(){var t,e,i,s,r,o,n,a;const l={pboCardId:(null==(t=this.card)?void 0:t.pboId)||"Unknown",productId:null==(e=this.card)?void 0:e.productId,sku:null==(i=this.card)?void 0:i.sku,variantId:null==(s=this.card)?void 0:s.variantId,font:(null==(r=this.fontSelector)?void 0:r.value)||"",text:(null==(o=this.greetingText)?void 0:o.value)||"",color:(null==(n=this.textColor)?void 0:n.value)||"",alignment:(null==(a=this.textAlignment)?void 0:a.value)||""};return eu(l)}handleFormChange(t){this.ctaButtonState=ou.CTA_STATES.primary,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var e;t.preventDefault();const i=null==(e=t.submitter)?void 0:e.name;if("danger"!==this.ctaButtonState.type)return""===this.greetingText.value||null===this.greetingText.value||void 0===this.greetingText.value?(this.ctaButtonState=ou.CTA_STATES.danger,void this.greetingText.focus()):void this.submitTypeForm(this.formData);"skip"===i&&this.submitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.formData.text.length;return U`
1477
- <form class="typing-form" @submit=${this.submitFormHandler}>
1478
- <pbo-textarea
1479
- class="greeting-text"
1480
- @pbo-input=${this.handleFormChange}
1481
- help-text=${t>1?`${t} characters`:`${t} character`}
1482
- maxlength="223"
1483
- rows="${window.innerHeight>=800?12:8}"
1484
- placeholder="Type your message here"
1485
- resize="none"
1486
- >
1487
- </pbo-textarea>
1488
-
1489
- <pbo-selector
1490
- label="Font"
1491
- class="font-selector"
1492
- .fonts="${[{value:"Calibri",label:"Calibri",font:"Calibri, sans-serif"},{value:"Caveat",label:"Caveat",font:"Caveat, cursive"},{value:"Dancing Script",label:"Dancing Script",font:"Dancing Script, cursive"},{value:"Kalam",label:"Kalam",font:"Kalam, cursive"},{value:"Sacramento",label:"Sacramento",font:"Sacramento, cursive"},{value:"Reenie Beanie",label:"Reenie Beanie",font:"Reenie Beanie, cursive"}]}"
1493
- @pbo-change=${this.handleFormChange}
1494
- size="large"
1495
- disabled="${this.disabled}"
1496
- ></pbo-selector>
1497
-
1498
- <div class="color-alignment-container">
1499
- <pbo-radio-group
1500
- class="text-color"
1501
- @pbo-change=${this.handleFormChange}
1502
- value="rgb(0,0,0)"
1503
- label="Color"
1504
- size="large"
1505
- >
1506
- <pbo-radio-button disabled="${this.disabled}" value="rgb(0,0,0)" size="small" circle></pbo-radio-button>
1507
- <pbo-radio-button disabled="${this.disabled}" value="rgb(255,255,255)" size="small" circle></pbo-radio-button>
1508
- </pbo-radio-group>
1509
-
1510
- <pbo-radio-group
1511
- class="text-alignment"
1512
- @pbo-change=${this.handleFormChange}
1513
- value="left"
1514
- label="Align"
1515
- size="large"
1516
- icon-group
1517
- >
1518
- <pbo-radio-button value="left" icon-only>
1519
- <svg
1520
- xmlns="http://www.w3.org/2000/svg"
1521
- height="1rem"
1522
- viewBox="0 -960 960 960"
1523
- width="1rem"
1524
- fill="#1f1f1f"
1525
- >
1526
- <path
1527
- d="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"
1528
- />
1529
- </svg>
1530
- </pbo-radio-button>
1531
- <pbo-radio-button value="center" icon-only>
1532
- <svg
1533
- xmlns="http://www.w3.org/2000/svg"
1534
- height="1rem"
1535
- viewBox="0 -960 960 960"
1536
- width="1rem"
1537
- fill="#1f1f1f"
1538
- >
1539
- <path
1540
- d="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"
1541
- />
1542
- </svg>
1543
- </pbo-radio-button>
1544
- <pbo-radio-button value="right" icon-only>
1545
- <svg
1546
- xmlns="http://www.w3.org/2000/svg"
1547
- height="1rem"
1548
- viewBox="0 -960 960 960"
1549
- width="1rem"
1550
- fill="#1f1f1f"
1551
- >
1552
- <path
1553
- d="M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"
1554
- />
1555
- </svg>
1556
- </pbo-radio-button>
1557
- </-alignment-radio-group>
1558
- </div>
1559
- <div class="cta-buttons">
1560
- <pbo-button
1561
- name="main-cta"
1562
- type="submit"
1563
- class="submit"
1564
- variant="${this.ctaButtonState.type}"
1565
- >
1566
- ${this.ctaButtonState.message}
1567
- </pbo-button>
1568
- ${"danger"===this.ctaButtonState.type?U`<pbo-button name="skip" type="submit" variant="text" size="small" class="skip">Skip</pbo-button>`:""}
1569
- </div>
1570
- </form>
1571
- `}};ou.styles=[sl,$h,Jd],ou.dependencies={"pbo-selector":t.PboSelector,"pbo-textarea":qd,"pbo-color-radio-group":Ld,"pbo-radio-group":Ld,"pbo-radio-button":Ld,"pbo-button":pd},ou.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}},ru([gt({type:String,reflect:!0})],ou.prototype,"cardInnerImageUrl",2),ru([gt()],ou.prototype,"card",2),ru([gt()],ou.prototype,"submitTypeForm",2),ru([gt({type:Boolean,reflect:!0})],ou.prototype,"loading",2),ru([gt({type:Boolean,reflect:!0})],ou.prototype,"disabled",2),ru([bt(".greeting-text")],ou.prototype,"greetingText",2),ru([bt(".font-selector")],ou.prototype,"fontSelector",2),ru([bt(".text-color")],ou.prototype,"textColor",2),ru([bt(".text-alignment")],ou.prototype,"textAlignment",2),ru([bt(".typing-form")],ou.prototype,"typingForm",2),ru([bt("pbo-textarea")],ou.prototype,"textArea",2),ru([yt(".cta-buttons pbo-button")],ou.prototype,"ctaButtons",2),ru([ft()],ou.prototype,"windowHeight",2),ru([ft()],ou.prototype,"charsNum",2),ru([ft()],ou.prototype,"ctaButtonState",2),ru([il("loading",{waitUntilFirstUpdate:!0})],ou.prototype,"isLoadingChanged",1),ru([il("disabled",{waitUntilFirstUpdate:!0})],ou.prototype,"disabledChanged",1),ou=ru([dt("pbo-type-form")],ou);
1572
- /**
1573
- * @license
1574
- * Copyright 2017 Google LLC
1575
- * SPDX-License-Identifier: BSD-3-Clause
1576
- */
1577
- const nu=t=>{return null!=(null==(i=null==(e=t)?void 0:e._$litType$)?void 0:i.h)?t._$litType$.h:t.strings;var e,i},au=Bh(class extends Rh{constructor(t){super(t),this.et=new WeakMap}render(t){return[t]}update(t,[e]){const i=zd(this.it)?nu(this.it):null,s=zd(e)?nu(e):null;if(null!==i&&(null===s||i!==s)){const e=Ud(t).pop();let s=this.et.get(i);if(void 0===s){const t=document.createDocumentFragment();s=lt(X,t),s.setConnected(!1),this.et.set(i,s)}Vd(s,[e]),Hd(s,0,e)}if(null!==s){if(null===i||i!==s){const e=this.et.get(s);if(void 0!==e){const i=Ud(e).pop();t._$AR(),Hd(t,0,i),Vd(t,[i])}}this.it=e}else this.it=void 0;return this.render(e)}}),lu=l`
1578
- :host {
1579
- display: block;
1580
- width: 100%;
1581
- height: auto;
1582
- }
1583
-
1584
- .main-slide-container {
1585
- display: inline;
1586
- position: relative;
1587
- width: 80%;
1588
- height: 100%;
1589
- }
1590
-
1591
- .zoomed-preview-open-button {
1592
- position: absolute;
1593
- right: 0;
1594
- bottom: 0;
1595
- padding: 0.5rem;
1596
- }
1597
-
1598
- .zoomed-preview-open-button svg:hover {
1599
- cursor: pointer;
1600
- scale: 1.3;
1601
- }
1602
-
1603
- /* Main slide styles */
1604
- .main-slide {
1605
- display: none;
1606
- width: 100%;
1607
- height: 100%;
1608
- background-color: var(--pbo-color-gray-100);
1609
- border: 2px solid var(--pbo-color-gray-100);
1610
- }
1611
-
1612
- @media screen and (min-width: 640px) {
1613
- .main-slide {
1614
- background-color: transparent;
1615
- }
1616
- }
1617
-
1618
- .main-slide img {
1619
- max-height: 100%;
1620
- max-width: 100%;
1621
- width: 100%;
1622
- height: auto;
1623
- object-fit: contain;
1624
- display: block;
1625
- margin-left: auto;
1626
- margin-right: auto;
1627
- }
1628
-
1629
- .card--slider--wrapper {
1630
- display: flex;
1631
- aspect-ratio: 4.5/3;
1632
- gap: 3%;
1633
- width: 100%;
1634
- height: 100%;
1635
- }
1636
-
1637
- @media screen and (min-width: 640px) {
1638
- .card--slider--wrapper {
1639
- aspect-ratio: unset;
1640
- }
1641
- }
1642
-
1643
- img {
1644
- -webkit-user-drag: none;
1645
- pointer-events: none;
1646
- }
1647
-
1648
- .thumbnails {
1649
- width: 20%;
1650
- display: flex;
1651
- flex-direction: column;
1652
- gap: 1.9%;
1653
- justify-content: start;
1654
- overflow-y: auto;
1655
- box-sizing: border-box;
1656
- }
1657
-
1658
- .thumbnail {
1659
- cursor: pointer;
1660
- opacity: 0.35;
1661
- width: 100%;
1662
- box-sizing: border-box;
1663
- border: 2px solid var(--pbo-color-gray-300);
1664
- }
1665
-
1666
- .thumbnail.active {
1667
- opacity: 1;
1668
- }
1669
-
1670
- .main-slide.active {
1671
- display: block;
1672
- }
1673
-
1674
- .thumbnail img,
1675
- .thumbnail pbo-image {
1676
- display: block;
1677
- width: 100%;
1678
- height: auto;
1679
- }
1680
- `,cu=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}",hu=l`
1681
- :host,
1682
- :host * {
1683
- max-height: 100%;
1684
- max-width: 100%;
1685
- width: 100%;
1686
- height: auto;
1687
- object-fit: contain;
1688
- display: block;
1689
- margin-left: auto;
1690
- margin-right: auto;
1691
- }
1692
-
1693
- .skeleton {
1694
- background: #f3f3f3;
1695
- animation: pulse 1.5s infinite;
1696
- height: auto;
1697
- width: 100%;
1698
- aspect-ratio: 3 / 4;
1699
- }
1700
-
1701
- img {
1702
- width: 100%;
1703
- height: auto;
1704
- opacity: 0;
1705
- transition: opacity 0.3s ease-in-out;
1706
- }
1707
-
1708
- img.hidden {
1709
- display: none;
1710
- }
1711
-
1712
- img.loaded {
1713
- opacity: 1;
1714
- display: block;
1715
- }
1716
-
1717
- @keyframes pulse {
1718
- 0% {
1719
- background-color: #f3f3f3;
1720
- }
1721
- 50% {
1722
- background-color: #e0e0e0;
1723
- }
1724
- 100% {
1725
- background-color: #f3f3f3;
1726
- }
1727
- }
1728
- `;var du=Object.defineProperty,uu=Object.getOwnPropertyDescriptor,pu=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?uu(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&du(e,i,o),o};let gu=class extends Kh{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.imgEl.onload=()=>this.handleOnLoad()}render(){return U`
1729
- ${this.loaded?"":U` <div class="skeleton"></div>`}
1730
- <img
1731
- src=${this.src}
1732
- alt=${this.alt}
1733
- class=${zh({loaded:this.loaded,hidden:!this.loaded})}
1734
- @error=${()=>this.handleError()}
1735
- />
1736
- `}};gu.styles=[sl,hu],pu([gt()],gu.prototype,"skeletonHeight",2),pu([gt()],gu.prototype,"skeletonWidth",2),pu([gt()],gu.prototype,"src",2),pu([gt()],gu.prototype,"alt",2),pu([gt()],gu.prototype,"placeholder",2),pu([ft()],gu.prototype,"loaded",2),pu([bt("img")],gu.prototype,"imgEl",2),pu([il("src")],gu.prototype,"handleSrcChange",1),gu=pu([dt("pbo-image")],gu);var fu=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,bu=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?mu(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&fu(e,i,o),o};let vu=class extends Kh{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.mainImageTemplates=[],this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.handleOpenZoomedClick=t=>{if(!Qd())return t.preventDefault(),void t.stopPropagation();this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",(t=>{var e,i;const{detail:s}=t,r=null==(e=this.shadowRoot)?void 0:e.querySelector("#handwritten-main-canvas"),o=null==(i=this.shadowRoot)?void 0:i.querySelector("#handwritten-zoomed-preview-canvas");r&&o&&(r.imageWidth=s.width,r.imageHeight=s.height,r.imageTop=s.top,r.imageLeft=s.left,o.imageWidth=s.width,o.imageHeight=s.height,o.imageTop=s.top,o.imageLeft=s.left)})),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(t,e)=>{t.addEventListener("click",(()=>{this.focusOn(e)}))};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,s,r,o;e&&(this.mainImageTemplates=[U`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,U`<pbo-type-canvas
1737
- background-url=${e.medias.insert.url}
1738
- message=${null==(i=this.livePreviewProps)?void 0:i.text}
1739
- alignment=${(null==(s=this.livePreviewProps)?void 0:s.alignment)||"left"}
1740
- color=${null==(r=this.livePreviewProps)?void 0:r.color}
1741
- font=${null==(o=this.livePreviewProps)?void 0:o.font}
1742
- @click="${this.handleOpenZoomedClick}"
1743
- ></pbo-type-canvas>`,U`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,s,r,o;0!==this.thumbnailElements.length&&t!==e&&(null==(i=this.thumbnailElements[t])||i.classList.remove("active"),null==(s=this.thumbnailElements[e])||s.classList.add("active"),null==(r=this.mainSlideElements[t])||r.classList.remove("active"),null==(o=this.mainSlideElements[e])||o.classList.add("active"),this.requestUpdate())}focusOn(t){t<0||t>=this.thumbnailElements.length?console.warn("Invalid index:",t):this.focusIndex=t}get mainSlides(){if(!this.card)return[];return[U`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,U`<pbo-type-canvas
1744
- background-url=${this.card.medias.insert.url}
1745
- message=${this.livePreviewProps.text}
1746
- alignment=${this.livePreviewProps.alignment}
1747
- color=${this.livePreviewProps.color}
1748
- font=${this.livePreviewProps.font}
1749
- @click="${this.handleOpenZoomedClick}"
1750
- ></pbo-type-canvas>`,U`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]}render(){var t,e,i,s,r,o,n,a,l,c,h,d,u,p,g,f,m,b,v,y;return U`
1751
- <div class="card--slider--wrapper">
1752
- <div id="thumbnails" class="thumbnails">
1753
- <div class="thumbnail">
1754
- <pbo-image src="${(null==(t=this.card)?void 0:t.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
1755
- </div>
1756
- <div class="thumbnail">
1757
- <pbo-image src="${(null==(e=this.card)?void 0:e.medias.rendered_1.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1758
- </div>
1759
- <div class="thumbnail">
1760
- <pbo-image src="${(null==(i=this.card)?void 0:i.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1761
- </div>
1762
- </div>
1763
-
1764
- <div class="main-slide-container">
1765
- <div>
1766
- <div class="main-slide" @click="${this.handleOpenZoomedClick}">
1767
- <pbo-image src="${(null==(s=this.card)?void 0:s.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
1768
- ${Qd()?U`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1769
- <svg
1770
- stroke="currentColor"
1771
- fill="none"
1772
- stroke-width="2"
1773
- viewBox="0 0 24 24"
1774
- stroke-linecap="round"
1775
- stroke-linejoin="round"
1776
- height="1.25rem"
1777
- width="1.25rem"
1778
- xmlns="http://www.w3.org/2000/svg"
1779
- style="color: rgb(74, 74, 74);"
1780
- >
1781
- <circle cx="11" cy="11" r="8"></circle>
1782
- <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
1783
- <line x1="11" y1="8" x2="11" y2="14"></line>
1784
- <line x1="8" y1="11" x2="14" y2="11"></line>
1785
- </svg>
1786
- </div>`:""}
1787
- </div>
1788
- <div class="main-slide" @click="${this.handleOpenZoomedClick}">
1789
- ${au("type"===this.type?U`<pbo-type-canvas
1790
- background-url=${null==(r=this.card)?void 0:r.medias.insert.url}
1791
- message=${null==(o=this.livePreviewProps)?void 0:o.text}
1792
- alignment=${(null==(n=this.livePreviewProps)?void 0:n.alignment)||"left"}
1793
- color=${null==(a=this.livePreviewProps)?void 0:a.color}
1794
- font=${null==(l=this.livePreviewProps)?void 0:l.font}
1795
- @click="${this.handleOpenZoomedClick}"
1796
- ></pbo-type-canvas>`:U`<pbo-handwritten-canvas
1797
- id="handwritten-main-canvas"
1798
- background-url=${null==(c=this.card)?void 0:c.medias.insert.url}
1799
- handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
1800
- @click="${this.handleOpenZoomedClick}"
1801
- ></pbo-handwritten-canvas>`)}
1802
- ${Qd()?U`<div class="zoomed-preview-open-button">
1803
- <svg
1804
- stroke="currentColor"
1805
- fill="none"
1806
- stroke-width="2"
1807
- viewBox="0 0 24 24"
1808
- stroke-linecap="round"
1809
- stroke-linejoin="round"
1810
- height="1.25rem"
1811
- width="1.25rem"
1812
- xmlns="http://www.w3.org/2000/svg"
1813
- style="color: rgb(74, 74, 74);"
1814
- >
1815
- <circle cx="11" cy="11" r="8"></circle>
1816
- <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
1817
- <line x1="11" y1="8" x2="11" y2="14"></line>
1818
- <line x1="8" y1="11" x2="14" y2="11"></line>
1819
- </svg>
1820
- </div>`:""}
1821
- </div>
1822
- <div class="main-slide" @click=${this.handleOpenZoomedClick}>
1823
- <pbo-image src="${(null==(h=this.card)?void 0:h.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1824
- ${Qd()?U`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1825
- <svg
1826
- stroke="currentColor"
1827
- fill="none"
1828
- stroke-width="2"
1829
- viewBox="0 0 24 24"
1830
- stroke-linecap="round"
1831
- stroke-linejoin="round"
1832
- height="1.25rem"
1833
- width="1.25rem"
1834
- xmlns="http://www.w3.org/2000/svg"
1835
- style="color: rgb(74, 74, 74);"
1836
- >
1837
- <circle cx="11" cy="11" r="8"></circle>
1838
- <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
1839
- <line x1="11" y1="8" x2="11" y2="14"></line>
1840
- <line x1="8" y1="11" x2="14" y2="11"></line>
1841
- </svg>
1842
- </div>`:""}
1843
- </div>
1844
- </div>
1845
- </div>
1846
- </div>
1847
- <pbo-drawer
1848
- placement="bottom"
1849
- style="${kd({"--size":"100%","--panel-background-color":"#454545ca"})}"
1850
- contained
1851
- class="editor__zoomed"
1852
- >
1853
- <pbo-zoomed-preview
1854
- .close=${this.closeZoomedPreview}
1855
- .formData=${this.livePreviewProps}
1856
- .cardUrl=${null==(d=this.card)?void 0:d.medias.insert.url}
1857
- >
1858
- <img
1859
- src="${(null==(u=this.card)?void 0:u.medias.cover.url)||"https://picsum.photos/id/1/300/400"}"
1860
- alt=""
1861
- style=${kd({display:0===this.focusIndex?"block":"none"})}
1862
- />
1863
- ${au("type"===this.type?U`<pbo-type-canvas
1864
- background-url=${null==(p=this.card)?void 0:p.medias.insert.url}
1865
- message=${null==(g=this.livePreviewProps)?void 0:g.text}
1866
- alignment=${(null==(f=this.livePreviewProps)?void 0:f.alignment)||"left"}
1867
- color=${null==(m=this.livePreviewProps)?void 0:m.color}
1868
- font=${null==(b=this.livePreviewProps)?void 0:b.font}
1869
- @click="${this.handleOpenZoomedClick}"
1870
- style=${kd({display:1===this.focusIndex?"block":"none"})}
1871
- ></pbo-type-canvas>`:"")}
1872
- ${au("handwritten"===this.type?U`<pbo-handwritten-canvas
1873
- id="handwritten-zoomed-preview-canvas"
1874
- background-url=${null==(v=this.card)?void 0:v.medias.insert.url}
1875
- handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
1876
- @click="${this.handleOpenZoomedClick}"
1877
- style=${kd({display:1===this.focusIndex?"block":"none"})}
1878
- ></pbo-handwritten-canvas>`:"")}
1879
- <img
1880
- src="${(null==(y=this.card)?void 0:y.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
1881
- alt=""
1882
- style=${kd({display:2===this.focusIndex?"block":"none"})}
1883
- />
1884
- </pbo-zoomed-preview>
1885
- </pbo-drawer>
1886
- `}};vu.styles=[sl,lu,a(cu)],vu.dependencies={"fabric-example":t.FabricExample,"pbo-image":gu},bu([gt({type:Object})],vu.prototype,"card",2),bu([gt({type:Number,reflect:!0})],vu.prototype,"focusIndex",2),bu([gt({type:Object})],vu.prototype,"livePreviewProps",2),bu([gt()],vu.prototype,"handwrittenPreviewProps",2),bu([gt()],vu.prototype,"type",2),bu([bt("#thumbnails")],vu.prototype,"thumbnailCarousel",2),bu([bt("#main-carousel")],vu.prototype,"mainCarousel",2),bu([bt(".editor__zoomed")],vu.prototype,"zoomedPreview",2),bu([bt(".main-slide.active")],vu.prototype,"activeMainSlide",2),bu([bt("pbo-type-canvas")],vu.prototype,"typeCanvas",2),bu([yt(".thumbnail")],vu.prototype,"thumbnailElements",2),bu([yt(".main-slide")],vu.prototype,"mainSlideElements",2),bu([ft()],vu.prototype,"mainImageTemplates",2),bu([il("card")],vu.prototype,"handleCardChange",1),bu([il("focusIndex")],vu.prototype,"handleFocusIndexChange",1),vu=bu([dt("pbo-editor-card-slider")],vu);var yu=Object.defineProperty,_u=Object.getOwnPropertyDescriptor,xu=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?_u(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&yu(e,i,o),o};let wu=class extends Kh{constructor(){super(...arguments),this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData,this.slider.focusOn(1)},this.handelHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.handleEditorChange=t=>{this.editorType=t.detail.value}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",(t=>{this.handwrittenForm.setDimensions(t.detail)})),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handelHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",(()=>{this.openZoomedPreview()}))}handleCardInnerImageUrlChange(){this.requestUpdate()}handleCardChange(){this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handelHandwrittenFormChange)}render(){var t;return U`
1887
- <div class="editor">
1888
- <div class="editor__card">
1889
- <pbo-editor-card-slider
1890
- focusIndex="0"
1891
- .livePreviewProps=${this.formData}
1892
- .handwrittenPreviewProps=${this.handwrittenFormState}
1893
- type=${this.editorType}
1894
- ></pbo-editor-card-slider>
1895
- </div>
1896
-
1897
- <div class="editor__form">
1898
- <pbo-editor-selector @pbo-change=${this.handleEditorChange}></pbo-editor-selector>
1899
- <pbo-type-form
1900
- .submitTypeForm=${this.submitTypeForm}
1901
- style=${kd({display:"type"===this.editorType?"block":"none"})}
1902
- ></pbo-type-form>
1903
- <pbo-handwritten-form
1904
- style=${kd({display:"handwritten"===this.editorType?"block":"none"})}
1905
- .submitHandwrittenForm=${this.submitHandwrittenForm}
1906
- .getProcessedImg=${this.getProcessedImg}
1907
- ></pbo-handwritten-form>
1908
- </div>
1909
- </div>
1910
-
1911
- <pbo-drawer
1912
- placement="bottom"
1913
- style="${kd({"--size":"100%","--panel-background-color":"#454545ca"})}"
1914
- contained
1915
- class="editor__zoomed"
1916
- >
1917
- <pbo-zoomed-preview
1918
- .formData=${this.formData}
1919
- .handwrittenPreviewProps=${this.handwrittenFormState}
1920
- .cardUrl=${null==(t=this.card)?void 0:t.medias.insert.url}
1921
- .close=${this.closeZoomedPreview}
1922
- ></pbo-zoomed-preview>
1923
- </pbo-drawer>
1924
- `}};wu.styles=[sl,Zd],wu.dependencies={"editor-card-slider":vu,"fabric-example":t.FabricExample,"pbo-type-form":ou},xu([gt({type:String,reflect:!0})],wu.prototype,"cardInnerImageUrl",2),xu([gt({type:Object})],wu.prototype,"card",2),xu([gt()],wu.prototype,"submitTypeForm",2),xu([gt()],wu.prototype,"submitHandwrittenForm",2),xu([gt()],wu.prototype,"getProcessedImg",2),xu([bt("pbo-type-form")],wu.prototype,"typeForm",2),xu([bt("pbo-handwritten-form")],wu.prototype,"handwrittenForm",2),xu([bt("pbo-editor-card-slider")],wu.prototype,"slider",2),xu([bt(".editor__zoomed")],wu.prototype,"zoomedPreview",2),xu([ft()],wu.prototype,"formData",2),xu([ft()],wu.prototype,"handwrittenFormState",2),xu([ft()],wu.prototype,"editorType",2),xu([il("cardInnerImageUrl")],wu.prototype,"handleCardInnerImageUrlChange",1),xu([il("card")],wu.prototype,"handleCardChange",1),wu=xu([dt("pbo-editor")],wu);const Cu=wu,Su=ou,ku=vu,Tu=l`
1925
- :host {
1926
- display: block;
1927
- }
1928
-
1929
- ::slotted([slot="title"]) {
1930
- font-size: var(--pbo-font-size-x-large);
1931
- font-weight: var(--pbo-font-weight-normal);
1932
- margin-top: var(--pbo-spacing-medium);
1933
- margin-bottom: var(--pbo-spacing-x-small);
1934
- }
1935
-
1936
- :host(:first-of-type) ::slotted([slot="title"]) {
1937
- margin-top: 0; /* Remove top margin for first category */
1938
- }
1939
- .category-container {
1940
- margin-left: auto;
1941
- margin-right: auto;
1942
- }
1943
- .splide {
1944
- margin: 0 auto;
1945
- width: 100%;
1946
- }
1947
-
1948
- .splide__slide {
1949
- width: 100%;
1950
- aspect-ratio: 3/4;
1951
- position: relative;
1952
- overflow: hidden;
1953
- border: 2px solid var(--pbo-color-gray-200);
1954
- }
1955
-
1956
- .splide__slide::before {
1957
- content: "";
1958
- position: absolute;
1959
- top: 0;
1960
- left: 0;
1961
- width: 100%;
1962
- height: 100%;
1963
- background: transparent;
1964
- box-shadow: inset 0 0 0 0 rgba(0, 0, 0, 0.1);
1965
- transition: all 0.3s ease;
1966
- z-index: 1;
1967
- pointer-events: none;
1968
- }
1969
-
1970
- .splide__slide:hover::before {
1971
- box-shadow: inset 0 0 20px 3px rgba(0, 0, 0, 0.3);
1972
- }
1973
-
1974
- .splide__slide img {
1975
- position: absolute;
1976
- top: 0;
1977
- left: 0;
1978
- width: 100%;
1979
- height: auto;
1980
- object-fit: contain;
1981
- cursor: pointer;
1982
- transition: all 0.3s ease;
1983
- }
1984
-
1985
- .splide__slide img:hover {
1986
- transform: scale(1.1);
1987
- }
1988
- `;function Eu(t,e,i){return e&&function(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}
1989
- /*!
1990
- * Splide.js
1991
- * Version : 4.1.4
1992
- * License : MIT
1993
- * Copyright: 2022 Naotoshi Fujita
1994
- */var Ou="(prefers-reduced-motion: reduce)",Du={CREATED:1,MOUNTED:2,IDLE:3,MOVING:4,SCROLLING:5,DRAGGING:6,DESTROYED:7};function Mu(t){t.length=0}function Pu(t,e,i){return Array.prototype.slice.call(t,e,i)}function Au(t){return t.bind.apply(t,[null].concat(Pu(arguments,1)))}var Fu=setTimeout,Iu=function(){};function Lu(t){return requestAnimationFrame(t)}function ju(t,e){return typeof e===t}function Bu(t){return!Nu(t)&&ju("object",t)}var Ru=Array.isArray,zu=Au(ju,"function"),$u=Au(ju,"string"),Hu=Au(ju,"undefined");function Nu(t){return null===t}function Vu(t){try{return t instanceof(t.ownerDocument.defaultView||window).HTMLElement}catch(e){return!1}}function Uu(t){return Ru(t)?t:[t]}function Wu(t,e){Uu(t).forEach(e)}function Xu(t,e){return t.indexOf(e)>-1}function Gu(t,e){return t.push.apply(t,Uu(e)),t}function Yu(t,e,i){t&&Wu(e,(function(e){e&&t.classList[i?"add":"remove"](e)}))}function qu(t,e){Yu(t,$u(e)?e.split(" "):e,!0)}function Ku(t,e){Wu(e,t.appendChild.bind(t))}function Zu(t,e){Wu(t,(function(t){var i=(e||t).parentNode;i&&i.insertBefore(t,e)}))}function Ju(t,e){return Vu(t)&&(t.msMatchesSelector||t.matches).call(t,e)}function Qu(t,e){var i=t?Pu(t.children):[];return e?i.filter((function(t){return Ju(t,e)})):i}function tp(t,e){return e?Qu(t,e)[0]:t.firstElementChild}var ep=Object.keys;function ip(t,e,i){return t&&(i?ep(t).reverse():ep(t)).forEach((function(i){"__proto__"!==i&&e(t[i],i)})),t}function sp(t){return Pu(arguments,1).forEach((function(e){ip(e,(function(i,s){t[s]=e[s]}))})),t}function rp(t){return Pu(arguments,1).forEach((function(e){ip(e,(function(e,i){Ru(e)?t[i]=e.slice():Bu(e)?t[i]=rp({},Bu(t[i])?t[i]:{},e):t[i]=e}))})),t}function op(t,e){Wu(e||ep(t),(function(e){delete t[e]}))}function np(t,e){Wu(t,(function(t){Wu(e,(function(e){t&&t.removeAttribute(e)}))}))}function ap(t,e,i){Bu(e)?ip(e,(function(e,i){ap(t,i,e)})):Wu(t,(function(t){Nu(i)||""===i?np(t,e):t.setAttribute(e,String(i))}))}function lp(t,e,i){var s=document.createElement(t);return e&&($u(e)?qu(s,e):ap(s,e)),i&&Ku(i,s),s}function cp(t,e,i){if(Hu(i))return getComputedStyle(t)[e];Nu(i)||(t.style[e]=""+i)}function hp(t,e){cp(t,"display",e)}function dp(t){t.setActive&&t.setActive()||t.focus({preventScroll:!0})}function up(t,e){return t.getAttribute(e)}function pp(t,e){return t&&t.classList.contains(e)}function gp(t){return t.getBoundingClientRect()}function fp(t){Wu(t,(function(t){t&&t.parentNode&&t.parentNode.removeChild(t)}))}function mp(t){return tp((new DOMParser).parseFromString(t,"text/html").body)}function bp(t,e){t.preventDefault(),e&&(t.stopPropagation(),t.stopImmediatePropagation())}function vp(t,e){return t&&t.querySelector(e)}function yp(t,e){return e?Pu(t.querySelectorAll(e)):[]}function _p(t,e){Yu(t,e,!1)}function xp(t){return t.timeStamp}function wp(t){return $u(t)?t:t?t+"px":""}var Cp="splide",Sp="data-"+Cp;function kp(t,e){if(!t)throw new Error("["+Cp+"] "+(e||""))}var Tp=Math.min,Ep=Math.max,Op=Math.floor,Dp=Math.ceil,Mp=Math.abs;function Pp(t,e,i){return Mp(t-e)<i}function Ap(t,e,i,s){var r=Tp(e,i),o=Ep(e,i);return s?r<t&&t<o:r<=t&&t<=o}function Fp(t,e,i){var s=Tp(e,i),r=Ep(e,i);return Tp(Ep(s,t),r)}function Ip(t){return+(t>0)-+(t<0)}function Lp(t,e){return Wu(e,(function(e){t=t.replace("%s",""+e)})),t}function jp(t){return t<10?"0"+t:""+t}var Bp={};function Rp(){var t=[];function e(t,e,i){Wu(t,(function(t){t&&Wu(e,(function(e){e.split(" ").forEach((function(e){var s=e.split(".");i(t,s[0],s[1])}))}))}))}return{bind:function(i,s,r,o){e(i,s,(function(e,i,s){var n="addEventListener"in e,a=n?e.removeEventListener.bind(e,i,r,o):e.removeListener.bind(e,r);n?e.addEventListener(i,r,o):e.addListener(r),t.push([e,i,s,r,a])}))},unbind:function(i,s,r){e(i,s,(function(e,i,s){t=t.filter((function(t){return!!(t[0]!==e||t[1]!==i||t[2]!==s||r&&t[3]!==r)||(t[4](),!1)}))}))},dispatch:function(t,e,i){var s,r=!0;return"function"==typeof CustomEvent?s=new CustomEvent(e,{bubbles:r,detail:i}):(s=document.createEvent("CustomEvent")).initCustomEvent(e,r,!1,i),t.dispatchEvent(s),s},destroy:function(){t.forEach((function(t){t[4]()})),Mu(t)}}}var zp="mounted",$p="ready",Hp="move",Np="moved",Vp="click",Up="active",Wp="inactive",Xp="visible",Gp="hidden",Yp="refresh",qp="updated",Kp="resize",Zp="resized",Jp="scroll",Qp="scrolled",tg="destroy",eg="arrows:mounted",ig="navigation:mounted",sg="autoplay:play",rg="autoplay:pause",og="lazyload:loaded",ng="sk",ag="sh",lg="ei";function cg(t){var e=t?t.event.bus:document.createDocumentFragment(),i=Rp();return t&&t.event.on(tg,i.destroy),sp(i,{bus:e,on:function(t,s){i.bind(e,Uu(t).join(" "),(function(t){s.apply(s,Ru(t.detail)?t.detail:[])}))},off:Au(i.unbind,e),emit:function(t){i.dispatch(e,t,Pu(arguments,1))}})}function hg(t,e,i,s){var r,o,n=Date.now,a=0,l=!0,c=0;function h(){if(!l){if(a=t?Tp((n()-r)/t,1):1,i&&i(a),a>=1&&(e(),r=n(),s&&++c>=s))return d();o=Lu(h)}}function d(){l=!0}function u(){o&&cancelAnimationFrame(o),a=0,o=0,l=!0}return{start:function(e){e||u(),r=n()-(e?a*t:0),l=!1,o=Lu(h)},rewind:function(){r=n(),a=0,i&&i(a)},pause:d,cancel:u,set:function(e){t=e},isPaused:function(){return l}}}var dg="Arrow",ug=dg+"Left",pg=dg+"Right",gg=dg+"Up",fg=dg+"Down",mg="ttb",bg={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[gg,pg],ArrowRight:[fg,ug]};var vg="role",yg="tabindex",_g="aria-",xg=_g+"controls",wg=_g+"current",Cg=_g+"selected",Sg=_g+"label",kg=_g+"labelledby",Tg=_g+"hidden",Eg=_g+"orientation",Og=_g+"roledescription",Dg=_g+"live",Mg=_g+"busy",Pg=_g+"atomic",Ag=[vg,yg,"disabled",xg,wg,Sg,kg,Tg,Eg,Og],Fg=Cp+"__",Ig="is-",Lg=Cp,jg=Fg+"track",Bg=Fg+"list",Rg=Fg+"slide",zg=Rg+"--clone",$g=Rg+"__container",Hg=Fg+"arrows",Ng=Fg+"arrow",Vg=Ng+"--prev",Ug=Ng+"--next",Wg=Fg+"pagination",Xg=Wg+"__page",Gg=Fg+"progress"+"__bar",Yg=Fg+"toggle",qg=Fg+"sr",Kg=Ig+"initialized",Zg=Ig+"active",Jg=Ig+"prev",Qg=Ig+"next",tf=Ig+"visible",ef=Ig+"loading",sf=Ig+"focus-in",rf=Ig+"overflow",of=[Zg,tf,Jg,Qg,ef,sf,rf],nf={slide:Rg,clone:zg,arrows:Hg,arrow:Ng,prev:Vg,next:Ug,pagination:Wg,page:Xg,spinner:Fg+"spinner"};var af="touchstart mousedown",lf="touchmove mousemove",cf="touchend touchcancel mouseup click";var hf="slide",df="loop",uf="fade";function pf(t,e,i,s){var r,o=cg(t),n=o.on,a=o.emit,l=o.bind,c=t.Components,h=t.root,d=t.options,u=d.isNavigation,p=d.updateOnMove,g=d.i18n,f=d.pagination,m=d.slideFocus,b=c.Direction.resolve,v=up(s,"style"),y=up(s,Sg),_=i>-1,x=tp(s,"."+$g);function w(){var r=t.splides.map((function(t){var i=t.splide.Components.Slides.getAt(e);return i?i.slide.id:""})).join(" ");ap(s,Sg,Lp(g.slideX,(_?i:e)+1)),ap(s,xg,r),ap(s,vg,m?"button":""),m&&np(s,Og)}function C(){r||S()}function S(){if(!r){var i=t.index;(o=k())!==pp(s,Zg)&&(Yu(s,Zg,o),ap(s,wg,u&&o||""),a(o?Up:Wp,T)),function(){var e=function(){if(t.is(uf))return k();var e=gp(c.Elements.track),i=gp(s),r=b("left",!0),o=b("right",!0);return Op(e[r])<=Dp(i[r])&&Op(i[o])<=Dp(e[o])}(),i=!e&&(!k()||_);t.state.is([4,5])||ap(s,Tg,i||"");ap(yp(s,d.focusableNodes||""),yg,i?-1:""),m&&ap(s,yg,i?-1:0);e!==pp(s,tf)&&(Yu(s,tf,e),a(e?Xp:Gp,T));if(!e&&document.activeElement===s){var r=c.Slides.getAt(t.index);r&&dp(r.slide)}}(),Yu(s,Jg,e===i-1),Yu(s,Qg,e===i+1)}var o}function k(){var s=t.index;return s===e||d.cloneStatus&&s===i}var T={index:e,slideIndex:i,slide:s,container:x,isClone:_,mount:function(){_||(s.id=h.id+"-slide"+jp(e+1),ap(s,vg,f?"tabpanel":"group"),ap(s,Og,g.slide),ap(s,Sg,y||Lp(g.slideLabel,[e+1,t.length]))),l(s,"click",Au(a,Vp,T)),l(s,"keydown",Au(a,ng,T)),n([Np,ag,Qp],S),n(ig,w),p&&n(Hp,C)},destroy:function(){r=!0,o.destroy(),_p(s,of),np(s,Ag),ap(s,"style",v),ap(s,Sg,y||"")},update:S,style:function(t,e,i){cp(i&&x||s,t,e)},isWithin:function(i,s){var r=Mp(i-e);return _||!d.rewind&&!t.is(df)||(r=Tp(r,t.length-r)),r<=s}};return T}var gf=Sp+"-interval";var ff={passive:!1,capture:!0};var mf={Spacebar:" ",Right:pg,Left:ug,Up:gg,Down:fg};function bf(t){return t=$u(t)?t:t.key,mf[t]||t}var vf="keydown";var yf=Sp+"-lazy",_f=yf+"-srcset",xf="["+yf+"], ["+_f+"]";var wf=[" ","Enter"];var Cf=Object.freeze({__proto__:null,Media:function(t,e,i){var s=t.state,r=i.breakpoints||{},o=i.reducedMotion||{},n=Rp(),a=[];function l(t){t&&n.destroy()}function c(t,e){var i=matchMedia(e);n.bind(i,"change",h),a.push([t,i])}function h(){var e=s.is(7),r=i.direction,o=a.reduce((function(t,e){return rp(t,e[1].matches?e[0]:{})}),{});op(i),d(o),i.destroy?t.destroy("completely"===i.destroy):e?(l(!0),t.mount()):r!==i.direction&&t.refresh()}function d(e,r,o){rp(i,e),r&&rp(Object.getPrototypeOf(i),e),!o&&s.is(1)||t.emit(qp,i)}return{setup:function(){var t="min"===i.mediaQuery;ep(r).sort((function(e,i){return t?+e-+i:+i-+e})).forEach((function(e){c(r[e],"("+(t?"min":"max")+"-width:"+e+"px)")})),c(o,Ou),h()},destroy:l,reduce:function(t){matchMedia(Ou).matches&&(t?rp(i,o):op(i,ep(o)))},set:d}},Direction:function(t,e,i){return{resolve:function(t,e,s){var r="rtl"!==(s=s||i.direction)||e?s===mg?0:-1:1;return bg[t]&&bg[t][r]||t.replace(/width|left|right/i,(function(t,e){var i=bg[t.toLowerCase()][r]||t;return e>0?i.charAt(0).toUpperCase()+i.slice(1):i}))},orient:function(t){return t*("rtl"===i.direction?1:-1)}}},Elements:function(t,e,i){var s,r,o,n=cg(t),a=n.on,l=n.bind,c=t.root,h=i.i18n,d={},u=[],p=[],g=[];function f(){s=v("."+jg),r=tp(s,"."+Bg),kp(s&&r,"A track/list element is missing."),Gu(u,Qu(r,"."+Rg+":not(."+zg+")")),ip({arrows:Hg,pagination:Wg,prev:Vg,next:Ug,bar:Gg,toggle:Yg},(function(t,e){d[e]=v("."+t)})),sp(d,{root:c,track:s,list:r,slides:u}),function(){var t=c.id||(o=Cp,""+o+jp(Bp[o]=(Bp[o]||0)+1)),e=i.role;var o;c.id=t,s.id=s.id||t+"-track",r.id=r.id||t+"-list",!up(c,vg)&&"SECTION"!==c.tagName&&e&&ap(c,vg,e);ap(c,Og,h.carousel),ap(r,vg,"presentation")}(),b()}function m(t){var e=Ag.concat("style");Mu(u),_p(c,p),_p(s,g),np([s,r],e),np(c,t?e:["style",Og])}function b(){_p(c,p),_p(s,g),p=y(Lg),g=y(jg),qu(c,p),qu(s,g),ap(c,Sg,i.label),ap(c,kg,i.labelledby)}function v(t){var e=vp(c,t);return e&&function(t,e){if(zu(t.closest))return t.closest(e);for(var i=t;i&&1===i.nodeType&&!Ju(i,e);)i=i.parentElement;return i}(e,"."+Lg)===c?e:void 0}function y(t){return[t+"--"+i.type,t+"--"+i.direction,i.drag&&t+"--draggable",i.isNavigation&&t+"--nav",t===Lg&&Zg]}return sp(d,{setup:f,mount:function(){a(Yp,m),a(Yp,f),a(qp,b),l(document,af+" keydown",(function(t){o="keydown"===t.type}),{capture:!0}),l(c,"focusin",(function(){Yu(c,sf,!!o)}))},destroy:m})},Slides:function(t,e,i){var s=cg(t),r=s.on,o=s.emit,n=s.bind,a=e.Elements,l=a.slides,c=a.list,h=[];function d(){l.forEach((function(t,e){p(t,e,-1)}))}function u(){f((function(t){t.destroy()})),Mu(h)}function p(e,i,s){var r=pf(t,i,s,e);r.mount(),h.push(r),h.sort((function(t,e){return t.index-e.index}))}function g(t){return t?m((function(t){return!t.isClone})):h}function f(t,e){g(e).forEach(t)}function m(t){return h.filter(zu(t)?t:function(e){return $u(t)?Ju(e.slide,t):Xu(Uu(t),e.index)})}return{mount:function(){d(),r(Yp,u),r(Yp,d)},destroy:u,update:function(){f((function(t){t.update()}))},register:p,get:g,getIn:function(t){var s=e.Controller,r=s.toIndex(t),o=s.hasFocus()?1:i.perPage;return m((function(t){return Ap(t.index,r,r+o-1)}))},getAt:function(t){return m(t)[0]},add:function(t,e){Wu(t,(function(t){if($u(t)&&(t=mp(t)),Vu(t)){var s=l[e];s?Zu(t,s):Ku(c,t),qu(t,i.classes.slide),r=t,a=Au(o,Kp),h=yp(r,"img"),(d=h.length)?h.forEach((function(t){n(t,"load error",(function(){--d||a()}))})):a()}var r,a,h,d})),o(Yp)},remove:function(t){fp(m(t).map((function(t){return t.slide}))),o(Yp)},forEach:f,filter:m,style:function(t,e,i){f((function(s){s.style(t,e,i)}))},getLength:function(t){return t?l.length:h.length},isEnough:function(){return h.length>i.perPage}}},Layout:function(t,e,i){var s,r,o,n=cg(t),a=n.on,l=n.bind,c=n.emit,h=e.Slides,d=e.Direction.resolve,u=e.Elements,p=u.root,g=u.track,f=u.list,m=h.getAt,b=h.style;function v(){s=i.direction===mg,cp(p,"maxWidth",wp(i.width)),cp(g,d("paddingLeft"),_(!1)),cp(g,d("paddingRight"),_(!0)),y(!0)}function y(t){var e=gp(p);(t||r.width!==e.width||r.height!==e.height)&&(cp(g,"height",function(){var t="";s&&(kp(t=x(),"height or heightRatio is missing."),t="calc("+t+" - "+_(!1)+" - "+_(!0)+")");return t}()),b(d("marginRight"),wp(i.gap)),b("width",i.autoWidth?null:wp(i.fixedWidth)||(s?"":w())),b("height",wp(i.fixedHeight)||(s?i.autoHeight?null:w():x()),!0),r=e,c(Zp),o!==(o=O())&&(Yu(p,rf,o),c("overflow",o)))}function _(t){var e=i.padding,s=d(t?"right":"left");return e&&wp(e[s]||(Bu(e)?0:e))||"0px"}function x(){return wp(i.height||gp(f).width*i.heightRatio)}function w(){var t=wp(i.gap);return"calc((100%"+(t&&" + "+t)+")/"+(i.perPage||1)+(t&&" - "+t)+")"}function C(){return gp(f)[d("width")]}function S(t,e){var i=m(t||0);return i?gp(i.slide)[d("width")]+(e?0:E()):0}function k(t,e){var i=m(t);if(i){var s=gp(i.slide)[d("right")],r=gp(f)[d("left")];return Mp(s-r)+(e?0:E())}return 0}function T(e){return k(t.length-1)-k(0)+S(0,e)}function E(){var t=m(0);return t&&parseFloat(cp(t.slide,d("marginRight")))||0}function O(){return t.is(uf)||T(!0)>C()}return{mount:function(){var t,e;v(),l(window,"resize load",(t=Au(c,Kp),e=hg(0,t,null,1),function(){e.isPaused()&&e.start()})),a([qp,Yp],v),a(Kp,y)},resize:y,listSize:C,slideSize:S,sliderSize:T,totalSize:k,getPadding:function(t){return parseFloat(cp(g,d("padding"+(t?"Right":"Left"))))||0},isOverflow:O}},Clones:function(t,e,i){var s,r=cg(t),o=r.on,n=e.Elements,a=e.Slides,l=e.Direction.resolve,c=[];function h(){o(Yp,d),o([qp,Kp],p),(s=g())&&(!function(e){var s=a.get().slice(),r=s.length;if(r){for(;s.length<e;)Gu(s,s);Gu(s.slice(-e),s.slice(0,e)).forEach((function(o,l){var h=l<e,d=function(e,s){var r=e.cloneNode(!0);return qu(r,i.classes.clone),r.id=t.root.id+"-clone"+jp(s+1),r}(o.slide,l);h?Zu(d,s[0].slide):Ku(n.list,d),Gu(c,d),a.register(d,l-e+(h?0:r),o.index)}))}}(s),e.Layout.resize(!0))}function d(){u(),h()}function u(){fp(c),Mu(c),r.destroy()}function p(){var t=g();s!==t&&(s<t||!t)&&r.emit(Yp)}function g(){var s=i.clones;if(t.is(df)){if(Hu(s)){var r=i[l("fixedWidth")]&&e.Layout.slideSize(0);s=r&&Dp(gp(n.track)[l("width")]/r)||i[l("autoWidth")]&&t.length||2*i.perPage}}else s=0;return s}return{mount:h,destroy:u}},Move:function(t,e,i){var s,r=cg(t),o=r.on,n=r.emit,a=t.state.set,l=e.Layout,c=l.slideSize,h=l.getPadding,d=l.totalSize,u=l.listSize,p=l.sliderSize,g=e.Direction,f=g.resolve,m=g.orient,b=e.Elements,v=b.list,y=b.track;function _(){e.Controller.isBusy()||(e.Scroll.cancel(),x(t.index),e.Slides.update())}function x(t){w(T(t,!0))}function w(i,s){if(!t.is(uf)){var r=s?i:function(i){if(t.is(df)){var s=k(i),r=s>e.Controller.getEnd();(s<0||r)&&(i=C(i,r))}return i}(i);cp(v,"transform","translate"+f("X")+"("+r+"px)"),i!==r&&n(ag)}}function C(t,e){var i=t-O(e),s=p();return t-=m(s*(Dp(Mp(i)/s)||1))*(e?1:-1)}function S(){w(E(),!0),s.cancel()}function k(t){for(var i=e.Slides.get(),s=0,r=1/0,o=0;o<i.length;o++){var n=i[o].index,a=Mp(T(n,!0)-t);if(!(a<=r))break;r=a,s=n}return s}function T(e,s){var r=m(d(e-1)-function(t){var e=i.focus;return"center"===e?(u()-c(t,!0))/2:+e*c(t)||0}(e));return s?function(e){i.trimSpace&&t.is(hf)&&(e=Fp(e,0,m(p(!0)-u())));return e}(r):r}function E(){var t=f("left");return gp(v)[t]-gp(y)[t]+m(h(!1))}function O(t){return T(t?e.Controller.getEnd():0,!!i.trimSpace)}return{mount:function(){s=e.Transition,o([zp,Zp,qp,Yp],_)},move:function(t,e,i,r){var o,l;t!==e&&(o=t>i,l=m(C(E(),o)),o?l>=0:l<=v[f("scrollWidth")]-gp(y)[f("width")])&&(S(),w(C(E(),t>i),!0)),a(4),n(Hp,e,i,t),s.start(e,(function(){a(3),n(Np,e,i,t),r&&r()}))},jump:x,translate:w,shift:C,cancel:S,toIndex:k,toPosition:T,getPosition:E,getLimit:O,exceededLimit:function(t,e){e=Hu(e)?E():e;var i=!0!==t&&m(e)<m(O(!1)),s=!1!==t&&m(e)>m(O(!0));return i||s},reposition:_}},Controller:function(t,e,i){var s,r,o,n,a=cg(t),l=a.on,c=a.emit,h=e.Move,d=h.getPosition,u=h.getLimit,p=h.toPosition,g=e.Slides,f=g.isEnough,m=g.getLength,b=i.omitEnd,v=t.is(df),y=t.is(hf),_=Au(T,!1),x=Au(T,!0),w=i.start||0,C=w;function S(){r=m(!0),o=i.perMove,n=i.perPage,s=D();var t=Fp(w,0,b?s:r-1);t!==w&&(w=t,h.reposition())}function k(){s!==D()&&c(lg)}function T(t,e){var i=o||(F()?1:n),r=E(w+i*(t?-1:1),w,!(o||F()));return-1===r&&y&&!Pp(d(),u(!t),1)?t?0:s:e?r:O(r)}function E(e,a,l){if(f()||F()){var c=function(e){if(y&&"move"===i.trimSpace&&e!==w)for(var s=d();s===p(e,!0)&&Ap(e,0,t.length-1,!i.rewind);)e<w?--e:++e;return e}(e);c!==e&&(a=e,e=c,l=!1),e<0||e>s?e=o||!Ap(0,e,a,!0)&&!Ap(s,a,e,!0)?v?l?e<0?-(r%n||n):r:e:i.rewind?e<0?s:0:-1:M(P(e)):l&&e!==a&&(e=M(P(a)+(e<a?-1:1)))}else e=-1;return e}function O(t){return v?(t+r)%r||0:t}function D(){for(var t=r-(F()||v&&o?1:n);b&&t-- >0;)if(p(r-1,!0)!==p(t,!0)){t++;break}return Fp(t,0,r-1)}function M(t){return Fp(F()?t:n*t,0,s)}function P(t){return F()?Tp(t,s):Op((t>=s?r-1:t)/n)}function A(t){t!==w&&(C=w,w=t)}function F(){return!Hu(i.focus)||i.isNavigation}function I(){return t.state.is([4,5])&&!!i.waitForTransition}return{mount:function(){S(),l([qp,Yp,lg],S),l(Zp,k)},go:function(t,e,i){if(!I()){var r=function(t){var e=w;if($u(t)){var i=t.match(/([+\-<>])(\d+)?/)||[],r=i[1],o=i[2];"+"===r||"-"===r?e=E(w+ +(""+r+(+o||1)),w):">"===r?e=o?M(+o):_(!0):"<"===r&&(e=x(!0))}else e=v?t:Fp(t,0,s);return e}(t),o=O(r);o>-1&&(e||o!==w)&&(A(o),h.move(r,o,C,i))}},scroll:function(t,i,r,o){e.Scroll.scroll(t,i,r,(function(){var t=O(h.toIndex(d()));A(b?Tp(t,s):t),o&&o()}))},getNext:_,getPrev:x,getAdjacent:T,getEnd:D,setIndex:A,getIndex:function(t){return t?C:w},toIndex:M,toPage:P,toDest:function(t){var e=h.toIndex(t);return y?Fp(e,0,s):e},hasFocus:F,isBusy:I}},Arrows:function(t,e,i){var s,r,o=cg(t),n=o.on,a=o.bind,l=o.emit,c=i.classes,h=i.i18n,d=e.Elements,u=e.Controller,p=d.arrows,g=d.track,f=p,m=d.prev,b=d.next,v={};function y(){!function(){var t=i.arrows;!t||m&&b||(f=p||lp("div",c.arrows),m=C(!0),b=C(!1),s=!0,Ku(f,[m,b]),!p&&Zu(f,g));m&&b&&(sp(v,{prev:m,next:b}),hp(f,t?"":"none"),qu(f,r=Hg+"--"+i.direction),t&&(n([zp,Np,Yp,Qp,lg],S),a(b,"click",Au(w,">")),a(m,"click",Au(w,"<")),S(),ap([m,b],xg,g.id),l(eg,m,b)))}(),n(qp,_)}function _(){x(),y()}function x(){o.destroy(),_p(f,r),s?(fp(p?[m,b]:f),m=b=null):np([m,b],Ag)}function w(t){u.go(t,!0)}function C(t){return mp('<button class="'+c.arrow+" "+(t?c.prev:c.next)+'" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="40" height="40" focusable="false"><path d="'+(i.arrowPath||"m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z")+'" />')}function S(){if(m&&b){var e=t.index,i=u.getPrev(),s=u.getNext(),r=i>-1&&e<i?h.last:h.prev,o=s>-1&&e>s?h.first:h.next;m.disabled=i<0,b.disabled=s<0,ap(m,Sg,r),ap(b,Sg,o),l("arrows:updated",m,b,i,s)}}return{arrows:v,mount:y,destroy:x,update:S}},Autoplay:function(t,e,i){var s,r,o=cg(t),n=o.on,a=o.bind,l=o.emit,c=hg(i.interval,t.go.bind(t,">"),(function(t){var e=d.bar;e&&cp(e,"width",100*t+"%"),l("autoplay:playing",t)})),h=c.isPaused,d=e.Elements,u=e.Elements,p=u.root,g=u.toggle,f=i.autoplay,m="pause"===f;function b(){h()&&e.Slides.isEnough()&&(c.start(!i.resetProgress),r=s=m=!1,_(),l(sg))}function v(t){void 0===t&&(t=!0),m=!!t,_(),h()||(c.pause(),l(rg))}function y(){m||(s||r?v(!1):b())}function _(){g&&(Yu(g,Zg,!m),ap(g,Sg,i.i18n[m?"play":"pause"]))}function x(t){var s=e.Slides.getAt(t);c.set(s&&+up(s.slide,gf)||i.interval)}return{mount:function(){f&&(!function(){i.pauseOnHover&&a(p,"mouseenter mouseleave",(function(t){s="mouseenter"===t.type,y()}));i.pauseOnFocus&&a(p,"focusin focusout",(function(t){r="focusin"===t.type,y()}));g&&a(g,"click",(function(){m?b():v(!0)}));n([Hp,Jp,Yp],c.rewind),n(Hp,x)}(),g&&ap(g,xg,d.track.id),m||b(),_())},destroy:c.cancel,play:b,pause:v,isPaused:h}},Cover:function(t,e,i){var s=cg(t).on;function r(t){e.Slides.forEach((function(e){var i=tp(e.container||e.slide,"img");i&&i.src&&o(t,i,e)}))}function o(t,e,i){i.style("background",t?'center/cover no-repeat url("'+e.src+'")':"",!0),hp(e,t?"none":"")}return{mount:function(){i.cover&&(s(og,Au(o,!0)),s([zp,qp,Yp],Au(r,!0)))},destroy:Au(r,!1)}},Scroll:function(t,e,i){var s,r,o=cg(t),n=o.on,a=o.emit,l=t.state.set,c=e.Move,h=c.getPosition,d=c.getLimit,u=c.exceededLimit,p=c.translate,g=t.is(hf),f=1;function m(t,i,o,n,d){var p=h();if(y(),o&&(!g||!u())){var m=e.Layout.sliderSize(),_=Ip(t)*m*Op(Mp(t)/m)||0;t=c.toPosition(e.Controller.toDest(t%m))+_}var x=Pp(p,t,1);f=1,i=x?0:i||Ep(Mp(t-p)/1.5,800),r=n,s=hg(i,b,Au(v,p,t,d),1),l(5),a(Jp),s.start()}function b(){l(3),r&&r(),a(Qp)}function v(t,e,s,o){var n=h(),a=t+(e-t)*function(t){var e=i.easingFunc;return e?e(t):1-Math.pow(1-t,4)}(o),l=(a-n)*f;p(n+l),g&&!s&&u()&&(f*=.6,Mp(l)<10&&m(d(u(!0)),600,!1,r,!0))}function y(){s&&s.cancel()}function _(){s&&!s.isPaused()&&(y(),b())}return{mount:function(){n(Hp,y),n([qp,Yp],_)},destroy:y,scroll:m,cancel:_}},Drag:function(t,e,i){var s,r,o,n,a,l,c,h,d=cg(t),u=d.on,p=d.emit,g=d.bind,f=d.unbind,m=t.state,b=e.Move,v=e.Scroll,y=e.Controller,_=e.Elements.track,x=e.Media.reduce,w=e.Direction,C=w.resolve,S=w.orient,k=b.getPosition,T=b.exceededLimit,E=!1;function O(){var t=i.drag;z(!t),n="free"===t}function D(t){if(l=!1,!c){var e=R(t);s=t.target,r=i.noDrag,Ju(s,"."+Xg+", ."+Ng)||r&&Ju(s,r)||!e&&t.button||(y.isBusy()?bp(t,!0):(h=e?_:window,a=m.is([4,5]),o=null,g(h,lf,M,ff),g(h,cf,P,ff),b.cancel(),v.cancel(),F(t)))}var s,r}function M(e){if(m.is(6)||(m.set(6),p("drag")),e.cancelable)if(a){b.translate(s+I(e)/(E&&t.is(hf)?5:1));var r=L(e)>200,o=E!==(E=T());(r||o)&&F(e),l=!0,p("dragging"),bp(e)}else(function(t){return Mp(I(t))>Mp(I(t,!0))})(e)&&(a=function(t){var e=i.dragMinThreshold,s=Bu(e),r=s&&e.mouse||0,o=(s?e.touch:+e)||10;return Mp(I(t))>(R(t)?o:r)}(e),bp(e))}function P(s){m.is(6)&&(m.set(3),p("dragged")),a&&(!function(s){var r=function(e){if(t.is(df)||!E){var i=L(e);if(i&&i<200)return I(e)/i}return 0}(s),o=function(t){return k()+Ip(t)*Tp(Mp(t)*(i.flickPower||600),n?1/0:e.Layout.listSize()*(i.flickMaxPages||1))}(r),a=i.rewind&&i.rewindByDrag;x(!1),n?y.scroll(o,0,i.snap):t.is(uf)?y.go(S(Ip(r))<0?a?"<":"-":a?">":"+"):t.is(hf)&&E&&a?y.go(T(!0)?">":"<"):y.go(y.toDest(o),!0);x(!0)}(s),bp(s)),f(h,lf,M),f(h,cf,P),a=!1}function A(t){!c&&l&&bp(t,!0)}function F(t){o=r,r=t,s=k()}function I(t,e){return B(t,e)-B(j(t),e)}function L(t){return xp(t)-xp(j(t))}function j(t){return r===t&&o||r}function B(t,e){return(R(t)?t.changedTouches[0]:t)["page"+C(e?"Y":"X")]}function R(t){return"undefined"!=typeof TouchEvent&&t instanceof TouchEvent}function z(t){c=t}return{mount:function(){g(_,lf,Iu,ff),g(_,cf,Iu,ff),g(_,af,D,ff),g(_,"click",A,{capture:!0}),g(_,"dragstart",bp),u([zp,qp],O)},disable:z,isDragging:function(){return a}}},Keyboard:function(t,e,i){var s,r,o=cg(t),n=o.on,a=o.bind,l=o.unbind,c=t.root,h=e.Direction.resolve;function d(){var t=i.keyboard;t&&(s="global"===t?window:c,a(s,vf,g))}function u(){l(s,vf)}function p(){var t=r;r=!0,Fu((function(){r=t}))}function g(e){if(!r){var i=bf(e);i===h(ug)?t.go("<"):i===h(pg)&&t.go(">")}}return{mount:function(){d(),n(qp,u),n(qp,d),n(Hp,p)},destroy:u,disable:function(t){r=t}}},LazyLoad:function(t,e,i){var s=cg(t),r=s.on,o=s.off,n=s.bind,a=s.emit,l="sequential"===i.lazyLoad,c=[Np,Qp],h=[];function d(){Mu(h),e.Slides.forEach((function(t){yp(t.slide,xf).forEach((function(e){var s=up(e,yf),r=up(e,_f);if(s!==e.src||r!==e.srcset){var o=i.classes.spinner,n=e.parentElement,a=tp(n,"."+o)||lp("span",o,n);h.push([e,t,a]),e.src||hp(e,"none")}}))})),l?f():(o(c),r(c,u),u())}function u(){(h=h.filter((function(e){var s=i.perPage*((i.preloadPages||1)+1)-1;return!e[1].isWithin(t.index,s)||p(e)}))).length||o(c)}function p(t){var e=t[0];qu(t[1].slide,ef),n(e,"load error",Au(g,t)),ap(e,"src",up(e,yf)),ap(e,"srcset",up(e,_f)),np(e,yf),np(e,_f)}function g(t,e){var i=t[0],s=t[1];_p(s.slide,ef),"error"!==e.type&&(fp(t[2]),hp(i,""),a(og,i,s),a(Kp)),l&&f()}function f(){h.length&&p(h.shift())}return{mount:function(){i.lazyLoad&&(d(),r(Yp,d))},destroy:Au(Mu,h),check:u}},Pagination:function(t,e,i){var s,r,o=cg(t),n=o.on,a=o.emit,l=o.bind,c=e.Slides,h=e.Elements,d=e.Controller,u=d.hasFocus,p=d.getIndex,g=d.go,f=e.Direction.resolve,m=h.pagination,b=[];function v(){s&&(fp(m?Pu(s.children):s),_p(s,r),Mu(b),s=null),o.destroy()}function y(t){g(">"+t,!0)}function _(t,e){var i=b.length,s=bf(e),r=x(),o=-1;s===f(pg,!1,r)?o=++t%i:s===f(ug,!1,r)?o=(--t+i)%i:"Home"===s?o=0:"End"===s&&(o=i-1);var n=b[o];n&&(dp(n.button),g(">"+o),bp(e,!0))}function x(){return i.paginationDirection||i.direction}function w(t){return b[d.toPage(t)]}function C(){var t=w(p(!0)),e=w(p());if(t){var i=t.button;_p(i,Zg),np(i,Cg),ap(i,yg,-1)}if(e){var r=e.button;qu(r,Zg),ap(r,Cg,!0),ap(r,yg,"")}a("pagination:updated",{list:s,items:b},t,e)}return{items:b,mount:function e(){v(),n([qp,Yp,lg],e);var o=i.pagination;m&&hp(m,o?"":"none"),o&&(n([Hp,Jp,Qp],C),function(){var e=t.length,o=i.classes,n=i.i18n,a=i.perPage,p=u()?d.getEnd()+1:Dp(e/a);qu(s=m||lp("ul",o.pagination,h.track.parentElement),r=Wg+"--"+x()),ap(s,vg,"tablist"),ap(s,Sg,n.select),ap(s,Eg,x()===mg?"vertical":"");for(var g=0;g<p;g++){var f=lp("li",null,s),v=lp("button",{class:o.page,type:"button"},f),w=c.getIn(g).map((function(t){return t.slide.id})),C=!u()&&a>1?n.pageX:n.slideX;l(v,"click",Au(y,g)),i.paginationKeyboard&&l(v,"keydown",Au(_,g)),ap(f,vg,"presentation"),ap(v,vg,"tab"),ap(v,xg,w.join(" ")),ap(v,Sg,Lp(C,g+1)),ap(v,yg,-1),b.push({li:f,button:v,page:g})}}(),C(),a("pagination:mounted",{list:s,items:b},w(t.index)))},destroy:v,getAt:w,update:C}},Sync:function(t,e,i){var s=i.isNavigation,r=i.slideFocus,o=[];function n(){var e,i;t.splides.forEach((function(e){e.isParent||(l(t,e.splide),l(e.splide,t))})),s&&(e=cg(t),(i=e.on)(Vp,h),i(ng,d),i([zp,qp],c),o.push(e),e.emit(ig,t.splides))}function a(){o.forEach((function(t){t.destroy()})),Mu(o)}function l(t,e){var i=cg(t);i.on(Hp,(function(t,i,s){e.go(e.is(df)?s:t)})),o.push(i)}function c(){ap(e.Elements.list,Eg,i.direction===mg?"vertical":"")}function h(e){t.go(e.index)}function d(t,e){Xu(wf,bf(e))&&(h(t),bp(e))}return{setup:Au(e.Media.set,{slideFocus:Hu(r)?s:r},!0),mount:n,destroy:a,remount:function(){a(),n()}}},Wheel:function(t,e,i){var s=cg(t).bind,r=0;function o(s){if(s.cancelable){var o=s.deltaY,n=o<0,a=xp(s),l=i.wheelMinThreshold||0,c=i.wheelSleep||0;Mp(o)>l&&a-r>c&&(t.go(n?"<":">"),r=a),function(s){return!i.releaseWheel||t.state.is(4)||-1!==e.Controller.getAdjacent(s)}(n)&&bp(s)}}return{mount:function(){i.wheel&&s(e.Elements.track,"wheel",o,ff)}}},Live:function(t,e,i){var s=cg(t).on,r=e.Elements.track,o=i.live&&!i.isNavigation,n=lp("span",qg),a=hg(90,Au(l,!1));function l(t){ap(r,Mg,t),t?(Ku(r,n),a.start()):(fp(n),a.cancel())}function c(t){o&&ap(r,Dg,t?"off":"polite")}return{mount:function(){o&&(c(!e.Autoplay.isPaused()),ap(r,Pg,!0),n.textContent="…",s(sg,Au(c,!0)),s(rg,Au(c,!1)),s([Np,Qp],Au(l,!0)))},disable:c,destroy:function(){np(r,[Dg,Pg,Mg]),fp(n)}}}}),Sf={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:nf,i18n:{prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function kf(t,e,i){var s=e.Slides;function r(){s.forEach((function(t){t.style("transform","translateX(-"+100*t.index+"%)")}))}return{mount:function(){cg(t).on([zp,Yp],r)},start:function(t,e){s.style("transition","opacity "+i.speed+"ms "+i.easing),Fu(e)},cancel:Iu}}function Tf(t,e,i){var s,r=e.Move,o=e.Controller,n=e.Scroll,a=e.Elements.list,l=Au(cp,a,"transition");function c(){l(""),n.cancel()}return{mount:function(){cg(t).bind(a,"transitionend",(function(t){t.target===a&&s&&(c(),s())}))},start:function(e,a){var c=r.toPosition(e,!0),h=r.getPosition(),d=function(e){var s=i.rewindSpeed;if(t.is(hf)&&s){var r=o.getIndex(!0),n=o.getEnd();if(0===r&&e>=n||r>=n&&0===e)return s}return i.speed}(e);Mp(c-h)>=1&&d>=1?i.useScroll?n.scroll(c,d,!1,a):(l("transform "+d+"ms "+i.easing),r.translate(c,!0),s=a):(r.jump(e),a())},cancel:c}}var Ef=function(){function t(e,i){var s;this.event=cg(),this.Components={},this.state=(s=1,{set:function(t){s=t},is:function(t){return Xu(Uu(t),s)}}),this.splides=[],this._o={},this._E={};var r=$u(e)?vp(document,e):e;kp(r,r+" is invalid."),this.root=r,i=rp({label:up(r,Sg)||"",labelledby:up(r,kg)||""},Sf,t.defaults,i||{});try{rp(i,JSON.parse(up(r,Sp)))}catch(o){kp(!1,"Invalid JSON")}this._o=Object.create(rp({},i))}var e=t.prototype;return e.mount=function(t,e){var i=this,s=this.state,r=this.Components;return kp(s.is([1,7]),"Already mounted!"),s.set(1),this._C=r,this._T=e||this._T||(this.is(uf)?kf:Tf),this._E=t||this._E,ip(sp({},Cf,this._E,{Transition:this._T}),(function(t,e){var s=t(i,r,i._o);r[e]=s,s.setup&&s.setup()})),ip(r,(function(t){t.mount&&t.mount()})),this.emit(zp),qu(this.root,Kg),s.set(3),this.emit($p),this},e.sync=function(t){return this.splides.push({splide:t}),t.splides.push({splide:this,isParent:!0}),this.state.is(3)&&(this._C.Sync.remount(),t.Components.Sync.remount()),this},e.go=function(t){return this._C.Controller.go(t),this},e.on=function(t,e){return this.event.on(t,e),this},e.off=function(t){return this.event.off(t),this},e.emit=function(t){var e;return(e=this.event).emit.apply(e,[t].concat(Pu(arguments,1))),this},e.add=function(t,e){return this._C.Slides.add(t,e),this},e.remove=function(t){return this._C.Slides.remove(t),this},e.is=function(t){return this._o.type===t},e.refresh=function(){return this.emit(Yp),this},e.destroy=function(t){void 0===t&&(t=!0);var e=this.event,i=this.state;return i.is(1)?cg(this).on($p,this.destroy.bind(this,t)):(ip(this._C,(function(e){e.destroy&&e.destroy(t)}),!0),e.emit(tg),e.destroy(),t&&Mu(this.splides),i.set(7)),this},Eu(t,[{key:"options",get:function(){return this._o},set:function(t){this._C.Media.set(t,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),t}(),Of=Ef;
1995
- /**
1996
- * @license
1997
- * Copyright 2021 Google LLC
1998
- * SPDX-License-Identifier: BSD-3-Clause
1999
- */
2000
- function*Df(t,e){if(void 0!==t){let i=0;for(const s of t)yield e(s,i++)}}Of.defaults={},Of.STATES=Du;var Mf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,Af=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Pf(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Mf(e,i,o),o};let Ff=class extends Kh{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new Of(this.imageCarousel,{perPage:2,perMove:1,autoHeight:!0,gap:"0.6%",rewind:!1,pagination:!1,isNavigation:!1,mediaQuery:"min",breakpoints:{640:{perPage:4,gap:"1rem"}}}),this.imageSplide.on("arrows:mounted arrows:updated",(()=>{this.updateArrowVisibility()})),this.imageSplide.mount()},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),null==(t=this.imageSplide)||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}render(){return U`
2001
- <div class="category-container">
2002
- <slot name="title"></slot>
2003
- <div
2004
- id="category-carousel"
2005
- class="splide"
2006
- aria-label="The carousel with thumbnails. Selecting a thumbnail will change the Beautiful Gallery carousel."
2007
- >
2008
- <div class="splide__track">
2009
- <ul class="splide__list">
2010
- ${Df(this.cards,(t=>U`
2011
- <li class="splide__slide">
2012
- <img
2013
- src=${t.medias.cover.url}
2014
- alt="${t.medias.cover.alt}"
2015
- @click=${this.clickHandler}
2016
- data-card-id="${t.pboId}"
2017
- />
2018
- </li>
2019
- `))}
2020
- </ul>
2021
- </div>
2022
- </div>
2023
- </div>
2024
- `}};Ff.styles=[sl,Tu,a(cu)],Af([bt("#category-carousel")],Ff.prototype,"imageCarousel",2),Af([ft()],Ff.prototype,"imageSplide",2),Af([ft()],Ff.prototype,"slides",2),Af([gt({type:Array,converter:{fromAttribute(t){try{return JSON.parse(t||"[]")}catch(e){return console.error("Invalid JSON for 'cards':",t),[]}},toAttribute:t=>JSON.stringify(t)}})],Ff.prototype,"cards",2),Ff=Af([dt("pbo-category")],Ff);const If=Ff,Lf=l`
2025
- :host {
2026
- --size: 70%;
2027
- --header-spacing: var(--pbo-spacing-large);
2028
- --body-spacing: var(--pbo-spacing-large);
2029
- --footer-spacing: var(--pbo-spacing-large);
2030
- --panel-background-color: var(--pbo-panel-background-color);
2031
- --overlay-background-color: var(--pbo-overlay-background-color);
2032
- display: contents;
2033
- }
2034
-
2035
- .drawer {
2036
- top: 0;
2037
- inset-inline-start: 0;
2038
- width: 100%;
2039
- height: 100%;
2040
- pointer-events: none;
2041
- overflow: hidden;
2042
- }
2043
-
2044
- .drawer__overlay {
2045
- display: block;
2046
- position: fixed;
2047
- top: 0;
2048
- right: 0;
2049
- bottom: 0;
2050
- left: 0;
2051
- background-color: var(--overlay-background-color);
2052
- pointer-events: all;
2053
- backdrop-filter: blur(1px);
2054
- -webkit-backdrop-filter: blur(1px);
2055
- }
2056
-
2057
- .drawer--contained .drawer__overlay {
2058
- display: none;
2059
- }
2060
-
2061
- .drawer__panel {
2062
- position: absolute;
2063
- flex-direction: column;
2064
- z-index: 2;
2065
- max-width: 100%;
2066
- max-height: 100%;
2067
- background-color: var(--panel-background-color);
2068
- box-shadow: var(--pbo-shadow-x-large);
2069
- overflow: auto;
2070
- pointer-events: all;
2071
- }
2072
-
2073
- .drawer--bottom .drawer__panel {
2074
- top: auto;
2075
- inset-inline-end: auto;
2076
- bottom: 0;
2077
- inset-inline-start: 0;
2078
- width: 100%;
2079
- height: var(--size);
2080
- border-radius: var(--pbo-border-radius-large) var(--pbo-border-radius-large) 0 0;
2081
- }
2082
-
2083
- .drawer--left .drawer__panel {
2084
- top: auto;
2085
- inset-inline-end: auto;
2086
- left: 0;
2087
- inset-inline-start: 0;
2088
- height: 100%;
2089
- width: var(--size);
2090
- }
2091
-
2092
- .drawer--right .drawer__panel {
2093
- top: auto;
2094
- inset-inline-end: auto;
2095
- right: 0;
2096
- inset-inline-start: 0;
2097
- height: 100%;
2098
- width: var(--size);
2099
- }
2100
-
2101
- .drawer--top .drawer__panel {
2102
- top: auto;
2103
- inset-inline-end: auto;
2104
- top: 0;
2105
- inset-inline-start: 0;
2106
- width: 100%;
2107
- height: var(--size);
2108
- }
2109
- `;var jf=Object.defineProperty,Bf=Object.getOwnPropertyDescriptor,Rf=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Bf(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&jf(e,i,o),o};let zf=class extends Kh{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1}requestClose(t){this.hide()}async hide(){this.open=!1,this.emit("pbo-after-drawer-closed")}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return U`
2110
- <div
2111
- part="base"
2112
- class=${zh({drawer:!0,"drawer--bottom":"bottom"===this.placement,"drawer--top":"top"===this.placement,"drawer--left":"left"===this.placement,"drawer--right":"right"===this.placement,"drawer--open":this.open,"drawer--contained":this.contained})}
2113
- >
2114
- <div part="overlay" class="drawer__overlay" @click=${()=>this.requestClose("overlay")}></div>
2115
- <div
2116
- part="panel"
2117
- class="${zh({drawer__panel:!0})}"
2118
- role="dialog"
2119
- aria-modal="true"
2120
- aria-hidden=${this.open?"false":"true"}
2121
- tabindex="0"
2122
- >
2123
- <slot part="body" class="drawer__body"></slot>
2124
- </div>
2125
- </div>
2126
- `}};zf.styles=[sl,Lf],Rf([bt(".drawer")],zf.prototype,"drawer",2),Rf([gt({type:Boolean,reflect:!0})],zf.prototype,"open",2),Rf([gt({reflect:!0})],zf.prototype,"placement",2),Rf([gt({type:Boolean,reflect:!0})],zf.prototype,"radius",2),Rf([gt({type:Boolean,reflect:!0})],zf.prototype,"contained",2),Rf([il("open",{waitUntilFirstUpdate:!0})],zf.prototype,"handleOpenChange",1),zf=Rf([dt("pbo-drawer")],zf);const $f=zf,Hf=l`
2127
- :host {
2128
- display: block;
2129
- width: 100%;
2130
- height: 100%;
2131
- }
2132
-
2133
- .body {
2134
- overflow: scroll;
2135
- }
2136
-
2137
- .back-button {
2138
- display: flex;
2139
- justify-content: start;
2140
- }
2141
-
2142
- .close-button {
2143
- display: flex;
2144
- justify-content: end;
2145
- }
2146
-
2147
- .header {
2148
- height: 2.5rem;
2149
- padding: 0 var(--pbo-spacing-large);
2150
- user-select: none;
2151
- position: sticky;
2152
- top: 0;
2153
- background-color: var(--pbo-color-gray-100);
2154
- display: grid;
2155
- grid-template-columns: 1fr auto 1fr;
2156
- align-items: center;
2157
- font-size: var(--pbo-font-size-2xl);
2158
- }
2159
-
2160
- .title {
2161
- font-size: var(--pbo-font-size-x-large);
2162
- }
2163
-
2164
- .icon-button {
2165
- all: unset; /* Removes default button styles (border, background, padding, etc.) */
2166
- display: flex;
2167
- align-items: center;
2168
- justify-content: center;
2169
- cursor: pointer;
2170
- color: var(--pbo-color-gray-500); /* Default icon color */
2171
- transition:
2172
- transform 0.2s ease-in-out,
2173
- color 0.2s ease-in-out;
2174
- }
2175
-
2176
- /* Apply hover effect */
2177
- .icon-button:hover {
2178
- transform: scale(1.1); /* Slightly enlarges the icon */
2179
- color: var(--pbo-color-gray-700); /* Changes icon color on hover */
2180
- }
2181
-
2182
- .page-manager {
2183
- position: relative;
2184
- height: 100%;
2185
- width: 100%;
2186
- display: grid;
2187
- grid-template-rows: min-content auto;
2188
- grid-gap: 0;
2189
- }
2190
-
2191
- .category-selection {
2192
- display: grid;
2193
- height: 100%;
2194
- grid-template-columns: repeat(12, 1fr);
2195
- padding: var(--pbo-spacing-small);
2196
- }
2197
- @media screen and (min-width: 640px) {
2198
- .category-selection {
2199
- padding: var(--pbo-spacing-medium);
2200
- }
2201
- }
2202
-
2203
- .category-selection pbo-card-selection {
2204
- grid-column: 1 / span 12;
2205
- }
2206
-
2207
- .editor {
2208
- padding: var(--pbo-spacing-small);
2209
- }
2210
-
2211
- @media screen and (min-width: 640px) {
2212
- .editor {
2213
- padding: var(--pbo-spacing-medium);
2214
- }
2215
- }
2216
-
2217
- @media screen and (min-width: 768px) {
2218
- .category-selection pbo-card-selection {
2219
- grid-column: 2 / span 10;
2220
- }
2221
- }
2222
-
2223
- @media screen and (min-width: 1280px) {
2224
- .category-selection pbo-card-selection {
2225
- grid-column: 4 / span 7;
2226
- }
2227
- }
2228
- `;var Nf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Uf=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Vf(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Nf(e,i,o),o};let Wf=class extends Kh{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);console.log(t),this.editorEl.card=i,this.goToEditor()}}handleSubmitTypeFormUpdate(){this.editorEl.submitTypeForm=async t=>{this.submitTypeForm&&(this.editorEl.typeForm.disabled=!0,this.editorEl.typeForm.loading=!0,await this.submitTypeForm(t),this.editorEl.typeForm.disabled=!1,this.editorEl.typeForm.loading=!1)}}handleSubmitHandwrittenFormUpdate(){this.editorEl.submitHandwrittenForm=async t=>{this.submitHandwrittenForm&&(this.editorEl.handwrittenForm.isSubmitDisabled=!0,this.editorEl.handwrittenForm.isSubmitLoading=!0,await this.submitHandwrittenForm(t),this.editorEl.handwrittenForm.isSubmitDisabled=!1,this.editorEl.handwrittenForm.isSubmitLoading=!1)}}handleGetProcessedImgUpdate(){this.editorEl.getProcessedImg=this.getProcessedImg}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}connectedCallback(){var t;super.connectedCallback(),null==(t=this.shadowRoot)||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.shadowRoot)||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){console.log(this.categories),this.cardSelectionEl&&void 0!==this.categories&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}findCardInCategoryById(t){console.log("Categories from findCardInCategoryById",this.categories);for(const e of this.categories){const i=e.cards.find((e=>e.pboId===t));if(console.log("card from findCardInCategoryById",i),i)return i}return null}render(){return U`
2229
- <div part="base" class="page-manager">
2230
- <div class="header">
2231
- <div class="back-button">
2232
- ${"selection"!==this.currentPage?U`<button @click=${this.goToSelector} class="icon-button">
2233
- <svg
2234
- xmlns="http://www.w3.org/2000/svg"
2235
- height="24px"
2236
- viewBox="0 -960 960 960"
2237
- width="24px"
2238
- fill="currentColor"
2239
- >
2240
- <path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z" />
2241
- </svg>
2242
- </button>`:""}
2243
- </div>
2244
- <div class="title">${"selection"===this.currentPage?"SELECT CARD":"PERSONALIZE"}</div>
2245
- <div class="close-button">
2246
- <button @click=${this.onClose} class="icon-button">
2247
- <svg
2248
- xmlns="http://www.w3.org/2000/svg"
2249
- height="24px"
2250
- viewBox="0 -960 960 960"
2251
- width="24px"
2252
- fill="currentColor"
2253
- >
2254
- <path
2255
- d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"
2256
- />
2257
- </svg>
2258
- </button>
2259
- </div>
2260
- </div>
2261
- <div class="body">
2262
- <div class="category-selection" ?hidden=${"selection"!==this.currentPage}>
2263
- <pbo-card-selection name="selection"></pbo-card-selection>
2264
- </div>
2265
- <div class="editor" ?hidden=${"editor"!==this.currentPage}>
2266
- <pbo-editor name="editor" ?hidden=${"editor"!==this.currentPage}></pbo-editor>
2267
- </div>
2268
- </div>
2269
- </div>
2270
- `}};Wf.styles=[sl,Hf],Uf([bt("pbo-card-selection")],Wf.prototype,"cardSelectionEl",2),Uf([bt("pbo-editor")],Wf.prototype,"editorEl",2),Uf([gt({type:Function})],Wf.prototype,"onClose",2),Uf([gt({type:String,reflect:!0})],Wf.prototype,"currentPage",2),Uf([gt()],Wf.prototype,"categories",2),Uf([gt()],Wf.prototype,"submitTypeForm",2),Uf([gt()],Wf.prototype,"submitHandwrittenForm",2),Uf([gt()],Wf.prototype,"getProcessedImg",2),Uf([ft()],Wf.prototype,"selectedCard",2),Uf([ft()],Wf.prototype,"selectedCardId",2),Uf([ft()],Wf.prototype,"selectedCardDetails",2),Uf([il("submitTypeForm")],Wf.prototype,"handleSubmitTypeFormUpdate",1),Uf([il("submitHandwrittenForm")],Wf.prototype,"handleSubmitHandwrittenFormUpdate",1),Uf([il("getProcessedImg")],Wf.prototype,"handleGetProcessedImgUpdate",1),Uf([il("categories")],Wf.prototype,"handleCategoriesUpdate",1),Wf=Uf([dt("pbo-page-manager")],Wf);const Xf=Wf,Gf=l`
2271
- :host {
2272
- display: block;
2273
- }
2274
- `;var Yf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Kf=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?qf(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Yf(e,i,o),o};let Zf=class extends Kh{constructor(){super(...arguments),this.categories=[]}render(){return U`
2275
- ${Df(this.categories,(t=>U`<pbo-category .cards=${t.cards} .name=${t.name}>
2276
- <h3 slot="title">${t.name}</h3>
2277
- </pbo-category>`))}
2278
- `}};Zf.styles=[sl,Gf],Kf([gt({type:Array})],Zf.prototype,"categories",2),Zf=Kf([dt("pbo-card-selection")],Zf);const Jf=Zf,Qf=l`
2279
- :host {
2280
- display: block;
2281
- width: 100%;
2282
- height: 100%;
2283
- }
2284
-
2285
- .fabric-container {
2286
- max-width: 100%;
2287
- max-height: 100%;
2288
- width: 100% !important;
2289
- height: 100% !important;
2290
- object-fit: contain;
2291
- display: flex;
2292
- margin-left: auto;
2293
- margin-right: auto;
2294
- flex-direction: column;
2295
- justify-content: center;
2296
- }
2297
-
2298
- .fabric-container canvas {
2299
- max-width: 100% !important;
2300
- max-height: 100% !important;
2301
- width: 100% !important;
2302
- height: auto !important;
2303
- display: block;
2304
- object-fit: contain;
2305
- }
2306
- `;var tm=Object.defineProperty,em=Object.getOwnPropertyDescriptor,im=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?em(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&tm(e,i,o),o};let sm=class extends Kh{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.backgroundImage=void 0,this.backgroundFabImg=void 0,this.rect=void 0,this.textBox=void 0,this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0}}handleAlignmentChange(t,e){t!==e&&this.textBox&&(this.textBox.set("textAlign",e),this.canvas.renderAll())}handleColorChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fill",e),this.canvas.renderAll())}handleFontChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fontFamily",e),this.canvas.renderAll())}handleMessageChange(t,e){if(this.textBox){this.textBox.set("text",e);const t=this.textBox.textLines;t.length>12&&this.textBox.set("text",t.slice(0,12).join("\n")),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new so({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0)"}),this.canvas.add(this.rect)),this.textBox?(this.textBox.set("left",this.areaPosition.left),this.textBox.set("top",this.areaPosition.top),this.textBox.set("width",this.areaSize.width),this.textBox.set("height",this.areaSize.height),this.textBox.set("lineHeight",1.1),this.textBox.set("fontSize",this.areaSize.height/13/1.1)):(this.textBox=new ha(this.message,{left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,lineHeight:1.1,fontSize:this.areaSize.height/13/1.1,alignment:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}async firstUpdated(){this.canvas=new Jo(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,(()=>{})),this.updateTextAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await xa.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return U`<canvas class="base-canvas"></canvas> `}};sm.styles=[sl,Qf],im([gt({attribute:"background-url"})],sm.prototype,"backgroundImageUrl",2),im([gt()],sm.prototype,"message",2),im([gt()],sm.prototype,"font",2),im([gt()],sm.prototype,"color",2),im([gt()],sm.prototype,"alignment",2),im([bt(".base-canvas")],sm.prototype,"baseCanvas",2),im([ft()],sm.prototype,"canvas",2),im([ft()],sm.prototype,"backgroundImage",2),im([ft()],sm.prototype,"backgroundFabImg",2),im([ft()],sm.prototype,"rect",2),im([ft()],sm.prototype,"textBox",2),im([ft()],sm.prototype,"areaPosition",2),im([ft()],sm.prototype,"areaSize",2),im([il("alignment")],sm.prototype,"handleAlignmentChange",1),im([il("color")],sm.prototype,"handleColorChange",1),im([il("font")],sm.prototype,"handleFontChange",1),im([il("message")],sm.prototype,"handleMessageChange",1),im([il("backgroundImageUrl")],sm.prototype,"handleBackgroundImageUrlChange",1),sm=im([dt("pbo-type-canvas")],sm);const rm=sm,om=l`
2307
- :host {
2308
- display: block;
2309
- height: 100%;
2310
- width: 100%;
2311
- }
2312
-
2313
- .zoomed-preview {
2314
- padding: 1.5rem;
2315
- height: 100%;
2316
- width: 100%;
2317
- }
2318
-
2319
- .panel {
2320
- width: 100%;
2321
- height: 100%;
2322
- }
2323
-
2324
- ::slotted(img) {
2325
- width: 100%;
2326
- max-height: 100%;
2327
- object-fit: contain;
2328
- }
2329
-
2330
- .close-button {
2331
- position: absolute;
2332
- right: 1em;
2333
- top: 1em;
2334
- cursor: pointer;
2335
- }
2336
-
2337
- .close-button svg {
2338
- height: 2rem;
2339
- width: 2rem;
2340
- fill: #d7d7d7;
2341
- }
2342
-
2343
- .close-button svg:hover {
2344
- fill: #fff9f9;
2345
- scale: 1.1;
2346
- }
2347
- `;var nm=Object.defineProperty,am=Object.getOwnPropertyDescriptor,lm=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?am(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&nm(e,i,o),o};let cm=class extends Kh{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""}}render(){return U`
2348
- <div class="panel">
2349
- <div class="zoomed-preview">
2350
- <div
2351
- style=${kd({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
2352
- >
2353
- <slot part="base"></slot>
2354
- </div>
2355
- </div>
2356
-
2357
- <div class="close-button" @click=${this.close}>
2358
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#F3F3F3">
2359
- <path
2360
- d="m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"
2361
- />
2362
- </svg>
2363
- </div>
2364
- </div>
2365
- `}};cm.styles=[sl,om],lm([gt()],cm.prototype,"formData",2),lm([gt()],cm.prototype,"cardUrl",2),lm([gt()],cm.prototype,"close",2),lm([gt()],cm.prototype,"handwrittenPreviewProps",2),cm=lm([dt("pbo-zoomed-preview")],cm);const hm=cm,dm=l`
2366
- :host {
2367
- display: block;
2368
- }
2369
-
2370
- .label {
2371
- line-height: normal;
2372
- font-size: 1rem;
2373
- }
2374
- .label svg {
2375
- vertical-align: middle;
2376
- }
2377
- .icon {
2378
- /* display: inline; */
2379
- vertical-align: top;
2380
- }
2381
- .choice-wrapper {
2382
- display: inline-flex;
2383
- }
2384
- `;var um=Object.defineProperty,pm=Object.getOwnPropertyDescriptor,gm=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?pm(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&um(e,i,o),o};let fm=class extends Kh{constructor(){super(...arguments),this.hasSlotController=new Fh(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():null==(t=this._choices)||t.enable()}get value(){var t;return null==(t=this._choices)?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var t;null==(t=this._choices)||t.destroy(),this._choices=new Ph(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:' \n <div class="choice-wrapper">\n <span class="label">Type message\n <svg\n stroke="currentColor"\n fill="none"\n stroke-width="0"\n viewBox="0 0 24 24"\n height="1.6em"\n width="1.6em"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path d="M6.5 3H3V6.5H4V4H6.5V3Z" fill="currentColor"></path>\n <path d="M8.5 4V3H11V4H8.5Z" fill="currentColor"></path>\n <path d="M13 4H15.5V3H13V4Z" fill="currentColor"></path>\n <path d="M17.5 3V4H20V6.5H21V3H17.5Z" fill="currentColor"></path>\n <path d="M21 8.5H20V11H21V8.5Z" fill="currentColor"></path>\n <path d="M21 13H20V15.5H21V13Z" fill="currentColor"></path>\n <path d="M21 17.5H20V20H17.5V21H21V17.5Z" fill="currentColor"></path>\n <path d="M15.5 21V20H13V21H15.5Z" fill="currentColor"></path>\n <path d="M11 21V20H8.5V21H11Z" fill="currentColor"></path>\n <path d="M6.5 21V20H4V17.5H3V21H6.5Z" fill="currentColor"></path>\n <path d="M3 15.5H4V13H3V15.5Z" fill="currentColor"></path>\n <path d="M3 11H4V8.5H3V11Z" fill="currentColor"></path>\n <path d="M11 9.5H7V7.5H17V9.5H13V16.5H11V9.5Z" fill="currentColor"></path>\n </svg>\n </span>'},{value:"handwritten",label:' \n <div class="choice-wrapper">\n <span class="label">Upload handwritten message\n <svg\n stroke="currentColor"\n fill="none"\n stroke-width="0"\n viewBox="0 0 24 24"\n height="1.6em"\n width="1.6em"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n fill-rule="evenodd"\n clip-rule="evenodd"\n d="M21.2635 2.29289C20.873 1.90237 20.2398 1.90237 19.8493 2.29289L18.9769 3.16525C17.8618 2.63254 16.4857 2.82801 15.5621 3.75165L4.95549 14.3582L10.6123 20.0151L21.2189 9.4085C22.1426 8.48486 22.338 7.1088 21.8053 5.99367L22.6777 5.12132C23.0682 4.7308 23.0682 4.09763 22.6777 3.70711L21.2635 2.29289ZM16.9955 10.8035L10.6123 17.1867L7.78392 14.3582L14.1671 7.9751L16.9955 10.8035ZM18.8138 8.98525L19.8047 7.99429C20.1953 7.60376 20.1953 6.9706 19.8047 6.58007L18.3905 5.16586C18 4.77534 17.3668 4.77534 16.9763 5.16586L15.9853 6.15683L18.8138 8.98525Z"\n fill="currentColor"\n ></path>\n <path d="M2 22.9502L4.12171 15.1717L9.77817 20.8289L2 22.9502Z" fill="currentColor"></path>\n </svg>\n <svg\n stroke="currentColor"\n fill="currentColor"\n stroke-width="0"\n viewBox="0 0 512 512"\n height="1.6em"\n width="1.6em"\n xmlns="http://www.w3.org/2000/svg"\n >\n <circle cx="256" cy="275" r="57.5"></circle>\n <path\n d="M417.5 160H363c-4.6 0-8.9-2-12-5.4-28.4-31.8-39.1-42.6-50.7-42.6h-85.5c-11.7 0-23.2 10.8-51.7 42.7-3 3.4-7.4 5.3-11.9 5.3h-4.1v-8c0-4.4-3.6-8-8-8h-26c-4.4 0-8 3.6-8 8v8h-7.5C79.9 160 64 173.2 64 190.7v176c0 17.5 15.9 33.3 33.5 33.3h320c17.6 0 30.5-15.8 30.5-33.3v-176c0-17.5-12.9-30.7-30.5-30.7zM260 360.4c-50.3 2.3-91.7-39.1-89.4-89.4 2-43.9 37.5-79.4 81.4-81.4 50.3-2.3 91.7 39.1 89.4 89.4-2 43.9-37.5 79.4-81.4 81.4zM352 218c-7.2 0-13-5.8-13-13s5.8-13 13-13 13 5.8 13 13-5.8 13-13 13z"\n ></path>\n </svg>\n <svg\n stroke="currentColor"\n fill="currentColor"\n stroke-width="0"\n viewBox="0 0 512 512"\n height="1.6em"\n width="1.6em"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n fill="none"\n stroke-linecap="round"\n stroke-linejoin="round"\n stroke-width="32"\n d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"\n ></path>\n </svg>\n </span>'}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",(t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))}))}render(){const t=this.hasSlotController.test("label"),e=!!this.label||!!t;return U` <div
2385
- class=${zh({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--radio-group":!0,"form-control--has-label":e})}
2386
- >
2387
- <label
2388
- part="form-control-label"
2389
- id="label"
2390
- class="form-control__label"
2391
- aria-hidden=${e?"false":"true"}
2392
- >
2393
- <slot name="label">${this.label}</slot>
2394
- </label>
2395
- </div>
2396
- <select part="base" class="js-choice"></select>`}};fm.styles=[sl,dm,$h,a(Ah)],gm([gt()],fm.prototype,"size",2),gm([gt()],fm.prototype,"label",2),gm([gt({type:Boolean,reflect:!0})],fm.prototype,"disabled",2),gm([il("disabled",{waitUntilFirstUpdate:!0})],fm.prototype,"handleDisabledChanged",1),gm([bt(".js-choice")],fm.prototype,"choiceEl",2),fm=gm([dt("pbo-editor-selector")],fm);const mm=fm,bm=l`
2397
- :host {
2398
- display: block;
2399
- }
2400
-
2401
- .pixel-input {
2402
- display: none;
2403
- height: 1;
2404
- width: 1;
2405
- opacity: 0;
2406
- }
2407
- .buttons-container {
2408
- display: flex;
2409
- flex-direction: column;
2410
- }
2411
-
2412
- .buttons-container pbo-button::part(base) {
2413
- font-size: var(--pbo-font-size-medium);
2414
- }
2415
-
2416
- .handwritten-form section h1 {
2417
- margin: 0;
2418
- font-size: var(--pbo-font-size-large);
2419
- }
2420
-
2421
- .handwritten-form section:not(:last-child) p {
2422
- margin-bottom: var(--pbo-spacing-medium);
2423
- }
2424
-
2425
- .handwritten-form section:first-child {
2426
- margin-top: var(--pbo-spacing-medium);
2427
- }
2428
-
2429
- .handwritten-form section p {
2430
- margin-top: var(--pbo-spacing-2x-small);
2431
- font-size: var(--pbo-font-size-medium);
2432
- }
2433
- `;var vm=Object.defineProperty,ym=Object.getOwnPropertyDescriptor,_m=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?ym(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&vm(e,i,o),o};let xm=class extends Kh{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{pred_image_uid:"",masked_img:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={fileUrl:null,imgId:null},this.processedFileUrl=null,this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.uploadButton.loading=t,this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleSourceImgChange(t,e){this.processedFileUrl=null,t!==e&&this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){e&&t!==e&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing)}get formData(){var t,e,i,s;const r=177.8/this.handwrittenDimensions.cardHeight,o=127/this.handwrittenDimensions.cardWidth,n={pboCardId:(null==(t=this.card)?void 0:t.pboId)||"Unknown",productId:null==(e=this.card)?void 0:e.productId,sku:null==(i=this.card)?void 0:i.sku,variantId:null==(s=this.card)?void 0:s.variantId,pred_image_uid:this.processedImg.imgId||"",position_x:this.handwrittenDimensions.top*o,position_y:this.handwrittenDimensions.left*r,height:this.handwrittenDimensions.height*r,width:this.handwrittenDimensions.width*o};return eu(n)}setDimensions(t){this.handwrittenDimensions=t}get form(){return{isLoading:this.sourceImg&&!this.processedFileUrl,processedFileUrl:this.processedFileUrl}}async handleFileChange(t){var e,i;const s=null==(i=null==(e=t.target)?void 0:e.files)?void 0:i[0];if(null==s)return;this.sourceImg=s,this.isImageProcessing=!0;const r=await this.getProcessedImg(s);this.isImageProcessing=!1,this.processedFileUrl=`data:image/png;base64,${r.masked_img}`}handleSubmit(t){t.preventDefault(),this.submitHandwrittenForm(this.formData)}render(){return U`
2434
- <form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
2435
- <section>
2436
- <h1>Step 1</h1>
2437
- <p>Write your message and signature on a white sheet of paper</p>
2438
- </section>
2439
-
2440
- <section>
2441
- <h1>Step 2</h1>
2442
- <p>Take a well-lit photo on your phone, then crop and save it</p>
2443
- </section>
2444
-
2445
- <section>
2446
- <h1>Step 3</h1>
2447
- <p>Upload photo (PNG or JPEG), then adjust it to fit inside the card</p>
2448
- </section>
2449
- <input
2450
- id="handwritten-file-input"
2451
- class="pixel-input"
2452
- type="file"
2453
- accept=".png, .jpeg, .jpg"
2454
- @change=${this.handleFileChange}
2455
- required
2456
- />
2457
- <div class="buttons-container">
2458
- <pbo-button
2459
- name="upload"
2460
- class="upload button"
2461
- size="medium"
2462
- variant="primary"
2463
- @click=${this.showPicker}
2464
- style=${kd({display:this.processedFileUrl?"none":"block"})}
2465
- >
2466
- Upload Handwritten Image
2467
- </pbo-button>
2468
-
2469
- <pbo-button
2470
- name="save"
2471
- type="submit"
2472
- variant="primary"
2473
- class="submit-cta"
2474
- style=${kd({display:this.sourceImg&&this.processedFileUrl&&!this.isImageProcessing?"block":"none"})}
2475
- >
2476
- Save and Continue
2477
- </pbo-button>
2478
- <pbo-button
2479
- name="reupload"
2480
- variant="text"
2481
- class="submit-cta"
2482
- @click=${this.showPicker}
2483
- size="small"
2484
- style=${kd({display:this.sourceImg&&this.processedFileUrl?"block":"none"})}
2485
- >
2486
- reupload image
2487
- </pbo-button>
2488
- </div>
2489
- </form>
2490
- `}};xm.styles=[sl,bm],_m([gt()],xm.prototype,"card",2),_m([gt()],xm.prototype,"submitHandwrittenForm",2),_m([gt()],xm.prototype,"getProcessedImg",2),_m([gt({type:Boolean,reflect:!0,attribute:"loading"})],xm.prototype,"isSubmitLoading",2),_m([gt({type:Boolean,reflect:!0,attribute:"disabled"})],xm.prototype,"isSubmitDisabled",2),_m([bt(".pixel-input")],xm.prototype,"imageInput",2),_m([bt(".handwritten-form")],xm.prototype,"handwrittenForm",2),_m([bt("pbo-button[name='upload']")],xm.prototype,"uploadButton",2),_m([bt("pbo-button[name='save']")],xm.prototype,"saveButton",2),_m([bt("pbo-button[name='reupload']")],xm.prototype,"reuploadButton",2),_m([ft()],xm.prototype,"isImageProcessing",2),_m([ft()],xm.prototype,"sourceImg",2),_m([ft()],xm.prototype,"processedImg",2),_m([ft()],xm.prototype,"processedFileUrl",2),_m([ft()],xm.prototype,"handwrittenDimensions",2),_m([il("isSubmitLoading")],xm.prototype,"handleSubmitLoadingChange",1),_m([il("isSubmitDisabled")],xm.prototype,"handleSubmitDisabledChange",1),_m([il("sourceImg")],xm.prototype,"handleSourceImgChange",1),_m([il("processedFileUrl")],xm.prototype,"handleProcessImageChange",1),_m([il("isImageProcessing")],xm.prototype,"handleImageProcessingChange",1),xm=_m([dt("pbo-handwritten-form")],xm);const wm=xm,Cm=l`
2491
- :host {
2492
- display: block;
2493
- width: 100%;
2494
- height: 100%;
2495
- }
2496
-
2497
- .fabric-container {
2498
- max-width: 100%;
2499
- max-height: 100%;
2500
- width: 100% !important;
2501
- height: 100% !important;
2502
- object-fit: contain;
2503
- margin-left: auto;
2504
- margin-right: auto;
2505
- display: flex;
2506
- flex-direction: column;
2507
- justify-content: center;
2508
- }
2509
-
2510
- .fabric-container canvas {
2511
- max-width: 100% !important;
2512
- max-height: 100% !important;
2513
- width: 100% !important;
2514
- height: auto !important;
2515
- display: block;
2516
- object-fit: contain;
2517
- }
2518
- `;var Sm=Object.defineProperty,km=Object.getOwnPropertyDescriptor,Tm=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?km(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Sm(e,i,o),o};let Em=class extends Kh{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(t,e){if(this.canvas){if(this.handwrittenImage&&this.canvas.remove(this.handwrittenImage),e){this.handwrittenImage=await xa.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const t=this.areaSize.width/this.handwrittenImage.width,i=this.areaSize.height/this.handwrittenImage.height,s=Math.min(t,i);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(Qd()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(Qd()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:s,scaleY:s,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*s,width:this.handwrittenImage.width*s}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const r=new so({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:r}),this.handwrittenImage.on("scaling",(t=>{const{top:e,left:i,height:s,width:r,scaleX:o,scaleY:n}=t.transform.target;this.setHandwrittenImageDimensions({top:e,left:i,height:s*n,width:r*o})})),this.handwrittenImage.on("moving",(t=>{const{top:e,left:i}=t.transform.target;this.setHandwrittenImageDimensions({top:e,left:i})})),this.handwrittenImage.on("selected",(()=>{var t,e;null==(t=this.rect)||t.set("visible",!0),null==(e=this.handwrittenImage)||e.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()})),this.handwrittenImage.on("deselected",(()=>{var t,e,i;null==(t=this.rect)||t.set("visible",!1),null==(e=this.handwrittenImage)||e.set({clipPath:r}),null==(i=this.clipMaskOverlay)||i.set("visible",!1)})),this.canvas.add(this.handwrittenImage),this.canvas.renderAll()}this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}}createClipMaskOverlay(){const t=this.canvas.getWidth(),e=this.canvas.getHeight(),{left:i,top:s}=this.areaPosition,{width:r,height:o}=this.areaSize,n="rgba(0,0,0,0.1)",a=new so({left:0,top:0,width:t,height:s,fill:n,selectable:!1,evented:!1}),l=new so({left:0,top:s+o,width:t,height:e-(s+o),fill:n,selectable:!1,evented:!1}),c=new so({left:0,top:s,width:i,height:o,fill:n,selectable:!1,evented:!1}),h=new so({left:i+r,top:s,width:t-(i+r),height:o,fill:n,selectable:!1,evented:!1});return new vo([a,l,c,h],{selectable:!1,evented:!1})}updateProcessedImgAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new so({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect))}handleHandwrittenImageDimensionsChange(t,e){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout((()=>{var t,e,i;this.applyHandwrittenImageDimensions(),null==(t=this.canvas)||t.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:(null==(e=this.backgroundFabImg)?void 0:e.height)||0,cardWidth:(null==(i=this.backgroundFabImg)?void 0:i.width)||0}})}),300)}applyHandwrittenImageDimensions(){tu(this.handwrittenImage)&&tu(this.imageLeft)&&tu(this.imageTop)&&tu(this.imageWidth)&&tu(this.imageHeight)&&(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}setHandwrittenImageDimensions(t){const{top:e=null,left:i=null,height:s=null,width:r=null}=t;e||i||s||r?(i&&this.imageLeft!==i&&(this.imageLeft=i),e&&this.imageTop!==e&&(this.imageTop=e),s&&this.imageHeight!==s&&(this.imageHeight=s),r&&this.imageWidth!==r&&(this.imageWidth=r)):console.warn("Invalid dimensions provided for handwritten image")}async firstUpdated(){this.canvas=new Jo(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,(()=>{})),this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await xa.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return U`<canvas class="base-canvas"></canvas> `}};Em.styles=[sl,Cm],Tm([gt({attribute:"background-url"})],Em.prototype,"backgroundImageUrl",2),Tm([gt({attribute:"handwritten-url"})],Em.prototype,"handwrittenImageUrl",2),Tm([gt({type:Number,reflect:!0,attribute:"height"})],Em.prototype,"imageHeight",2),Tm([gt({type:Number,reflect:!0,attribute:"width"})],Em.prototype,"imageWidth",2),Tm([gt({type:Number,reflect:!0,attribute:"left"})],Em.prototype,"imageLeft",2),Tm([gt({type:Number,reflect:!0,attribute:"top"})],Em.prototype,"imageTop",2),Tm([bt(".base-canvas")],Em.prototype,"baseCanvas",2),Tm([ft()],Em.prototype,"canvas",2),Tm([ft()],Em.prototype,"backgroundFabImg",2),Tm([ft()],Em.prototype,"rect",2),Tm([ft()],Em.prototype,"areaPosition",2),Tm([ft()],Em.prototype,"handwrittenImage",2),Tm([ft()],Em.prototype,"clipMaskOverlay",2),Tm([ft()],Em.prototype,"areaSize",2),Tm([il("backgroundImageUrl")],Em.prototype,"handleBackgroundImageUrlChange",1),Tm([il("handwrittenImageUrl")],Em.prototype,"handleHandwrittenImageUrlChange",1),Tm([il("imageLeft"),il("imageTop"),il("imageWidth"),il("imageHeight")],Em.prototype,"handleHandwrittenImageDimensionsChange",1),Em=Tm([dt("pbo-handwritten-canvas")],Em);const Om=Em,Dm=l`
2519
- :host {
2520
- display: block;
2521
- width: auto;
2522
- color: #1f1f1f;
2523
- }
2524
-
2525
- .gift-options {
2526
- display: flex;
2527
- flex-direction: column;
2528
- gap: 1rem;
2529
- padding: 1rem 0;
2530
- }
2531
-
2532
- /* 🎁 Gift section - top checkbox with border */
2533
- .gift-options > div:first-of-type {
2534
- border-bottom: 1px dashed #ccc;
2535
- padding-bottom: 0.5rem;
2536
- margin-bottom: 0.5rem;
2537
- }
2538
-
2539
- label {
2540
- display: flex;
2541
- align-items: center;
2542
- gap: 0.4rem;
2543
- font-size: 0.95rem;
2544
- cursor: pointer;
2545
- }
2546
-
2547
- input[type="checkbox"] {
2548
- accent-color: #0070f3;
2549
- cursor: pointer;
2550
- }
2551
-
2552
- /* 📝 Free message textarea */
2553
- textarea {
2554
- margin-left: 1.5rem;
2555
- margin-top: 0.25rem;
2556
- padding: 0.5rem;
2557
- font-size: 0.9rem;
2558
- line-height: 1.4;
2559
- width: 100%;
2560
- max-width: 500px;
2561
- border: 1px solid #ccc;
2562
- border-radius: 4px;
2563
- resize: vertical;
2564
- min-height: 6rem;
2565
- }
2566
- `;var Mm=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Am=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?Pm(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&Mm(e,i,o),o};let Fm=class extends Kh{constructor(){super(...arguments),this.hasSlotController=new Fh(this,"is-gift-label","premium-card-label","free-message-label"),this.freeMessage="",this.hidden=!1,this.expand=!1,this.isGift=!0,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}setGiftOptionEnabled(t){var e;this.isGift=t,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="",null==(e=this.onFreeMessageClear)||e.call(this))}firstUpdated(t){}setPremiumEnabled(t){var e;this.isPremiumChecked=t,this.isPremiumChecked&&(this.isFreeMessageChecked=!1,null==(e=this.onFreeMessageClear)||e.call(this)),this.isPremiumChecked?this.emit("pbo-open-drawer"):this.emit("pbo-close-drawer"),this.onPremiumSelected&&this.onPremiumSelected(t)}setFreeMessageEnabled(t){var e;this.isFreeMessageChecked=t,this.isFreeMessageChecked||(this.freeMessage="",null==(e=this.onFreeMessageClear)||e.call(this))}handlePremiumChange(t){const e=t.target.checked;this.setPremiumEnabled(e)}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("free-message-label");return U`
2567
- <div part="base" class="gift-options" ?hidden=${this.hidden}>
2568
- <!-- 🎁 Is this a gift -->
2569
- <div class="is-gift" part="is-gift" ?hidden=${!t}>
2570
- <label class="is-gift-label">
2571
- <input
2572
- type="checkbox"
2573
- ?checked=${this.isGift}
2574
- @change=${t=>{const e=t.target.checked;this.isGift=e,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="")}}
2575
- />
2576
- <slot name="is-gift-label" part="is-gift-label"></slot>
2577
- <span class="is-gift-icon">
2578
- <slot name="is-gift-icon" part="is-gift-icon"></slot>
2579
- </span>
2580
- </label>
2581
- </div>
2582
-
2583
- <!-- 💌 Premium Card -->
2584
- <div class="premium-card" part="premium-card" ?hidden=${!this.isGift||!e}>
2585
- <label class="premium-card-label">
2586
- <input type="checkbox" .checked=${this.isPremiumChecked} @change=${this.handlePremiumChange} />
2587
- <slot name="premium-card-label" part="premium-card-label"></slot>
2588
- </label>
2589
- <p class="premium-card-description">
2590
- <slot name="premium-card-description" part="premium-card-description"></slot>
2591
- </p>
2592
- </div>
2593
-
2594
- <!-- 📝 Free Message -->
2595
- <div class="free-message" part="free-message" ?hidden=${!this.isGift||!i}>
2596
- <label class="free-message-label" part="free-message-label">
2597
- <input
2598
- type="checkbox"
2599
- .checked=${this.isFreeMessageChecked}
2600
- @change=${()=>{var t;this.isFreeMessageChecked=!this.isFreeMessageChecked,this.isFreeMessageChecked?this.isPremiumChecked=!1:(this.freeMessage="",null==(t=this.onFreeMessageClear)||t.call(this))}}
2601
- />
2602
- <slot name="free-message-label"></slot>
2603
- </label>
2604
-
2605
- <pbo-textarea
2606
- class="free-message-textarea"
2607
- part="free-message-textarea"
2608
- placeholder="Leave your message"
2609
- .value=${this.freeMessage}
2610
- ?hidden=${!this.isFreeMessageChecked}
2611
- @input=${t=>{var e;this.freeMessage=t.target.value,null==(e=this.onFreeMessageChange)||e.call(this,this.freeMessage)}}
2612
- ></pbo-textarea>
2613
- <div></div>
2614
- </div>
2615
- </div>
2616
- `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};Fm.styles=[sl,Dm],Am([gt()],Fm.prototype,"freeMessage",2),Am([gt({type:Function})],Fm.prototype,"onPremiumSelected",2),Am([gt({type:Function})],Fm.prototype,"onFreeMessageChange",2),Am([gt({type:Function})],Fm.prototype,"onFreeMessageClear",2),Am([gt({type:Boolean,reflect:!0})],Fm.prototype,"hidden",2),Am([gt({type:Boolean,reflect:!0})],Fm.prototype,"expand",2),Am([ft()],Fm.prototype,"isGift",2),Am([ft()],Fm.prototype,"isPremiumChecked",2),Am([ft()],Fm.prototype,"isFreeMessageChecked",2),Fm=Am([dt("pbo-gift-options")],Fm);const Im=Fm,Lm=cd,jm=gu;t.PboBridge=class{constructor({getCards:t,getCategories:e,drawer:i,pageManager:s,giftOptions:r,selectionGroupBy:o="category",submitTypeForm:n,submitHandwrittenForm:a,getProcessedImg:l}){this._isLoading={isLoading:!1,isError:!1},this._cards=[],this._categories=[],this.setDrawer(i||null),this.setPageManager(s||null),this.setGiftOptions(r||null);const c=this.getDrawer(),h=this.getPageManager(),d=this.getGiftOptions();if(!h)throw new Error("Page manager element is required");if(c&&(console.log(c),document.addEventListener("pbo-open-drawer",(t=>{console.log("pbo-open-drawer event triggered",t),null==c||c.show()}))),null==c||c.addEventListener("pbo-after-drawer-closed",(()=>{null==d||d.setPremiumEnabled(!1)})),h.onClose=()=>{null==c||c.hide()},"category"===o){if(!e)throw new Error("getCategories function is required when selectionGroupBy is 'category'");this.setIsLoading(!0),e().then((t=>{this.setCategories(t)})).catch((t=>{console.error("Failed to fetch categories:",t),this.setIsError(!0)})).finally((()=>{this.setIsLoading(!1)}))}if("none"===o){if(!t)throw new Error("getCards function is required when selectionGroupBy is 'none'");this.setIsLoading(!0),t().then((t=>{this.setCards(t)})).catch((t=>{console.error("Failed to fetch cards:",t),this.setIsError(!0)})).finally((()=>{this.setIsLoading(!1)}))}n&&(h.submitTypeForm=n),a&&(h.submitHandwrittenForm=a),l&&(h.getProcessedImg=l)}setDrawer(t){if(null===this._drawer||this._drawer)throw new Error("Drawer can only be set during initialization");if(null!==t)switch(typeof t){case"string":const e=document.querySelector(t);if(!e)throw new Error(`Drawer element with selector ${t} not found`);this._drawer=e;break;case"object":if(t instanceof zf){this._drawer=t;break}throw new Error("Drawer must be a string or an instance of PboDrawer");default:throw new Error("Drawer must be a string or an instance of PboDrawer")}else this._drawer=null}getDrawer(){return this._drawer}setGiftOptions(t){if(null===this._giftOptions||this._giftOptions)throw new Error("Gift options can only be set during initialization");if(null!==t)switch(typeof t){case"string":const e=document.querySelector(t);if(!e)throw new Error(`Gift options element with selector "${t}" not found`);return void(this._giftOptions=e);case"object":if(t instanceof zf)return void(this._giftOptions=t);throw new Error("Gift options must be a string or an instance of PboDrawer");default:throw new Error("Gift options must be a string or an instance of PboDrawer")}else this._giftOptions=null}getGiftOptions(){return this._giftOptions}setPageManager(t){if(null===this._pageManager||this._pageManager)throw new Error("Page manager can only be set during initialization");if(null!==t)switch(typeof t){case"string":const e=document.querySelector(t);if(!e)throw new Error(`Page manager element with selector "${t}" not found`);return void(this._pageManager=e);case"object":if(t instanceof Wf)return void(this._pageManager=t);throw new Error("Page manager must be a string or an instance of PboDrawer");default:throw new Error("Page manager must be a string or an instance of PboDrawer")}else this._pageManager=null}getPageManager(){return this._pageManager}getCategories(){return this._categories}setCategories(t){this._categories=t,this._pageManager?this._pageManager.categories=t:console.warn("Page manager is not set, categories will not be updated")}getCards(){return this._cards}setCards(t){this._cards=t,this._pageManager||console.warn("Page manager is not set, cards will not be updated")}setIsLoading(t){this._isLoading.isLoading=t}setIsError(t){this._isLoading.isError=t}},t.PboButton=gd,t.PboButtonGroup=xd,t.PboCardSelection=Jf,t.PboCategory=If,t.PboDrawer=$f,t.PboEditor=Cu,t.PboEditorCardSlider=ku,t.PboEditorSelector=mm,t.PboGiftOption=Im,t.PboHandwrittenCanvas=Om,t.PboHandwrittenForm=wm,t.PboImage=jm,t.PboPageManager=Xf,t.PboRadioButton=Md,t.PboRadioGroup=jd,t.PboSpinner=Lm,t.PboTextarea=Kd,t.PboTypeCanvas=rm,t.PboTypeForm=Su,t.PboZoomedPreview=hm,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));